:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #697586;
  --line: #d9e2ec;
  --brand: #176b87;
  --brand-dark: #0f4c60;
  --accent: #2f8068;
  --soft-blue: #e7f2f5;
  --soft-green: #e8f4ef;
  --soft-yellow: #fff3d8;
  --shadow: 0 14px 34px rgba(25, 45, 66, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.button:hover {
  border-color: var(--brand);
}

.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.full {
  width: 100%;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.logged-out .app-shell {
  grid-template-columns: minmax(320px, 430px);
  justify-content: center;
  background: #172634;
}

.logged-out .sidebar {
  min-height: 100vh;
  justify-content: center;
}

.logged-out .login-card {
  padding: 16px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  background: #172634;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 74px;
  padding: 10px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-copy {
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand strong,
.user-card strong,
.side-note strong {
  display: block;
}

.brand span,
.side-note span,
.user-card span,
.user-card em,
#loginTip {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-style: normal;
}

.login-card,
.user-card,
.side-note {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.user-card-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.user-card-main strong {
  min-width: 0;
}

.user-card-main button {
  flex: 0 0 auto;
}

.brand .user-card {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.brand .user-card-main {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  margin-top: 0;
}

.brand .user-card span,
.brand .user-card em {
  margin-top: 0;
}

.brand .user-card strong {
  max-width: 74px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand .user-card button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
}

.brand .user-card em {
  display: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.sidebar label {
  color: rgba(255, 255, 255, 0.78);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

.login-card {
  display: grid;
  gap: 12px;
}

.login-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.login-head strong {
  font-size: 15px;
}

.login-head span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
}

.code-row button {
  padding-right: 8px;
  padding-left: 8px;
  white-space: nowrap;
}

.code-row button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

#loginTip.success {
  color: #b9f6ca;
}

#loginTip.error {
  color: #ffcdd2;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  color: rgba(255, 255, 255, 0.84);
  background: transparent;
  border-color: transparent;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.main {
  min-width: 0;
  max-width: 100%;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 10px;
  font-size: 26px;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.app-home-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid #cfe0df;
  border-radius: 8px;
  background: #f0f7f5;
  box-shadow: var(--shadow);
}

.app-home-card span {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.app-home-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 22px;
}

.app-home-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

#learn .app-home-card {
  display: none;
}

.media-context {
  margin: -2px 0 12px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 32, 0.58);
}

.entry-modal {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(380px, 100%);
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 32, 0.28);
}

.entry-modal h2 {
  margin: 2px 0 6px;
  font-size: 24px;
}

.entry-modal p {
  margin: 0;
  color: var(--muted);
}

.app-mode-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 28px;
}

.app-mode-head img {
  width: 54px;
  height: 54px;
  border-radius: 14px;
}

.app-mode-head h2 {
  margin: 2px 0 0;
}

.icon-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
}

.entry-qr {
  width: min(240px, 72vw);
  aspect-ratio: 1;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.entry-link {
  overflow-wrap: anywhere;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6f8fb;
  color: var(--ink);
  font-size: 13px;
}

.install-steps {
  display: grid;
  gap: 10px;
}

.install-steps div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.install-steps strong {
  color: var(--ink);
}

.install-steps span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  min-width: 0;
  max-width: 100%;
}

.status-strip div,
.panel,
.course-hero {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-strip div {
  padding: 14px;
}

.status-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.status-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.learner-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.learner-metrics .duration-metric {
  grid-column: 1 / -1;
  padding: 18px;
  border-color: #bfdcd8;
  background: linear-gradient(135deg, #eef8f7 0%, #ffffff 72%);
}

.learner-metrics .duration-metric strong {
  font-size: 32px;
}

.learner-metrics div:not(.duration-metric) {
  padding: 10px 12px;
}

.learner-metrics div:not(.duration-metric) strong {
  font-size: 18px;
}

.view {
  display: none;
  min-width: 0;
  max-width: 100%;
}

.view.active {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.view.active > * {
  min-width: 0;
  max-width: 100%;
}

.course-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(240px, 0.8fr);
  gap: 20px;
  padding: 22px;
}

.lesson-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.learner-course-list {
  display: grid;
  gap: 12px;
}

.course-switch-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.course-switch-toggle {
  display: none;
}

.course-switch-body {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.learner-course-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  width: 100%;
  min-height: 116px;
  padding: 16px;
  text-align: left;
  background: #ffffff;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.learner-course-card.active {
  border-color: var(--line);
  background:
    radial-gradient(circle at 100% 0%, rgba(83, 180, 154, 0.38), transparent 42%),
    linear-gradient(135deg, #0f4c60 0%, #176b87 58%, #2f8068 100%);
  box-shadow:
    0 14px 30px rgba(15, 76, 96, 0.26);
}

.learner-course-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(25, 45, 66, 0.1);
}

.learner-course-card strong {
  display: block;
  font-size: 18px;
}

.learner-course-card.active strong {
  color: #fff;
  font-weight: 900;
}

.course-card-subtitle {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.course-card-meta {
  display: block;
  margin-top: 8px;
  color: var(--brand-dark);
  font-size: 14px;
  font-weight: 700;
}

.learner-course-card.active .course-card-meta {
  color: rgba(255, 255, 255, 0.86);
}

.learner-course-card.active .course-card-subtitle {
  color: rgba(255, 255, 255, 0.78);
}

.learner-course-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.learner-course-card em {
  min-width: 64px;
  color: var(--brand-dark);
  font-style: normal;
  font-weight: 800;
  text-align: right;
}

.lesson-tab {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 0;
  align-items: start;
  justify-content: stretch;
  justify-items: stretch;
  min-height: 0;
  padding: 9px 12px;
  text-align: left;
  background: #ffffff;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.lesson-tab.active {
  border-color: var(--line);
  background:
    radial-gradient(circle at 100% 0%, rgba(83, 180, 154, 0.34), transparent 44%),
    linear-gradient(135deg, #0f4c60 0%, #176b87 60%, #2f8068 100%);
  box-shadow:
    0 14px 30px rgba(15, 76, 96, 0.26);
}

.lesson-tab:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(25, 45, 66, 0.1);
}

.lesson-tab strong {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--brand-dark);
  text-align: left;
}

.lesson-tab strong span {
  min-width: 0;
  color: var(--brand-dark);
}

.lesson-tab.active strong span {
  color: #fff;
  font-weight: 900;
}

.lesson-tab.active .lesson-progress {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.lesson-tab .lesson-progress {
  position: relative;
  display: block;
  width: 92px;
  height: 20px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: #e53935;
  color: #fff;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  text-align: right;
}

.lesson-tab .lesson-progress i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress);
  min-width: 0;
  background: #b71c1c;
}

.lesson-tab .lesson-progress b {
  position: relative;
  z-index: 1;
  display: block;
  padding: 0 8px;
  color: #fff;
  font: inherit;
  line-height: 20px;
  text-align: center;
}

.lesson-tab .lesson-progress.started {
  background: #1e88e5;
  color: #fff;
}

.lesson-tab .lesson-progress.started i {
  background: #0d47a1;
}

.lesson-tab .lesson-progress.done {
  background: #00a85a;
  color: #fff;
}

.lesson-tab .lesson-progress.done i {
  background: #008f4c;
}

.lesson-tab span,
.lesson-tab em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.5;
}

.user-card em:empty {
  display: none;
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.course-meta {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft-green);
}

.course-meta span {
  color: var(--muted);
  font-size: 13px;
}

.course-meta strong {
  margin-bottom: 6px;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.wide-panel {
  grid-column: 1 / -1;
}

.panel {
  padding: 18px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.panel-title span {
  color: var(--muted);
  font-size: 13px;
}

audio,
video {
  width: 100%;
  margin-bottom: 10px;
}

video {
  aspect-ratio: 16 / 9;
  background: #111827;
  border-radius: 8px;
}

.audio-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.media-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 0 12px;
}

.media-actions button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: #ffffff;
  color: var(--brand);
  font-weight: 700;
}

.media-actions button:disabled {
  border-color: var(--line);
  background: #f5f7f9;
  color: var(--muted);
}

.listen-mode-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8fb;
}

.listen-mode-toggle button {
  min-height: 32px;
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.listen-mode-toggle button.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 14px rgba(0, 91, 112, 0.18);
}

.audio-tools label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.audio-tools select {
  width: 112px;
  min-height: 36px;
  padding: 6px 9px;
}

.clean-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.key-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.key-grid div {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.key-grid span,
small {
  color: var(--muted);
  line-height: 1.6;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.outline-scroll {
  max-height: 420px;
  overflow-y: auto;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  line-height: 1.8;
}

.outline-scroll h4 {
  margin: 18px 0 8px;
  font-size: 16px;
}

.outline-scroll h4:first-child {
  margin-top: 0;
}

.outline-scroll p {
  margin: 0 0 12px;
}

.quiz {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  font-weight: 700;
}

.quiz-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start;
  gap: 8px;
  margin: 9px 0;
  color: var(--ink);
}

.quiz-option input {
  width: 16px;
  margin-top: 3px;
}

.prompt-box {
  display: grid;
  gap: 12px;
}

.practice-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.practice-actions span {
  color: var(--muted);
  font-size: 13px;
}

.assignment-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
}

.assignment-user-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.assignment-user {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.assignment-user small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.45;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.upload-grid .wide {
  grid-column: 1 / -1;
}

.upload-result {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft-green);
  color: var(--brand-dark);
  line-height: 1.7;
}

.manage-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.manage-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.manage-summary span,
.list-toolbar span,
.table-note {
  color: var(--muted);
}

.manage-summary strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
}

.form-actions,
.list-toolbar,
.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.list-toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.row-actions button {
  padding: 7px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.table-note {
  margin: 6px 0 0;
  max-width: 360px;
  line-height: 1.5;
}

.course-group-row {
  background: #f5f8f7;
}

.course-group-row td {
  border-top: 1px solid var(--line);
  font-weight: 600;
}

.lesson-row td:first-child {
  padding-left: 34px;
}

.level-label {
  display: inline-flex;
  align-items: center;
  margin-right: 8px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.level-label.sub {
  background: #dfe9e5;
  color: var(--brand-dark);
}

.ai-feedback {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft-yellow);
  line-height: 1.7;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .logged-out .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    gap: 12px;
    padding: 14px 14px 10px;
    background: #fff;
    color: var(--ink);
  }

  .brand {
    min-height: 70px;
    padding: 8px 0 12px;
    border-bottom-color: var(--line);
  }

  .brand-mark {
    background: #fff;
  }

  .brand span,
  .side-note span,
  .user-card span,
  .user-card em {
    color: var(--muted);
  }

  .logged-out .sidebar {
    min-height: 100vh;
    padding: 20px;
    background: #172634;
    color: #fff;
  }

  .logged-out .brand {
    border-bottom-color: rgba(255, 255, 255, 0.16);
  }

  .logged-out .brand-mark {
    background: #fff;
  }

  .logged-out .brand span {
    color: rgba(255, 255, 255, 0.7);
  }

  .user-card,
  .side-note {
    border-color: var(--line);
    background: #f8fafc;
  }

  .user-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 10px 12px;
  }

  .main {
    padding: 12px 14px 92px;
  }

  .brand {
    min-height: auto;
  }

  .side-note {
    display: none;
  }

  .nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(76px, 1fr);
    overflow-x: auto;
    gap: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 28px rgba(15, 23, 32, 0.1);
  }

  .nav-item {
    justify-content: center;
    min-height: 44px;
    padding: 8px 6px;
    border-color: transparent;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
  }

  .nav-item.active,
  .nav-item:hover {
    background: #e8f4f8;
    border-color: #d2e9f0;
    color: var(--brand);
  }

  .topbar {
    display: none !important;
  }

  .top-actions #resetBtn {
    display: none;
  }

  .app-home-card {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  .app-home-card button {
    width: 100%;
  }

  .topbar,
  .course-hero,
  .two-column,
  .upload-grid,
  .assignment-tools,
  .assignment-user-list,
  .manage-summary,
  .lesson-tabs,
  .learner-course-card {
    grid-template-columns: 1fr;
  }

  .learner-course-card em {
    text-align: left;
  }

  .learner-course-card {
    min-height: auto;
    gap: 10px;
    padding: 14px;
  }

  .learner-course-card strong {
    font-size: 17px;
    line-height: 1.35;
  }

  .course-card-meta {
    font-size: 13px;
  }

  .course-card-subtitle {
    font-size: 13px;
  }

  .learner-course-card p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .panel {
    padding: 14px;
  }

  .panel-title {
    align-items: flex-start;
  }

  video {
    max-height: 54vh;
  }

  .topbar {
    display: grid;
  }

  .status-strip,
  .key-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .learner-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .learner-metrics .duration-metric {
    grid-column: 1 / -1;
  }

  .learner-metrics div:not(.duration-metric) {
    padding: 9px 8px;
  }

  .learner-metrics div:not(.duration-metric) span {
    font-size: 11px;
  }

  .learner-metrics div:not(.duration-metric) strong {
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  body {
    min-width: 0;
  }

  .app-shell {
    width: 100%;
    max-width: 100%;
  }

  .logged-out .app-shell {
    grid-template-columns: minmax(0, 430px);
  }

  .status-strip,
  .key-grid {
    grid-template-columns: 1fr;
  }

  .learner-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .learner-metrics .duration-metric {
    grid-column: 1 / -1;
  }

  .sidebar {
    gap: 8px;
    padding: 10px 12px 8px;
  }

  .brand {
    gap: 10px;
    min-height: 76px;
    padding: 10px 0 14px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .brand strong {
    font-size: 18px;
  }

  .brand span {
    font-size: 12px;
  }

  .user-card {
    border-radius: 8px;
  }

  .user-card strong {
    font-size: 16px;
  }

  .topbar {
    gap: 10px;
    padding: 10px 14px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 22px;
  }

  .app-home-card strong {
    font-size: 18px;
    line-height: 1.35;
  }

  .app-home-card p,
  .learner-course-card p {
    font-size: 14px;
    line-height: 1.55;
  }

  .lesson-tab {
    padding: 10px;
  }

  #learn .course-switch-panel {
    order: 1;
  }

  #learn .media-study-section {
    order: 2;
  }

  #learn #courseOutlinePanel {
    order: 3;
  }

  #learn > .two-column:not(.media-study-section) {
    order: 4;
  }

  .media-study-section .panel {
    padding: 14px;
  }

  .media-study-section .panel-title {
    margin-bottom: 10px;
  }

  #mediaHint {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.55;
  }

  .course-switch-panel {
    gap: 10px;
  }

  .course-switch-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 14px;
    border: 1px solid #cfe0df;
    border-radius: 8px;
    background: #eef8f8;
    color: var(--ink);
    text-align: left;
    box-shadow: 0 8px 20px rgba(15, 23, 32, 0.06);
  }

  .course-switch-toggle span {
    display: grid;
    gap: 3px;
    min-width: 0;
  }

  .course-switch-toggle strong {
    font-size: 16px;
  }

  .course-switch-toggle small {
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .course-switch-toggle b {
    flex: 0 0 auto;
    color: var(--brand);
    font-size: 14px;
  }

  .course-switch-panel.collapsed .course-switch-body {
    display: none;
  }

  .course-switch-body {
    gap: 10px;
  }

  .lesson-tab .lesson-progress {
    width: 100%;
  }

  .panel-title {
    display: grid;
    gap: 4px;
  }

  .audio-tools {
    justify-content: stretch;
    align-items: stretch;
    flex-direction: column;
  }

  .media-actions {
    justify-content: stretch;
  }

  .media-actions button {
    width: 100%;
  }

  .audio-tools label,
  .audio-tools select {
    width: 100%;
  }

  .listen-mode-toggle {
    width: 100%;
  }

  .listen-mode-toggle button {
    flex: 1;
  }

  #learningStats .table-wrap {
    overflow-x: visible;
  }

  #learningStats table,
  #learningStats thead,
  #learningStats tbody,
  #learningStats tr,
  #learningStats td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  #learningStats thead {
    display: none;
  }

  #learningStats tr {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  #learningStats td {
    padding: 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

  #learningStats td + td {
    margin-top: 10px;
  }

  #learningStats td::before {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  #learningStats td:nth-child(1)::before {
    content: "课程";
  }

  #learningStats td:nth-child(2)::before {
    content: "学习进度";
  }

  #learningStats td:nth-child(3)::before {
    content: "学习时长";
  }

  #learningStats td:nth-child(4)::before {
    content: "测试";
  }

  #learningStats td:nth-child(5)::before {
    content: "评价";
  }

  #learningStats td:nth-child(6)::before {
    content: "最近学习";
  }

  video {
    border-radius: 6px;
  }

  .entry-modal {
    padding: 18px;
  }
}
