/* Nói Hán Tự — style.css. Themes: "Neon đêm" (default, dark + glow) and "Dễ thương" (light, clay, rounded).
   Components use semantic tokens only. Mobile-first (390×844), desktop layout from 900px. */

/* ============================================================ tokens */
:root {
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-display: "Baloo 2", "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-hz: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  --font-num: ui-rounded, "Nunito", "Segoe UI", system-ui, sans-serif;
  --r-btn: 18px; --r-card: 24px; --r-chip: 14px; --r-modal: 28px;
  --tap: 44px;
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);
  --t-fast: 120ms; --t-mid: 240ms;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
html[data-theme="neon"] {
  color-scheme: dark;
  --bg: #070A14;
  --bg-grid: rgba(120, 140, 255, .06);
  --bg-glow-1: rgba(34, 211, 238, .14);
  --bg-glow-2: rgba(192, 132, 252, .14);
  --surface: #0F1426;
  --surface-2: #141B33;
  --surface-3: #1B2444;
  --line: rgba(140, 160, 255, .18);
  --line-strong: rgba(160, 180, 255, .38);
  --ink: #EAF0FF;
  --ink-soft: #A3AED0;
  --ink-faint: #7E89AD;
  --primary: #22D3EE;
  --primary-2: #0EA5E9;
  --on-primary: #04121A;
  --primary-soft: rgba(34, 211, 238, .14);
  --accent: #C084FC;
  --pink: #FF5FA2;
  --star: #FCD34D;
  --good: #4ADE80; --good-bg: rgba(74, 222, 128, .14);
  --warn: #FBBF24; --warn-bg: rgba(251, 191, 36, .15);
  --bad: #FF5C77; --bad-bg: rgba(255, 92, 119, .15);
  --miss: #94A3B8; --miss-bg: rgba(148, 163, 184, .10);
  --shadow-card: 0 0 0 1px var(--line), 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-btn: 0 0 18px rgba(34, 211, 238, .45);
  --glow-primary: 0 0 24px rgba(34, 211, 238, .55);
  --glow-text: 0 0 18px rgba(34, 211, 238, .35);
  --mic-grad: radial-gradient(circle at 35% 30%, #67E8F9, #22D3EE 45%, #0891B2);
  --mic-live: radial-gradient(circle at 35% 30%, #FF9CC4, #FF5FA2 50%, #DB2777);
  --border-w: 1px;
}
html[data-theme="cute"] {
  color-scheme: light;
  --bg: #FFF8EE;
  --bg-grid: rgba(91, 75, 219, .045);
  --bg-glow-1: rgba(255, 200, 221, .55);
  --bg-glow-2: rgba(189, 224, 254, .6);
  --surface: #FFFFFF;
  --surface-2: #F6F1FF;
  --surface-3: #EEE6FF;
  --line: #E6DDF6;
  --line-strong: #CFC2EE;
  --ink: #2B2350;
  --ink-soft: #5B5680;
  --ink-faint: #77729A;
  --primary: #5B4BDB;
  --primary-2: #4636C4;
  --on-primary: #FFFFFF;
  --primary-soft: #E6E1FF;
  --accent: #FF8A3D;
  --pink: #FF5E8A;
  --star: #F5A524;
  --good: #1B8A57; --good-bg: #DDF5E9;
  --warn: #A86200; --warn-bg: #FFF0CF;
  --bad: #C9303A; --bad-bg: #FFE1E3;
  --miss: #6B6790; --miss-bg: #F0EEF7;
  --shadow-card: 0 6px 0 rgba(43, 35, 80, .10), 0 14px 28px rgba(43, 35, 80, .10);
  --shadow-btn: 0 5px 0 #3B2DAE, 0 10px 18px rgba(91, 75, 219, .25);
  --glow-primary: 0 0 0 6px rgba(91, 75, 219, .14);
  --glow-text: none;
  --mic-grad: radial-gradient(circle at 35% 30%, #8F82F0, #5B4BDB 55%, #4636C4);
  --mic-live: radial-gradient(circle at 35% 30%, #FFA3BD, #FF5E8A 55%, #E23E6E);
  --border-w: 2px;
}

/* ============================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font: 16px/1.5 var(--font); color: var(--ink); background: var(--bg);
  background-image:
    radial-gradient(60vw 40vh at 0% 0%, var(--bg-glow-1), transparent 70%),
    radial-gradient(60vw 40vh at 100% 100%, var(--bg-glow-2), transparent 70%),
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  background-attachment: fixed;
  overflow-x: hidden;
  transition: background-color .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 10px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--primary); color: var(--on-primary); padding: 10px 14px; border-radius: 12px; font-weight: 800; }
.skip-link:focus { top: 8px; }
[hidden] { display: none !important; }
.ic { width: 24px; height: 24px; flex: none; display: inline-block; vertical-align: middle; }
main { outline: none; }
[lang="zh-CN"], .hz { font-family: var(--font-hz); }

/* ============================================================ screens + transitions */
.screen { max-width: 1180px; margin: 0 auto; padding: calc(8px + var(--safe-t)) 16px 0; animation: screen-in var(--t-mid) ease-out; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================================================ buttons */
.btn {
  min-height: var(--tap); padding: 10px 18px; border-radius: var(--r-btn);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; letter-spacing: .01em; border: var(--border-w) solid var(--line-strong);
  background: var(--surface-2); color: var(--ink);
  transition: transform var(--t-fast) ease-out, box-shadow var(--t-fast), background-color .2s, opacity .2s;
  touch-action: manipulation; user-select: none;
}
.btn:active { transform: translateY(2px) scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: transparent; box-shadow: var(--shadow-btn); }
html[data-theme="neon"] .btn-primary { background: linear-gradient(135deg, #22D3EE, #38BDF8 60%, #818CF8); }
html[data-theme="cute"] .btn-primary:active { box-shadow: 0 2px 0 #3B2DAE; transform: translateY(3px); }
.btn-ghost { background: transparent; }
.btn-good { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.btn-bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn-danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn-xl { min-height: 56px; font-size: 18px; padding: 12px 22px; width: 100%; }
.btn-xl .ic { width: 26px; height: 26px; }
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 14px; display: inline-grid; place-items: center;
  background: var(--surface); border: var(--border-w) solid var(--line); color: var(--ink);
  transition: transform var(--t-fast), background-color .2s; flex: none;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn[aria-pressed="false"] { color: var(--ink-faint); }
.icon-btn-spacer { width: var(--tap); }
.link-btn { background: none; border: 0; color: var(--primary); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; min-height: var(--tap); padding: 0 6px; }

/* ============================================================ banners, toast */
.banners { position: sticky; top: 0; z-index: 30; display: grid; gap: 6px; padding: 0 8px; }
.banners:not(:empty) { padding-top: calc(6px + var(--safe-t)); }
.banner {
  display: flex; gap: 10px; align-items: flex-start; max-width: 860px; margin: 0 auto; width: 100%;
  background: var(--surface); border: var(--border-w) solid var(--warn); border-radius: 16px; padding: 10px 8px 10px 14px;
  box-shadow: var(--shadow-card); font-size: 14px; animation: pop-in .28s var(--ease-pop);
}
.banner.info { border-color: var(--primary); }
.banner .b-text { flex: 1; padding-top: 2px; }
.banner strong { color: var(--ink); }
.banner .b-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.banner .btn { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 60;
  background: var(--surface-3); color: var(--ink); border: var(--border-w) solid var(--line-strong);
  padding: 12px 16px; border-radius: 16px; max-width: min(92vw, 460px); font-weight: 700; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease-pop); box-shadow: var(--shadow-card);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { border-color: var(--warn); }

/* ============================================================ setup */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: .01em; white-space: nowrap; text-shadow: var(--glow-text); }
html[data-theme="neon"] .brand-name { background: linear-gradient(90deg, #67E8F9, #C084FC); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.streak-chip {
  display: inline-flex; align-items: center; gap: 2px; height: 36px; padding: 0 8px; border-radius: 999px;
  background: var(--surface); border: var(--border-w) solid var(--line); font-weight: 800; color: var(--accent);
}
.streak-chip .ic { width: 18px; height: 18px; }
.streak-chip.hot { color: var(--pink); }

.setup-grid { display: grid; gap: 16px; padding-bottom: calc(150px + var(--safe-b)); }
.hero { display: flex; align-items: center; gap: 12px; margin: 4px 0 6px; }
.hero h1 { font-family: var(--font-display); font-size: 26px; line-height: 1.2; margin: 0 0 4px; }
.hero p { margin: 0; color: var(--ink-soft); font-size: 15px; }
.hero-mascot { flex: none; }
.block { border: 0; margin: 0 0 4px; padding: 0; min-width: 0; }
.block-title { display: block; font-weight: 800; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); margin: 14px 0 8px; padding: 0; }
.hint { color: var(--ink-faint); font-size: 13px; margin: 6px 0 0; }

.mode-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mode-card {
  text-align: left; display: flex; flex-direction: column; gap: 4px; min-height: 120px; padding: 12px 10px;
  background: var(--surface); border: var(--border-w) solid var(--line); border-radius: 20px; box-shadow: var(--shadow-card);
  transition: transform var(--t-fast), border-color .2s, box-shadow .2s, background-color .2s;
}
.mode-card:active { transform: scale(.98); }
.mode-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); }
.mode-name { font-weight: 800; font-size: 16px; }
.mode-desc { font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; }
.mode-card[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--glow-primary), var(--shadow-card); }
.mode-card[aria-checked="true"] .mode-ic { background: var(--primary); color: var(--on-primary); }

.select-wrap { position: relative; }
.select-wrap::after { content: ""; position: absolute; right: 16px; top: 50%; width: 9px; height: 9px; border-right: 2.5px solid var(--ink-soft); border-bottom: 2.5px solid var(--ink-soft); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
select {
  width: 100%; min-height: 50px; appearance: none; -webkit-appearance: none; padding: 10px 40px 10px 14px; border-radius: 16px;
  background: var(--surface); border: var(--border-w) solid var(--line-strong); font-weight: 700; color: var(--ink);
}
html[data-theme="neon"] select option, html[data-theme="neon"] select optgroup { background: #0F1426; color: #EAF0FF; }
.material-meta { display: flex; gap: 10px; align-items: center; margin-top: 8px; color: var(--ink-soft); font-size: 14px; flex-wrap: wrap; }
.material-meta .stars-mini { color: var(--star); font-weight: 800; display: inline-flex; align-items: center; gap: 2px; }
.material-meta .stars-mini .ic { width: 16px; height: 16px; }
.mini-bar { flex: 1; min-width: 100px; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.mini-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--good), var(--primary)); border-radius: 99px; transition: width .4s; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; flex-wrap: nowrap; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: var(--tap); min-width: 76px; padding: 8px 16px; border-radius: 999px;
  background: var(--surface); border: var(--border-w) solid var(--line-strong); font-weight: 800;
  transition: background-color .2s, border-color .2s, transform var(--t-fast);
}
.chip[aria-checked="true"] { background: var(--primary); color: var(--on-primary); border-color: transparent; box-shadow: var(--shadow-btn); }
.chip:active { transform: scale(.96); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; background: var(--surface); border: var(--border-w) solid var(--line); border-radius: 16px; padding: 4px; }
.seg > button { flex: 1 1 auto; min-height: 40px; min-width: 56px; border: 0; background: transparent; border-radius: 12px; font-weight: 800; color: var(--ink-soft); padding: 6px 12px; transition: background-color .2s, color .2s; }
.seg > button[aria-checked="true"] { background: var(--primary); color: var(--on-primary); }
.seg > button { min-height: var(--tap); }

.topic-progress summary { cursor: pointer; list-style: none; min-height: var(--tap); display: flex; align-items: center; gap: 8px; }
.topic-progress summary::-webkit-details-marker { display: none; }
.topic-progress summary::after { content: ""; width: 8px; height: 8px; border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(-45deg); transition: transform .2s; margin-left: 4px; }
.topic-progress[open] summary::after { transform: rotate(45deg); }
.topic-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.topic-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; background: var(--surface); border: var(--border-w) solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.topic-list .t-name { font-weight: 800; }
.topic-list .t-num { color: var(--ink-soft); font-weight: 700; }
.topic-list .mini-bar { grid-column: 1 / -1; }

.mic-note { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-soft); font-size: 13.5px; background: var(--surface); border: var(--border-w) dashed var(--line-strong); border-radius: 14px; padding: 10px 12px; margin: 16px 0 0; }
.mic-note .ic { width: 20px; height: 20px; color: var(--primary); margin-top: 1px; }

.start-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 10px 16px calc(12px + var(--safe-b)); display: grid; gap: 8px;
  background: var(--surface); border-top: var(--border-w) solid var(--line);
  border-radius: 22px 22px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .22);
}
html[data-theme="neon"] .start-bar { background: rgba(15, 20, 38, .94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
html[data-theme="cute"] .start-bar { box-shadow: 0 -8px 24px rgba(43, 35, 80, .10); }
.start-summary { text-align: center; font-weight: 800; color: var(--ink-soft); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.setup-side { display: none; }

/* ============================================================ practice */
.ptop { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; min-height: 56px; }
.ptop-mid { display: flex; align-items: center; justify-content: center; gap: 10px; }
.ptop-right { display: flex; gap: 6px; }
.ptop-title { margin: 0; text-align: center; font-family: var(--font-display); font-size: 20px; }
.counter { font-family: var(--font-num); font-weight: 900; font-size: 18px; min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.avg-pill { display: inline-flex; align-items: baseline; gap: 4px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: var(--border-w) solid var(--line); font-weight: 900; font-variant-numeric: tabular-nums; }
.avg-label { font-size: 11px; color: var(--ink-faint); letter-spacing: .06em; }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 2px 0 12px; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .45s ease-out; }
html[data-theme="neon"] .progress-fill { box-shadow: 0 0 12px rgba(34, 211, 238, .6); }

.practice-body { max-width: 720px; margin: 0 auto; padding-bottom: calc(24px + var(--safe-b)); display: grid; gap: 14px; }
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); border: var(--border-w) solid var(--line); }
html[data-theme="cute"] .card { border-width: 3px; border-color: #EFE8FB; }
.prompt-card { padding: 18px 16px 16px; text-align: center; position: relative; animation: card-in .32s var(--ease-pop); }
.prompt-card.no-anim { animation: none; }
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.prompt-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.prompt-hz { font-family: var(--font-hz); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: .04em; text-shadow: var(--glow-text); word-break: keep-all; }
.mode-word .prompt-hz { font-size: clamp(64px, 22vw, 104px); }
.mode-sentence .prompt-hz, .mode-dialogue .prompt-hz { font-size: clamp(30px, 8.6vw, 46px); letter-spacing: .02em; }
.say-btns { display: flex; gap: 6px; align-items: center; }
.say-btn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: var(--border-w) solid var(--line-strong); background: var(--surface-2); color: var(--primary); transition: transform var(--t-fast); }
.say-btn.slow { width: 44px; height: 44px; color: var(--accent); }
.say-btn:active { transform: scale(.92); }
.say-btn.playing { box-shadow: var(--glow-primary); animation: speak-pulse 1s ease-in-out infinite; }
@keyframes speak-pulse { 50% { transform: scale(1.08); } }
.prompt-py { font-weight: 800; font-size: 22px; color: var(--primary); margin: 8px 0 0; letter-spacing: .02em; min-height: 33px; }
.mode-sentence .prompt-py, .mode-dialogue .prompt-py { font-size: 18px; }
html[data-theme="cute"] .prompt-py { color: var(--primary); }
.prompt-vi { color: var(--ink-soft); font-size: 17px; margin: 4px 0 0; }
.reveal-btn { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px; border-radius: 999px; border: var(--border-w) dashed var(--line-strong); background: transparent; color: var(--ink-soft); font-weight: 700; font-size: 14px; }
.reveal-btn .ic { width: 18px; height: 18px; }
.interim { min-height: 28px; margin-top: 10px; font-family: var(--font-hz); font-size: 20px; color: var(--ink-faint); opacity: .75; transition: opacity .2s; }
.interim:empty::before { content: "\00a0"; }

.dlg-head { font-size: 13.5px; color: var(--ink-soft); font-weight: 800; margin-bottom: 8px; }
.turn-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-weight: 900; font-size: 13px; margin-bottom: 8px; }
.turn-tag.user { background: var(--primary-soft); color: var(--primary); }
.turn-tag.partner { background: var(--surface-3); color: var(--accent); }
.speaker-name { font-family: var(--font-hz); font-size: 15px; color: var(--ink-soft); margin-bottom: 2px; }
.chat-log { display: grid; gap: 6px; max-height: 30vh; overflow-y: auto; padding: 2px; scroll-behavior: smooth; }
.chat-log:empty { display: none; }
.bubble { max-width: 86%; padding: 8px 12px; border-radius: 16px; background: var(--surface); border: var(--border-w) solid var(--line); font-size: 14px; }
.bubble .b-hz { font-family: var(--font-hz); font-size: 17px; }
.bubble .b-py { color: var(--ink-faint); font-size: 12.5px; }
.bubble.me { justify-self: end; background: var(--primary-soft); border-color: transparent; }
.bubble .b-score { float: right; margin-left: 8px; font-weight: 900; font-size: 12px; color: var(--ink-soft); }

/* ---- mic zone */
.action-zone { display: grid; justify-items: center; gap: 10px; padding: 6px 0 4px; }
.mic-wrap { position: relative; width: 132px; height: 132px; display: grid; place-items: center; }
.mic-btn {
  position: relative; z-index: 2; width: 96px; height: 96px; border-radius: 50%; border: 0; color: #fff;
  background: var(--mic-grad); display: grid; place-items: center; box-shadow: var(--glow-primary), 0 10px 26px rgba(0, 0, 0, .3);
  transition: transform .18s var(--ease-pop), background .2s;
  transform: scale(calc(1 + var(--lvl, 0) * .12));
}
.mic-btn .ic { width: 42px; height: 42px; }
.mic-btn:active { transform: scale(.94); }
.mic-btn[disabled] { opacity: .5; cursor: not-allowed; }
html[data-theme="cute"] .mic-btn { box-shadow: 0 6px 0 #3B2DAE, 0 14px 26px rgba(91, 75, 219, .3); }
.mic-ring, .mic-ring2 { position: absolute; inset: 18px; border-radius: 50%; border: 3px solid var(--primary); opacity: 0; pointer-events: none; }
.mic-level { position: absolute; inset: 12px; border-radius: 50%; background: var(--primary-soft); transform: scale(calc(.9 + var(--lvl, 0) * .5)); transition: transform 80ms linear; opacity: 0; }
.mic-timer { position: absolute; inset: 0; width: 132px; height: 132px; transform: rotate(-90deg); pointer-events: none; }
.mic-timer circle { fill: none; stroke-width: 4; }
.mic-timer .track { stroke: var(--surface-3); opacity: 0; }
.mic-timer .bar { stroke: var(--pink); stroke-linecap: round; stroke-dasharray: 389.6; stroke-dashoffset: 0; opacity: 0; }
.listening .mic-btn { background: var(--mic-live); box-shadow: 0 0 28px rgba(255, 95, 162, .55); }
.listening .mic-ring { animation: ring 1.4s ease-out infinite; border-color: var(--pink); }
.listening .mic-ring2 { animation: ring 1.4s ease-out .7s infinite; border-color: var(--pink); }
.listening .mic-level { opacity: 1; background: rgba(255, 95, 162, .16); }
.listening .mic-timer .track, .listening .mic-timer .bar { opacity: 1; }
.listening .mic-timer .bar { animation: countdown var(--listen-ms, 5000ms) linear forwards; }
@keyframes countdown { to { stroke-dashoffset: 389.6; } }
@keyframes ring { from { transform: scale(1); opacity: .85; } to { transform: scale(1.75); opacity: 0; } }
.mic-hint { font-weight: 800; color: var(--ink-soft); min-height: 24px; text-align: center; }
.listening .mic-hint { color: var(--pink); }
.dots::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.skip-btn { min-height: var(--tap); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
.row-btns .btn { flex: 1 1 0; min-width: 0; padding: 10px 10px; white-space: nowrap; font-size: 15.5px; gap: 6px; }
.tip-line { font-size: 13px; color: var(--ink-faint); text-align: center; margin: 0; }
.kbd { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line-strong); font-size: 12px; font-weight: 800; line-height: 20px; text-align: center; }

/* ---- feedback */
.feedback { padding: 16px; display: grid; gap: 12px; animation: card-in .32s var(--ease-pop); }
.fb-top { display: flex; align-items: center; gap: 14px; }
.score-ring { position: relative; width: 92px; height: 92px; flex: none; }
.score-ring svg { width: 92px; height: 92px; transform: rotate(-90deg); }
.score-ring circle { fill: none; stroke-width: 9; }
.score-ring .track { stroke: var(--surface-3); }
.score-ring .bar { stroke: var(--good); stroke-linecap: round; stroke-dasharray: 245; stroke-dashoffset: 245; transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1); }
.score-ring.fail .bar { stroke: var(--warn); }
.score-ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-num); font-weight: 900; font-size: 30px; font-variant-numeric: tabular-nums; }
.fb-head { flex: 1; min-width: 0; }
.fb-title { font-family: var(--font-display); font-weight: 800; font-size: 21px; margin: 0; line-height: 1.2; }
.fb-title.pass { color: var(--good); }
.fb-title.fail { color: var(--warn); }
.stars { display: flex; gap: 4px; margin-top: 6px; }
.stars .ic { width: 26px; height: 26px; color: var(--surface-3); }
.stars .ic.on { color: var(--star); animation: star-pop .45s var(--ease-pop) both; filter: drop-shadow(0 0 6px rgba(252, 211, 77, .5)); }
.stars .ic.on:nth-child(2) { animation-delay: .12s; }
.stars .ic.on:nth-child(3) { animation-delay: .24s; }
@keyframes star-pop { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }
.self-tag { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--ink-soft); }

.syl-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.syl {
  display: grid; justify-items: center; gap: 0; min-width: 58px; min-height: 64px; padding: 6px 8px 4px; border-radius: var(--r-chip);
  border: 2px solid; background: var(--surface-2); animation: chip-in .3s var(--ease-pop) both; animation-delay: calc(var(--i, 0) * 60ms);
}
button.syl { font: inherit; }
@keyframes chip-in { from { opacity: 0; transform: translateY(8px) scale(.9); } to { opacity: 1; transform: none; } }
.syl .s-py { font-weight: 800; font-size: 14px; }
.syl .s-hz { font-family: var(--font-hz); font-size: 24px; line-height: 1.15; }
.syl .s-st { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 900; text-transform: lowercase; }
.syl .s-st .ic { width: 13px; height: 13px; }
.syl.correct { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.syl.tone { border-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.syl.sound { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }
.syl.missing { border-color: var(--miss); border-style: dashed; background: var(--miss-bg); color: var(--miss); }
.syl .s-hz, .syl .s-py { color: var(--ink); }
.syl.missing .s-hz { opacity: .6; }
.syl .s-heard { font-size: 11px; font-weight: 700; color: inherit; opacity: .9; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; font-size: 12px; color: var(--ink-faint); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.heard-line { font-size: 15px; color: var(--ink-soft); text-align: center; margin: 0; }
.heard-line .hz { color: var(--ink); font-size: 18px; }
.comment { margin: 0; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border-left: 4px solid var(--accent); font-size: 15px; display: flex; gap: 10px; align-items: flex-start; }
.comment .mini-mascot { flex: none; margin-top: -2px; }

.self-panel { padding: 16px; display: grid; gap: 12px; text-align: center; }
.self-panel h2 { margin: 0; font-size: 18px; font-family: var(--font-display); }
.self-panel p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }
.self-steps { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--ink-faint); }
.self-steps span { padding: 3px 10px; border-radius: 99px; background: var(--surface-2); font-weight: 700; }

/* ---- role select */
.role-screen { display: grid; gap: 14px; text-align: center; padding: 6px 0; }
.role-screen .r-title { font-family: var(--font-display); font-size: 24px; margin: 0; }
.role-screen .r-zh { font-family: var(--font-hz); font-size: 22px; color: var(--primary); margin: 0; }
.role-screen .r-meta { color: var(--ink-soft); margin: 0; }
.role-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-card { display: grid; gap: 4px; justify-items: center; padding: 16px 10px; border-radius: 20px; background: var(--surface); border: var(--border-w) solid var(--line-strong); box-shadow: var(--shadow-card); transition: transform var(--t-fast), border-color .2s; min-height: 150px; align-content: center; }
.role-card:hover, .role-card:focus-visible { border-color: var(--primary); }
.role-card:active { transform: scale(.97); }
.role-card .rc-badge { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 20px; background: var(--primary); color: var(--on-primary); }
.role-card.b .rc-badge { background: var(--accent); color: var(--on-primary); }
html[data-theme="neon"] .role-card.b .rc-badge { color: #1B0B2E; }
.role-card .rc-name { font-family: var(--font-hz); font-size: 22px; font-weight: 700; }
.role-card .rc-vi { color: var(--ink-soft); font-size: 13px; }
.role-card .rc-count { font-weight: 800; font-size: 14px; color: var(--primary); }

/* ============================================================ result */
.result-body { max-width: 760px; margin: 0 auto; padding-bottom: calc(32px + var(--safe-b)); display: grid; gap: 14px; }
.result-hero { padding: 18px 16px; display: grid; gap: 12px; justify-items: center; text-align: center; animation: card-in .4s var(--ease-pop); }
.result-hero h1 { font-family: var(--font-display); font-size: 25px; margin: 0; }
.result-hero .r-msg { color: var(--ink-soft); margin: 0; max-width: 46ch; }
.big-ring { position: relative; width: 150px; height: 150px; }
.big-ring svg { width: 150px; height: 150px; transform: rotate(-90deg); }
.big-ring circle { fill: none; stroke-width: 12; }
.big-ring .track { stroke: var(--surface-3); }
.big-ring .bar { stroke: url(#ring-grad); stroke-linecap: round; stroke-dasharray: 414.7; stroke-dashoffset: 414.7; transition: stroke-dashoffset 1s cubic-bezier(.2, .8, .2, 1); }
.big-ring .center { position: absolute; inset: 0; display: grid; place-content: center; }
.big-ring .pct { font-family: var(--font-num); font-weight: 900; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.big-ring .pct-l { font-size: 12.5px; color: var(--ink-soft); font-weight: 800; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 100%; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 10px; display: grid; gap: 0; }
.stat b { font-family: var(--font-num); font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }
.stat .ic { width: 18px; height: 18px; color: var(--star); vertical-align: -2px; }
.result-actions { display: grid; gap: 8px; }
.review { padding: 14px; }
.review h2 { margin: 0 0 10px; font-size: 18px; font-family: var(--font-display); }
.review-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.review-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 8px 8px 12px; border-radius: 14px; background: var(--surface-2); animation: chip-in .3s ease-out both; animation-delay: calc(var(--i, 0) * 40ms); }
.review-row .rr-hz { font-family: var(--font-hz); font-size: 22px; font-weight: 700; line-height: 1.2; }
.review-row .rr-py { color: var(--primary); font-weight: 800; font-size: 14px; }
.review-row .rr-vi { color: var(--ink-soft); font-size: 13.5px; }
.badge { font-size: 12px; font-weight: 900; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.badge.skip { background: var(--miss-bg); color: var(--miss); border: 1px dashed var(--miss); }
.badge.low { background: var(--warn-bg); color: var(--warn); }
.badge.self { background: var(--surface-3); color: var(--ink-soft); }
.badge.ok { background: var(--good-bg); color: var(--good); }
.empty-note { color: var(--ink-soft); margin: 0; }
details.passed-list summary { cursor: pointer; font-weight: 800; min-height: var(--tap); display: flex; align-items: center; }

/* ============================================================ settings */
.settings { max-width: 640px; margin: 0 auto; display: grid; gap: 12px; padding-bottom: calc(40px + var(--safe-b)); }
.set-group { background: var(--surface); border: var(--border-w) solid var(--line); border-radius: 20px; padding: 12px 14px 14px; margin: 0; display: grid; gap: 10px; box-shadow: var(--shadow-card); }
.set-group legend { font-weight: 900; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); padding: 0 6px; float: left; width: 100%; margin-bottom: 4px; }
.set-group .seg { clear: both; }
.set-sub { font-weight: 800; font-size: 14px; margin-top: 4px; }
.set-row { display: flex; justify-content: space-between; font-weight: 700; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); font-weight: 700; cursor: pointer; }
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 30px; border-radius: 99px; background: var(--surface-3); border: var(--border-w) solid var(--line-strong); position: relative; transition: background-color .2s; flex: none; cursor: pointer; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink-soft); transition: transform .2s var(--ease-pop), background-color .2s; }
.switch:checked { background: var(--primary); border-color: transparent; }
.switch:checked::after { transform: translateX(22px); background: var(--on-primary); }
input[type="range"] { width: 100%; accent-color: var(--primary); min-height: var(--tap); }
.about { text-align: center; color: var(--ink-faint); font-size: 13px; }

/* ============================================================ modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(5, 8, 18, .62); display: grid; align-items: end; justify-items: center; padding: 12px; animation: fade-in .18s ease-out; }
html[data-theme="cute"] .modal-backdrop { background: rgba(43, 35, 80, .38); }
.modal { width: min(520px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto; background: var(--surface); border-radius: var(--r-modal); border: var(--border-w) solid var(--line-strong); box-shadow: 0 20px 60px rgba(0, 0, 0, .45); padding: 18px 16px calc(16px + var(--safe-b)); animation: sheet-in .28s var(--ease-pop); }
.modal h2 { margin: 0 0 8px; font-family: var(--font-display); font-size: 21px; display: flex; align-items: center; gap: 10px; }
.modal .m-body { color: var(--ink-soft); font-size: 15px; }
.modal .m-body p { margin: 0 0 10px; }
.modal .m-body ul, .modal .m-body ol { margin: 0 0 10px; padding-left: 20px; }
.modal .m-body li { margin-bottom: 4px; }
.modal .m-body strong { color: var(--ink); }
.modal .m-actions { display: grid; gap: 8px; margin-top: 14px; }
.modal .m-close { float: right; margin: -6px -4px 0 8px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop-in { from { transform: scale(.9); opacity: 0; } }

/* ============================================================ fx */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti { position: absolute; width: 9px; height: 14px; border-radius: 3px; top: -20px; animation: fall var(--d, 1.6s) cubic-bezier(.2, .6, .4, 1) forwards; }
@keyframes fall { to { transform: translate(var(--dx, 0), 105vh) rotate(var(--r, 540deg)); opacity: .9; } }
.shake, .prompt-card.shake { animation: shake .32s ease-in-out; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* ============================================================ mascot */
.mascot { display: block; overflow: visible; }
.mascot.bob .m-all { animation: bob 2.4s ease-in-out infinite; transform-origin: 60px 110px; }
.mascot.wave .m-wing-r { animation: wave 1.6s ease-in-out infinite; transform-origin: 90px 66px; }
.mascot.happy .m-all { animation: jump .9s ease-in-out infinite; transform-origin: 60px 110px; }
.mascot .m-eyes-happy, .mascot .m-eyes-sad, .mascot .m-tear, .mascot .m-mouth-o { display: none; }
.mascot.happy .m-eyes-open { display: none; }
.mascot.happy .m-eyes-happy { display: inline; }
.mascot.sad .m-eyes-open { display: none; }
.mascot.sad .m-eyes-sad, .mascot.sad .m-tear { display: inline; }
.mascot.talk .m-mouth-o { display: inline; animation: talk .35s ease-in-out infinite; transform-origin: 60px 73px; }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes wave { 50% { transform: rotate(-24deg); } }
@keyframes jump { 40% { transform: translateY(-10px) scale(1.02, .98); } 60% { transform: translateY(-10px); } }
@keyframes talk { 50% { transform: scaleY(.4); } }

.mobile-only { display: flex; }
.noscript { padding: 20px; text-align: center; }

/* ============================================================ desktop */
@media (min-width: 900px) {
  .screen { padding-left: 32px; padding-right: 32px; }
  .setup-grid { grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; padding-bottom: 40px; align-items: start; }
  .setup-side { display: block; position: sticky; top: 16px; }
  .side-card { background: var(--surface); border: var(--border-w) solid var(--line); border-radius: var(--r-card); padding: 20px; box-shadow: var(--shadow-card); display: grid; gap: 14px; }
  .side-title { margin: 0; font-family: var(--font-display); font-size: 20px; }
  .summary-list { margin: 0; display: grid; gap: 8px; }
  .summary-list div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
  .summary-list dt { color: var(--ink-soft); font-weight: 700; }
  .summary-list dd { margin: 0; font-weight: 800; text-align: right; }
  .steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
  .steps li { display: flex; gap: 10px; align-items: center; color: var(--ink-soft); font-weight: 700; }
  .step-n { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 900; }
  .side-card .mic-note { margin: 0; }
  .start-bar, .mobile-only { display: none; }
  .chips { flex-wrap: wrap; overflow: visible; }
  .mode-card { min-height: 132px; padding: 16px 14px; }
  .mode-desc { font-size: 13.5px; }
  .hero h1 { font-size: 34px; }
  .practice-body { gap: 18px; }
  .prompt-card { padding: 28px 24px 22px; }
  .mode-word .prompt-hz { font-size: 120px; }
  .mode-sentence .prompt-hz, .mode-dialogue .prompt-hz { font-size: 48px; }
  .modal-backdrop { align-items: center; }
  .result-actions { grid-template-columns: 1.7fr 1fr 1fr; }
  .result-actions .btn-xl { font-size: 16px; white-space: nowrap; }
  .brand-name { font-size: 22px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .toast { bottom: 32px; }
}
@media (max-width: 360px) {
  .mode-desc { display: none; }
  .mode-card { min-height: 86px; }
  .hero-mascot { display: none; }
}

/* ============================================================ reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .listening .mic-ring, .listening .mic-ring2 { animation: none !important; opacity: .5; transform: scale(1.3); }
  .listening .mic-timer .bar { animation: countdown var(--listen-ms, 5000ms) linear forwards !important; }
  .mascot .m-all, .mascot .m-wing-r { animation: none !important; }
  .fx-layer { display: none; }
}
