:root {
  color-scheme: dark;
  --bg: #171a1d;
  --panel: #21262b;
  --panel-2: #292f35;
  --line: #3b434a;
  --text: #f2f0eb;
  --muted: #adb4b9;
  --orange: #f08a55;
  --orange-deep: #7c3f2a;
  --blue: #72a8df;
  --blue-deep: #293f59;
  --green: #74c497;
  --red: #e97a74;
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
a { color: var(--blue); }
[hidden] { display: none !important; }

.app-shell { width: min(100%, 560px); min-height: 100dvh; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 18px calc(108px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.brand { min-width: 0; }
.brand small, .eyebrow { display: block; color: var(--orange); font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.brand strong { display: block; font-size: 1.05rem; }
.icon-button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 1.2rem; }
.icon-button:disabled { opacity: .35; }

h1 { margin: 8px 0 12px; font-size: 1.85rem; line-height: 1.16; letter-spacing: -.03em; }
h2 { margin: 0 0 8px; font-size: 1.12rem; }
p { margin: 0; }
.lead { color: var(--muted); font-size: 1rem; max-width: 42rem; }
.quiet { color: var(--muted); font-size: .87rem; }
.preview-notice { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: -8px 0 20px; padding: 11px 12px; border: 1px solid #5a665f; border-radius: 14px; background: #202923; color: #cbe1d2; font-size: .82rem; }
.preview-notice span, .preview-notice strong { display: block; }
.preview-notice strong { margin-bottom: 1px; color: var(--green); }
.preview-notice button { flex: 0 0 auto; min-height: 38px; padding: 0 12px; border: 1px solid #56645b; border-radius: 11px; background: transparent; color: #d8e8dd; font-weight: 760; }

.hero { padding: 8px 0 22px; }
.hero-progress { margin-top: 22px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.progress-copy { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.progress-copy span { color: var(--muted); font-size: .88rem; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #111416; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--orange); transition: width 180ms ease; }
.primary, .secondary, .audio-button, .practice-button, .reveal-button, .tab-button { min-height: 46px; border-radius: 13px; border: 1px solid transparent; font-weight: 760; cursor: pointer; }
.primary { width: 100%; margin-top: 14px; background: var(--orange); color: #23130d; }
.primary:active { transform: translateY(1px); }
.secondary { background: var(--panel); border-color: var(--line); padding: 0 16px; }
.secondary.done, .practice-button.done { border-color: var(--green); color: var(--green); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin: 8px 0 18px; background: #111416; border-radius: 14px; }
.tab-button { background: transparent; color: var(--muted); }
.tab-button.active { background: var(--panel-2); color: var(--text); }

.day-list { display: grid; gap: 10px; }
.day-card { display: grid; grid-template-columns: 50px 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 14px; text-align: left; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.day-card.current { border-color: var(--orange); }
.day-card.locked { opacity: .52; }
.day-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--panel-2); font-size: 1.35rem; }
.day-copy strong, .day-copy span { display: block; }
.day-copy span { color: var(--muted); font-size: .83rem; }
.day-state { color: var(--muted); font-size: .78rem; }
.archive-link { display: block; margin-top: 22px; padding: 14px 0; color: var(--muted); text-align: center; font-size: .86rem; }

.lesson-header { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 44px 1fr 48px; align-items: center; gap: 10px; margin: calc(-18px - env(safe-area-inset-top)) -6px 22px; padding: calc(12px + env(safe-area-inset-top)) 6px 12px; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); }
.lesson-meta { min-width: 0; }
.lesson-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.lesson-meta .progress-track { margin-top: 7px; height: 5px; }
.step-count { color: var(--muted); text-align: right; font-size: .8rem; }
.step { animation: enter 180ms ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.stack { display: grid; gap: 12px; margin-top: 22px; }
.card, .sentence-card, .word-card, .note-card, .cloze-card, .recall-card, .record-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 16px; }
.sentence-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.speaker { flex: 0 0 auto; padding: 4px 9px; border-radius: 999px; background: var(--blue-deep); color: #bedcff; font-size: .72rem; font-weight: 800; }
.speaker.jade { background: var(--orange-deep); color: #ffd1bd; }
.speaker.coach { background: #244735; color: #bfe8d0; }
.english { margin-top: 5px; font-size: 1.14rem; font-weight: 780; line-height: 1.35; }
.chinese { margin-top: 5px; color: var(--muted); }
.audio-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.audio-button { background: var(--panel-2); border-color: var(--line); }
.audio-button.fufu { color: #ffb18a; }
.audio-button.ai { color: #a8cfff; }
.audio-button.playing { border-color: currentColor; background: #343b42; }
.practice-button { width: 100%; margin-top: 9px; background: transparent; border-color: var(--line); color: var(--muted); }

.section-label { margin: 26px 0 10px; color: var(--muted); font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.word-card { display: grid; grid-template-columns: minmax(74px, .7fr) minmax(0, 1.5fr); gap: 6px 12px; align-items: start; }
.word-card .english { margin: 0; }
.word-card .audio-pair, .word-card .practice-button { grid-column: 1 / -1; }
.focus-card { border-color: #76513f; }
.focus-badge { color: var(--orange); font-size: .72rem; font-weight: 800; }
.warmup-card .answer { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.learning-rule, .must-do { margin-top: 18px; padding: 15px 16px; border: 1px solid oklch(0.66 0.11 55); border-radius: 15px; background: oklch(0.26 0.035 48); }
.learning-rule strong, .learning-rule span, .must-do strong, .must-do span { display: block; }
.learning-rule strong, .must-do strong { color: oklch(0.82 0.12 56); font-size: 1.08rem; }
.learning-rule span, .must-do span { margin-top: 5px; color: var(--text); font-size: .95rem; }
.scene-preview { margin-top: 18px; padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.scene-preview-label { margin-bottom: 9px; color: var(--orange); font-size: .8rem; font-weight: 820; }
.scene-preview-line { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; padding: 8px 0; }
.scene-preview-line + .scene-preview-line { border-top: 1px solid var(--line); }
.scene-preview-line span { color: var(--muted); font-size: .78rem; font-weight: 780; }
.scene-preview-line p { color: var(--text); }
.breakdown-list { display: grid; gap: 18px; margin-top: 22px; }
.breakdown-group { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.breakdown-context { padding: 17px 16px; background: var(--panel-2); }
.breakdown-context .speaker { display: inline-block; margin-bottom: 7px; }
.breakdown-sentence { font-size: 1.06rem; font-weight: 820; line-height: 1.4; }
.breakdown-label { padding: 12px 16px 7px; color: var(--orange); font-size: .72rem; font-weight: 820; letter-spacing: .06em; text-transform: uppercase; }
.breakdown-phrase, .breakdown-word { display: grid; grid-template-columns: minmax(0, 1fr) 156px; gap: 8px 12px; align-items: start; padding: 12px 16px; border-top: 1px solid var(--line); }
.breakdown-phrase strong, .breakdown-phrase span, .breakdown-word strong, .breakdown-word span { display: block; }
.breakdown-phrase span, .breakdown-word span { color: var(--muted); }
.phrase-note { margin-top: 6px; color: var(--text); font-size: .88rem; font-weight: 650; }
.breakdown-phrase .audio-pair, .breakdown-word .audio-pair { margin: 0; }
.breakdown-phrase .practice-button, .breakdown-word .practice-button { grid-column: 1 / -1; margin-top: 0; }
.known-words { padding: 13px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.sentence-finish { padding: 14px 16px 17px; border-top: 1px solid var(--line); background: oklch(0.235 0.015 250); }
.sentence-finish .breakdown-label { padding: 0 0 7px; }
.sentence-finish-copy { margin-bottom: 8px; color: var(--text); font-size: 1.12rem; font-weight: 820; line-height: 1.42; }
.sentence-finish > strong { display: block; font-size: 1.05rem; }
.sentence-finish > p { margin-top: 4px; color: var(--text); font-size: .9rem; }
.note-card.must-see { border-color: oklch(0.68 0.12 55); background: oklch(0.25 0.03 48); }
.note-kicker { display: inline-block; margin-bottom: 8px; padding: 4px 8px; border-radius: 999px; background: oklch(0.77 0.14 55); color: oklch(0.24 0.035 48); font-size: .76rem; font-weight: 850; }
.note-card h2 { color: var(--text); font-size: 1.2rem; }
.note-card ul { margin: 10px 0 0; padding-left: 1.2rem; color: var(--text); font-size: .98rem; }
.note-card li + li { margin-top: 8px; }

.cloze-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 20px; }
.cloze-tabs button { min-height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--muted); }
.cloze-tabs button.active { color: var(--text); border-color: var(--orange); }
.cloze-prompt { font-size: 1.18rem; font-weight: 780; }
.blank { color: var(--orange); letter-spacing: .08em; }
.hint-box { margin-top: 12px; padding: 11px 12px; border-radius: 12px; background: #171b1f; color: var(--muted); }
.hint-box strong { display: block; margin-top: 4px; color: var(--text); }
.reveal-button { width: 100%; margin-top: 12px; background: transparent; border-color: var(--line); color: var(--blue); }

.recall-card { cursor: pointer; }
.recall-card .answer { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.recall-card .answer[hidden] { display: none; }

.lesson-footer { position: fixed; left: 50%; bottom: 0; z-index: 20; width: min(100%, 560px); transform: translateX(-50%); padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 26%); }
.lesson-footer .primary { margin: 18px 0 0; }
.record-button { width: 100%; min-height: 52px; margin-top: 14px; border: 0; border-radius: 14px; background: var(--red); color: #26100f; font-weight: 820; }
.record-button.recording { background: #f0d36d; }
.record-playback { width: 100%; margin-top: 12px; }
.record-plan { display: grid; grid-template-columns: 1fr auto 1.35fr auto 1fr; gap: 7px; align-items: center; margin: 20px 0; color: var(--muted); font-size: .78rem; text-align: center; }
.record-plan strong { color: var(--text); font-weight: 760; }
.record-guide { margin-top: 14px; padding: 12px 13px; border: 1px solid oklch(0.63 0.08 55); border-radius: 12px; background: oklch(0.25 0.026 48); color: var(--text); font-size: .92rem; font-weight: 700; line-height: 1.55; }
.record-guide.done { border-color: oklch(0.64 0.09 155); background: oklch(0.24 0.025 155); }
.record-playback-label { margin-top: 14px; color: var(--orange); font-size: .82rem; font-weight: 800; }
.upload-state { margin-top: 10px; color: var(--green); font-size: .86rem; }

@media (max-width: 430px) {
  .record-plan { grid-template-columns: 1fr; text-align: left; }
  .record-plan span { display: none; }
}

.coach-login { margin-top: 72px; }
.coach-login form { display: grid; gap: 10px; margin-top: 24px; }
.coach-login label { color: var(--muted); font-size: .82rem; font-weight: 760; }
.coach-login input { width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); color: var(--text); }
.coach-login input:focus { border-color: var(--blue); outline: 3px solid color-mix(in srgb, var(--blue) 24%, transparent); }
.coach-login code { color: var(--text); }
.login-error { margin-top: 18px; color: var(--red); }
.coach-exit { min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: transparent; color: var(--muted); }
.coach-current { margin-top: 10px; color: var(--text); font-weight: 720; }
.coach-section { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.listening-summary { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 14px 0; color: var(--muted); font-size: .84rem; }
.listening-list { margin: 0; padding: 0; list-style: none; }
.listening-list li { display: grid; grid-template-columns: 54px 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.listening-list strong, .listening-list span, .listening-list small { display: block; }
.listening-list span, .listening-list small { color: var(--muted); }
.listening-list small { margin-top: 3px; font-size: .74rem; }
.listen-rank { color: var(--orange) !important; font-weight: 800; }
.record-day { margin-top: 18px; }
.record-day > header { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.record-day > header span { color: var(--muted); font-size: .8rem; }
.coach-last-active { margin-top: 26px; }

.library-toolbar { display: grid; gap: 10px; margin: 16px 0; }
.direction-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.direction-toggle button { min-height: 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--muted); }
.direction-toggle button.active { border-color: var(--blue); color: var(--text); }
.library-card { cursor: pointer; }
.library-answer { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.review-choice { display: grid; gap: 8px; margin-top: 10px; }
.review-choice .practice-button { margin-top: 0; }
.topic-label { color: var(--orange); font-size: .72rem; font-weight: 800; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 50; max-width: calc(100% - 40px); transform: translate(-50%, 14px); padding: 10px 14px; border-radius: 12px; background: #090b0d; color: var(--text); opacity: 0; pointer-events: none; transition: 160ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
@media (max-width: 420px) { .breakdown-phrase, .breakdown-word { grid-template-columns: 1fr; } .breakdown-phrase .audio-pair, .breakdown-word .audio-pair { margin-top: 4px; } }
@media (max-width: 360px) { .preview-notice { align-items: stretch; flex-direction: column; } }
@media (min-width: 620px) { .app-shell { padding-inline: 22px; } }
