/* ==========================================================================
   Học cùng Tako — design system (Redesign Phase 1, 2026-10-29)
   Replaces app.css + unified-v8.css + bloom-v9.css + layout-v10.css +
   learning-ui.css. One file, cascade layers in a fixed order:
     reset → tokens → base → components → screens → utilities
   Presentation only: no API, data or grading behaviour lives here.
   ========================================================================== */
@layer reset, tokens, base, components, screens, utilities;

/* ============================== RESET ============================== */
@layer reset {
  *,*::before,*::after { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html, body { margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
  img, svg, video, iframe { max-width: 100%; }
  img { height: auto; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; }
  h1, h2, h3, p, ul, ol { margin-top: 0; }
  [inert] { pointer-events: none !important; }
}

/* ============================== TOKENS ============================== */
@layer tokens {
  :root {
    /* colour — Brand identity v2 (docs/brand-v2/BRAND.md). ONE palette: the --tk-* primitives below
       are the only brand hex values; every semantic token (here and in pop.css) points at them. */
    --tk-indigo: #30246D; --tk-indigo-800: #231A52; --tk-indigo-600: #4A3C96; --tk-indigo-100: #DEDAF2; --tk-indigo-50: #EFEDF8;
    --tk-coral: #FF654F; --tk-coral-600: #D63D27; --tk-coral-700: #B8321F; --tk-coral-800: #962715; --tk-coral-100: #FFD9D2; --tk-coral-50: #FFF0EC;
    --tk-sakura: #FFB9C8; --tk-sakura-700: #B83A5E; --tk-sakura-50: #FFF0F3;
    --tk-matcha: #3CBF9B; --tk-matcha-700: #147A5C; --tk-matcha-800: #0F5E47; --tk-matcha-50: #E3F6F0;
    --tk-mikan: #FFB347; --tk-mikan-700: #8A5200; --tk-mikan-50: #FFF4E2;
    --tk-sky: #63BBF5; --tk-sky-700: #1A65A0; --tk-sky-50: #E6F4FE;
    --tk-violet: #7B6CF0; --tk-violet-700: #4F3DB8; --tk-violet-50: #EEEBFD;
    --tk-beige: #FFF7ED; --tk-charcoal: #1F2937; --tk-slate: #5B6475;
    --canvas: var(--tk-beige); --surface: #FFFFFF; --surface-warm: #FFEFE4; --surface-2: #FFFBF6;
    --matcha: var(--tk-matcha-700); --matcha-hover: var(--tk-matcha-800); --matcha-edge: var(--tk-matcha-800); --matcha-deep: var(--tk-matcha-800);
    --coral: var(--tk-coral); --coral-ink: var(--tk-coral-700); --coral-soft: var(--tk-coral-50);
    --honey: var(--tk-mikan); --honey-ink: var(--tk-mikan-700); --honey-soft: var(--tk-mikan-50);
    --sakura: var(--tk-sakura); --sakura-soft: var(--tk-sakura-50); --sakura-ink: var(--tk-sakura-700);
    --ink: var(--tk-charcoal); --muted: var(--tk-slate); --line: #F1E3D3; --line-strong: #DECDBA;
    --mint: var(--tk-matcha-50); --mint-ink: var(--tk-matcha-800);
    --danger: #B54552; --danger-soft: #FDECEA; --danger-edge: #8B2F3B;
    --focus: var(--tk-indigo-600);
    /* level accent (overridden by body[data-level]) */
    --accent: var(--tk-matcha-700); --accent-soft: var(--tk-matcha-50); --accent-ink: var(--tk-matcha-800); /* accent-ink = text-safe on accent-soft (AA) */
    /* type */
    --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-jp: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, "Noto Sans CJK JP", sans-serif;
    /* radii */
    --r-8: 8px; --r-12: 12px; --r-14: 14px; --r-16: 16px; --r-24: 24px; --r-pill: 999px;
    /* 8pt spacing scale */
    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 40px; --s-8: 48px;
    /* elevation */
    --shadow-sm: 0 1px 2px rgba(31,41,55,.05), 0 2px 8px rgba(31,41,55,.04);
    --shadow-md: 0 6px 20px rgba(31,41,55,.07);
    --shadow-lg: 0 18px 48px rgba(31,41,55,.18);
    /* motion */
    --t-press: 120ms; --t-fast: 160ms; --t-enter: 280ms; --ease: cubic-bezier(.22,1,.36,1);
    /* layout */
    --side-w: 264px; --content-max: 1040px; --nav-h: 68px; --lesson-max: 920px;
  }
  /* level accents (brand v2): N5 matcha · N4 coral · N3 sky · N2 violet · N1 mikan — -700 shades are AA on white */
  body[data-level="N5"] { --accent: var(--tk-matcha-700); --accent-soft: var(--tk-matcha-50); --accent-ink: var(--tk-matcha-800); }
  body[data-level="N4"] { --accent: var(--tk-coral-700); --accent-soft: var(--tk-coral-50); --accent-ink: var(--tk-coral-800); }
  body[data-level="N3"] { --accent: var(--tk-sky-700); --accent-soft: var(--tk-sky-50); --accent-ink: var(--tk-sky-700); }
  body[data-level="N2"] { --accent: var(--tk-violet-700); --accent-soft: var(--tk-violet-50); --accent-ink: var(--tk-violet-700); }
  body[data-level="N1"] { --accent: var(--tk-mikan-700); --accent-soft: var(--tk-mikan-50); --accent-ink: var(--tk-mikan-700); }
}

/* ============================== BASE ============================== */
@layer base {
  body {
    background: var(--canvas); color: var(--ink); font-family: var(--font);
    font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; overflow-x: hidden;
  }
  /* Japanese text only: [lang=ja] / .jp */
  [lang="ja"], .jp { font-family: var(--font-jp); font-synthesis: none; line-height: 1.8; }
  a { color: var(--matcha); text-underline-offset: 3px; }
  a:hover { color: var(--matcha-hover); }
  :focus { outline: none; }
  :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
  [tabindex="-1"]:focus { outline: none; }
  ::selection { background: var(--honey); color: var(--ink); }
  h1 { font-size: 28px; line-height: 1.25; margin: 0 0 var(--s-2); font-weight: 800; letter-spacing: -.015em; }
  h2 { font-size: 21px; line-height: 1.35; margin: var(--s-5) 0 var(--s-3); font-weight: 750; }
  h3 { font-size: 17px; line-height: 1.4; margin: 0; font-weight: 700; }
  @media (min-width: 861px) { h1 { font-size: 34px; } h2 { font-size: 23px; } }
  audio { accent-color: var(--matcha); }
  .skip-link { position: fixed; left: 12px; top: -60px; z-index: 300; background: var(--ink); color: #fff;
    padding: 10px 16px; border-radius: var(--r-12); transition: top var(--t-fast); }
  .skip-link:focus { top: 12px; color: #fff; }

  /* ---------- shell ---------- */
  .shell { display: block; }
  .side { display: none; }
  .main { min-width: 0; }
  .content { max-width: var(--content-max); margin: 0 auto;
    padding: var(--s-4) var(--s-4) calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s-6)); }
  @media (min-width: 768px) { .content { padding: var(--s-5) var(--s-5) 96px; } }
  @media (min-width: 1024px) {
    .shell { display: grid; grid-template-columns: var(--side-w) minmax(0,1fr); min-height: 100vh; }
    .side { display: flex; flex-direction: column; gap: var(--s-3); position: sticky; top: 0; height: 100vh;
      padding: var(--s-5) var(--s-4); overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); }
    .content { padding: var(--s-6) var(--s-7) 96px; }
  }
  .brand { display: flex; gap: var(--s-3); align-items: center; text-decoration: none; color: var(--ink); margin-bottom: var(--s-1); }
  .brand-mascot { width: 48px; height: 48px; flex: none; }
  .brand-text { display: flex; flex-direction: column; line-height: 1.25; }
  .brand-name { font-weight: 800; font-size: 17px; }
  .brand-sub { font-size: 12px; color: var(--muted); }
  #sideNav { display: flex; flex-direction: column; gap: 2px; }
  #sideNav a { display: flex; align-items: center; gap: var(--s-3); padding: 10px var(--s-3); min-height: 44px;
    border-radius: var(--r-12); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px;
    transition: background var(--t-fast), color var(--t-fast); }
  #sideNav a svg { flex: none; }
  #sideNav a:hover { background: var(--surface-warm); }
  #sideNav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
  .side-foot { margin-top: auto; padding-top: var(--s-4); font-size: 12px; color: var(--muted); line-height: 1.55; }
  .account-chip { display: flex; align-items: center; gap: 10px; }
  .avatar { border-radius: 50%; background: var(--surface-warm); display: grid; place-items: center; flex: none; overflow: hidden; }
  .avatar img { width: 100%; height: 100%; object-fit: cover; }

  /* ---------- mobile tab bar: 5 items ---------- */
  #tabBar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; display: grid;
    grid-template-columns: repeat(5,minmax(0,1fr)); column-gap: 2px; padding: 0 6px max(4px, env(safe-area-inset-bottom));
    background: rgba(255,255,255,.97); backdrop-filter: blur(10px); border-top: 1px solid var(--line); min-height: var(--nav-h); }
  #tabBar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0;
    min-height: 56px; margin: 5px 0; padding: 6px 2px 4px; color: var(--muted); text-decoration: none;
    font-size: 11.5px; font-weight: 650; border-radius: var(--r-14); transition: background var(--t-fast), color var(--t-fast); }
  #tabBar a svg { width: 23px; height: 23px; }
  #tabBar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #tabBar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
  @media (min-width: 1024px) { #tabBar { display: none; } }
  body.v8-guest #tabBar { display: none !important; }
  body.v8-guest .content { padding-bottom: var(--s-6); }
  /* focused workflows: exam room / exam detail / result hide the tab bar & mascot */
  body.exam-mode #tabBar, body.v8-exam-detail #tabBar, body.v8-exam-result #tabBar { display: none !important; }
  body.exam-mode .content, body.v8-exam-detail .content, body.v8-exam-result .content { padding-bottom: max(40px, env(safe-area-inset-bottom)); }
  body.exam-mode .content { padding-bottom: max(140px, env(safe-area-inset-bottom) + 124px); }
  body.exam-mode .mascot, body.exam-mode .brand-mascot { display: none !important; }
}

/* ============================== COMPONENTS ============================== */
@layer components {
  /* ---------- button: chunky 3D pressed bottom edge ---------- */
  .btn { --btn-bg: var(--matcha); --btn-fg: #fff; --btn-edge: var(--matcha-edge); --btn-hover: var(--matcha-hover);
    position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    min-height: 48px; padding: 10px var(--s-5); border: 1px solid transparent; border-radius: var(--r-14);
    background: var(--btn-bg); color: var(--btn-fg); font-weight: 700; font-size: 15.5px; line-height: 1.25;
    text-decoration: none; text-align: center; box-shadow: 0 3px 0 var(--btn-edge);
    transition: transform var(--t-press) ease-out, box-shadow var(--t-press) ease-out, background var(--t-fast); }
  .btn:hover { background: var(--btn-hover); color: var(--btn-fg); }
  .btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-edge); }
  .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
  .btn.ghost { --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-edge: var(--line-strong); --btn-hover: var(--surface-warm); border-color: var(--line-strong); }
  /* WCAG AA: coral buttons use the text-safe coral ink fill with white text
     (5.7:1); raw coral #F9704E with ink text is only 4.45:1, so it stays
     decorative (edges, nodes, accents). */
  .btn.coral { --btn-bg: var(--coral-ink); --btn-fg: #fff; --btn-edge: #7E2C15; --btn-hover: #9C3519; }
  .btn.coral-ink { --btn-bg: var(--coral-ink); --btn-fg: #fff; --btn-edge: #7E2C15; --btn-hover: #9C3519; }
  .btn.danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-edge: var(--danger-edge); --btn-hover: #9C3A46; }
  .btn.honey, .btn.amber-btn { --btn-bg: var(--honey); --btn-fg: var(--honey-ink); --btn-edge: #C99520; --btn-hover: #F5B93A; }
  .btn.google { --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-edge: var(--line-strong); --btn-hover: var(--surface-warm); border-color: var(--line-strong); width: 100%; }
  .btn.sm { min-height: 44px; padding: 8px var(--s-4); font-size: 14.5px; border-radius: var(--r-12); white-space: nowrap; }
  .btn.lg { min-height: 56px; padding: 14px var(--s-6); font-size: 17px; border-radius: var(--r-16); box-shadow: 0 4px 0 var(--btn-edge); }
  .btn.lg:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--btn-edge); }
  .btn.block { width: 100%; }
  .btn .spin, .spin { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: tk-spin .7s linear infinite; display: inline-block; }
  @keyframes tk-spin { to { transform: rotate(360deg); } }
  .icon-btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: var(--r-12);
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); box-shadow: 0 2px 0 var(--line-strong);
    transition: transform var(--t-press), box-shadow var(--t-press); }
  .icon-btn:active { transform: translateY(2px); box-shadow: none; }
  .v8-doc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px;
    padding: 8px var(--s-3); border: 1px solid var(--line-strong); border-radius: var(--r-12); background: var(--surface);
    color: var(--matcha); font-size: 13.5px; font-weight: 700; }
  .v8-doc-btn:hover { background: var(--mint); }
  .v8-text-button { min-height: 40px; background: none; border: 0; padding: 7px; color: var(--matcha); font-size: 13.5px; font-weight: 700; }

  /* ---------- chip / pill / tag ---------- */
  .chip { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 8px var(--s-4);
    border-radius: var(--r-pill); border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink);
    font-weight: 650; font-size: 14.5px; text-decoration: none; transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-press); }
  .chip:hover { border-color: var(--accent); }
  .chip:active:not(:disabled) { transform: scale(.97); }
  .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
  .chip:disabled { opacity: .55; cursor: wait; }
  .chip-otaff { border-color: #9A4E14; color: #7E3F10; font-weight: 700; justify-content: center; } /* màu đầy đủ: pop.css (OTAFF) */
  .level-chips { display: flex; gap: 6px; flex-wrap: wrap; }
  .level-chips .chip { min-width: 48px; justify-content: center; }
  .level-chips.side-levels { flex-wrap: nowrap; gap: 4px; }
  .level-chips.side-levels .chip { flex: 1; min-width: 0; padding: 6px 0; min-height: 40px; font-size: 13px; }
  .level-pill[data-lv="N5"].on { background: #14705C; border-color: #14705C; }
  .level-pill[data-lv="N4"].on { background: #177D80; border-color: #177D80; }
  .level-pill[data-lv="N3"].on { background: #466AB5; border-color: #466AB5; }
  .level-pill[data-lv="N2"].on { background: #8163A5; border-color: #8163A5; }
  .level-pill[data-lv="N1"].on { background: #A45E72; border-color: #A45E72; }
  .goal-chips { display: flex; gap: var(--s-2); justify-content: center; flex-wrap: wrap; margin: var(--s-4) 0 var(--s-1); }
  .tk-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px var(--s-3); border-radius: var(--r-pill);
    background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 650; color: var(--ink); white-space: nowrap; }
  .tk-chip-honey { background: var(--honey-soft); border-color: #F3DDA0; color: var(--honey-ink); }
  .tk-chip-honey svg { color: var(--coral-ink); }
  .tk-chip-mint { background: var(--mint); border-color: #C6E5D2; color: var(--mint-ink); }
  .tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill);
    background: var(--surface-warm); color: var(--ink); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
  .tag.ok { background: var(--mint); color: var(--matcha); }
  .tag.red { background: var(--danger-soft); color: var(--danger); }
  .tag.amber { background: var(--honey-soft); color: var(--honey-ink); }
  .tag.teal { background: var(--accent-soft); color: var(--accent-ink); }
  .tag.coral { background: var(--coral-soft); color: var(--coral-ink); }
  .v8-pill { display: inline-flex; padding: 5px 10px; background: var(--accent); border-radius: var(--r-8); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
  .eyebrow { display: inline-block; color: var(--accent-ink); letter-spacing: .07em; font-size: 11.5px; font-weight: 800; text-transform: uppercase; margin: 0 0 4px; }

  /* ---------- card / list / item ---------- */
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-24);
    padding: var(--s-4) var(--s-5); margin-bottom: var(--s-4); box-shadow: var(--shadow-sm); overflow-wrap: anywhere; }
  @media (max-width: 560px) { .card { padding: var(--s-4); border-radius: var(--r-16); } }
  .card h2 { margin-top: 0; }
  a.card { display: block; color: var(--ink); text-decoration: none; transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast); }
  a.card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
  .list { display: flex; flex-direction: column; gap: 10px; margin-bottom: var(--s-4); }
  .item { display: flex; align-items: center; gap: var(--s-3); background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-16); padding: var(--s-3) var(--s-4); box-shadow: var(--shadow-sm); min-width: 0; }
  .item > .grow, .row > .grow { min-width: 0; }
  a.item { text-decoration: none; color: var(--ink); }
  a.item:hover { border-color: var(--accent); }
  .item .ic { color: var(--accent-ink); display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: var(--r-14); background: var(--accent-soft); }
  .list .item:nth-child(4n+2) .ic { background: var(--surface-warm); color: var(--coral-ink); }
  .list .item:nth-child(4n+3) .ic { background: var(--sakura-soft); color: var(--sakura-ink); }
  .list .item:nth-child(4n+4) .ic { background: var(--honey-soft); color: var(--honey-ink); }
  .note { background: var(--honey-soft); border: 1px solid #EBD9A8; color: #5F450A; border-radius: var(--r-12); padding: 10px var(--s-3); font-size: 14px; line-height: 1.55; margin: 10px 0; }
  .note.blue { background: var(--mint); border-color: #A9D8C3; color: var(--matcha-deep); }
  details.card > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 44px; }
  details.card > summary::-webkit-details-marker { display: none; }
  details.card > summary h2 { display: inline; margin: 0; font-size: 19px; }
  details.card > summary .chev { margin-left: auto; color: var(--muted); display: inline-flex; transform: rotate(90deg); transition: transform var(--t-fast); }
  details.card[open] > summary .chev { transform: rotate(-90deg); }
  details.card[open] > summary { margin-bottom: var(--s-3); }

  /* ---------- progress: bar + ring ---------- */
  .progressbar { height: 10px; border-radius: var(--r-pill); background: var(--surface-warm); overflow: hidden; min-width: 60px; }
  .progressbar > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--accent); transition: width 400ms ease-out; }
  .ring { position: relative; display: inline-grid; place-items: center; flex: none; }
  .ring svg { display: block; }
  .ring-bg { stroke: var(--surface-warm); }
  .ring-fg { stroke: var(--accent); transition: stroke-dashoffset 600ms var(--ease); }
  .ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.15; padding: 0 12px; }
  .ring-center b { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
  .ring-center small { font-size: 11px; color: var(--muted); margin-top: 2px; }

  /* ---------- tabs ---------- */
  .tk-tabs { display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); max-width: 100%; overflow-x: auto; }
  .tk-tab { min-height: 40px; display: inline-flex; align-items: center; padding: 8px var(--s-4); border-radius: var(--r-pill); color: var(--muted); font-weight: 700; font-size: 14px; text-decoration: none; white-space: nowrap; }
  .tk-tab:hover { color: var(--ink); background: var(--surface-warm); }
  .tk-tab.on { background: var(--accent); color: #fff; }

  /* ---------- mascot + empty state ---------- */
  .mascot { display: block; flex: none; object-fit: contain; }
  .tk-empty { text-align: center; padding: var(--s-6) var(--s-5); }
  .tk-empty .mascot { margin: 0 auto var(--s-3); }
  .tk-empty h2 { margin: 0 0 6px; }
  .tk-empty p { margin: 0 auto; max-width: 44ch; }
  .v8-empty-inline { padding: var(--s-4); border: 1px dashed var(--line-strong); background: var(--surface); border-radius: var(--r-14); color: var(--muted); font-size: 14px; }

  /* ---------- skeleton ---------- */
  .skel { border-radius: var(--r-24); background: var(--surface); border: 1px solid var(--line); padding: var(--s-5); margin-bottom: var(--s-3); }
  .skel .bar { height: 14px; border-radius: var(--r-8); margin: 10px 0;
    background: linear-gradient(100deg, var(--surface-warm) 40%, #FBE2CB 50%, var(--surface-warm) 60%); background-size: 200% 100%; animation: tk-shimmer 1.3s infinite; }
  @keyframes tk-shimmer { to { background-position: -200% 0; } }

  /* ---------- forms ---------- */
  .fld { margin-bottom: var(--s-4); }
  .fld label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
  .fld input, .v8-search input { width: 100%; min-height: 48px; padding: 11px var(--s-3); border: 1.5px solid var(--line-strong);
    border-radius: var(--r-14); background: var(--surface); color: var(--ink); }
  .fld input:focus, .v8-search input:focus { border-color: var(--focus); outline: 3px solid rgba(23,92,150,.25); outline-offset: 0; }
  .fld .hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
  .fld input[aria-invalid="true"] { border-color: var(--danger); }
  .pw-wrap { position: relative; }
  .pw-wrap input { padding-right: 52px; }
  .pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 10px; }
  .form-err { background: var(--danger-soft); border: 1px solid #F0C4CB; color: #6E2430; border-radius: var(--r-12); padding: 10px var(--s-3); font-size: 14.5px; margin-bottom: var(--s-4); }
  .divider { display: flex; align-items: center; gap: var(--s-3); color: var(--muted); font-size: 13px; margin: var(--s-4) 0; }
  .divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
  .v8-search { display: flex; align-items: center; position: relative; margin: 0 0 var(--s-3); }
  .v8-search > svg { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
  .v8-search input { padding-left: 44px; font-size: 15px; }

  /* ---------- filter pills ---------- */
  .v8-filter-list, .learning-stage-filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 1px 10px; margin-bottom: 2px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .learning-stage-filters { flex-wrap: wrap; align-items: center; overflow: visible; }
  .v8-filter-list button, .learning-stage-filters button { min-height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); color: var(--ink);
    background: var(--surface); padding: 8px 14px; white-space: nowrap; font-size: 13.5px; font-weight: 650; }
  .v8-filter-list button.selected, .learning-stage-filters button.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
  .learning-filter-caption { color: var(--muted); font-size: 12px; font-weight: 700; margin-right: 3px; }

  /* ---------- check (day tick) ---------- */
  .check { width: 46px; height: 46px; flex: none; border-radius: 50%; border: 2.5px solid var(--line-strong); background: var(--surface);
    color: #fff; display: grid; place-items: center; padding: 0; transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-press); }
  .check:hover { border-color: var(--matcha); }
  .check:active { transform: scale(.94); }
  .check.done { background: var(--matcha); border-color: var(--matcha); }
  .check[disabled] { opacity: .6; cursor: wait; }

  /* ---------- dialog / bottom sheet (ui.js openDialog) ---------- */
  .dlg-layer { position: fixed; inset: 0; z-index: 130; background: rgba(31,41,55,.46); display: flex; align-items: center; justify-content: center; padding: var(--s-4); overscroll-behavior: contain; }
  .dlg { position: relative; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; background: var(--surface);
    border-radius: var(--r-24); padding: var(--s-5); box-shadow: var(--shadow-lg); animation: tk-dlg-in 220ms var(--ease); }
  .dlg:focus { outline: none; }
  .dlg-sheet { align-items: flex-end; padding: 0; }
  .dlg-sheet .dlg { max-width: 600px; border-radius: var(--r-24) var(--r-24) 0 0; max-height: 86vh;
    padding: var(--s-3) var(--s-5) calc(var(--s-5) + env(safe-area-inset-bottom)); animation-name: tk-sheet-in; }
  @media (min-width: 768px) { .dlg-sheet { align-items: center; padding: var(--s-5); } .dlg-sheet .dlg { border-radius: var(--r-24); } }
  .dlg-grip { display: block; width: 44px; height: 5px; border-radius: var(--r-pill); background: var(--line-strong); margin: 0 auto var(--s-3); }
  @media (min-width: 768px) { .dlg-grip { display: none; } }
  .dlg-head { display: flex; align-items: flex-start; gap: var(--s-3); margin-bottom: var(--s-2); }
  .dlg-head h2 { flex: 1; min-width: 0; margin: 4px 0 0; font-size: 20px; }
  .dlg-x { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: var(--r-12); border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
  .dlg-x:hover { background: var(--surface-warm); }
  .dlg-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: var(--s-4); }
  .dlg-confirm-in { display: flex; gap: var(--s-4); }
  .dlg-confirm-in h2 { margin: 0 0 var(--s-2); font-size: 20px; }
  .dlg-confirm-in p { margin: 0; }
  @media (max-width: 560px) { .dlg-confirm-in { flex-direction: column; } }
  @keyframes tk-dlg-in { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes tk-sheet-in { from { transform: translateY(24px); } to { transform: none; } }
  .day-tasks { margin: 0 0 var(--s-4); padding-left: 20px; }
  .day-tasks li { margin: 6px 0; }
  /* documents sheet */
  .docs-sect { font-weight: 800; font-size: 12.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: var(--s-4) 0 var(--s-2); }
  .docs-item { display: flex; gap: 11px; align-items: center; padding: 12px 10px; min-height: 48px; border-radius: var(--r-14);
    color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14.5px; }
  .docs-item > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .docs-item:hover { background: var(--surface-warm); }
  .docs-item svg { flex: none; color: var(--matcha); }
  .docs-item.is-off { cursor: default; }
  .docs-item.is-off:hover { background: none; }

  /* ---------- toast ---------- */
  #toastRoot { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
    z-index: 150; display: flex; flex-direction: column; gap: var(--s-2); align-items: center; pointer-events: none; width: min(420px, calc(100vw - 24px)); }
  @media (min-width: 1024px) { #toastRoot { bottom: var(--s-5); } }
  body.exam-mode #toastRoot { bottom: calc(115px + env(safe-area-inset-bottom)); }
  .toast { background: var(--ink); color: #fff; border-radius: var(--r-14); padding: 12px 18px; font-size: 14.5px; font-weight: 600;
    box-shadow: var(--shadow-lg); animation: tk-dlg-in 180ms var(--ease); max-width: 100%; text-align: center; }
  .toast.err { background: var(--danger); }

  /* ---------- stats ---------- */
  .stat-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  @media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(4,minmax(0,1fr)); } }
  .stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-16); padding: 14px var(--s-4); box-shadow: var(--shadow-sm); min-width: 0; }
  .stat:nth-child(4n+2) { background: var(--mint); }
  .stat:nth-child(4n+3) { background: var(--surface-warm); }
  .stat:nth-child(4n+4) { background: var(--sakura-soft); }
  .stat b { font-size: 21px; display: block; line-height: 1.25; font-variant-numeric: tabular-nums; }
  .stat span { font-size: 12.5px; color: var(--muted); }
  .bar-row { display: grid; grid-template-columns: 110px 1fr 64px; gap: var(--s-3); align-items: center; margin: 9px 0; font-size: 14.5px; }

  /* ---------- Drive player: responsive 16:9, lazy iframe ---------- */
  .player-frame { position: relative; width: 100%; aspect-ratio: 16/9; border-radius: var(--r-16); overflow: hidden; background: #101418; }
  .player-frame iframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; }
  /* Narrow DESKTOP windows only (mouse, no touch — video-v8.js adds .is-scaled): render a 720px logical
     player and scale it into the 16:9 box so Drive's desktop UI is not cropped. NEVER on touch devices:
     a 720px viewport makes Drive serve its desktop (hover) player to phones — dark control scrim that
     lingers, tiny scaled controls, and an element-fullscreen button iPhone Safari cannot honour
     (hotfix v8, iPhone report 2026-10-30). Phones get the iframe at its real size → Drive's mobile player. */
  .player-frame.is-scaled iframe { width: 720px; height: 405px; max-width: none; transform: scale(var(--jlpt-embed-scale,1)); transform-origin: 0 0; }
  .player-frame:fullscreen iframe, .player-frame:-webkit-full-screen iframe { width: 100%; height: 100%; transform: none; }
  .player-wrap { position: relative; }
  .player-tools { display: flex; justify-content: flex-end; margin-top: var(--s-2, 8px); }
  .player-tools .fs-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
  .player-frame:fullscreen, .player-frame:-webkit-full-screen { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; background: #000; }

  /* ---------- page header (shared by library screens) ---------- */
  .v8-page { max-width: 980px; margin-inline: auto; }
  .v8-pagehead { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-4);
    padding: var(--s-5); background: linear-gradient(120deg, var(--surface) 30%, var(--accent-soft) 100%);
    border: 1px solid var(--line); border-radius: var(--r-24); box-shadow: var(--shadow-sm); }
  .v8-pagehead .v9-head-copy { flex: 1 1 15rem; min-width: 0; }
  .v8-pagehead h1 { margin: 2px 0 6px; }
  .v8-pagehead p { font-size: 14.5px; line-height: 1.55; color: var(--muted); margin: 0; max-width: 60ch; }
  .v8-pagehead .v9-head-art { flex: none; width: 104px; height: auto; object-fit: contain; }
  .v8-pagehead .v9-doc-wrap { flex: 1 1 100%; display: flex; justify-content: flex-end; }
  @media (max-width: 560px) { .v8-pagehead { padding: var(--s-4); } .v8-pagehead .v9-head-art { display: none; } .v8-pagehead .v9-doc-wrap { justify-content: flex-start; } }
  .v8-detail-nav { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin: 0 0 var(--s-3); }
  .v8-detail-nav > a { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; color: var(--matcha); font-weight: 700; font-size: 14px; }
  .sub { color: var(--muted); margin: 0 0 var(--s-4); max-width: 68ch; }
  .v8-subtitle { font-size: 19px; margin: var(--s-5) 0 var(--s-3); }
  .v8-subtitle span { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 5px; }
  .v8-list-count { display: flex; justify-content: space-between; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 13px; color: var(--muted); min-height: 34px; margin-bottom: 6px; }
  .v8-error { max-width: 680px; margin: 7vh auto 0; background: var(--surface); border: 1px solid var(--line); padding: var(--s-5); border-radius: var(--r-24); }
  .v8-error h1 { font-size: 25px; margin: 8px 0 12px; }
  .v8-error p { color: var(--muted); }
  .v8-action-row { display: flex; align-items: center; gap: var(--s-3) var(--s-4); flex-wrap: wrap; }

  /* ---------- reward effects (practice/results only; never exam room): motion-v9 petals ---------- */
  .v9-petal { position: fixed; width: 12px; height: 9px; border-radius: 80% 15% 65% 20%; z-index: 1500; pointer-events: none; will-change: transform, opacity; }
  .anim-pop { animation: tk-pop 240ms ease-out; }
  @keyframes tk-pop { 40% { transform: scale(1.025); } }
  .anim-shake { animation: tk-shake 300ms ease-out; }
  @keyframes tk-shake { 20%,60% { transform: translateX(-4px); } 40%,80% { transform: translateX(4px); } }

  /* ---------- entrance motion (motion-v9.js marks ≤10 nodes) ---------- */
  .v9-enter .v9-staged { animation: tk-rise-in var(--t-enter) var(--ease) both; animation-delay: var(--v9-delay, 0ms); }
  @keyframes tk-rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  .v9-staged[hidden] { animation: none !important; }
}

/* ============================== SCREENS ============================== */
@layer screens {
  /* ---------- Hôm nay ---------- */
  .home { max-width: 860px; margin-inline: auto; display: flex; flex-direction: column; gap: var(--s-4); }
  .home > * { margin: 0; }
  .home-hero { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); padding: var(--s-5);
    background: linear-gradient(135deg, var(--surface) 35%, var(--accent-soft)); border: 1px solid var(--line); border-radius: var(--r-24); box-shadow: var(--shadow-sm); }
  .home-greet { flex: 1 1 18rem; min-width: 0; display: flex; align-items: flex-start; gap: var(--s-3); }
  .home-mascot { width: 72px; height: 72px; }
  .home-greet h1 { font-size: 23px; margin: 0 0 var(--s-2); }
  .home-greet { position: relative; }
  .home-greet .icon-btn { position: absolute; top: -4px; right: -4px; }
  .home-greet > .grow { padding-right: 48px; }
  @media (max-width: 420px) { .home-hero { padding: var(--s-4); } .home-mascot { width: 56px; height: 56px; } }
  @media (min-width: 861px) { .home-greet h1 { font-size: 30px; } }
  .home-name { color: var(--accent-ink); }
  .home-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .home-ring { flex: none; margin-inline: auto; }
  @media (min-width: 640px) { .home-ring { margin: 0; } }
  .home-levels .level-chips { flex-wrap: nowrap; }
  .home-levels .chip { flex: 1; min-width: 0; padding: 6px 0; }
  @media (min-width: 1024px) { .home-levels { display: none; } }
  .home-next { padding: var(--s-5); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
  .home-next h2 { margin: 2px 0 4px; font-size: 22px; }
  .home-next .mut { margin: 0 0 var(--s-3); font-size: 14px; }
  .home-next .progressbar { margin-bottom: var(--s-4); }
  .home-sec-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
  .home-sec-head h2 { margin: 0; font-size: 19px; flex: 1; min-width: 0; }
  .home-tick { display: inline-flex; align-items: center; gap: var(--s-2); font-size: 13px; color: var(--muted); font-weight: 600; }
  .mission-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
  @media (min-width: 768px) { .mission-list { grid-template-columns: repeat(3,minmax(0,1fr)); } }
  .mission { display: flex; align-items: flex-start; gap: var(--s-3); margin: 0; padding: var(--s-4); font-size: 14.5px; line-height: 1.5; }
  .mission-no { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r-8); background: var(--accent-soft); color: var(--accent-ink); font-weight: 800; font-size: 14px; }
  .mission:nth-child(2) .mission-no { background: var(--coral-soft); color: var(--coral-ink); }
  .mission:nth-child(3) .mission-no { background: var(--honey-soft); color: var(--honey-ink); }
  .mission.done { opacity: .7; }
  .mission.done .mission-no { background: var(--matcha); color: #fff; }
  .home-more { display: inline-flex; align-items: center; gap: 4px; margin-top: var(--s-2); font-size: 14px; font-weight: 700; text-decoration: none; min-height: 40px; }
  .home-missions .tiny { margin: var(--s-2) 0 0; }
  .home-grid { display: grid; gap: var(--s-3); }
  @media (min-width: 768px) { .home-grid { grid-template-columns: minmax(0,1fr) minmax(0,1.4fr); } }
  .home-grid > .card { margin: 0; }
  .home-due { display: flex !important; align-items: center; gap: var(--s-3); }
  .home-due-ic { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: var(--r-14); background: var(--sakura-soft); color: var(--sakura-ink); }
  .home-due b { font-size: 24px; font-variant-numeric: tabular-nums; margin-right: 4px; }
  .home-due small { display: block; font-size: 12.5px; color: var(--muted); }
  .home-path-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s-3); }
  .home-path-head small { color: var(--muted); font-size: 13px; }
  .path-row { display: flex; align-items: center; }
  .path-node { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 800;
    border: 2px solid var(--line-strong); background: var(--surface); color: var(--muted); }
  .path-node.done { background: var(--matcha); border-color: var(--matcha); color: #fff; }
  .path-node.current { border-color: var(--coral); background: var(--coral-soft); color: var(--coral-ink); box-shadow: 0 0 0 4px rgba(249,112,78,.22); }
  .path-link { flex: 1; min-width: 6px; height: 0; border-top: 2px dashed var(--line-strong); }
  .home-empty h2 { margin-top: 0; }

  /* ---------- auth / onboarding ---------- */
  .auth-wrap { max-width: 480px; margin: 0 auto; }
  @media (min-width: 1024px) { .auth-wrap { max-width: 980px; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-6); align-items: center; } }
  .auth-art { display: none; }
  @media (min-width: 1024px) { .auth-art { display: block; width: 100%; max-height: 500px; object-fit: contain; } }
  .auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-24); padding: clamp(18px,4vw,30px); box-shadow: var(--shadow-md); min-width: 0; }
  .auth-card .mascot { margin: 0 auto; }
  .auth-tabs { display: flex; gap: var(--s-2); margin-bottom: var(--s-4); }
  .auth-tabs a { flex: 1; display: grid; place-items: center; padding: 10px; border-radius: var(--r-12); min-height: 44px; color: var(--muted); text-decoration: none; font-weight: 700; background: var(--surface-warm); }
  .auth-tabs a[aria-current="page"] { background: var(--matcha); color: #fff; }
  .ob-wrap { max-width: 640px; margin: 0 auto; text-align: center; padding-top: var(--s-2); }
  .ob-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-24); padding: var(--s-6) var(--s-5); box-shadow: var(--shadow-md); }
  .ob-card .mascot { margin: 0 auto 6px; }
  .ob-title { font-size: 24px; font-weight: 800; margin: 10px 0 var(--s-2); }
  .ob-body { color: var(--muted); max-width: 46ch; margin: 0 auto; }
  .ob-dots { display: flex; gap: 7px; justify-content: center; margin: var(--s-4) 0; }
  .ob-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
  .ob-dots i.on { background: var(--coral); width: 26px; border-radius: 99px; }
  .ob-art { display: none; }
  .mascot-bob { animation: tk-bob 3.6s ease-in-out infinite; }
  @keyframes tk-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

  /* ---------- verify banner ---------- */
  #verifyBanner { background: var(--honey-soft); border-bottom: 1px solid #EBD9A8; color: #5F450A; padding: var(--s-2) var(--s-3); font-size: 13.5px; }
  #verifyBanner .vb-in { max-width: var(--content-max); margin: 0 auto; display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; line-height: 1.45; }
  #verifyBanner .vb-in .grow { flex: 1 1 210px; overflow-wrap: anywhere; }
  #verifyBanner .vb-tako { width: 40px; height: 40px; }
  #verifyBanner input { width: 130px; min-height: 42px; padding: 8px 12px; border: 1.5px solid #D8BE7E; border-radius: var(--r-14); letter-spacing: 3px; text-align: center; background: #fff; }

  /* ---------- roadmap ---------- */
  .v8-progress-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-16); padding: var(--s-4) var(--s-5); margin-bottom: var(--s-4); box-shadow: var(--shadow-sm); }
  .v8-progress-head { display: flex; justify-content: space-between; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 14px; }
  .v8-progress-card .progressbar { margin: var(--s-3) 0 0; }
  .v8-roadmap-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 9px; flex-wrap: wrap; margin: 0 0 var(--s-3); }
  .v8-segments { display: flex; gap: 4px; border: 1px solid var(--line); padding: 3px; border-radius: var(--r-pill); background: var(--surface); }
  .v8-segments button { border: 0; background: none; border-radius: var(--r-pill); padding: 8px 14px; min-height: 40px; color: var(--muted); font-weight: 700; }
  .v8-segments button.active { background: var(--accent); color: #fff; }
  .v8-roadmap-group { border: 1px solid var(--line); border-radius: var(--r-16); background: var(--surface); overflow: hidden; margin-bottom: var(--s-2); box-shadow: var(--shadow-sm); }
  .v8-roadmap-group[open] { border-color: var(--accent); }
  .v8-roadmap-group summary { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); min-height: 64px; cursor: pointer; list-style: none; }
  .v8-roadmap-group summary::-webkit-details-marker { display: none; }
  .v8-roadmap-group summary > svg { flex: none; color: var(--muted); transition: transform var(--t-fast); }
  .v8-roadmap-group[open] summary > svg { transform: rotate(90deg); }
  .v8-group-number { width: 38px; height: 38px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--r-12); font-weight: 800; font-size: 13px; }
  .v8-group-title { display: grid; gap: 2px; flex: 1; min-width: 0; }
  .v8-group-title b { font-size: 15px; }
  .v8-group-title small { font-size: 12.5px; color: var(--muted); }
  .v8-group-days { padding: var(--s-3) var(--s-4) var(--s-4); border-top: 1px solid var(--line); }
  .v8-group-days .progressbar { margin-bottom: var(--s-3); }
  .v8-day-grid { display: flex; gap: var(--s-2); flex-wrap: wrap; }
  .node { width: 46px; height: 46px; border-radius: 50%; border: 2.5px solid var(--line-strong); background: var(--surface); font-weight: 800; font-size: 14.5px;
    display: grid; place-items: center; color: var(--ink); padding: 0; transition: transform var(--t-fast), border-color var(--t-fast); }
  .node:hover { border-color: var(--coral); transform: translateY(-2px); }
  .node.done { background: var(--matcha); border-color: var(--matcha); color: #fff; }
  .node.current { border-color: var(--coral); background: var(--coral-soft); color: var(--coral-ink); box-shadow: 0 0 0 4px rgba(249,112,78,.25); }
  .node.future { color: var(--muted); }
  .v8-day-list { display: grid; gap: var(--s-2); }
  .v8-day-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-14); display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); }
  .v8-day-row > div { flex: 1; min-width: 0; }
  .v8-day-row p { margin: 4px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }

  /* ---------- lessons (catalog + detail + sheet) ---------- */
  .v8-list-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  @media (max-width: 720px) { .v8-list-grid { grid-template-columns: 1fr; } }
  .v8-list-item { min-width: 0; display: flex; align-items: center; gap: var(--s-3); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    padding: var(--s-3) var(--s-4); border-radius: var(--r-16); text-decoration: none; text-align: left; min-height: 76px; box-shadow: var(--shadow-sm);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast); }
  .v8-list-item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
  .v8-list-item[hidden] { display: none !important; }
  .v8-list-index { width: 34px; height: 34px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--r-12); flex: none; font-size: 12px; font-weight: 800; }
  .v9-skill-thumb { width: 49px; height: 40px; object-fit: contain; flex: none; border-radius: var(--r-8); background: var(--surface-2); }
  @media (max-width: 380px) { .v9-skill-thumb { display: none; } }
  .v8-list-body { display: grid; gap: 4px; flex: 1; min-width: 0; }
  .v8-list-body strong { font-size: 14.5px; line-height: 1.42; overflow-wrap: anywhere; }
  .v8-list-body small { font-size: 12.5px; color: var(--muted); line-height: 1.4; overflow-wrap: anywhere; }
  .v8-list-item > svg { flex: none; color: var(--muted); }
  .v8-tiny-progress { background: var(--surface-warm); border-radius: 50px; height: 4px; overflow: hidden; }
  .v8-tiny-progress i { height: 100%; display: block; background: var(--accent); }
  .learning-catalog-context, .learning-card-desc { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
  .learning-card-desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
  .playlist .item { flex-wrap: wrap; row-gap: 6px; text-align: left; width: 100%; }
  .playlist .item .grow { flex: 1 1 11rem; min-width: 0; overflow-wrap: anywhere; }
  .playlist .item.active { border-color: var(--accent); background: var(--accent-soft); }
  .playlist .item [data-watch], .playlist .item [data-preview] { flex: none; margin-left: auto; }
  .lesson-skill-head { margin: var(--s-5) 0 10px; font-size: 19px; }
  .lesson-skill-head .mut { font-weight: 600; }
  .learning-context { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
  .learning-objective { margin: var(--s-2) 0 var(--s-3); max-width: 72ch; }
  .learning-overview { border: 1px solid var(--line); border-radius: var(--r-16); padding: var(--s-4); margin: var(--s-4) 0 var(--s-5); background: var(--surface); box-shadow: var(--shadow-sm); }
  .learning-overview-top { display: flex; justify-content: space-between; gap: var(--s-3); align-items: center; font-size: 14px; margin-bottom: 10px; }
  .learning-meter { width: 100%; height: 9px; border-radius: 999px; background: var(--surface-warm); overflow: hidden; }
  .learning-meter span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .2s ease; }
  .learning-jump { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-4); }
  .learning-jump a { display: inline-flex; align-items: center; padding: 8px 12px; min-height: 40px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; font-size: 13px; font-weight: 650; }
  .learning-section { margin: var(--s-5) 0; scroll-margin-top: var(--s-5); }
  .learning-section-heading { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-3); padding-top: 3px; }
  .learning-section .lesson-skill-head { margin: 0; }
  .learning-goal { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
  .learning-count { flex: none; color: var(--muted); font-size: 12px; padding: 6px 10px; border-radius: 999px; background: var(--surface-warm); }
  .learning-section-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
  .learning-toggle { border: 1px solid var(--line-strong); background: var(--surface); padding: 8px 12px; min-height: 40px; border-radius: var(--r-12); font-size: 12.5px; }
  .learning-section-body[hidden] { display: none !important; }
  .learning-detail-layout { display: grid; grid-template-columns: minmax(0,1fr); align-items: start; gap: var(--s-5); margin-top: var(--s-3); }
  .learning-stage-column, .learning-sections-column { min-width: 0; }
  .learning-stage-column .card { max-width: 100%; }
  @media (min-width: 1180px) {
    .learning-detail-layout { grid-template-columns: minmax(0,1.12fr) minmax(0,.88fr); }
    .learning-stage-column { position: sticky; top: 18px; }
    .learning-sections-column .learning-section:first-child { margin-top: 0; }
  }
  .learning-play-target { display: flex; flex: 1 1 14rem; min-width: 0; align-items: center; gap: var(--s-3); padding: 4px 0; background: transparent; border: 0; text-align: left; }
  .learning-play-target .grow { display: block; flex: 1 1 auto; min-width: 0; }
  .learning-play-target strong { display: block; line-height: 1.45; overflow-wrap: anywhere; }
  .learning-play-target .mut { display: block; margin-top: 3px; }
  .learning-video-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: var(--s-3) 0; }
  .learning-video-nav button { min-height: 44px; padding: 8px 12px; border-radius: var(--r-12); border: 1px solid var(--line-strong); background: var(--surface); color: var(--matcha); font-size: 13.5px; font-weight: 700; }
  .learning-video-nav button:disabled { opacity: .45; cursor: default; }
  .learning-video-nav span { text-align: center; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
  .learning-transcript { margin: var(--s-3) 0; border: 1px solid var(--line-strong); border-radius: var(--r-12); padding: 10px 12px; }
  .learning-transcript summary { cursor: pointer; min-height: 32px; font-weight: 700; font-size: 13.5px; }
  .learning-transcript-note { font-size: 12.5px; color: var(--muted); margin: var(--s-2) 0; }
  .learning-transcript-body { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; padding: var(--s-3); margin: 0; border-radius: var(--r-8); background: var(--surface-2); font-size: 14px; }
  .learning-transcript-body:not([lang]) { font-family: inherit; }
  .transcript-panel { margin-top: var(--s-2); width: 100%; }
  .transcript-head { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-bottom: var(--s-2); }
  .transcript-body { background: var(--surface-2); border-radius: var(--r-12); padding: var(--s-3); max-height: 340px; overflow: auto; }
  .learning-no-video { padding: var(--s-4); }
  .learning-item-objective { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 12.5px; }
  .learning-status-live { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  @media (max-width: 600px) {
    .learning-section-actions { width: 100%; justify-content: space-between; }
    .learning-overview { padding: var(--s-3); }
  }
  .lesson-sheet { max-width: 520px; background: var(--canvas); overscroll-behavior: contain; animation: tk-sheet-in 220ms var(--ease); }
  .lesson-sheet h2 { margin: 0 52px 8px 0; overflow-wrap: anywhere; }
  .lesson-sheet-close { position: absolute; top: 14px; right: 14px; min-width: 40px; min-height: 40px; }
  .lesson-sheet-desc { font-size: 13.5px; color: var(--ink); margin: 0 30px 10px 0; overflow-wrap: anywhere; }
  .lesson-sheet-meta { font-size: 12.5px; color: var(--muted); margin: 0 0 var(--s-3); }
  .lesson-sheet-overview { margin: 0 0 var(--s-3); padding: var(--s-3); }
  .lesson-sheet-s3 { display: flex; align-items: center; gap: 10px; width: 100%; background: var(--surface); border: 1.5px solid var(--matcha); color: var(--matcha-deep); font-weight: 750; font-size: 14px; border-radius: var(--r-14); padding: 12px 14px; margin: 0 0 10px; text-decoration: none; }
  .lesson-sheet-s3 .grow { flex: 1; }
  @media (max-width: 540px) { .lesson-sheet-s3 .mut { display: none; } }
  .lesson-sheet-stage { margin: 6px 0 10px; }
  .lesson-sheet-stage-title { display: block; font-size: 16px; line-height: 1.45; margin-bottom: 10px; overflow-wrap: anywhere; }
  .lesson-sheet-stage-hint { margin: 6px 2px; }
  .lesson-sheet-cats { border-bottom: 1px solid var(--line); }
  .lesson-cat { border-top: 1px solid var(--line); }
  .lesson-cat-row { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 14px 2px; text-align: left; min-height: 52px; }
  .lesson-cat-row .grow { flex: 1; min-width: 0; }
  .lesson-cat-name { font-weight: 750; font-size: 15.5px; display: block; }
  .lesson-cat-goal { display: block; font-weight: 500; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
  .lesson-cat-chev { color: var(--muted); font-size: 20px; line-height: 1; transition: transform var(--t-fast); flex: none; }
  .lesson-cat.open .lesson-cat-chev { transform: rotate(90deg); }
  .lesson-cat-body { padding: 2px 0 var(--s-3); }
  .lesson-cat-body[hidden] { display: none !important; }
  .lesson-gallery-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-2); }
  .lesson-sheet-continue { display: flex; width: 100%; margin-top: var(--s-3); }

  /* ---------- listening ---------- */
  .v8-audio-empty, .v8-audio-player { display: flex; align-items: center; gap: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-16); background: var(--surface); padding: var(--s-4); margin: 0 0 var(--s-4); box-shadow: var(--shadow-sm); }
  .v8-audio-empty > svg { color: var(--accent); flex: none; }
  .v8-audio-empty span { display: grid; gap: 4px; }
  .v8-audio-empty small { color: var(--muted); font-size: 13px; }
  .v8-audio-player { display: block; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border-color: var(--accent); }
  .v8-audio-player h2 { font-size: 20px; margin: var(--s-2) 0 var(--s-3); overflow-wrap: anywhere; }
  .v8-audio-player audio { display: block; width: 100%; margin-bottom: var(--s-2); }
  .v8-audio-player[hidden], .v8-audio-empty[hidden], .v8-empty-inline[hidden] { display: none !important; }
  .v8-audio-list { display: grid; gap: var(--s-2); }
  .v8-audio-item { width: 100%; }
  .v8-audio-item.selected { border-color: var(--accent); background: var(--accent-soft); }

  /* ---------- flashcards: 3D flip ---------- */
  .fc-stage { perspective: 1200px; max-width: 560px; margin: 0 auto; min-width: 0; }
  .fc-card { position: relative; width: 100%; max-width: min(100%,570px); margin-inline: auto; min-height: 320px; cursor: pointer; transform-style: preserve-3d; transition: transform 450ms var(--ease); }
  .fc-card.flipped { transform: rotateY(180deg); }
  .fc-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: var(--r-24); }
  .fc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-24); box-shadow: var(--shadow-md); padding: var(--s-5); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-3); text-align: center; overflow-y: auto; }
  .fc-front { background: linear-gradient(150deg, var(--surface) 40%, var(--accent-soft)); border-bottom: 4px solid color-mix(in srgb, var(--accent) 40%, var(--line)); }
  .fc-face.fc-back { transform: rotateY(180deg); justify-content: flex-start; padding-top: var(--s-6); }
  .fc-word { font-size: 46px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
  .fc-word.sm-word { font-size: 30px; }
  .fc-reading { font-size: 21px; color: var(--accent-ink); font-weight: 700; }
  .fc-back-meaning { font-size: 19px; line-height: 1.6; overflow-wrap: anywhere; }
  .fc-example { background: var(--surface-warm); border-radius: var(--r-16); padding: var(--s-3) var(--s-4); font-size: 16.5px; overflow-wrap: anywhere; max-width: 100%; }
  .grade-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: var(--s-2); max-width: 560px; margin: 0 auto; }
  .grade-btn { min-height: 52px; padding: 10px 6px; font-size: 15px; }
  @media (max-width: 430px) { .grade-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .fc-word { font-size: 38px; } }
  #fcGrades[hidden], #fcFlip[hidden] { display: none !important; }
  .deck-item .grow b { overflow-wrap: anywhere; }
  .deck-item .btn { flex: none; }

  /* ---------- exams ---------- */
  .v8-exam-information { display: flex; align-items: flex-start; gap: 9px; padding: var(--s-3) var(--s-4); background: var(--mint); border: 1px solid #C6E5D2; border-radius: var(--r-12); color: var(--mint-ink); font-size: 13.5px; margin-bottom: var(--s-5); }
  .v8-exam-information > svg { flex: none; margin-top: 2px; }
  .v8-exam-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--s-3); }
  @media (max-width: 740px) { .v8-exam-grid { grid-template-columns: 1fr; } }
  .v8-exam-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: var(--s-4) var(--s-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-16); min-width: 0; box-shadow: var(--shadow-sm); }
  .v8-exam-card:hover { border-color: var(--accent); }
  .v8-exam-card[hidden] { display: none !important; }
  .v8-exam-head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; padding-right: 56px; min-height: 40px; }
  .v8-exam-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-12); background: var(--accent-soft); color: var(--accent-ink); }
  .v9-exam-scene { position: absolute; right: var(--s-4); top: var(--s-3); width: 49px; height: 40px; object-fit: contain; opacity: .8; }
  .v8-exam-card h3 { font-size: 17px; overflow-wrap: anywhere; }
  .v8-exam-meta { display: flex; flex-wrap: wrap; gap: 6px var(--s-4); font-size: 12.5px; color: var(--muted); }
  .v8-exam-meta span { display: flex; align-items: center; gap: 5px; }
  .v8-exam-note { font-size: 13px; color: #6E541C; background: var(--honey-soft); border-radius: var(--r-8); padding: var(--s-2) var(--s-3); margin: 0; }
  .v8-exam-last { font-size: 13px; color: var(--matcha); margin: 0; }
  .v8-exam-card > .btn { margin-top: auto; align-self: flex-start; }
  .mode-cards { display: grid; gap: var(--s-3); }
  @media (min-width: 768px) { .mode-cards { grid-template-columns: 1fr 1fr; } }
  .mode-card { border: 2px solid var(--line); border-radius: var(--r-24); padding: var(--s-5); background: var(--surface); min-height: 170px; }
  .mode-card.practice { border-color: #BFE0CC; background: linear-gradient(180deg, var(--surface), var(--mint)); }
  .mode-card.exam { border-color: #F6C6B4; background: linear-gradient(180deg, var(--surface), var(--coral-soft)); }
  .mode-card h3 { display: flex; gap: 9px; align-items: center; margin-bottom: 6px; }
  /* exam room — calm: no motion, no mascot, compact sticky header */
  .exam-head { position: sticky; top: 0; z-index: 60; background: rgba(254,248,239,.97); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
    margin: calc(var(--s-4) * -1) calc(var(--s-4) * -1) var(--s-4); padding: var(--s-3) var(--s-4) 10px; }
  @media (min-width: 768px) { .exam-head { margin: calc(var(--s-5) * -1) calc(var(--s-5) * -1) var(--s-5); padding: 14px var(--s-5) 12px; } }
  @media (min-width: 1024px) { .exam-head { margin: calc(var(--s-6) * -1) calc(var(--s-7) * -1) var(--s-5); padding: 14px var(--s-7) 12px; } }
  .exam-head .ttl { font-weight: 800; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 17px; }
  .timer.low { color: var(--danger); }
  .mode-chip { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: var(--r-pill); }
  .mode-chip.practice { background: var(--mint); color: var(--matcha-deep); }
  .mode-chip.exam { background: var(--coral-soft); color: var(--coral-ink); }
  .index-panel { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-16); padding: var(--s-3); box-shadow: var(--shadow-md); max-height: 46vh; overflow-y: auto; }
  .grid-nav { display: grid; grid-template-columns: repeat(auto-fill,minmax(44px,1fr)); gap: 6px; }
  .grid-nav button { height: 44px; border-radius: var(--r-12); border: 1.5px solid var(--line-strong); background: var(--surface); font-weight: 700; font-size: 14px; padding: 0; position: relative; }
  .grid-nav button.answered { background: var(--matcha); border-color: var(--matcha); color: #fff; }
  .grid-nav button.flg::after { content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--honey); border: 1.5px solid #fff; }
  .grid-nav button.now { box-shadow: 0 0 0 3px rgba(23,92,150,.55); }
  .index-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
  .index-legend i { width: 11px; height: 11px; border-radius: 4px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
  .sectitle { display: flex; align-items: baseline; gap: 10px; margin: var(--s-5) 0 var(--s-3); }
  .qcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-24); padding: var(--s-5); margin-bottom: var(--s-4); box-shadow: var(--shadow-sm); scroll-margin-top: 150px; }
  @media (max-width: 560px) { .qcard { padding: var(--s-4); border-radius: var(--r-16); } }
  .qcard.cur { border-color: var(--coral); }
  .qhead { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: var(--s-3); }
  .qno { font-weight: 800; font-size: 16.5px; }
  .flagbtn { margin-left: auto; width: 44px; height: 44px; border-radius: var(--r-12); border: 1.5px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; color: var(--muted); padding: 0; }
  .flagbtn.on { background: var(--honey-soft); border-color: var(--honey); color: var(--honey-ink); }
  .passage { background: var(--surface-warm); border-radius: var(--r-16); padding: var(--s-4); margin-bottom: var(--s-3); font-size: 18px; line-height: 1.95; white-space: pre-wrap; overflow-wrap: anywhere; }
  .prompt { font-size: 19px; line-height: 1.85; margin: 10px 0 var(--s-3); overflow-wrap: anywhere; }
  .prompt u { text-decoration-thickness: 2px; text-underline-offset: 4px; }
  .qcard audio { width: 100%; margin: 6px 0 var(--s-3); height: 44px; }
  /* V12 (ported from the production audio rollout): shared Mondai audio
     groups — one sticky player per shared file in the exam room, so the
     player stays visible only while scrolling its own group; per-question
     segment buttons seek it to the question's slice. In the review list
     the same bar is static (.review-bar). */
  .audio-group { margin-bottom: 4px; }
  .audio-group-bar { position: sticky; top: 128px; z-index: 40; margin-bottom: var(--s-4);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-16);
    padding: 10px 12px; box-shadow: var(--shadow-md); }
  @media (min-width: 768px) { .audio-group-bar { top: 136px; } }
  .audio-group-bar audio { width: 100%; height: 44px; display: block; }
  .audio-group-bar.review-bar { position: static; }
  .audio-group-cap { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
  .qcard.qcard-ingroup { scroll-margin-top: 248px; }
  .seg-row { margin: 2px 0 var(--s-3); }
  .seg-btn { gap: 7px; }
  .seg-range { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 600; }
  .qimg { max-width: 100%; border-radius: var(--r-12); border: 1px solid var(--line); }
  .opts { display: flex; flex-direction: column; gap: 9px; }
  .opt { display: flex; align-items: center; gap: var(--s-3); text-align: left; width: 100%; min-height: 56px; padding: var(--s-3) var(--s-4); border: 2px solid var(--line); border-radius: var(--r-16);
    background: var(--surface); font-size: 17px; line-height: 1.6; color: var(--ink); transition: border-color var(--t-fast), background var(--t-fast); }
  .opt:hover { border-color: var(--matcha); }
  .opt .k { flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-warm); display: grid; place-items: center; font-weight: 800; font-size: 14.5px; color: var(--muted); font-family: var(--font); }
  .opt.sel { border-color: var(--matcha); background: var(--mint); }
  .opt.sel .k { background: var(--matcha); color: #fff; }
  .opt.right { border-color: var(--matcha); background: var(--mint); }
  .opt.right .k { background: var(--matcha); color: #fff; }
  .opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
  .opt.wrong .k { background: var(--danger); color: #fff; }
  div.opt { cursor: default; }
  div.opt:hover { border-color: var(--line); }
  div.opt.right:hover { border-color: var(--matcha); }
  div.opt.wrong:hover { border-color: var(--danger); }
  .feedback { margin-top: var(--s-3); font-size: 15px; }
  .feedback:empty { display: none; }
  .fb-ok { color: var(--matcha); font-weight: 700; }
  .fb-ng { color: var(--danger); font-weight: 600; }
  .exam-foot { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 50; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-16); box-shadow: var(--shadow-md); padding: var(--s-3); display: flex; gap: var(--s-2); align-items: center; }
  body.exam-mode .exam-foot { bottom: max(12px, env(safe-area-inset-bottom)); }
  @media (min-width: 1024px) { .exam-foot { bottom: var(--s-4); } }
  .exam-foot .btn { flex: 1; min-width: 0; padding-inline: var(--s-2); white-space: nowrap; gap: 4px; }
  @media (max-width: 400px) { .exam-foot { gap: 6px; padding: 10px; } .exam-foot .btn { font-size: 14px; } }
  .scorebig { font-size: 54px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
  .result-mascot { display: flex; justify-content: center; margin-bottom: 4px; }
  .result-mascot .mascot { margin: 0 auto; }
  .weak-row { align-items: flex-start; }
  .weak-row .tag { flex: none; min-width: 86px; justify-content: center; margin-top: 1px; }
  .weak-row > span:last-child { min-width: 0; overflow-wrap: anywhere; }
  .v9-milestone-art { display: block; margin: 2px auto 10px; width: min(220px,70%); height: auto; }
  /* coach marks (exam room, first visit) — no mascot in the exam room */
  .coach-layer { position: fixed; inset: 0; z-index: 140; background: rgba(31,41,55,.45); }
  .coach-spot { position: fixed; border: 3px solid var(--honey); border-radius: var(--r-14); pointer-events: none; background: rgba(255,201,77,.14); }
  .coach-card { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--s-4) + env(safe-area-inset-bottom)); z-index: 141; width: min(520px, calc(100vw - 28px));
    background: var(--surface); border-radius: var(--r-24); padding: var(--s-4); display: flex; gap: var(--s-3); box-shadow: var(--shadow-lg); }

  /* ---------- profile / admin ---------- */
  .hello { display: flex; gap: var(--s-4); align-items: center; margin-bottom: var(--s-4); }
  .hello .bubble { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-24); border-bottom-left-radius: var(--r-8); padding: var(--s-3) var(--s-4); box-shadow: var(--shadow-sm); font-size: 15.5px; min-width: 0; }
  .level-card { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
  .level-card > .grow { flex: 1 1 12rem; }
  .acct-row .grow { flex: 1 1 12rem; min-width: 0; }
  .acct-row .tag, .acct-row .avatar { flex: none; }
  .badge-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--s-3); }
  @media (min-width: 768px) { .badge-grid { grid-template-columns: repeat(4,minmax(0,1fr)); } }
  .badge-cell { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px; background: var(--surface-warm); border: 1px solid var(--line); border-radius: var(--r-16); padding: var(--s-4) 10px 14px; }
  .badge-cell:nth-child(4n+2) { background: var(--mint); }
  .badge-cell:nth-child(4n+3) { background: var(--sakura-soft); }
  .badge-cell:nth-child(4n+4) { background: var(--honey-soft); }
  .badge-cell img { width: 76px; height: 76px; object-fit: contain; border-radius: 50%; background: var(--surface-2); }
  .badge-cell.locked img { filter: grayscale(.85); opacity: .55; }
  .badge-cell b { font-size: 14.5px; line-height: 1.35; }
  .more-list { margin-top: 10px; }
  .subhead { font-size: 16px; margin: var(--s-4) 0 10px; }
  .utable-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-16); background: var(--surface); max-width: 100%; }
  .utable { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 760px; }
  .utable th, .utable td { padding: var(--s-3) 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .utable th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-warm); }
}

/* ============================== UTILITIES ============================== */
@layer utilities {
  .row { display: flex; align-items: center; gap: var(--s-3); }
  .wrap { flex-wrap: wrap; }
  .grow { flex: 1; min-width: 0; }
  .mut { color: var(--muted); }
  .sm { font-size: 14px; line-height: 1.5; }
  .tiny { font-size: 12px; line-height: 1.5; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

  /* exam room: no animation at all */
  body.exam-mode *, body.exam-mode *::before, body.exam-mode *::after { animation: none !important; transition: none !important; }

  /* prefers-reduced-motion: every animation & transition off */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
    .v9-petal { display: none !important; }
    .btn:active:not(:disabled), .icon-btn:active, .chip:active:not(:disabled), .check:active { transform: none; }
    /* the flashcard keeps flipping (state change), just without the 3D animation */
  }
  @media print {
    #tabBar, .side, .v9-petal { display: none !important; }
    .card, .v8-pagehead, .item { box-shadow: none; }
  }
}

/* ==========================================================================
   Redesign Phase 2 — per-screen "Học cùng Tako" (2026-10-29)
   Appended layers re-open the existing ones, so the cascade order above is
   unchanged. No rule here relies on inline style="" from the SPA: dynamic
   widths/sizes come from data-w / data-size (ui.js applyDynStyles).
   ========================================================================== */
@layer components {
  /* in-page segmented tabs (ui.js uiTabList / bindTabList) */
  .tk-seg { display: flex; gap: 4px; padding: 4px; margin: 0 0 var(--s-4); background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-pill); overflow-x: auto; scrollbar-width: none; box-shadow: var(--shadow-sm); }
  .tk-seg::-webkit-scrollbar { display: none; }
  .tk-seg-tab { flex: 1 0 auto; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px var(--s-4);
    border: 0; border-radius: var(--r-pill); background: none; color: var(--muted); font-weight: 750; font-size: 14.5px; white-space: nowrap; }
  .tk-seg-tab:hover { color: var(--ink); background: var(--surface-warm); }
  .tk-seg-tab.on { background: var(--accent); color: #fff; box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 60%, #000); }
  .tk-seg-count { font-size: 12px; font-weight: 800; padding: 1px 7px; border-radius: var(--r-pill); background: var(--surface-warm); color: var(--ink); }
  .tk-seg-tab.on .tk-seg-count { background: rgba(255,255,255,.25); color: #fff; }
  .lt-panel:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: var(--r-16); }
  /* skeleton bar widths (was inline style) */
  .skel .bar.w55 { width: 55%; } .skel .bar.w92 { width: 92%; } .skel .bar.w78 { width: 78%; }
  .progressbar.thin { height: 6px; min-width: 0; display: block; margin-top: 6px; }
  .account-name { line-height: 1.3; }
  .account-actions { margin-top: 10px; }
  /* furigana */
  ruby rt { font-size: .5em; color: var(--accent-ink); font-weight: 600; letter-spacing: .02em; }
}

@layer screens {
  /* ---------- Hành trình: winding path ---------- */
  .journey-head .journey-ring { flex: none; }
  .journey-legend { display: flex; flex-wrap: wrap; gap: 6px var(--s-4); margin-top: var(--s-3); font-size: 12.5px; color: var(--muted); font-weight: 600; }
  .journey-legend span { display: inline-flex; align-items: center; gap: 6px; }
  .journey-legend i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); }
  .journey-legend .lg-done { background: var(--matcha); border-color: var(--matcha); }
  .journey-legend .lg-cur { background: var(--coral-soft); border-color: var(--coral); }
  .v8-group-title .tag { margin-left: 4px; vertical-align: 1px; }
  .wind { position: relative; padding: var(--s-2) 0; }
  .wind-road { position: absolute; left: 0; top: var(--s-2); width: 100%; height: calc(100% - var(--s-4)); overflow: visible; pointer-events: none; }
  .wind-road path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
  .wind-road-bg { stroke: var(--line-strong); stroke-width: 10; stroke-dasharray: 1 16; }
  .wind-road-done { stroke: color-mix(in srgb, var(--matcha) 55%, #fff); stroke-width: 10; }
  .wind-list { position: relative; list-style: none; margin: 0; padding: 0; }
  .wind-row { height: 76px; display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); align-items: center; justify-items: center; }
  .wind-node { width: 58px; height: 58px; font-size: 16px; box-shadow: 0 4px 0 var(--line-strong); grid-row: 1; }
  .wind-node.done { box-shadow: 0 4px 0 var(--matcha-edge); }
  .wind-node.current { width: 64px; height: 64px; box-shadow: 0 4px 0 var(--coral-ink), 0 0 0 6px rgba(249,112,78,.22); font-size: 18px; }
  .wind-node:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line-strong); }
  .wind-c1 { grid-column: 1; } .wind-c2 { grid-column: 2; } .wind-c3 { grid-column: 3; } .wind-c4 { grid-column: 4; } .wind-c5 { grid-column: 5; }
  .wind-tako { grid-row: 1; width: 56px; height: 56px; pointer-events: none; animation: tk-bob 3.6s ease-in-out infinite; }
  .wind-tako-l { justify-self: end; transform: scaleX(-1); }
  .wind-tako-r { justify-self: start; }
  .v8-group-days { padding: var(--s-2) var(--s-3) var(--s-4); }
  .v8-day-row.is-today { border-color: var(--coral); }
  /* day bottom sheet */
  .day-sheet .dlg-head { align-items: center; }
  .day-sheet-tako { width: 48px; height: 48px; }
  .day-sheet-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--s-4); }
  .day-tasks { list-style: none; padding: 0; display: grid; gap: var(--s-2); }
  .day-tasks li { display: flex; gap: var(--s-3); align-items: flex-start; margin: 0; padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-16); background: var(--surface-2); }
  .day-tasks li:nth-child(3n+2) .mission-no { background: var(--coral-soft); color: var(--coral-ink); }
  .day-tasks li:nth-child(3n+3) .mission-no { background: var(--honey-soft); color: var(--honey-ink); }
  .day-sheet-foot { display: flex; align-items: center; gap: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line); }

  /* ---------- Học: lesson card grid ---------- */
  .lesson-grid { grid-template-columns: 1fr; gap: var(--s-3); }
  @media (min-width: 640px) { .lesson-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
  @media (min-width: 1180px) { .lesson-grid { grid-template-columns: repeat(3,minmax(0,1fr)); } }
  .lesson-card { position: relative; flex-direction: column; align-items: stretch; gap: var(--s-3); padding: var(--s-4); border-radius: var(--r-24); min-height: 0;
    box-shadow: 0 3px 0 var(--line), var(--shadow-sm); }
  .lesson-card:hover { transform: translateY(-2px); }
  .lesson-card:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--line); }
  .lesson-card-top { display: flex; align-items: center; gap: var(--s-2); }
  .lesson-card-top .tag { margin-left: auto; }
  .lesson-card .v9-skill-thumb { width: 56px; height: 46px; display: block; background: var(--accent-soft); padding: 4px; border-radius: var(--r-12); }
  .lesson-card .v8-list-body strong { font-size: 16px; }
  .lesson-card .v8-tiny-progress { height: 8px; margin-top: 4px; }
  .lesson-card-go { position: absolute; right: var(--s-4); bottom: var(--s-4); color: var(--muted); display: none; }
  .lesson-card.is-done { background: linear-gradient(160deg, var(--surface) 55%, var(--mint)); }
  .lesson-card.is-doing { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

  /* ---------- lesson detail ---------- */
  .lesson-hero { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; padding: var(--s-5); margin-bottom: var(--s-4);
    background: linear-gradient(135deg, var(--surface) 40%, var(--accent-soft)); border: 1px solid var(--line); border-radius: var(--r-24); box-shadow: var(--shadow-sm); }
  .lesson-hero-copy { flex: 1 1 18rem; min-width: 0; }
  .lesson-hero h1 { margin: 2px 0 6px; }
  .lesson-hero .sub { margin: 0; }
  .lesson-hero-ring { flex: none; }
  @media (max-width: 560px) { .lesson-hero { padding: var(--s-4); } }
  .stage-card { max-width: var(--lesson-max); }
  .stage-title { display: block; font-size: 17px; line-height: 1.45; margin-bottom: 10px; overflow-wrap: anywhere; }
  .stage-bar { margin-bottom: 12px; }
  .stage-note { margin: 12px 0 0; }
  .learning-no-video { display: flex; align-items: center; gap: var(--s-3); }
  .lt-sub { font-size: 18px; margin: var(--s-5) 0 var(--s-3); }
  .lt-goto-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
  .lt-goto { width: 100%; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); min-height: 60px; text-align: left;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-16); box-shadow: var(--shadow-sm); color: var(--ink); }
  .lt-goto:hover { border-color: var(--accent); }
  .lt-goto b { display: block; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
  .lt-goto small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
  .lt-goto-ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--r-12); background: var(--accent-soft); color: var(--accent-ink); }
  .lt-goto > svg { flex: none; color: var(--muted); }
  .vocab-deck { padding: var(--s-5); }
  .vocab-deck-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-3); }
  .vocab-deck-head h2 { margin: 2px 0; font-size: 19px; }
  .vocab-deck-head .mut { margin: 0; }
  .vocab-list { list-style: none; margin: var(--s-2) 0 0; padding: 0; display: grid; gap: var(--s-2); }
  @media (min-width: 768px) { .vocab-list { grid-template-columns: repeat(2,minmax(0,1fr)); } }
  .vocab-row { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; column-gap: var(--s-4); row-gap: 2px; padding: var(--s-3) var(--s-4);
    border: 1px solid var(--line); border-radius: var(--r-16); background: var(--surface-2); }
  .vocab-word { grid-row: span 2; font-size: 30px; font-weight: 700; line-height: 1.5; min-width: 2.2em; text-align: center; }
  .vocab-word rt { font-size: 13px; }
  .vocab-mean { font-size: 15.5px; font-weight: 650; overflow-wrap: anywhere; }
  .vocab-ex { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }

  /* lesson sheet now rides on .dlg (ui.js openDialog, variant "sheet") */
  .dlg.lesson-sheet { max-width: 560px; background: var(--canvas); overscroll-behavior: contain; }
  .dlg.lesson-sheet .lesson-sheet-close { top: 18px; }
}

@layer screens {
  /* ---------- Luyện nghe: player card ---------- */
  .v8-audio-empty .mascot { width: 64px; height: 64px; }
  .listen-card { padding: var(--s-5); border-radius: var(--r-24); background: linear-gradient(150deg, var(--accent-soft), var(--surface) 70%); box-shadow: var(--shadow-md); }
  .listen-top { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
  .listen-top h2 { margin: 2px 0 0; font-size: 20px; overflow-wrap: anywhere; }
  .listen-top .eyebrow { margin: 0; }
  .listen-disc { width: 64px; height: 64px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff;
    box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, #000), inset 0 0 0 6px rgba(255,255,255,.18); }
  .listen-card audio { width: 100%; height: 48px; margin: 0 0 var(--s-3); }
  .listen-controls { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); flex-wrap: wrap; }
  .listen-rate { display: flex; gap: 4px; }
  .listen-rate .chip { min-height: 40px; padding: 6px 12px; font-size: 13.5px; }
  .listen-ts { margin-top: var(--s-3); }
  .listen-play { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); }
  .v8-audio-item.selected .listen-play { background: var(--accent); color: #fff; }
  .mt-8 { margin: 8px 0 0; }

  /* ---------- Thẻ nhớ ---------- */
  .fc-today { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; background: linear-gradient(135deg, var(--surface) 40%, var(--sakura-soft)); }
  .fc-today .grow { flex: 1 1 14rem; font-size: 16px; font-weight: 650; }
  .fc-today-n { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; margin-right: 4px; color: var(--sakura-ink); }
  .fc-today p { margin: 2px 0 0; font-weight: 400; }
  .stat-grid-gap { margin-bottom: var(--s-4); }
  .deck-grid { display: grid; gap: var(--s-3); }
  @media (min-width: 900px) { .deck-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
  .deck-item { border-radius: var(--r-24); padding: var(--s-4); align-items: flex-start; }
  .deck-item.has-due { border-color: color-mix(in srgb, var(--coral) 45%, var(--line)); }
  .deck-tags { gap: 6px; margin-top: 6px; }
  .deck-item .progressbar { margin-top: 10px; }
  .center-card { text-align: center; }
  .center-card h2 { margin: 0 0 6px; }
  .center-card p { margin: 0 auto 14px; max-width: 46ch; }
  .center-row { justify-content: center; margin-top: var(--s-4); flex-wrap: wrap; }
  .back-line { margin-bottom: 6px; }
  .fc-review { max-width: 620px; margin: 0 auto; }
  .fc-topbar { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
  .fc-progress { height: 14px; }
  .fc-progress > i { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--honey))); }
  .fc-count { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
  .fc-title { font-size: 22px; margin: 0 0 2px; }
  .fc-hint { margin: 0 0 var(--s-3); }
  .fc-card { min-height: 360px; }
  @media (min-width: 768px) { .fc-card { min-height: 400px; } }
  .fc-word { font-size: 64px; }
  .fc-word.sm-word { font-size: 38px; }
  .fc-word rt { font-size: 15px; }
  @media (max-width: 430px) { .fc-word { font-size: 52px; } }
  #fcGrades { margin-top: var(--s-4); }
  #fcFlip { margin-top: var(--s-4); }
  .grade-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 72px; padding: 10px 6px;
    border: 2px solid transparent; border-radius: var(--r-16); font-size: 16px; color: var(--ink); box-shadow: 0 3px 0 var(--edge, var(--line-strong));
    transition: transform var(--t-press), box-shadow var(--t-press); }
  .grade-btn b { font-size: 16.5px; }
  .grade-btn small { font-size: 12px; color: inherit; opacity: .8; font-weight: 600; }
  .grade-btn kbd { position: absolute; top: 6px; right: 8px; font: 700 11px var(--font); opacity: .55; }
  .grade-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge, var(--line-strong)); }
  .grade-btn:disabled { opacity: .6; cursor: wait; }
  .grade-btn.is-saving { opacity: 1; outline: 3px solid var(--focus); outline-offset: 2px; }
  .g-forgot { background: var(--danger-soft); border-color: #F0C4CB; color: #6E2430; --edge: #E3A9B2; }
  .g-hard { background: var(--honey-soft); border-color: #F3DDA0; color: var(--honey-ink); --edge: #E6C46F; }
  .g-good { background: var(--mint); border-color: #BFE0CC; color: var(--matcha-deep); --edge: #94CBA9; }
  .g-easy { background: #E6EEFB; border-color: #C5D5F2; color: #2D4C86; --edge: #A3BBE6; }
  .fc-foot { text-align: center; margin: var(--s-4) 0 0; }
  .fc-done { padding: var(--s-6) var(--s-5); background: linear-gradient(180deg, var(--surface) 50%, var(--sakura-soft)); }
  .fc-done .mascot { margin: 0 auto -8px; }
  .fc-done-title { font-size: 28px; margin: 6px 0; }
  .fc-done .v9-milestone-art { width: min(180px,55%); }
  .fc-tally { list-style: none; padding: 0; margin: var(--s-4) auto 0; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: var(--s-2); max-width: 420px; }
  .fc-tally li { border-radius: var(--r-16); padding: 10px 4px; display: grid; gap: 2px; border: 2px solid transparent; }
  .fc-tally b { font-size: 22px; font-variant-numeric: tabular-nums; }
  .fc-tally span { font-size: 12.5px; font-weight: 700; }
}

@layer screens {
  /* ---------- Thi thử: list ---------- */
  .exam-summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--s-4); }
  .exam-card { border-radius: var(--r-24); padding: var(--s-5); border-top: 6px solid var(--kind, var(--accent)); box-shadow: 0 3px 0 var(--line), var(--shadow-sm); }
  .exam-card.k-exam { --kind: var(--coral); }
  .exam-card.k-exam .v8-exam-icon { background: var(--coral-soft); color: var(--coral-ink); }
  .exam-card.k-practice { --kind: var(--accent); }
  .exam-card.k-lesson { --kind: var(--honey); }
  .exam-card.k-lesson .v8-exam-icon { background: var(--honey-soft); color: var(--honey-ink); }
  .exam-card .v8-exam-head { padding-right: 0; }
  .exam-card h3 { font-size: 18px; line-height: 1.4; }
  .exam-card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; margin-top: auto; padding-top: var(--s-2); border-top: 1px dashed var(--line); }
  .exam-card-foot .btn { margin: 0; }
  .v8-exam-last b { font-size: 16px; }
  .v8-exam-last.is-new { color: var(--muted); }
  /* ---------- exam detail ---------- */
  .exam-hero { display: flex; gap: var(--s-4); align-items: center; padding: var(--s-5); margin-bottom: var(--s-3); border-radius: var(--r-24);
    background: linear-gradient(135deg, var(--surface) 40%, var(--coral-soft)); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
  .exam-hero h1 { margin: 2px 0 var(--s-3); }
  .exam-hero-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .exam-sec-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: var(--s-2); }
  .exam-sec { display: grid; gap: 4px; margin: 0; }
  .resume-card { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; border-color: var(--accent); background: var(--accent-soft); }
  .resume-card > svg { color: var(--accent-ink); flex: none; }
  .resume-card p { margin: 2px 0 0; }
  .mt-12 { margin-top: 12px; }
  /* ---------- exam room: calm ---------- */
  .exam-head-row { display: flex; align-items: center; gap: 9px; }
  .exam-head-row + .exam-head-row { margin-top: 9px; gap: 10px; }
  .timer-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill); background: var(--surface); border: 1.5px solid var(--line-strong); font-weight: 800; }
  .timer-pill .timer { font-size: 16px; }
  .timer-pill.low { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
  .timer-pill.low .timer { color: var(--danger); }
  .save-pill { min-height: 32px; padding: 4px 10px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
  .save-pill[data-state="saving"] { color: var(--honey-ink); background: var(--honey-soft); border-color: #F3DDA0; }
  .save-pill[data-state="failed"] { color: #fff; background: var(--danger); border-color: var(--danger); cursor: pointer; }
  .save-pill:disabled { cursor: default; }
  .index-legend .lg-ans { background: var(--matcha); }
  .index-legend .lg-empty { background: var(--surface); border: 1.5px solid var(--line); }
  .index-legend .lg-flag { background: var(--honey); border-radius: 50%; }
  .index-legend .lg-now { background: var(--surface); box-shadow: 0 0 0 2px var(--focus); }
  .grid-nav button[aria-current="true"] { box-shadow: 0 0 0 3px rgba(23,92,150,.55); }
  .sectitle h2 { margin: 0; font-size: 19px; }
  .mondai-line { margin: 2px 0 8px; }
  .passage-title { margin-bottom: 6px; }
  .qimg-wrap { margin: 10px 0; }
  .restore-note { margin-top: 0; }
  body.exam-mode .qcard { border-width: 1.5px; }
  body.exam-mode .qcard.cur { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow-sm); }
  body.exam-mode .opt { min-height: 60px; font-size: 18px; }
  body.exam-mode .opt .k { width: 36px; height: 36px; font-size: 15px; }
  .opt[aria-pressed="true"] { border-color: var(--matcha); }
  .src-line { margin-top: 6px; }
  .feedback .note { margin-top: 8px; }
  .exam-foot-note { text-align: center; margin-top: 10px; }
  .exam-foot #submitBtn { flex: 1.3; }
  @media (max-width: 420px) { .hide-xs { display: none; } }
  @media (min-width: 1180px) {
    body.exam-mode .exam-body, body.exam-mode .exam-foot, body.exam-mode .exam-foot-note, body.exam-mode .restore-note { margin-right: 300px; }
    body.exam-mode .index-panel { position: fixed; right: var(--s-6); top: 132px; width: 272px; max-height: calc(100vh - 160px); margin: 0; z-index: 55; }
    body.exam-mode .exam-head { margin-bottom: var(--s-5); }
  }
  /* ---------- result ---------- */
  .result-hero { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; justify-content: center; padding: var(--s-5); text-align: left; }
  .result-hero.is-great { background: linear-gradient(135deg, var(--surface) 40%, var(--mint)); }
  .result-hero.is-ok { background: linear-gradient(135deg, var(--surface) 40%, var(--honey-soft)); }
  .result-hero.is-low { background: linear-gradient(135deg, var(--surface) 40%, var(--sakura-soft)); }
  .result-hero .result-mascot { margin: 0; }
  .result-ring { flex: none; }
  .result-ring .ring-center b { font-size: 30px; }
  .result-ring .ring-center small { font-size: 12.5px; }
  .result-copy { flex: 1 1 16rem; min-width: 0; }
  .result-copy .v9-milestone-art { margin: 0 0 8px; width: 140px; }
  .result-copy p { margin: 6px 0 0; }
  .result-actions { margin-top: var(--s-4); }
  .result-score { text-align: center; }
  .scorebig .mut { font-size: 22px; }
  .bar-val { text-align: right; font-variant-numeric: tabular-nums; }
  .progressbar.is-good > i { background: var(--matcha); }
  .progressbar.is-mid > i { background: var(--honey); }
  .progressbar.is-low > i { background: var(--coral); }
  .weak-row { margin: 6px 0; }
  .review-card.is-wrong { border-left: 6px solid var(--danger); }
  .review-card.is-right { border-left: 6px solid var(--matcha); }
  .opt-tag { margin-left: auto; }
}

@layer screens {
  /* ---------- auth / forgot / welcome ---------- */
  .ta-c { text-align: center; }
  .auth-head { text-align: center; margin-bottom: var(--s-4); }
  .auth-head .mascot { margin: 0 auto var(--s-2); }
  .auth-head h1 { margin: 0 0 4px; }
  .auth-head .sub { margin: 0 auto; }
  .auth-forgot { text-align: right; margin: 12px 0 0; }
  .auth-legal { text-align: center; margin: 16px 0 0; }
  .auth-card form .btn.block { margin-top: var(--s-2); }
  .auth-solo { max-width: 480px !important; display: block !important; }
  .fp-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 var(--s-4); }
  .fp-steps li { flex: 1; text-align: center; padding: 8px; border-radius: var(--r-pill); background: var(--surface-warm); color: var(--muted); font-size: 13px; font-weight: 750; }
  .fp-steps li.on { background: var(--accent); color: #fff; }
  .fp-form { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px dashed var(--line-strong); }
  .ob-actions { margin-top: var(--s-2); }
  /* ---------- Cá nhân ---------- */
  .profile-hero { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: var(--s-4); align-items: center; padding: var(--s-5); margin-bottom: var(--s-4);
    background: linear-gradient(135deg, var(--surface) 40%, var(--accent-soft)); border: 1px solid var(--line); border-radius: var(--r-24); box-shadow: var(--shadow-sm); }
  .profile-hero .hello { grid-column: 1 / -1; margin: 0; }
  .profile-id { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
  .profile-id h1 { margin: 2px 0; font-size: 26px; overflow-wrap: anywhere; }
  .profile-id p { margin: 0; }
  .profile-id .avatar { border: 3px solid var(--surface); box-shadow: var(--shadow-md); }
  @media (max-width: 560px) { .profile-hero { grid-template-columns: 1fr; padding: var(--s-4); } .profile-ring { justify-self: center; } }
  .stat-ic { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-12); background: rgba(255,255,255,.7); color: var(--accent-ink); margin-bottom: 6px; }
  .stat-note { margin: 0 0 var(--s-4); }
  .card-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-3); }
  .card-head h2 { margin: 0; }
  .card-h { margin: 0 0 4px; font-size: 19px; }
  .card-foot { margin: 12px 0 0; }
  .ic-soft { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-12); background: var(--sakura-soft); color: var(--sakura-ink); flex: none; }
  .tag-row { gap: 6px; }
  .badge-bar { width: 80%; margin: 2px auto 0; }
  .best-row { display: flex; align-items: center; gap: var(--s-3); margin: 8px 0; }
  .best-bar { width: 90px; flex: none; margin: 0; }
  .list-tight { margin-bottom: 0; }
  .goal-art { border-radius: var(--r-16); flex: none; }
  .goal-chips-left { justify-content: flex-start; margin: 4px 0 10px; }
  /* ---------- Quản trị ---------- */
  .row-tight { gap: 6px; }
  .code-row { margin: 6px 0; flex-wrap: wrap; }
  .otp-code { font-size: 16px; letter-spacing: 2px; font-weight: 800; background: var(--surface-warm); padding: 2px 8px; border-radius: var(--r-8); }
  .m-0 { margin: 0; }
  .utable tbody tr:hover { background: var(--surface-2); }
}

@layer screens {
  /* Phase 2 QA fixes from the 390px screenshots */
  .vocab-deck-head > .grow { flex: 1 1 12rem; }
  @media (max-width: 560px) { .vocab-deck-head .btn { width: 100%; } .vocab-deck { padding: var(--s-4); } }
  @media (max-width: 480px) { .tk-seg-tab { padding: 8px 10px; font-size: 13.5px; gap: 4px; } .tk-seg-count { padding: 1px 5px; } }
  .listen-controls { flex-wrap: nowrap; }
  .listen-controls > .btn { padding: 8px 10px; min-width: 0; gap: 2px; }
  .listen-rate .chip { padding: 6px 9px; min-width: 0; }
  @media (max-width: 360px) { .listen-controls { flex-wrap: wrap; justify-content: center; } }
  .profile-id .tag { margin-top: 4px; }
}
@layer screens {
  @media (max-width: 480px) { .tk-seg .tk-seg-count { display: none; } .tk-seg-tab { flex: 1 1 auto; padding: 8px 6px; } }
}
