/* Ôn thi Đại diện SHCN — design tokens + components. Brand: ANHPC navy/gold. */
:root {
  --navy: #0F2340; --navy-2: #1A3560; --gold: #FAAE17; --gold-ink: #8A5A00;
  --bg: #F3F6FA; --surface: #FFFFFF; --surface-2: #F7F9FC; --line: #DCE1E8; --line-2: #E9EDF3;
  --ink: #1B2230; --ink-2: #3A4456; --muted: #5B6577;
  --primary: #1F4FD1; --primary-ink: #FFFFFF; --primary-soft: #E8EEFC;
  --ok: #067647; --ok-soft: #E3F6EC; --bad: #B42318; --bad-soft: #FDECEA; --warn: #8A5A00; --warn-soft: #FFF4DB;
  --g-P1: #1D4ED8; --g-P2: #1E3A8A; --g-N1: #047857; --g-N2: #115E59; --g-S1: #6D28D9; --g-S2: #4338CA;
  --g-D1: #C2410C; --g-D2: #9A3412; --g-T1: #BE185D; --g-T2: #9F1239;
  --radius: 16px; --radius-sm: 10px; --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(15,35,64,.06), 0 4px 14px rgba(15,35,64,.06);
  --shadow-lg: 0 10px 30px rgba(15,35,64,.12);
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 16px; --sidebar: 252px; --tabbar: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1220; --surface: #121B2D; --surface-2: #17223A; --line: #2A3752; --line-2: #212C44;
    --ink: #E7ECF4; --ink-2: #C9D2E1; --muted: #9AA6BA;
    --primary: #7EA2FF; --primary-ink: #0B1220; --primary-soft: #1B2A4D;
    --ok: #4ADE80; --ok-soft: #0F2E1F; --bad: #F87171; --bad-soft: #3A1616; --warn: #FBBF24; --warn-soft: #33270C;
    --gold-ink: #FBBF24; --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 30px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1220; --surface: #121B2D; --surface-2: #17223A; --line: #2A3752; --line-2: #212C44;
  --ink: #E7ECF4; --ink-2: #C9D2E1; --muted: #9AA6BA;
  --primary: #7EA2FF; --primary-ink: #0B1220; --primary-soft: #1B2A4D;
  --ok: #4ADE80; --ok-soft: #0F2E1F; --bad: #F87171; --bad-soft: #3A1616; --warn: #FBBF24; --warn-soft: #33270C;
  --gold-ink: #FBBF24; --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 30px rgba(0,0,0,.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.55; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; } .icon.lg { width: 24px; height: 24px; }

/* ---------- Shell ---------- */
.app { min-height: 100vh; display: flex; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line-2); padding: calc(var(--safe-t) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px; min-height: 56px; }
.topbar .brand-mini { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.topbar .brand-mini img { width: 30px; height: 30px; border-radius: 8px; }
.topbar h1 { font-size: 1.02rem; margin: 0; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); }
.content { width: 100%; max-width: 1120px; margin: 0 auto; padding: 18px 16px calc(var(--tabbar) + var(--safe-b) + 28px); }
.content.narrow { max-width: 820px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabbar); text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar a[aria-current="page"] .icon { stroke-width: 2.4; }

@media (min-width: 1024px) {
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; width: var(--sidebar); flex: none; background: var(--navy); color: #DCE4F2; padding: 18px 14px; overflow-y: auto; }
  .sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; color: #fff; text-decoration: none; }
  .sidebar .brand img { width: 42px; height: 42px; border-radius: 12px; }
  .sidebar .brand b { display: block; font-size: 1.02rem; letter-spacing: -.01em; }
  .sidebar .brand small { color: var(--gold); font-weight: 600; font-size: .76rem; letter-spacing: .04em; text-transform: uppercase; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar .nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #8FA0BC; margin: 16px 10px 6px; font-weight: 700; }
  .sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #DCE4F2; text-decoration: none; font-weight: 600; font-size: .94rem; }
  .sidebar nav a:hover { background: rgba(255,255,255,.07); }
  .sidebar nav a[aria-current="page"] { background: rgba(250,174,23,.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
  .sidebar nav a[aria-current="page"] .icon { color: var(--gold); }
  .sidebar .side-foot { margin-top: auto; padding: 12px 10px 0; font-size: .76rem; color: #8FA0BC; }
  .tabbar { display: none; }
  .topbar .brand-mini { display: none; }
  .topbar { padding: 12px 28px; }
  .content { padding: 26px 28px 48px; }
}

/* ---------- Typography & generic ---------- */
.eyebrow { font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--primary); margin: 0 0 6px; }
.page-title { font-size: clamp(1.55rem, 4.6vw, 2.3rem); line-height: 1.15; margin: 0 0 6px; letter-spacing: -.02em; font-weight: 800; }
.page-sub { color: var(--muted); margin: 0 0 22px; }
h2.section { font-size: 1.12rem; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .tiny { font-size: .76rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 14px; }
@media (min-width: 720px) { .grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 719px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
a.card { color: inherit; text-decoration: none; display: block; transition: transform .12s ease, box-shadow .12s ease; }
a.card:hover { box-shadow: var(--shadow-lg); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; background: var(--surface); color: var(--ink); border-color: var(--line); transition: background .12s ease, opacity .12s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { opacity: .92; background: var(--primary); }
.btn.gold { background: var(--gold); color: #1B2230; border-color: var(--gold); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: .88rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .86rem; font-weight: 600; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.chip[aria-pressed="true"], .chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
textarea.input { min-height: 160px; line-height: 1.6; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box .input { padding-left: 42px; }
.progress { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .3s ease; }
.progress.gold > span { background: var(--gold); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; margin: 0 auto 10px; color: var(--line); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--ink); font-size: .9rem; }
.notice .icon { color: var(--warn); margin-top: 2px; }
.notice.info { background: var(--primary-soft); } .notice.info .icon { color: var(--primary); }
hr.sep { border: 0; border-top: 1px solid var(--line-2); margin: 18px 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { flex: none; padding: 12px 14px; border: 0; background: none; color: var(--muted); font-weight: 700; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.tabs [aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Home ---------- */
.hero { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 22px; color: #fff; background: radial-gradient(120% 140% at 100% 0%, #2B4C86 0%, var(--navy) 55%); box-shadow: var(--shadow-lg); }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; border: 18px solid rgba(250,174,23,.22); }
@media (max-width: 600px) { .hero::after { width: 120px; height: 120px; right: -50px; top: -50px; border-width: 14px; opacity: .6; } }
.hero > * { position: relative; z-index: 1; }
.hero h2 { margin: 0 0 4px; font-size: clamp(1.3rem, 4vw, 1.75rem); letter-spacing: -.02em; }
.hero p { margin: 0; color: #C9D6EC; }
.hero .count { display: flex; align-items: baseline; gap: 8px; margin: 16px 0 4px; }
.hero .count b { font-size: 2.6rem; line-height: 1; color: var(--gold); font-weight: 800; }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; position: relative; z-index: 1; }
.hero .btn { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; }
.hero .btn.gold { background: var(--gold); color: #1B2230; border-color: var(--gold); }
.stat { padding: 16px; }
.stat .k { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat .v { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat .k .icon { color: var(--primary); }
.stat.flame .k .icon { color: #E8590C; }
.todo { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.todo .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.todo .ic.gold { background: var(--warn-soft); color: var(--gold-ink); }
.todo .ic.ok { background: var(--ok-soft); color: var(--ok); }
.todo b { display: block; }
.todo .icon.chev { color: var(--muted); }

/* ---------- Learn (K12-style topic cards) ---------- */
.topic { overflow: hidden; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.topic-head { display: flex; align-items: center; gap: 14px; padding: 18px 20px; color: #fff; }
.topic-head .ti { width: 46px; height: 46px; border-radius: 14px; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }
.topic-head .ti .icon { width: 24px; height: 24px; }
.topic-head small { display: block; font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.topic-head b { display: block; font-size: 1.08rem; line-height: 1.3; }
.topic-head .count { margin-left: auto; background: rgba(255,255,255,.2); padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: .82rem; white-space: nowrap; }
.g-P .topic-head, .bg-P { background: linear-gradient(110deg, var(--g-P1), var(--g-P2)); }
.g-N .topic-head, .bg-N { background: linear-gradient(110deg, var(--g-N1), var(--g-N2)); }
.g-S .topic-head, .bg-S { background: linear-gradient(110deg, var(--g-S1), var(--g-S2)); }
.g-D .topic-head, .bg-D { background: linear-gradient(110deg, var(--g-D1), var(--g-D2)); }
.g-T .topic-head, .bg-T { background: linear-gradient(110deg, var(--g-T1), var(--g-T2)); }
.lesson-row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line-2); color: inherit; text-decoration: none; min-height: 60px; }
.lesson-row:hover { background: var(--surface-2); }
.lesson-row .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .82rem; flex: none; }
.g-P .num { background: #E8EEFC; color: var(--g-P1); } .g-N .num { background: #E2F5EE; color: var(--g-N1); }
.g-S .num { background: #EFE8FD; color: var(--g-S1); } .g-D .num { background: #FDEDE3; color: var(--g-D1); } .g-T .num { background: #FCE7F1; color: var(--g-T1); }
:root[data-theme="dark"] .lesson-row .num { background: var(--surface-2); color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lesson-row .num { background: var(--surface-2); color: var(--ink); } }
.lesson-row .t { flex: 1; min-width: 0; }
.lesson-row .t b { display: block; font-weight: 600; line-height: 1.35; }
.lesson-row .t .progress { height: 5px; margin-top: 7px; max-width: 220px; }
.lesson-row .icon.chev { color: var(--muted); }

/* ---------- Lesson ---------- */
.lesson-hero { border-radius: var(--radius-lg); padding: 22px; color: #fff; margin-bottom: 18px; }
.lesson-hero small { font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: .7rem; opacity: .9; }
.lesson-hero h2 { margin: 4px 0 8px; font-size: clamp(1.25rem, 3.8vw, 1.7rem); letter-spacing: -.01em; line-height: 1.25; }
.lesson-hero p { margin: 0; opacity: .92; }
.lesson-hero .scope { margin-top: 10px; font-size: .85rem; opacity: .9; display: flex; gap: 8px; align-items: flex-start; }
.lesson-hero .scope .icon { margin-top: 2px; }
.kp-group { padding: 16px 18px; }
.kp-group h3 { margin: 0 0 10px; font-size: 1rem; display: flex; gap: 8px; align-items: center; }
.kp-group ul { margin: 0; padding-left: 20px; } .kp-group li { margin: 6px 0; }
.kp-group li::marker { color: var(--gold); }

/* ---------- Markdown ---------- */
.md { overflow-wrap: anywhere; }
.md h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 14px; }
.md h2 { font-size: 1.22rem; margin: 30px 0 10px; padding-top: 6px; border-top: 1px solid var(--line-2); }
.md h3 { font-size: 1.06rem; margin: 22px 0 8px; } .md h4 { font-size: 1rem; margin: 18px 0 6px; }
.md p, .md ul, .md ol { margin: 0 0 12px; } .md li { margin: 4px 0; }
.md blockquote { margin: 0 0 14px; padding: 10px 14px; border-left: 4px solid var(--gold); background: var(--warn-soft); border-radius: 0 10px 10px 0; color: var(--ink-2); }
.md blockquote p:last-child { margin: 0; }
.md code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.md pre { background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; }
.md hr { border: 0; border-top: 1px dashed var(--line); margin: 22px 0; }
.table-wrap { overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--line-2); border-radius: 12px; }
.md table { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 520px; }
.md th, .md td { padding: 9px 11px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); font-weight: 700; }
.md tr:last-child td { border-bottom: 0; }
.md mark, mark { background: color-mix(in srgb, var(--gold) 45%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.reader { padding: 20px; }
@media (min-width: 720px) { .reader { padding: 28px 34px; } }
.toc-btn { position: fixed; right: 16px; bottom: calc(var(--tabbar) + var(--safe-b) + 16px); z-index: 25; box-shadow: var(--shadow-lg); }
@media (min-width: 1024px) { .toc-btn { bottom: 24px; } }
.sheet { position: fixed; inset: 0; z-index: 60; display: none; }
.sheet.open { display: block; }
.sheet .scrim { position: absolute; inset: 0; background: rgba(8,14,28,.55); }
.sheet .panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 78vh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); }
@media (min-width: 720px) { .sheet .panel { left: auto; top: 0; width: 400px; max-height: none; border-radius: 0; } }
.sheet.dialog { z-index: 90; }
.sheet.dialog .panel { inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: min(440px, calc(100vw - 32px)); max-height: none; border-radius: 20px; padding: 22px; box-shadow: var(--shadow-lg); }
.dlg-msg { margin: 0 0 18px; font-weight: 600; font-size: 1.02rem; line-height: 1.5; }
.sheet .panel .toc-link { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 10px; color: var(--ink); font-size: .92rem; cursor: pointer; }
.sheet .panel .toc-link.l3 { padding-left: 26px; color: var(--muted); font-size: .86rem; }
.sheet .panel .toc-link:hover { background: var(--surface-2); }

/* ---------- Accounts ---------- */
.auth-wrap { max-width: 460px; margin: 8px auto 0; display: flex; flex-direction: column; gap: 16px; }
.auth-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); justify-content: center; }
.auth-brand img { width: 44px; height: 44px; border-radius: 12px; }
.auth-brand b { display: block; } .auth-brand small { color: var(--gold-ink); font-weight: 700; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; }
.auth-card { padding: 24px 22px; } .auth-card h2 { margin: 0 0 4px; font-size: 1.35rem; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; } .field label { font-weight: 600; font-size: .9rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; margin: 4px 0 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.pw-rules { list-style: none; padding: 0; margin: -6px 0 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); }
.pw-rules li { display: inline-flex; gap: 4px; align-items: center; } .pw-rules li.ok { color: var(--ok); font-weight: 600; }
.notice.error { background: var(--bad-soft); } .notice.error .icon { color: var(--bad); }
form .notice { margin: 0 0 14px; }
.mini-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .7s linear infinite; }
.side-user { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); display: flex; gap: 8px; align-items: center; font-size: .84rem; color: #DCE4F2; overflow: hidden; }
.side-user span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero.welcome h2 { font-size: clamp(1.4rem, 4.4vw, 2rem); }

/* ---------- Admin ---------- */
.user-card { padding: 16px 18px; margin-bottom: 12px; }
.user-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); margin-top: 8px; }
.user-acts { margin-top: 12px; gap: 8px; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; white-space: pre-wrap; word-break: break-all; user-select: all; }
.sheet.dialog.wide .panel { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; }

/* ---------- Billing ---------- */
.paywall { text-align: center; padding: 34px 22px; max-width: 640px; margin: 10px auto; }
.paywall h2 { margin: 6px 0 10px; font-size: 1.3rem; text-wrap: balance; }
.paywall .pw-ic { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--warn-soft); color: var(--gold-ink); }
.plans .plan { padding: 22px 20px; display: flex; flex-direction: column; gap: 8px; }
.plans .plan h3 { margin: 4px 0 0; font-size: 1.05rem; }
.plans .plan .price { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.plans .plan .btn { margin-top: auto; }
.plans .plan.hl { border: 2px solid var(--gold); box-shadow: var(--shadow-lg); }
.plans .plan .badge { align-self: flex-start; }
.dl-table.cmp td:nth-child(n+2), .dl-table.cmp th:nth-child(n+2) { text-align: center; width: 110px; }
.dl-table.cmp td .icon { margin: 0 auto; color: var(--ok); }
@media (max-width: 719px) { .dl-table.cmp thead { display: table-header-group; } .dl-table.cmp tr { display: table-row; padding: 0; } .dl-table.cmp td { display: table-cell; padding: 9px 8px; border-top: 1px solid var(--line-2); } .dl-table.cmp td:nth-child(n+2), .dl-table.cmp th:nth-child(n+2) { width: 64px; } }
.qr-box { display: grid; place-items: center; } .qr-box img { width: 100%; max-width: 300px; height: auto; border-radius: 12px; background: #fff; }
.qr-ph { width: 100%; max-width: 300px; aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 16px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 16px; }
.pay-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.pay-row span { min-width: 130px; } .pay-row b { flex: 1; word-break: break-all; }
.lesson-row.locked .t b { color: var(--muted); }
.lesson-row.locked .num { background: var(--warn-soft) !important; color: var(--gold-ink) !important; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; overflow-x: auto; }
.bar { flex: 1; min-width: 34px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bar span { width: 100%; max-width: 36px; border-radius: 6px 6px 2px 2px; background: var(--primary); }
.bar small { font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-edit { margin-bottom: 10px; }
form h3 { font-size: 1rem; margin: 18px 0 10px; }

/* ---------- News & laws ---------- */
.news-item b { display: block; line-height: 1.4; margin-bottom: 4px; }
.news-sum { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.law { padding: 16px 18px; margin-bottom: 12px; }
.law h3 { margin: 10px 0 8px; font-size: 1.02rem; line-height: 1.4; }
.law-code { font-family: ui-monospace, Consolas, monospace; font-size: .86em; background: var(--primary-soft); color: var(--primary); padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.law-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 16px; margin: 0 0 10px; }
.law-meta dt { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; } .law-meta dd { margin: 0; font-weight: 600; font-size: .92rem; }
.law-links { gap: 8px; margin-top: 10px; }
.sheet .panel a { display: block; padding: 9px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: .92rem; }
.sheet .panel a.l3 { padding-left: 26px; color: var(--muted); font-size: .86rem; }
.sheet .panel a:hover { background: var(--surface-2); }

/* ---------- Quiz player (K12-style) ---------- */
.player { max-width: 860px; margin: 0 auto; }
.player-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: .88rem; color: var(--muted); }
.player-top b { color: var(--ink); }
.player-top > span:first-child { white-space: nowrap; }
@media (max-width: 480px) { .player-top .btn.ghost { padding: 0 8px; } }
.player .progress { margin-bottom: 18px; }
.qcard { padding: 22px 20px; }
@media (min-width: 720px) { .qcard { padding: 28px 32px; } }
.qtext { font-size: 1.08rem; font-weight: 600; line-height: 1.6; margin: 10px 0 18px; }
.qtext::after { content: ""; display: block; width: 64px; height: 4px; border-radius: 4px; background: var(--gold); margin-top: 12px; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; padding: 13px 16px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; min-height: 54px; line-height: 1.45; font-size: .98rem; transition: border-color .12s, background .12s; }
.opt:hover:not([disabled]) { border-color: color-mix(in srgb, var(--primary) 55%, var(--line)); }
.opt .key { width: 28px; height: 28px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: none; color: var(--ink-2); }
.opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.opt.sel .key { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt[disabled] { cursor: default; }
.tf { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf .opt { justify-content: center; align-items: center; font-weight: 800; font-size: 1.05rem; min-height: 64px; }
.match-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px; border: 2px solid var(--line); border-radius: 16px; }
@media (min-width: 720px) { .match-row { grid-template-columns: 1fr 1fr; align-items: center; } }
.match-row .l { font-weight: 600; }
.match-row.right { border-color: var(--ok); background: var(--ok-soft); } .match-row.wrong { border-color: var(--bad); background: var(--bad-soft); }
.match-row .fix { font-size: .84rem; color: var(--ok); font-weight: 700; grid-column: 1 / -1; display: flex; gap: 6px; align-items: flex-start; }
.match-row .fix .icon { margin-top: 2px; }
.feedback .trap { display: flex; gap: 8px; align-items: flex-start; } .feedback .trap .icon { margin-top: 3px; color: var(--warn); }
.notice a { font-weight: 700; }
.feedback { margin-top: 18px; border-radius: 16px; padding: 16px 18px; border: 1px solid transparent; }
.feedback.ok { background: var(--ok-soft); } .feedback.bad { background: var(--bad-soft); }
.feedback .verdict { display: flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 8px; }
.feedback.ok .verdict { color: var(--ok); } .feedback.bad .verdict { color: var(--bad); }
.feedback .basis { margin-top: 10px; font-size: .9rem; display: flex; gap: 8px; align-items: flex-start; }
.feedback .basis .icon { margin-top: 3px; color: var(--primary); }
.feedback .trap { margin-top: 10px; font-size: .9rem; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); }
.player-bar { position: sticky; bottom: calc(var(--tabbar) + var(--safe-b)); margin-top: 16px; display: flex; gap: 10px; align-items: center; padding: 12px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); z-index: 10; }
@media (min-width: 1024px) { .player-bar { bottom: 12px; } }
.mascot { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.mascot .m { width: 40px; height: 40px; border-radius: 50%; background: var(--gold); display: grid; place-items: center; color: var(--navy); flex: none; }
.mascot .bubble { font-size: .86rem; font-weight: 700; padding: 6px 12px; border: 2px solid color-mix(in srgb, var(--gold) 60%, transparent); border-radius: 14px; background: var(--surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) { .mascot .bubble { display: none; } }
.finish { text-align: center; padding: 34px 20px; }
.finish .ring { width: 132px; height: 132px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line-2) 0); }
.finish .ring > div { width: 104px; height: 104px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 1.7rem; font-weight: 800; }
.finish .eyebrow { color: var(--ok); }
.review-item { padding: 14px 16px; border-top: 1px solid var(--line-2); }
.review-item:first-child { border-top: 0; }

/* ---------- Flashcards ---------- */
.flash { perspective: 1400px; max-width: 640px; margin: 0 auto; }
.flash-inner { position: relative; min-height: 300px; transition: transform .45s ease; transform-style: preserve-3d; cursor: pointer; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: var(--radius-lg); padding: 26px 22px; display: flex; flex-direction: column; justify-content: center; text-align: center; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); }
.flash-face.back { transform: rotateY(180deg); background: var(--surface); }
.flash-face .lbl { position: absolute; top: 16px; left: 18px; font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.flash-face .txt { font-size: 1.18rem; font-weight: 700; line-height: 1.5; }
.flash-face.back .txt { font-size: 1.02rem; font-weight: 500; }
.flash-face .basis { margin-top: 14px; font-size: .84rem; color: var(--muted); }
.flash-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 640px; margin: 16px auto 0; }
.flash-actions .btn { border-radius: 14px; flex-direction: column; gap: 2px; min-height: 58px; font-size: .9rem; }
.flash-actions .btn small { font-weight: 500; color: var(--muted); font-size: .72rem; }
@media (prefers-reduced-motion: reduce) { .flash-inner { transition: none; } * { scroll-behavior: auto !important; } }

/* ---------- Exam ---------- */
.exam-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.exam-card .tag { align-self: flex-start; }
.exam-card h3 { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.timer { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; font-weight: 800; padding: 6px 14px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.qnav { display: flex; gap: 8px; flex-wrap: wrap; }
.qnav button { width: 42px; height: 42px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-weight: 800; cursor: pointer; }
.qnav button.cur { border-color: var(--primary); color: var(--primary); }
.qnav button.done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.barem { width: 100%; border-collapse: collapse; font-size: .92rem; }
.barem td { padding: 10px 8px; border-top: 1px solid var(--line-2); vertical-align: top; }
.barem tr:first-child td { border-top: 0; }
.barem td.pts { white-space: nowrap; font-weight: 800; text-align: right; color: var(--primary); }
.barem label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.barem input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ok); flex: none; }
.barem .cc { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }
.score-big { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }
details.fold { border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); margin: 0 0 12px; }
details.fold > summary { cursor: pointer; list-style: none; padding: 14px 16px; font-weight: 700; display: flex; gap: 10px; align-items: center; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .icon.chev { margin-left: auto; transition: transform .15s; color: var(--muted); }
details.fold[open] > summary .icon.chev { transform: rotate(90deg); }
details.fold > .body { padding: 0 16px 16px; }
.answer-view { white-space: pre-wrap; background: var(--surface-2); border-radius: 12px; padding: 14px; font-size: .95rem; border: 1px solid var(--line-2); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-top: 1px solid var(--line-2); color: inherit; text-decoration: none; }
.list-item:first-child { border-top: 0; }
a.list-item:hover { background: var(--surface-2); }
.list-item .code { font-family: ui-monospace, Consolas, monospace; font-size: .78rem; color: var(--muted); }
.dl-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.dl-table td, .dl-table th { padding: 11px 12px; border-top: 1px solid var(--line-2); text-align: left; vertical-align: top; }
.dl-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-top: 0; }
.dl-table td.v { font-weight: 700; }
@media (max-width: 719px) {
  .dl-table thead { display: none; }
  .dl-table tr { display: block; padding: 12px 14px; border-top: 1px solid var(--line-2); }
  .dl-table td { display: block; border: 0; padding: 2px 0; }
}
.setting { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.setting:first-child { border-top: 0; }
.setting .t { flex: 1; min-width: 200px; } .setting .t b { display: block; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface-2); }
.seg button { border: 0; background: none; padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: .86rem; cursor: pointer; color: var(--muted); min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--safe-b) + 18px); transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 80; font-weight: 600; font-size: .9rem; max-width: calc(100vw - 32px); }
@media (min-width: 1024px) { .toast { bottom: 24px; } }
.unverified { color: var(--warn); font-weight: 700; font-size: .8rem; white-space: nowrap; }
@media print { .sidebar, .tabbar, .topbar, .player-bar, .toc-btn { display: none !important; } .content { padding: 0; } }
