:root {
  color-scheme: light;
  --ink: #243042;
  --muted: #667085;
  --line: #d9e1ea;
  --paper: #fffaf3;
  --panel: #ffffff;
  --mint: #37b899;
  --sky: #4d9de0;
  --rose: #e86f8f;
  --gold: #f5b83d;
  --leaf: #72b85d;
  --shadow: 0 18px 40px rgba(36, 48, 66, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(77, 157, 224, 0.18), transparent 310px),
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  padding: 24px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--sky), var(--mint));
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-title h3,
.section-title p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
}

.brand p,
.eyebrow,
.section-title p,
.child-panel label {
  color: var(--muted);
}

.child-panel {
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.child-panel label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.child-panel input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.child-panel input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(77, 157, 224, 0.18);
}

.volume-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.volume-label strong {
  color: var(--ink);
}

.volume-control {
  width: 100%;
  accent-color: var(--sky);
}

.stars {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  color: #8a5b00;
  font-weight: 700;
}

.lesson-list {
  display: grid;
  gap: 8px;
}

.lesson-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.lesson-button.active {
  border-color: var(--sky);
  background: #eef7ff;
}

.lesson-button.done {
  border-color: rgba(55, 184, 153, 0.55);
}

.lesson-badge {
  display: grid;
  min-width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--mint);
  font-size: 13px;
  font-weight: 800;
}

.workspace {
  padding: 26px;
}

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

.eyebrow {
  font-size: 14px;
  font-weight: 700;
}

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0;
}

.progress-wrap {
  display: grid;
  gap: 8px;
  min-width: 190px;
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf3;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--gold));
  transition: width 0.25s ease;
}

.hero-lesson {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(380px, 1.05fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.mnemonic-card {
  display: grid;
  grid-template-columns: minmax(132px, 0.78fr) minmax(0, 1fr);
  gap: 16px;
  min-height: 280px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.memory-art {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 206px;
  overflow: hidden;
  border: 1px solid rgba(77, 157, 224, 0.3);
  border-radius: 8px;
  background: #e8f7ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.memory-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.memory-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.air-test-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.air-flow {
  fill: none;
  stroke: #4d9de0;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 7px;
}

.air-flow.quiet {
  stroke: #9dc8de;
  stroke-dasharray: 2 7;
  stroke-width: 5px;
}

.anchor-scene {
  display: grid;
  height: 100%;
  min-height: 206px;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 16px;
  background:
    radial-gradient(circle at 18% 18%, #fff7c9 0 10%, transparent 10.5%),
    radial-gradient(circle at 84% 78%, #d8f5ea 0 13%, transparent 13.5%),
    linear-gradient(145deg, #eaf7ff, #fdfcff 58%, #fff4e9);
  text-align: center;
}

.anchor-emoji {
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 1px solid rgba(77, 157, 224, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 22px rgba(36, 48, 66, 0.13);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 62px;
  line-height: 1;
}

.anchor-word {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.anchor-sound {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.anchor-sound strong {
  color: var(--blue);
  font-size: 18px;
}

.memory-copy {
  display: grid;
  align-content: center;
  gap: 12px;
  min-width: 0;
}

.memory-copy h3 {
  margin: 0;
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.2;
}

.memory-copy p {
  margin: 0;
}

.memory-points {
  display: grid;
  gap: 8px;
}

.memory-point {
  position: relative;
  padding: 10px 12px;
  padding-left: 34px;
  border-radius: 8px;
  color: var(--ink);
  border: 1px solid rgba(77, 157, 224, 0.12);
  background: linear-gradient(180deg, #f8fbff, #eef5fb);
  font-weight: 700;
}

.memory-point::before {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--rose));
  content: "";
  transform: translateY(-50%);
}

.lesson-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lesson-card {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 28px;
}

.lesson-card-main {
  display: grid;
  grid-template-columns: minmax(150px, 240px) minmax(180px, 1fr);
  gap: 20px;
  align-items: center;
}

.pinyin-big {
  width: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--sky), var(--rose));
  font-size: clamp(62px, 10vw, 118px);
  font-weight: 900;
  line-height: 1;
  overflow-wrap: anywhere;
  text-align: center;
}

.mouth-tip {
  margin: 0 0 8px;
  font-size: 21px;
  font-weight: 800;
}

.teacher-line {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 17px;
}

.action-row,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.contrast-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(245, 184, 61, 0.45);
  border-radius: 8px;
  background: #fff8e6;
}

.contrast-card strong,
.contrast-card p {
  margin: 0;
}

.contrast-card p {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

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

.primary-btn,
.secondary-btn,
.danger-btn,
.tab,
.chip,
.quiz-option {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.compact-btn {
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
}

.learn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.primary-btn {
  color: #fff;
  background: var(--sky);
}

.secondary-btn {
  color: var(--ink);
  background: #f2f6fa;
  border-color: var(--line);
}

.danger-btn {
  color: #fff;
  background: #c84b5d;
}

.tabs {
  margin-bottom: 12px;
}

.tab {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.tab.active {
  color: #fff;
  background: var(--ink);
}

.panel {
  display: none;
  padding: 22px;
}

.panel.active {
  display: block;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.section-title h3 {
  font-size: 24px;
}

.card-grid,
.quiz-options,
.chip-grid,
.tone-train,
.parent-grid {
  display: grid;
  gap: 12px;
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.pinyin-card,
.tone-card {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.pinyin-card strong,
.tone-card strong {
  display: block;
  font-size: 46px;
  line-height: 1;
}

.pinyin-card span,
.tone-card span {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.tone-card.disabled,
.tone-card:disabled {
  cursor: not-allowed;
  color: #9aa6b2;
  background: #eef2f6;
  opacity: 0.72;
}

.tone-train {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

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

.quiz-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.quiz-meta {
  color: var(--muted);
  font-weight: 900;
}

.speed-board {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.speed-board h4 {
  margin: 0 0 8px;
}

.speed-board ol {
  display: grid;
  gap: 6px;
  padding-left: 22px;
  margin: 0;
  color: var(--ink);
  font-weight: 900;
}

.quiz-options {
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
}

.test-lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.test-lesson-choice {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 60px;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.test-lesson-choice:has(input:checked) {
  border-color: rgba(55, 184, 153, 0.75);
  background: #eefaf7;
}

.test-lesson-choice input {
  position: absolute;
  opacity: 0;
}

.test-checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid #aab8c7;
  border-radius: 5px;
  background: #fff;
}

.test-lesson-choice input:checked + .test-checkmark {
  border-color: var(--mint);
  background: var(--mint);
  box-shadow: inset 0 0 0 4px #fff;
}

.test-lesson-name {
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.test-lesson-count {
  color: var(--muted);
  font-weight: 800;
}

.test-startbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.test-startbar p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.custom-test-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.dictation-setup {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.dictation-setup h4,
.dictation-setup p {
  margin: 0;
}

.dictation-setup p {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.dictation-counts {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
}

.count-choice {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
}

.count-choice.active {
  color: #fff;
  background: var(--ink);
}

.count-choice:disabled {
  color: #a5b0bc;
  cursor: not-allowed;
}

.dictation-box {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.dictation-board {
  width: 100%;
  height: 240px;
  border: 2px dashed #b8c9d8;
  border-radius: 8px;
  background-color: #fff;
  background-image: linear-gradient(#edf3f8 1px, transparent 1px), linear-gradient(90deg, #edf3f8 1px, transparent 1px);
  background-size: 28px 28px;
  touch-action: none;
}

.dictation-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dictation-hint span {
  padding: 6px 10px;
  border: 1px solid rgba(77, 157, 224, 0.42);
  border-radius: 999px;
  color: #21699e;
  background: #eef8ff;
  font-weight: 900;
}

.dictation-answer {
  padding: 14px 16px;
  border: 1px solid rgba(55, 184, 153, 0.52);
  border-radius: 8px;
  color: #0c6f5d;
  background: #e9fbf6;
  font-size: 34px;
  font-weight: 900;
  text-align: center;
}

.dictation-review {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.dictation-review-summary {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  color: var(--muted);
  font-weight: 800;
}

.dictation-review-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(77, 157, 224, 0.42);
  border-radius: 8px;
  color: var(--ink);
  background: #f5fbff;
  font-weight: 900;
}

.dictation-review-item img {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  object-fit: contain;
}

.dictation-review-answer {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: #0c6f5d;
  background: #e9fbf6;
  font-weight: 900;
}

.dictation-review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.review-mark {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
}

.review-mark.is-correct.active {
  border-color: rgba(55, 184, 153, 0.65);
  color: #0c6f5d;
  background: #e9fbf6;
}

.review-mark.is-wrong.active {
  border-color: rgba(232, 111, 143, 0.65);
  color: #a33f5a;
  background: #fff0f4;
}

.dictation-actions {
  display: flex;
  justify-content: flex-end;
}

.quiz-option {
  min-height: 72px;
  border-color: var(--line);
  background: #fff;
  font-size: 30px;
}

.quiz-option.pending {
  border-color: rgba(241, 180, 54, 0.9);
  color: #745000;
  background: #fff8df;
  box-shadow: inset 0 0 0 2px rgba(241, 180, 54, 0.18);
}

.quiz-option.correct {
  border-color: rgba(55, 184, 153, 0.7);
  color: #0c6f5d;
  background: #e9fbf6;
}

.quiz-option.wrong {
  border-color: rgba(232, 111, 143, 0.7);
  color: #a33f5a;
  background: #fff0f4;
}

.quiz-option:disabled {
  cursor: default;
}

.feedback {
  min-height: 28px;
  margin: 0;
  color: var(--mint);
  font-size: 20px;
  font-weight: 900;
}

.test-wrong-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.test-wrong-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(232, 111, 143, 0.42);
  border-radius: 8px;
  color: #874157;
  background: #fff5f7;
  font-weight: 800;
  cursor: pointer;
}

.test-wrong-item strong {
  color: var(--ink);
  font-size: 20px;
}

.spell-modebar {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
}

.spell-mode {
  min-height: 38px;
  padding: 8px 16px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
}

.spell-mode.active {
  color: #fff;
  background: var(--ink);
}

.spell-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr minmax(220px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.spell-layout.two-mode {
  grid-template-columns: 1fr 1fr minmax(220px, 0.8fr);
}

.is-hidden {
  display: none;
}

.spell-layout h4 {
  margin: 0 0 10px;
}

.chip-grid {
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
}

.chip {
  border-color: var(--line);
  background: #fff;
  font-size: 22px;
}

.chip.selected {
  color: #fff;
  background: var(--mint);
}

.chip.disabled,
.chip:disabled {
  color: #9aa4b2;
  background: #edf1f5;
  border-color: #e1e7ee;
  cursor: not-allowed;
  opacity: 0.68;
}

.chip.disabled.selected,
.chip:disabled.selected {
  color: #9aa4b2;
  background: #edf1f5;
}

.result-box {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: #fff7df;
}

.result-box span {
  font-size: 30px;
  font-weight: 900;
}

.spell-tones {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.spell-tone-btn {
  min-height: 46px;
  padding: 8px;
  border: 1px solid rgba(245, 184, 61, 0.65);
  border-radius: 8px;
  color: var(--ink);
  background: #fffdfa;
  font-size: 20px;
  font-weight: 900;
}

.spell-tone-btn.active {
  color: #fff;
  background: var(--gold);
}

.spell-tone-btn.disabled,
.spell-tone-btn:disabled {
  color: #9aa4b2;
  background: #edf1f5;
  border-color: #e1e7ee;
  cursor: not-allowed;
  opacity: 0.68;
}

.parent-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 16px;
}

.parent-item {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.parent-item strong {
  font-size: 34px;
}

.parent-item span {
  color: var(--muted);
}

.offline-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(77, 157, 224, 0.28);
  border-radius: 8px;
  background: #f7fbff;
}

.offline-card h4,
.offline-card p {
  margin: 0;
}

.offline-card p {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.offline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .lesson-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .hero-lesson,
  .mnemonic-card,
  .spell-layout {
    grid-template-columns: 1fr;
  }

  .lesson-card-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-title {
    align-items: start;
    flex-direction: column;
  }

  .progress-wrap {
    width: 100%;
  }

  .memory-art {
    min-height: 190px;
  }

  .mnemonic-card,
  .lesson-card {
    padding: 18px;
  }

  .parent-grid {
    grid-template-columns: 1fr;
  }

  .test-startbar {
    align-items: stretch;
    flex-direction: column;
  }

  .offline-card {
    align-items: stretch;
    flex-direction: column;
  }

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