/* ══ Fonts (all bundled, served from node_modules/@fontsource) ══════════════
   "BoText"/"BoAlt" cover ONLY the Tibetan block, so they sit first in every
   font stack: Tibetan glyphs always come from Noto Serif Tibetan (fallback
   Jomolhari → OS fonts); Latin/Vietnamese falls through to Be Vietnam Pro. */
@font-face {
  font-family: 'BoText'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/noto-serif-tibetan/noto-serif-tibetan-tibetan-400-normal.woff2) format('woff2');
  unicode-range: U+0F00-0FFF, U+25CC;
}
@font-face {
  font-family: 'BoText'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(/fonts/noto-serif-tibetan/noto-serif-tibetan-tibetan-700-normal.woff2) format('woff2');
  unicode-range: U+0F00-0FFF, U+25CC;
}
@font-face {
  font-family: 'BoAlt'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/jomolhari/jomolhari-tibetan-400-normal.woff2) format('woff2');
  unicode-range: U+0F00-0FFF, U+25CC;
}
/* Be Vietnam Pro: vietnamese + latin subsets (ranges copied from @fontsource/be-vietnam-pro 5.3.0) */
@font-face { font-family: 'BVP'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-vietnamese-400-normal.woff2) format('woff2'); unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'BVP'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'BVP'; font-style: italic; font-weight: 400; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-vietnamese-400-italic.woff2) format('woff2'); unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'BVP'; font-style: italic; font-weight: 400; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-latin-400-italic.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'BVP'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-vietnamese-500-normal.woff2) format('woff2'); unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'BVP'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'BVP'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-vietnamese-600-normal.woff2) format('woff2'); unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'BVP'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'BVP'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-vietnamese-700-normal.woff2) format('woff2'); unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'BVP'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/be-vietnam-pro/be-vietnam-pro-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* ══ Tokens ═══════════════════════════════════════════════════════════════
   Palette from Tibetan manuscript & thangka pigments:
   mthing shog (indigo-dyed leaf) + gold ink is the one bold surface;
   cinnabar = mistakes, malachite = correct/passed; the rest is quiet. */
:root {
  --mist: #ebeef2;        /* page ground */
  --leaf-white: #ffffff;  /* surfaces */
  --ink: #1a2547;         /* text, primary buttons */
  --ink-2: #2d3a63;       /* hover */
  --mthing: #22306a;      /* indigo manuscript leaf */
  --gold: #d9ae45;        /* gold ink on the leaf */
  --gold-soft: #b9c0da;   /* secondary text on the leaf */
  --cinnabar: #b53d2a;
  --cinnabar-bg: #f8e6e2;
  --malachite: #2c7a5f;
  --malachite-bg: #e2f1ea;
  --muted: #5b6582;
  --line: #d5dae3;
  --line-2: #c3c9d6;
  --focus: #3b5bdb;

  --r-leaf: 6px;   /* manuscript leaf: nearly square, like paper */
  --r-ctl: 8px;    /* buttons, inputs */
  --r-opt: 10px;   /* answer options */

  --bo: 'BoText', 'BoAlt', 'Noto Serif Tibetan', 'Jomolhari', 'Microsoft Himalaya', 'Kailasa', 'Tibetan Machine Uni', serif;
  --ui: 'BoText', 'BoAlt', 'BVP', 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

  /* type scale (≈ 1.25) */
  --t-xs: 13px; --t-sm: 14px; --t-md: 16px; --t-lg: 20px; --t-xl: 26px; --t-2xl: 32px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--ui);
  font-size: var(--t-md);
  color: var(--ink);
  background: var(--mist);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
/* Tibetan text: generous line-height so stacked consonants & vowel marks never clip */
.bo, [lang="bo"] {
  font-family: var(--bo);
  line-height: 2.1;
  font-style: normal;
  font-feature-settings: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;   /* allows wrapping after tsheg on narrow screens */
}
/* Tibetan runs inside Vietnamese sentences (mixed()): Noto's Tibetan glyphs are optically small */
.bo-in { font-size: 1.3em; }
a { color: var(--ink); text-underline-offset: 3px; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wy { font-style: italic; }             /* Wylie transliteration */
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }

/* ══ Chrome ═══════════════════════════════════════════════════════════════ */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 20px; background: var(--leaf-white); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-bo { font-size: 24px; line-height: 2; color: var(--mthing); }
.brand-txt { font-weight: 600; font-size: var(--t-sm); color: var(--muted); }
.userbox { display: flex; align-items: center; gap: 10px; font-size: var(--t-sm); }
.userbox img { width: 28px; height: 28px; border-radius: 50%; }
.userbox button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }
.userbox button:hover { color: var(--ink); }
@media (max-width: 520px) { .userbox .uname { display: none; } }

.container { max-width: 760px; margin: 0 auto; padding: 28px 16px 72px; min-height: 70vh; }
.foot { text-align: center; color: var(--muted); font-size: var(--t-xs); padding: 20px 16px 28px; }
.loading { color: var(--muted); padding: 48px 0; text-align: center; }

h1, h2, h3 { line-height: 1.3; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
.sub { color: var(--muted); margin: 6px 0 24px; max-width: 62ch; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--muted); text-decoration: none; margin-bottom: 14px; }
.back::before { content: '‹'; font-size: 20px; line-height: 1; }
.back:hover { color: var(--ink); }
.section-h { font-size: var(--t-md); margin: 36px 0 12px; }

/* ══ Controls ═════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: var(--r-ctl);
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.ghost { background: var(--leaf-white); color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--mthing); }
.btn.gold:hover { background: #e6bd57; border-color: #e6bd57; }
.btn.danger { background: var(--cinnabar); border-color: var(--cinnabar); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: var(--t-sm); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.error { background: var(--cinnabar-bg); color: var(--cinnabar); padding: 12px 14px; border-radius: var(--r-ctl); margin: 12px 0; }
.panel { background: var(--leaf-white); border: 1px solid var(--line); border-radius: var(--r-opt); padding: 20px; }

/* status words (sentence case, colored, no pill chrome) */
.st { font-size: var(--t-sm); font-weight: 600; white-space: nowrap; }
.st.ok { color: var(--malachite); }
.st.now { color: var(--mthing); }
.st.lock { color: var(--muted); font-weight: 500; }

/* ══ The manuscript leaf (mthing shog): the one bold surface ═══════════════ */
.leaf {
  position: relative; background: var(--mthing); color: #fff; border-radius: var(--r-leaf);
  box-shadow: 0 1px 1px rgba(26, 37, 71, .25), 0 10px 24px -12px rgba(26, 37, 71, .55);
}
.leaf::before {          /* the ruled frame of a pecha page, in gold */
  content: ''; position: absolute; inset: 10px; pointer-events: none;
  border: 1px solid rgba(217, 174, 69, .45); border-radius: 3px;
}
.leaf .bo { color: var(--gold); }
.leaf .muted { color: var(--gold-soft); }

/* ══ Login ════════════════════════════════════════════════════════════════ */
.login { max-width: 520px; margin: 24px auto 0; }
.login .leaf { padding: 36px 28px 30px; text-align: center; }
.login .hero-bo { font-size: clamp(40px, 11vw, 60px); margin: 0; line-height: 2.1; }
.login .leaf p { margin: 0; }
.login h1 { margin-top: 24px; }
.login .lead { color: var(--muted); margin: 8px 0 0; }
.login .gbtn { display: flex; justify-content: flex-start; margin: 24px 0 8px; min-height: 44px; }
.devlogin { margin-top: 24px; padding-top: 18px; border-top: 1px dashed var(--line-2); }
.devlogin label { display: block; font-size: var(--t-sm); color: var(--muted); margin-bottom: 6px; }
.devlogin .row input { flex: 1; min-width: 200px; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--r-ctl); background: #fff; }

/* ══ Dashboard ════════════════════════════════════════════════════════════ */
.resume { display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; align-items: end; padding: 26px 30px 28px; }
.resume .title-bo { font-size: clamp(34px, 7vw, 46px); line-height: 2.1; grid-column: 1 / -1; margin-bottom: -4px; }
.resume h2 { color: #fff; font-size: var(--t-lg); }
.resume .muted { font-size: var(--t-sm); margin-top: 2px; }
@media (max-width: 560px) { .resume { grid-template-columns: 1fr; padding: 22px 22px 24px; } .resume .btn { width: 100%; } }

.path { list-style: none; margin: 0; padding: 0; position: relative; }
.path::before { content: ''; position: absolute; left: 23px; top: 24px; bottom: 24px; width: 2px; background: var(--line-2); }
.path li { position: relative; }
.lesson {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 4px 16px; align-items: center;
  padding: 14px 0; text-decoration: none; color: inherit;
}
.lesson .num {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; z-index: 1;
  background: var(--leaf-white); border: 2px solid var(--line-2); color: var(--muted);
  font-family: var(--bo); font-size: 26px; line-height: 1;
}
.lesson.now .num { background: var(--mthing); border-color: var(--mthing); color: var(--gold); }
.lesson.passed .num { border-color: var(--malachite); color: var(--malachite); }
.lesson .title-bo { font-size: 22px; line-height: 2; color: var(--mthing); }
.lesson h3 { font-size: var(--t-md); font-weight: 600; }
.lesson .stats { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: var(--t-sm); color: var(--muted); margin-top: 2px; }
.lesson .bar { margin-top: 8px; }
.lesson.locked { color: var(--muted); }
.lesson.locked .title-bo { color: var(--muted); opacity: .7; }
a.lesson:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 560px) { .lesson { grid-template-columns: 48px 1fr; } .lesson .st { grid-column: 2; } }

.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; max-width: 320px; }
.bar > i { display: block; height: 100%; background: var(--mthing); border-radius: 4px; }
.lesson.passed .bar > i { background: var(--malachite); }

details.rules-note { margin-top: 32px; font-size: var(--t-sm); color: var(--muted); }
details.rules-note summary { cursor: pointer; color: var(--ink); font-weight: 600; }
details.rules-note ul { margin: 10px 0 0; padding-left: 20px; }

/* ══ Lesson hub ═══════════════════════════════════════════════════════════ */
.hub-head .title-bo { font-size: clamp(34px, 7vw, 44px); line-height: 2.1; color: var(--mthing); }
.steps { list-style: none; margin: 8px 0 0; padding: 0; counter-reset: step; }
.step {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 4px 16px; align-items: start;
  padding: 18px 0; border-top: 1px solid var(--line);
}
.step:last-child { border-bottom: 1px solid var(--line); }
.step .n {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line-2); color: var(--muted); font-weight: 700; font-size: var(--t-sm); margin-top: 2px;
}
.step.now .n { background: var(--ink); border-color: var(--ink); color: #fff; }
.step.done .n { border-color: var(--malachite); background: var(--malachite); color: #fff; }
.step p { margin: 4px 0 0; color: var(--muted); font-size: var(--t-sm); max-width: 52ch; }
.step .st { display: block; margin-top: 6px; }
.step .act { align-self: center; }
@media (max-width: 560px) { .step { grid-template-columns: 36px 1fr; } .step .act { grid-column: 2; margin-top: 8px; } }

.table-wrap { overflow-x: auto; }
table.hist { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
table.hist td, table.hist th { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.hist th { color: var(--muted); font-weight: 500; }
.res-passed { color: var(--malachite); font-weight: 600; }
.res-failed { color: var(--cinnabar); font-weight: 600; }

/* ══ Flash cards ══════════════════════════════════════════════════════════ */
.deck-progress { display: flex; align-items: center; gap: 12px; font-size: var(--t-sm); color: var(--muted); margin: -8px 0 18px; }
.deck-progress .bar { flex: 1; }
.fc-wrap { perspective: 1400px; margin: 0 auto; }
.fc {
  position: relative; display: grid; transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.3, .7, .3, 1); cursor: pointer; outline-offset: 6px; border-radius: var(--r-leaf);
  touch-action: pan-y;
}
.fc.flipped { transform: rotateY(180deg); }
/* Both faces share one grid cell so the card grows to the taller face (ADR-017). */
.fc-face {
  grid-area: 1 / 1; min-height: 340px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--r-leaf);
}
.fc-front { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 34px 28px; text-align: center; }
.fc-front .cat { position: absolute; top: 20px; left: 24px; font-size: var(--t-xs); color: var(--gold-soft); }
.fc-front .big { font-size: clamp(72px, 18vw, 132px); line-height: 2; }
.fc-front .big.long { font-size: clamp(36px, 8vw, 58px); line-height: 2.1; }
.fc-front .hint { position: absolute; bottom: 20px; font-size: var(--t-xs); color: var(--gold-soft); }
.fc-back {
  transform: rotateY(180deg); background: var(--leaf-white); border: 1px solid var(--line);
  padding: 22px 26px 24px; box-shadow: 0 10px 24px -14px rgba(26, 37, 71, .35);
}
.fc-back .head { display: flex; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.fc-back .head .bo { font-size: 52px; color: var(--mthing); }
.fc-back .head .wy { font-size: var(--t-lg); color: var(--muted); }
dl.kv { display: grid; grid-template-columns: 96px 1fr; gap: 10px 16px; margin: 0; font-size: 15px; }
dl.kv dt { color: var(--muted); font-size: var(--t-sm); padding-top: 2px; }
dl.kv dd { margin: 0; }
dl.kv dd .bo { font-size: 24px; }
dl.kv .en { color: var(--muted); }
@media (max-width: 480px) { dl.kv { grid-template-columns: 1fr; gap: 2px; } dl.kv dd { margin-bottom: 10px; } .fc-back { padding: 18px; } }

.fc-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 18px; }
.fc-nav #prev { justify-self: start; }
.fc-nav #next { justify-self: end; }
.fc-count { color: var(--muted); font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.deck-next { display: flex; justify-content: center; margin-top: 20px; }

.grid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.gl-item {
  position: relative; padding: 6px 8px 8px; text-align: center; cursor: pointer;
  border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--leaf-white); color: var(--ink);
}
.gl-item:hover { border-color: var(--line-2); }
.gl-item .bo { font-size: 26px; display: block; }
.gl-item small { color: var(--muted); font-style: italic; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-item.viewed::after { content: ''; position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--malachite); }
.gl-item.current { border-color: var(--mthing); box-shadow: inset 0 0 0 1px var(--mthing); }

/* ══ Quiz (practice & test) ═══════════════════════════════════════════════ */
.quiz { max-width: 680px; margin: 0 auto; }
.qtop { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.qtop h1 { font-size: var(--t-lg); }
.qhead { display: flex; align-items: center; gap: 14px; margin: 10px 0 16px; }
.qhead .count { font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress { flex: 1; min-width: 80px; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--mthing); transition: width .3s; }
.tally { font-size: var(--t-sm); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tally.ok { color: var(--malachite); }
.tally.bad { color: var(--cinnabar); }
.timer { --p: 1; width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: conic-gradient(var(--mthing) calc(var(--p) * 360deg), var(--line) 0); position: relative; }
.timer::after { content: ''; position: absolute; inset: 4px; background: var(--mist); border-radius: 50%; }
.timer span { position: relative; z-index: 1; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.timer.low { background: conic-gradient(var(--cinnabar) calc(var(--p) * 360deg), var(--line) 0); }
.timer.low span { color: var(--cinnabar); }

.qcard { padding: 24px; }
.qstem { color: var(--muted); font-size: var(--t-sm); margin-bottom: 4px; }
.qprompt { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.qprompt.bo { font-size: clamp(48px, 11vw, 80px); font-weight: 400; text-align: center; line-height: 2; color: var(--mthing); }
.qprompt.bo.long { font-size: clamp(28px, 6vw, 42px); line-height: 2.1; }
.qsub { color: var(--muted); text-align: center; margin-bottom: 8px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.options.wide { grid-template-columns: 1fr; }
@media (max-width: 560px) { .options { grid-template-columns: 1fr; } }
.opt {
  text-align: left; padding: 10px 14px; border-radius: var(--r-opt); border: 1px solid var(--line-2); background: var(--leaf-white);
  cursor: pointer; display: flex; gap: 12px; align-items: center; min-height: 56px; color: var(--ink);
}
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt .k { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.opt .t { flex: 1; }
.opt .t.bo { font-size: 34px; line-height: 2; }
.opt.correct { border-color: var(--malachite); background: var(--malachite-bg); box-shadow: inset 0 0 0 1px var(--malachite); }
.opt.correct .k { background: var(--malachite); border-color: var(--malachite); color: #fff; }
.opt.wrong { border-color: var(--cinnabar); background: var(--cinnabar-bg); box-shadow: inset 0 0 0 1px var(--cinnabar); }
.opt.wrong .k { background: var(--cinnabar); border-color: var(--cinnabar); color: #fff; }
.opt:disabled { cursor: default; }
.opt:disabled:not(.correct):not(.wrong) { opacity: .6; }
.feedback { margin-top: 16px; padding: 12px 16px; border-radius: var(--r-ctl); white-space: pre-line; font-size: 15px; border-left: 4px solid; }
.feedback b { display: block; }
.feedback.ok { background: var(--malachite-bg); color: #1f5a46; border-color: var(--malachite); }
.feedback.bad { background: var(--cinnabar-bg); color: #8a2e20; border-color: var(--cinnabar); }
.qfoot { display: flex; align-items: center; gap: 10px; margin-top: 16px; min-height: 44px; }
.keyhint { font-size: var(--t-xs); color: var(--muted); }
@media (hover: none) { .keyhint { display: none; } }

.confirm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 12px; border-radius: var(--r-ctl); background: var(--cinnabar-bg); color: #8a2e20; }
.confirm-bar p { margin: 0; flex: 1 1 240px; }

.rules { margin: 14px 0 22px; padding-left: 20px; }
.rules li { margin: 6px 0; }

/* ══ Results ══════════════════════════════════════════════════════════════ */
.result { text-align: center; padding: 32px 22px; }
.result .score { font-size: 64px; font-weight: 700; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.result.pass .score { color: var(--malachite); }
.result h2 { margin-top: 10px; }
.result p { color: var(--muted); margin: 8px auto 20px; max-width: 46ch; }
.result .row { justify-content: center; }
.review { text-align: left; margin-top: 8px; display: grid; gap: 10px; }
.review .item { padding: 14px 16px; border-left: 3px solid var(--cinnabar); }
.review .prompt { font-size: 18px; }
.review .answer { margin-top: 4px; }
.review .why { font-size: var(--t-sm); color: var(--muted); white-space: pre-line; margin-top: 6px; }

/* ══ Sound ════════════════════════════════════════════════════════════════
   .snd = play button (speaker icon + label); .snd-slow = text-only "Chậm";
   .playing swaps the icon for three moving bars (motion answers the tap). */
.snd-group { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; flex-wrap: wrap; }
.snd {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px 4px 10px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--leaf-white); color: var(--ink);
  font-size: var(--t-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.snd:hover { border-color: var(--ink); }
.snd svg { width: 18px; height: 18px; flex: none; }
.snd .wave { display: none; }
.snd.playing { background: var(--ink); border-color: var(--ink); color: #fff; }
.snd.playing svg { display: none; }
.snd.playing .wave { display: inline-flex; }
.snd-slow { padding: 4px 12px; font-weight: 500; color: var(--muted); }
.snd-slow.playing { color: #fff; }
/* "≈": approximate clip (AI take that did not pass the automatic check) */
.snd-approx { align-self: center; padding: 0 4px; font-weight: 600; color: var(--muted); cursor: help; }
.snd.err { border-color: var(--cinnabar); color: var(--cinnabar); }
.snd.nudge { box-shadow: 0 0 0 3px rgba(59, 91, 219, .35); }
.wave { align-items: center; gap: 2px; width: 18px; height: 18px; justify-content: center; }
.wave i { display: block; width: 3px; height: 8px; border-radius: 2px; background: currentColor; animation: wave .9s ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: .15s; }
.wave i:nth-child(3) { animation-delay: .3s; }
@keyframes wave { 0%, 100% { height: 5px; } 50% { height: 16px; } }

/* icon-only button on the indigo card front */
.snd-icon { padding: 0; width: 44px; height: 44px; justify-content: center; }
.snd.on-leaf { position: absolute; right: 20px; bottom: 16px; background: transparent; border-color: rgba(217, 174, 69, .6); color: var(--gold); }
.snd.on-leaf:hover { border-color: var(--gold); }
.snd.on-leaf.playing { background: var(--gold); color: var(--mthing); border-color: var(--gold); }

.fc-back .head .snd-group { margin-left: auto; }
.ex-line { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; }

/* record-yourself row on the card back */
.speak { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; margin: -4px 0 16px; border-radius: var(--r-ctl); background: var(--mist); }
.speak .btn svg { width: 16px; height: 16px; }
.speak .bo-in { font-size: 1.4em; }
.speak.rec { background: var(--cinnabar-bg); color: #8a2e20; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cinnabar); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.snd.mine { border-color: var(--malachite); color: var(--malachite); }
.snd.mine.playing { background: var(--malachite); color: #fff; }

/* listening question prompt */
.listen-prompt { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0 4px; }
.snd-big { width: 88px; height: 88px; padding: 0; justify-content: center; background: var(--ink); border-color: var(--ink); color: #fff; }
.snd-big svg { width: 38px; height: 38px; }
.snd-big .wave { width: 38px; height: 38px; gap: 4px; }
.snd-big .wave i { width: 5px; }
.snd-big:hover { background: var(--ink-2); }
.snd-big.nudge { animation: nudge 1.2s ease-in-out 2; }
@keyframes nudge { 50% { box-shadow: 0 0 0 10px rgba(26, 37, 71, .15); } }

/* answer audio inside feedback / review */
.say { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; white-space: normal; }
.feedback .snd { background: rgba(255, 255, 255, .7); }

/* sound settings popover in the top bar */
.sndset { position: relative; }
.sndset summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); padding: 6px 4px; border-radius: var(--r-ctl); }
.sndset summary::-webkit-details-marker { display: none; }
.sndset summary svg { width: 18px; height: 18px; }
.sndset summary:hover, .sndset[open] summary { color: var(--ink); }
.sndset-panel {
  position: absolute; right: 0; top: calc(100% + 6px); width: min(320px, calc(100vw - 32px)); z-index: 20;
  background: var(--leaf-white); border: 1px solid var(--line); border-radius: var(--r-opt); padding: 14px 16px;
  box-shadow: 0 12px 28px -12px rgba(26, 37, 71, .4); display: grid; gap: 10px; font-size: var(--t-sm);
}
.sndset-panel label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.sndset-panel input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--ink); flex: none; }
.sndset-panel p { margin: 0; }
@media (max-width: 520px) { .sndset-label { display: none; } }

/* ══ Motion preferences ═══════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .fc, .progress > i { transition: none; }
  .wave i, .snd-big.nudge, .rec-dot { animation: none; }
  .wave i { height: 12px; }
}
