/* BongOun — clean, calm interface. One accent per learner: rose (English) and indigo (Khmer). */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f2f2ee;
  --text: #17171a;
  --muted: #6e6e76;
  --faint: #a1a1a8;
  --line: #e6e6e1;
  --line-strong: #d6d6d0;

  --accent: #17171a;
  --accent-ink: #ffffff;
  --accent-soft: #ededea;

  --ok: #15803d;
  --ok-soft: #eaf7ee;
  --bad: #d92d20;
  --bad-soft: #fdf0ef;
  --gold: #d4960f;
  --sA: #2563eb;
  --sA-soft: #eaf0fd;
  --sO: #8b3fd4;
  --sO-soft: #f3ebfb;

  --guide: #e9e7e1;
  --ink: var(--accent);
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 2px 8px rgba(20, 20, 30, 0.03);
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --khmer: 'Kantumruy Pro', 'Khmer Sangam MN', 'Khmer MN', 'Noto Sans Khmer', sans-serif;
  --hand: 'Andika', 'Avenir Next', sans-serif;
  color-scheme: light dark;
}
:root[data-theme='lotus'] { --accent: #d1366f; --accent-soft: #fbeaf1; }
:root[data-theme='temple'] { --accent: #4f46e5; --accent-soft: #ecebfd; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #1a1a1d;
    --surface-2: #232327;
    --text: #f2f2f3;
    --muted: #a0a0a8;
    --faint: #6c6c74;
    --line: #2b2b30;
    --line-strong: #3a3a40;
    --accent: #f2f2f3;
    --accent-ink: #111113;
    --accent-soft: #2a2a2f;
    --ok: #3fb96a;
    --ok-soft: #14271b;
    --bad: #f0645a;
    --bad-soft: #2d1716;
    --sA-soft: #1a2440;
    --sO-soft: #281b3a;
    --guide: #2c2c31;
    --shadow: none;
  }
  :root[data-theme='lotus'] { --accent: #f0699b; --accent-soft: #33192a; --accent-ink: #1a0b12; }
  :root[data-theme='temple'] { --accent: #8f88ff; --accent-soft: #23214a; --accent-ink: #0f0e26; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
[lang='km'], .km { font-family: var(--khmer); line-height: 1.7; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; touch-action: manipulation; padding: 0; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 1rem; }
[hidden] { display: none !important; }
.icon { display: inline-flex; flex: none; }
.muted { color: var(--muted); }
.small, .note { font-size: 0.85rem; color: var(--muted); }
.center, .center-text { text-align: center; justify-content: center; }
.row { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.row.start { justify-content: flex-start; }

.screen { max-width: 560px; margin: 0 auto; padding: 12px 16px 48px; animation: fade 0.2s ease-out; }
@keyframes fade { from { opacity: 0; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card h3 { margin-bottom: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: var(--radius-sm); font-weight: 600;
  background: var(--surface); border: 1px solid var(--line-strong); transition: background 0.15s, transform 0.08s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.4; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--line);
}
.icon-btn.ghost { background: transparent; border-color: transparent; }
.icon-btn.ghost:active { background: var(--surface-2); }
.icon-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.link { color: var(--muted); font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; padding: 8px; }
.mini {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 0.9rem;
}
.mini.wide { padding: 6px 14px; font-size: 1.05rem; color: var(--text); }
.tool {
  height: 40px; min-width: 40px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 0.9rem;
}
.tool.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- home ---------- */
.home { padding-top: 56px; }
.brand { text-align: center; margin-bottom: 36px; }
.brand-mark {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center;
  background: var(--text); color: var(--bg); font-size: 1.6rem; line-height: 1;
  display: flex; gap: 4px; justify-content: center; font-weight: 700;
}
.brand-mark [lang='km'] { line-height: 1; padding-top: 4px; font-weight: 600; }
.brand-name { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { color: var(--muted); margin-top: 4px; }
.profiles { display: grid; gap: 12px; }
.profile-card {
  display: flex; align-items: center; gap: 16px; text-align: left; padding: 18px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.profile-card:active { transform: scale(0.99); }
.profile-card .icon { color: var(--faint); }
.p-glyph { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; font-weight: 650; flex: none; }
.t-lotus .p-glyph { background: #fbeaf1; color: #d1366f; }
.t-temple .p-glyph { background: #ecebfd; color: #4f46e5; }
.p-glyph[lang='km'] { line-height: 1; padding-top: 4px; }
.p-text { display: grid; flex: 1; }
.p-title { font-size: 1.15rem; font-weight: 650; line-height: 1.35; }
.p-sub { color: var(--muted); font-size: 0.92rem; }
.footer-links { display: flex; justify-content: center; gap: 8px; margin-top: 32px; }

/* ---------- dashboard ---------- */
.dash-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.dash-title { flex: 1; font-weight: 650; font-size: 1.1rem; }
.stat { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 0.9rem; }
.stat .icon { color: #e8590c; }
.today { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.today-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.today-label { font-size: 1.2rem; font-weight: 650; }
.today-meta { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.today-progress { height: 6px; border-radius: 3px; background: var(--surface-2); margin: 16px 0 12px; overflow: hidden; }
.today-progress span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.today-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.9rem; }
.goal { position: relative; width: 48px; height: 48px; flex: none; }
.goal svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 4; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset 0.6s; }
.goal-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 650; font-size: 0.85rem; }
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 12px 0 8px; }
.tool-card {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 0.92rem; text-align: left;
}
.tool-ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.lesson-group { margin-top: 22px; }
.group-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; margin: 0 4px 8px; }
.lesson-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.lesson { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; text-align: left; border-top: 1px solid var(--line); }
.lesson:first-child { border-top: none; }
.lesson:active { background: var(--surface-2); }
.lesson-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); font-size: 1.25rem; font-weight: 650; flex: none; }
.lesson-ic[lang='km'] { line-height: 1; padding-top: 3px; color: var(--accent); }
.lesson.fresh .lesson-ic { opacity: 0.55; }
.lesson.current .lesson-ic { background: var(--accent); color: var(--accent-ink); }
.lesson-body { flex: 1; display: grid; gap: 7px; min-width: 0; }
.lesson-title { font-weight: 550; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.lesson-bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.lesson-end { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson-end.go { color: var(--accent); font-weight: 650; }
.lesson-end.done { color: var(--ok); }

/* ---------- session ---------- */
.session { padding-bottom: 24px; }
.s-head { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 6px 0 10px; }
.progress { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.35s ease; }
.s-count { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-top: 8px; animation: fade 0.2s ease-out; }
.instruction { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; text-align: center; color: var(--muted); font-weight: 550; font-size: 1rem; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 0.85rem; }
.prompt { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.foot { position: sticky; bottom: 0; width: 100%; padding: 12px 0 4px; background: linear-gradient(transparent, var(--bg) 30%); }

.speaker {
  width: 52px; height: 52px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.speaker.big { width: 88px; height: 88px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.speaker.slow { width: auto; padding: 0 14px; border-radius: 999px; display: inline-flex; gap: 6px; color: var(--muted); }
.speaker.slow small { font-weight: 600; font-size: 0.8rem; }
.speaker:active { transform: scale(0.95); }

.pic { font-size: 5.2rem; line-height: 1.1; }
.pic.small { font-size: 2.6rem; }
.word { font-size: 2.2rem; font-weight: 650; letter-spacing: -0.01em; }
.word.big { font-size: 2.8rem; }
.meaning { font-size: 1.15rem; color: var(--muted); }
.rom { font-size: 1.15rem; font-weight: 600; color: var(--accent); }
.khmer-big { font-size: 2.8rem; }
.khmer-huge { font-size: 5rem; line-height: 1.5; }
.letter-pair { font-family: var(--hand); font-size: 5.2rem; font-weight: 700; line-height: 1; display: flex; gap: 20px; }
.letter-pair span { color: var(--muted); }
.intro {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 26px 20px; box-shadow: var(--shadow);
}
.example { display: flex; align-items: center; gap: 12px; }
.hl { color: var(--accent); }
.hint { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 999px; padding: 4px 12px; font-size: 0.9rem; }

/* options */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.opt {
  min-height: 72px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1.5px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.opt:active:not(:disabled) { transform: scale(0.98); border-color: var(--accent); }
.options.pics .opt { min-height: 124px; }
.options.three { grid-template-columns: repeat(3, 1fr); }
.options.vowels { grid-template-columns: repeat(5, 1fr); gap: 8px; }
.options.vowels .opt { min-height: 64px; }
.opt-pic { font-size: 3.6rem; line-height: 1; }
.opt-pic.sm { font-size: 1.9rem; }
.options.three .opt-pic { font-size: 3rem; }
.opt-label, .opt-word { font-weight: 600; font-size: 1.05rem; }
.opt-km { font-size: 1.5rem; }
.opt-km.huge { font-size: 2.6rem; }
.opt-rom { color: var(--muted); }
.opt-letter { font-family: var(--hand); font-size: 2.8rem; font-weight: 700; line-height: 1.1; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake 0.3s; }
.opt:disabled:not(.right):not(.wrong) { opacity: 0.5; }
.opt.speaking { border-color: var(--accent); background: var(--accent-soft); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* build (spelling / sentence) */
.answer-slot { min-height: 64px; width: 100%; border-bottom: 2px solid var(--line-strong); display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; padding: 6px; }
.answer-slot.right { border-color: var(--ok); }
.answer-slot.wrong { border-color: var(--bad); }
.tile-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tile { min-width: 48px; height: 52px; padding: 0 14px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); font-family: var(--hand); font-size: 1.5rem; font-weight: 700; }
.tile:disabled { opacity: 0.2; }
.tile.chosen { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* feedback sheet */
.sheet { position: sticky; bottom: 0; width: 100%; border-radius: 18px; padding: 16px; display: grid; gap: 12px; border: 1px solid transparent; animation: rise 0.2s ease-out; }
.sheet.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.sheet.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.sheet-head { display: flex; align-items: center; gap: 10px; }
.sheet-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.sheet.ok .sheet-icon { background: var(--ok); }
.sheet.bad .sheet-icon { background: var(--bad); }
.sheet-msg { font-weight: 650; font-size: 1.05rem; }
.sheet.ok .sheet-msg { color: var(--ok); }
.sheet.bad .sheet-msg { color: var(--bad); }
.sheet-answer { font-size: 1.1rem; font-weight: 600; padding-left: 40px; }
.sheet.ok .btn.primary { background: var(--ok); border-color: var(--ok); color: #fff; }
.sheet.bad .btn.primary { background: var(--bad); border-color: var(--bad); color: #fff; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* done */
.done { padding-top: 48px; text-align: center; gap: 14px; }
.done-badge { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.done-stars { display: flex; gap: 6px; color: var(--gold); }
.done-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin: 8px 0 12px; }
.done-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: grid; }
.done-stats b { font-size: 1.5rem; }
.done-stats span { color: var(--muted); font-size: 0.85rem; }

/* ---------- writing ---------- */
.pad-wrap { line-height: 0; }
.trace { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; touch-action: none; box-shadow: var(--shadow); }
canvas.shake { animation: shake 0.3s; }
.pad-tools { display: flex; gap: 8px; justify-content: center; }
.stroke-hint { min-height: 1.4em; font-weight: 600; text-align: center; font-size: 0.95rem; }
.stroke-hint.bad { color: var(--bad); }
.stroke-hint.good { color: var(--ok); }
.copy-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
.model-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 4px; line-height: 0; }
.case-cue { display: flex; align-items: center; gap: 16px; font-family: var(--hand); font-size: 3.2rem; font-weight: 700; color: var(--text); }
.case-cue .icon { color: var(--faint); }
.cue-blank { color: var(--accent); border-bottom: 3px dashed var(--accent); min-width: 0.8em; text-align: center; line-height: 1.1; }

/* writing screen */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; min-height: 44px; }
.top-title { font-weight: 650; display: inline-flex; align-items: center; gap: 8px; }
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.mode-tab { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 4px; border-radius: 10px; font-weight: 600; font-size: 0.88rem; color: var(--muted); }
.mode-tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.mode-icon { display: inline-flex; }
.set-tabs { display: flex; gap: 6px; justify-content: center; margin: 12px 0 4px; }
.set-tab { padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: 0.92rem; border: 1px solid var(--line); background: var(--surface); }
.set-tab.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.writing .instruction { margin: 4px 0; font-size: 0.92rem; flex-wrap: wrap; }
.glyph-strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; scroll-snap-type: x proximity; }
.glyph-strip::-webkit-scrollbar { display: none; }
.gchip {
  flex: none; min-width: 46px; height: 50px; padding: 0 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  font-family: Battambang, var(--khmer); font-size: 1.4rem; display: grid; place-items: center; line-height: 1.15; scroll-snap-align: center;
}
.gchip.latin { font-family: var(--hand); font-size: 1.5rem; font-weight: 700; }
.gchip.sA { color: var(--sA); }
.gchip.sO { color: var(--sO); }
.gchip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.gstar { font-size: 0.5rem; color: var(--gold); font-family: var(--ui); line-height: 1; }
.gchip.on .gstar { color: var(--accent-ink); }
.writing .stage { gap: 8px; padding-top: 4px; }
.write-prompt { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.write-label { display: flex; align-items: center; gap: 6px; }
.trace-result { min-height: 32px; display: flex; align-items: center; gap: 8px; }
.stars { display: inline-flex; gap: 4px; color: var(--gold); }

/* ---------- phonics ---------- */
.blend { display: flex; gap: 14px; font-family: var(--hand); font-size: 3.2rem; font-weight: 700; transition: gap 0.5s ease; }
.blend span { opacity: 0; animation: drop 0.4s ease-out forwards; }
.blend .vowel, .opt-letter.vowel, .blank { color: var(--accent); }
.blend.merged { gap: 0; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
.blank { display: inline-block; min-width: 0.7em; text-align: center; border-bottom: 3px solid currentColor; line-height: 1; margin: 0 2px; }

/* ---------- speaking ---------- */
.say-word { font-family: var(--hand); font-size: 3rem; font-weight: 700; letter-spacing: 0.03em; }
.say-letter.bad { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 8px; }
.mic { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.mic.sm { width: 56px; height: 56px; background: var(--accent-soft); color: var(--accent); }
.mic.recording { background: var(--bad); color: #fff; animation: pulse-rec 1.2s infinite; }
.mic:disabled { opacity: 0.6; }
@keyframes pulse-rec { 50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--bad) 18%, transparent); } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.say-result { display: grid; justify-items: center; gap: 6px; min-height: 56px; }
.say-verdict { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.say-verdict.correct { background: var(--ok); }
.say-verdict.close { background: var(--gold); }
.say-verdict.wrong, .say-verdict.silent { background: var(--bad); }
.say-heard { display: inline-flex; align-items: center; gap: 6px; font-size: 1.1rem; font-weight: 600; color: var(--muted); }

/* ---------- native check & voice ---------- */
.check-card { display: flex; flex-direction: column; align-items: center; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); }
.verdict { display: flex; gap: 20px; }
.vbtn { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; }
.vbtn.ok { background: var(--ok-soft); color: var(--ok); }
.vbtn.bad { background: var(--bad-soft); color: var(--bad); }
.vbtn:active { transform: scale(0.95); }
.voice-row { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.voice-hint { flex-basis: 100%; text-align: center; color: var(--muted); font-size: 0.92rem; font-weight: 550; }
.flag-list { padding-left: 0; list-style: none; display: grid; gap: 8px; }
.flag-list b { font-size: 1.2rem; }

/* ---------- Khmer script ---------- */
.badge { border-radius: 999px; padding: 2px 9px; font-size: 0.75rem; font-weight: 650; vertical-align: middle; }
.badge.sA { background: var(--sA-soft); color: var(--sA); }
.badge.sO { background: var(--sO-soft); color: var(--sO); }
.vowel-pair, .demo-row { display: flex; gap: 10px; align-items: center; justify-content: center; }
.vcell { display: grid; justify-items: center; min-width: 92px; padding: 8px 12px; border-radius: 14px; font-weight: 600; }
.vcell [lang='km'], .vcell .km { font-size: 1.9rem; }
.vcell small { font-weight: 500; opacity: 0.8; }
.vcell.sA { background: var(--sA-soft); color: var(--sA); }
.vcell.sO { background: var(--sO-soft); color: var(--sO); }
.vs { font-size: 1.5rem; color: var(--faint); }
.demo { display: grid; gap: 8px; }
.kgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.kcell { display: grid; justify-items: center; padding: 6px 2px; border-radius: 12px; }
.kcell.sA { background: var(--sA-soft); }
.kcell.sO { background: var(--sO-soft); }
.kch { font-size: 1.9rem; }
.kcell.sA .kch { color: var(--sA); }
.kcell.sO .kch { color: var(--sO); }
.krom { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.vtable { display: grid; gap: 6px; }
.vrow { display: grid; grid-template-columns: 48px 1fr 1fr; gap: 6px; align-items: center; }
.vsign { font-size: 1.7rem; text-align: center; color: var(--muted); }
.sub-card { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.sub-word { font-size: 1.9rem; font-family: var(--khmer); text-align: left; }
.sub-card ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.sub-card b { font-size: 1.25rem; color: var(--text); }

/* ---------- settings & translator ---------- */
.key-input, .translate-input {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); margin: 8px 0;
}
.translate-input { resize: vertical; min-height: 92px; }
.key-status { font-weight: 600; margin-top: 10px; font-size: 0.92rem; }
.translation .khmer-big { font-size: 2rem; line-height: 1.6; }
.tw-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.tw { background: var(--surface-2); border-radius: 10px; padding: 6px 10px; }
.tw [lang='km'] { font-size: 1.2rem; display: inline-flex; align-items: center; gap: 4px; }
.tw .rom { font-size: 0.9rem; }
.example-line { padding: 8px 0; border-top: 1px solid var(--line); }
.example-line [lang='km'] { font-size: 1.15rem; }
.history { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 6px; }
.history summary { cursor: pointer; }
.history .card { border: none; box-shadow: none; padding: 8px 0 0; margin: 0; }
.section { margin: 22px 4px 8px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.backup-dlg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); width: min(92vw, 480px); }
.backup { width: 100%; font: 0.8rem ui-monospace, monospace; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- sight words ---------- */
.word.sight, .opt-sight { font-family: var(--hand); font-weight: 700; }
.word.sight { font-size: 3.4rem; }
.opt-sight { font-size: 1.9rem; }
.sound-opt { gap: 6px; }
.opt-num { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.opt.picked { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.options.one { grid-template-columns: 1fr; }
.sentence-opt { min-height: 60px; font-size: 1.15rem; font-weight: 600; text-align: center; align-items: center; }
.lesson:disabled { cursor: default; }
.lesson:disabled .lesson-title { color: var(--muted); }
.tool-card:disabled { opacity: 0.5; }

/* ---------- stories (read-along) ---------- */
.story-head { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 4px 0 14px; text-align: center; }
.story-title { font-family: var(--hand); font-size: 2rem; }
.read-list { display: grid; gap: 10px; }
.read-line { display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color 0.2s, background 0.2s; }
.read-line.active { border-color: var(--accent); background: var(--accent-soft); }
.read-text { display: grid; gap: 6px; flex: 1; }
.read-words { display: flex; flex-wrap: wrap; gap: 2px 8px; font-family: var(--hand); font-size: 1.75rem; font-weight: 700; line-height: 1.35; }
.rw { border-radius: 8px; padding: 0 3px; transition: background 0.1s, color 0.1s; }
.rw.lit { background: var(--accent); color: var(--accent-ink); }
.read-km { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.95rem; text-align: left; }
.reader .foot { justify-content: space-between; }

/* ---------- conversations ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 18px; text-align: left; display: grid; gap: 2px; border: 1px solid var(--line); background: var(--surface); transition: box-shadow 0.2s; }
.bubble.me { align-self: flex-end; background: var(--accent-soft); border-color: transparent; border-bottom-right-radius: 6px; }
.bubble.them { align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.active { box-shadow: 0 0 0 2px var(--accent); }
.b-km { font-size: 1.3rem; line-height: 1.6; }
.b-rom { color: var(--accent); font-weight: 600; font-size: 0.92rem; }
.b-en { color: var(--muted); font-size: 0.88rem; }
.dialogue .foot { justify-content: space-between; }
.stage > .bubble { align-self: center; max-width: 100%; }

/* ---------- grammar ---------- */
.sentence { font-family: var(--hand); font-size: 1.9rem; font-weight: 700; line-height: 1.35; text-align: center; }
.hand { font-family: var(--hand); font-weight: 700; }
.opt-word.hand { font-size: 1.4rem; }
.time-badge { display: inline-flex; gap: 4px; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 650; background: var(--surface-2); color: var(--muted); }
.lesson-card { gap: 14px; text-align: left; align-items: stretch; }
.lesson-name { text-align: center; font-size: 1.5rem; }
.explain { display: flex; gap: 12px; align-items: flex-start; text-align: left; background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; font-size: 1.02rem; line-height: 1.7; }
.explain-ic { color: var(--accent); padding-top: 3px; }
.examples { display: grid; gap: 6px; }
.example-row { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; text-align: left; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); }
.example-row .icon { grid-row: span 2; color: var(--accent); }
.ex-en { font-family: var(--hand); font-weight: 700; font-size: 1.2rem; }
.ex-km { color: var(--muted); font-size: 0.95rem; }
.grammar-card h3 { font-size: 1.15rem; margin-bottom: 10px; }
.grammar-card .explain { margin-bottom: 10px; }
.b-main { font-size: 1.35rem; line-height: 1.4; }

/* ---------- meaning & example while writing ---------- */
.meaning-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.meaning-row .pic.small { font-size: 2.2rem; }
.meaning-text { display: grid; text-align: left; line-height: 1.3; }
.meaning-text b { font-size: 1.1rem; }
.meaning-row .word.hand { font-size: 1.6rem; }
.example-card { display: flex; align-items: center; gap: 10px; }
.example-card .model-card { padding: 2px; }
