:root {
  --paper: #f4f0e7;
  --card: #fffdf9;
  --ink: #241c16;
  --muted: #5e564c;
  --line: #e4d8c8;
  --accent: #1d4e89;
  --soft: #e7eef6;
  --good: #1f6b4a;
  --bad: #8d3d32;
  --radius: 18px;
  color-scheme: light;
}

body[data-track="child"] {
  --paper: #fff6ec;
  --accent: #b8431c;
  --soft: #ffe8d8;
  --ink: #2b2118;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  font-size: 17px;
  line-height: 1.55;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
#app { min-height: 100vh; }
.wrap { width: min(980px, calc(100% - 28px)); margin: 0 auto; padding-bottom: 48px; }
.top { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 18px 0; }
.brand { display: flex; gap: 8px; align-items: center; color: var(--ink); font-weight: 700; text-decoration: none; }
.mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--accent); color: white; }
nav { display: flex; gap: 8px; align-items: center; }
nav a, .text-button { color: var(--muted); text-decoration: none; background: none; border: 0; padding: 8px 10px; border-radius: 999px; }
nav a.on, nav a:hover { background: white; color: var(--ink); }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.2; margin: 0 0 8px; }
h2 { margin: 0 0 8px; }
.eyebrow { color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.lead, .quiet { color: var(--muted); }
.hero { padding-top: 8px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.card, .panel, .word, .lesson { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card { padding: 22px; min-height: 220px; display: flex; flex-direction: column; gap: 10px; }
.card p { margin: 0; color: var(--muted); flex: 1; }
.card.adult { border-top: 6px solid #1d4e89; }
.card.child { border-top: 6px solid #2f7ead; }
.btn, .option-btn, .match, .lesson {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 12px;
  min-height: 48px;
  padding: 10px 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn.secondary, .btn.ghost, .option-btn, .match { background: white; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: var(--soft); color: var(--accent); }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 0.92rem; }
.btn:disabled, .lesson:disabled { opacity: 0.55; cursor: not-allowed; }
.row, .stats { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stats { margin: 14px 0; }
.stats div, .panel, .word { padding: 14px; }
.stats strong, .en { display: block; font-family: Georgia, "Iowan Old Style", Palatino, serif; }
.en { font-size: 1.45rem; line-height: 1.3; overflow-wrap: anywhere; }
.en.small { font-size: 1.1rem; }
.stats span, label { color: var(--muted); }
label, .stack { display: flex; flex-direction: column; gap: 6px; }
.narrow { width: min(640px, 100%); }
input, select {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: white;
  font-size: 16px;
}
.fill { width: 100%; }
.banner, .form-message { background: #fff6df; color: #6d4d12; border-radius: 12px; padding: 10px 12px; }
.form-message:empty { display: none; }
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson { width: 100%; color: var(--ink); background: var(--card); justify-content: space-between; text-align: left; gap: 10px; }
.num { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--soft); color: var(--accent); font-weight: 700; }
.badge { color: var(--muted); font-size: 0.92rem; }
.word-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.word { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.art { display: block; width: 72px; height: 72px; }
.line { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 12px 0; }
.step { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: white; color: var(--muted); }
.step.now { background: var(--accent); color: white; border-color: var(--accent); }
.option { display: flex; gap: 8px; align-items: center; color: var(--ink); margin: 6px 0; }
.option-btn, .match { width: 100%; justify-content: flex-start; gap: 10px; text-align: left; }
.option-btn.picked, .match.picked { border-color: var(--accent); background: var(--soft); }
.good { color: var(--good); font-weight: 700; }
.bad { color: var(--bad); font-weight: 700; }
.timer { font-weight: 700; color: var(--accent); }
.voice-bar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 10px 0 12px;
}
.voice-bar select { min-height: 38px; padding: 0 10px; font-size: 0.92rem; }
.chip-btn {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-size: 0.92rem;
}
.chip-btn.on { background: var(--accent); color: white; border-color: var(--accent); }
.chip-link { font-size: 0.92rem; margin-left: auto; }
.sep { color: var(--line); }
.script-box {
  background: var(--soft);
  border-radius: 14px;
  padding: 14px 16px;
}
.meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e9dfd0;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 80ms linear;
}
.shadow-box {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #faf6ef;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shadow-head { justify-content: space-between; }
.small-chip { min-height: 34px; padding: 4px 10px; font-size: 0.85rem; }
.small-opt { font-size: 0.9rem; margin: 2px 0; }
.score-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}
.score-grid div {
  background: var(--soft);
  border-radius: 10px;
  padding: 8px 4px;
}
.score-grid strong { display: block; font-size: 1.3rem; color: var(--accent); }
.score-grid span { font-size: 0.85rem; color: var(--muted); }
.stars { font-size: 1.6rem; color: #d89b1c; margin: 0; letter-spacing: 4px; }
.word-chip {
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--soft);
  color: var(--accent);
  font-size: 0.9rem;
}
.shadow-box audio { max-width: 100%; height: 40px; }
.lesson.recommended { border: 2px solid var(--accent); background: var(--soft); }
.badge-rec { color: var(--accent); font-weight: 700; }
.lesson-title-wrap { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.stress-word {
  background: #ffe9a8;
  color: inherit;
  padding: 0 4px;
  border-radius: 6px;
}
.zh-main { margin: 2px 0 0; font-size: 1.05rem; }
.meta-grid p { margin: 2px 0; font-size: 0.95rem; }
.chunk-box { display: flex; flex-direction: column; gap: 6px; }
.chunk-pill {
  background: var(--soft);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.9rem;
}
.pattern-box {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f2ea;
  border-left: 4px solid var(--accent);
}
.alt-box { gap: 8px; }
.alt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 12px;
  background: #faf7f2;
  border: 1px solid var(--line);
}
.alt-text { flex: 1; min-width: 180px; }
.tone-tag {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.tone-tag.polite { background: #e1f0e8; color: #1f6b4a; }
.tone-tag.casual { background: #fdebd0; color: #8c4a12; }
.ipa-tag {
  font-family: "Lucida Sans Unicode", "Arial Unicode MS", sans-serif;
  font-size: 0.95rem;
  color: var(--muted);
  background: var(--soft);
  padding: 2px 8px;
  border-radius: 8px;
}
.scene-note {
  margin: 0;
  padding: 10px 12px;
  background: var(--soft);
  border-radius: 12px;
}
.mistake-item, .reply-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: #faf6ef;
  border: 1px solid var(--line);
}
.mistake-item p, .reply-item p { margin: 2px 0; }
.story-card {
  background: linear-gradient(135deg, #fff2e0 0%, #fffdf9 100%);
  border: 2px solid #f0c28f;
}
.sticker-preview {
  margin: 0;
  display: inline-block;
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 999px;
  background: white;
  border: 1px dashed var(--accent);
  font-weight: 700;
}
.sticker-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  background: #fff3de;
  border: 2px solid #f0c28f;
}
.sticker-icon { font-size: 2.2rem; line-height: 1; }
.reveal-card {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
}
.reveal-card.revealed {
  background: #fff8eb;
  border-color: var(--accent);
}
.reveal-content { font-size: 0.95rem; color: var(--muted); }
.reveal-card.revealed .reveal-content { color: var(--ink); font-weight: 600; }
.interactive-sentence {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sentence-surface {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #faf7f1;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.sentence-surface:hover { border-color: var(--accent); background: #f6f2e8; }
.interactive-sentence.is-playing .sentence-surface {
  border-color: var(--accent);
  background: var(--soft);
  box-shadow: 0 0 0 2px rgba(29, 78, 137, 0.14);
}
.sent-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sent-meta-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sent-speaker { font-size: 0.92rem; color: var(--accent); }
.sent-text { margin: 0; line-height: 1.55; }
.sent-actions { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; align-items: center; }
.sent-btn { white-space: nowrap; }
.word-token {
  display: inline;
  background: transparent;
  border: 0;
  border-bottom: 1.5px dotted rgba(36, 28, 22, 0.35);
  border-radius: 5px;
  padding: 1px 3px;
  margin: 0;
  font: inherit;
  color: inherit;
  line-height: inherit;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease;
}
.word-token:hover, .word-token.active-word {
  background: #dce9f8;
  border-bottom-color: var(--accent);
}
body[data-track="child"] .word-token:hover,
body[data-track="child"] .word-token.active-word {
  background: #ffd9be;
}
.word-token.stress-word {
  background: #ffe9a8;
}
.word-token.stress-word:hover, .word-token.stress-word.active-word {
  background: #ffd96a;
}
.word-token.chunk-token {
  border-bottom: 2px solid rgba(29, 78, 137, 0.45);
}
body[data-track="child"] .word-token.chunk-token {
  border-bottom-color: rgba(184, 67, 28, 0.5);
}
.word-popover {
  position: fixed;
  z-index: 900;
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(36, 28, 22, 0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(68vh, 420px);
  overflow-y: auto;
}
.word-popover.child-pop {
  background: #fffaf3;
  border-width: 2px;
}
.pop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.pop-word { font-family: Georgia, "Iowan Old Style", Palatino, serif; font-size: 1.15rem; color: var(--accent); }
.pop-close {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center;
}
.pop-block { display: flex; flex-direction: column; gap: 2px; }
.pop-block p { margin: 0; font-size: 0.94rem; }
.pop-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.pop-ipa {
  font-family: "Lucida Sans Unicode", "Arial Unicode MS", sans-serif;
  color: var(--muted);
}
.pop-extras {
  border-top: 1px dashed var(--line);
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pop-extra { margin: 0; font-size: 0.88rem; color: var(--muted); }
.pop-mistake { color: var(--bad); }
.pop-head-actions { display: flex; gap: 6px; align-items: center; }
.pop-speak {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
}
.pop-footer { padding-top: 6px; border-top: 1px solid var(--line); }
.stack-tight { display: flex; flex-direction: column; gap: 6px; }
.dict-search-row { display: flex; gap: 10px; align-items: center; }
.dict-search-row input { flex: 1; }
.dict-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.dict-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dict-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; transition: border-color 0.15s; }
.dict-card:hover { border-color: var(--accent); text-decoration: none; }
.dict-card-head, .dict-detail-head, .dict-sense-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.dict-sense-head { justify-content: flex-start; align-items: center; }
.dict-hw-wrap { display: flex; flex-direction: column; gap: 2px; }
.dict-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.82rem;
  color: var(--muted);
}
.level-pill { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 700; }
.dict-gloss { margin: 0; font-size: 0.95rem; }
.dict-match-note { margin: 0; font-size: 0.85rem; color: var(--accent); }
.dict-irr { margin: 0; font-size: 0.94rem; }
.sentence-note { margin: 0; font-size: 0.9rem; }
fieldset { border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (max-width: 760px) {
  .cards, .word-grid, .dict-grid, .dict-filters { grid-template-columns: 1fr; }
  .top { align-items: flex-start; flex-direction: column; }
  .lesson { align-items: flex-start; flex-direction: column; }
  .sentence-surface { flex-direction: column; align-items: stretch; }
  .sent-actions { width: 100%; justify-content: flex-start; }
  .steps { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .step { font-size: 0.82rem; padding: 0 2px; }
}
