/* HSKK 4 · design system — "ink & seal": deep ink-navy, Chinese seal red, warm paper. Light + dark. */
:root, [data-theme="light"] {
  --bg: #f6f3ee; --bg-grad: radial-gradient(1200px 500px at 80% -10%, #fde9e4 0%, transparent 60%);
  --surface: #ffffff; --surface-2: #faf8f4; --surface-3: #f2eee7; --line: #e8e2d8; --line-2: #ddd5c8;
  --ink: #18203a; --text: #2c3348; --muted: #6f7486;
  --brand: #1f2d4d; --brand-h: #2c3f6b; --brand-soft: #e7ebf4; --on-brand: #ffffff;
  --accent: #c0392b; --accent-h: #a93226; --accent-soft: #fbe7e3;
  --p1: #2563eb; --p1-soft: #e6eefe; --p2: #c97a0a; --p2-soft: #fdf1dc; --p3: #0f8a6c; --p3-soft: #ddf3ec;
  --listen: #2563eb; --prep: #c97a0a; --speak: #dc2626; --ok: #15803d; --ok-soft: #dcfce7; --warn: #c2410c; --warn-soft: #ffedd5;
  --hl: #fff1b8; --shadow: 0 1px 2px rgba(24,32,58,.06), 0 6px 20px rgba(24,32,58,.06); --shadow-lg: 0 12px 40px rgba(24,32,58,.14);
  --r: 18px; --r-sm: 12px;
  --zh: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ui: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f131c; --bg-grad: radial-gradient(1200px 500px at 80% -10%, #2a1715 0%, transparent 60%);
  --surface: #181d29; --surface-2: #1e2432; --surface-3: #252c3d; --line: #2a3142; --line-2: #343c50;
  --ink: #f1f3f8; --text: #d6dae5; --muted: #949bb0;
  --brand: #4a6bb3; --brand-h: #5a7cc6; --brand-soft: #23304d; --on-brand: #ffffff;
  --accent: #e15a4b; --accent-h: #ec6e60; --accent-soft: #3a1f1d;
  --p1: #6ea0ff; --p1-soft: #1c2a47; --p2: #f0a73a; --p2-soft: #3a2b12; --p3: #3cc9a2; --p3-soft: #123a31;
  --listen: #6ea0ff; --prep: #f0a73a; --speak: #ff6b6b; --ok: #4ade80; --ok-soft: #133523; --warn: #fb923c; --warn-soft: #3b2412;
  --hl: #5a4a12; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg-grad), var(--bg); background-attachment: fixed; color: var(--text); font: 15.5px/1.55 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; } h2 { font-size: 18px; font-weight: 700; } h3 { font-size: 16px; font-weight: 700; }
p { margin: 6px 0; }
.zh { font-family: var(--zh); }
.muted { color: var(--muted); } .small { font-size: 13.5px; } .mt { margin-top: 10px; } .h3 { margin: 18px 0 8px; }
.hide { display: none !important; } .grow { flex: 1; }
.c-ok { color: var(--ok); } .c-warn { color: var(--warn); } .c-listen { color: var(--listen); } .c-prep { color: var(--prep); } .c-speak { color: var(--speak); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1320px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.logo { display: flex; align-items: center; gap: 10px; }
.seal { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font: 700 22px/1 "Noto Serif SC", var(--zh); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); transform: rotate(-4deg); }
.logo-t { font-weight: 800; font-size: 20px; color: var(--ink); line-height: 1; }
.logo-t b { color: var(--accent); } .logo-t small { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; color: var(--muted); margin-top: 3px; }
.nav { display: flex; gap: 4px; margin: 0 auto; }
.nav a { padding: 8px 16px; border-radius: 999px; font-weight: 600; color: var(--muted); transition: .15s; }
.nav a:hover { color: var(--ink); background: var(--surface-3); }
.nav a.active { color: var(--ink); background: var(--brand-soft); box-shadow: inset 0 -2px 0 var(--accent); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-3); font-size: 17px; color: var(--ink); transition: .15s; }
.icon-btn:hover { background: var(--line); }
.lang-sw { display: flex; background: var(--surface-3); border-radius: 10px; padding: 3px; }
.lang-sw button { padding: 5px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.lang-sw button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
main { max-width: 1320px; margin: 0 auto; padding: 20px 20px 80px; }

/* ---------- buttons, pills, tabs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 18px; border-radius: 999px; font-weight: 600; background: var(--brand); color: var(--on-brand); white-space: nowrap; transition: .15s; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.btn:hover { background: var(--brand-h); transform: translateY(-1px); }
.btn.sm { padding: 6px 13px; font-size: 13.5px; } .btn.lg { padding: 12px 24px; font-size: 16px; } .btn.full { width: 100%; }
.btn.accent { background: var(--accent); } .btn.accent:hover { background: var(--accent-h); }
.btn.ghost { background: var(--surface-3); color: var(--ink); box-shadow: none; } .btn.ghost:hover { background: var(--line); }
.btn.ghost-inv { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.4); } .btn.ghost-inv:hover { background: rgba(255,255,255,.22); }
.btn[disabled] { opacity: .45; transform: none; }
.btn svg { width: 15px; height: 15px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--surface-3); color: var(--muted); }
.pill.new { background: var(--accent); color: #fff; }
.pill.p1 { background: var(--p1-soft); color: var(--p1); } .pill.p2 { background: var(--p2-soft); color: var(--p2); } .pill.p3 { background: var(--p3-soft); color: var(--p3); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 16px; padding: 4px; background: var(--surface-3); border-radius: 14px; width: fit-content; max-width: 100%; }
.tab { padding: 7px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.toggles { display: inline-flex; gap: 6px; }
.toggle { padding: 5px 12px; border-radius: 999px; background: var(--surface-3); font-size: 13px; font-weight: 600; color: var(--muted); }
.toggle.on { background: var(--brand); color: var(--on-brand); }
.seg { display: flex; background: var(--surface-3); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; padding: 8px 10px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.layout.learn { grid-template-columns: 290px minmax(0, 1fr); }
.stack { display: grid; gap: 18px; }
.sec-head { display: flex; align-items: center; gap: 10px; } .sec-head.wrap { flex-wrap: wrap; }
.side h3 { margin-bottom: 10px; }
.alert { background: var(--warn-soft); color: var(--warn); border-radius: var(--r-sm); padding: 12px 16px; margin-bottom: 14px; font-weight: 500; }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; border-radius: 24px; padding: 34px 36px; margin-bottom: 20px; color: #fff;
  background: linear-gradient(135deg, #18203a 0%, #24345e 55%, #3b2a4a 100%); box-shadow: var(--shadow-lg); }
.hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(600px 300px at 100% 0%, rgba(192,57,43,.45), transparent 60%); pointer-events: none; }
.hero-txt { position: relative; z-index: 1; max-width: 720px; }
.hero h1 { color: #fff; font-size: 32px; margin: 8px 0 10px; }
.hero p { opacity: .86; font-size: 16px; max-width: 640px; }
.eyebrow { display: inline-block; font-size: 13px; letter-spacing: .14em; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.1); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hero-stats { margin-top: 14px; font-size: 13.5px; opacity: .7; }
.hero-seal { position: absolute; right: 36px; top: 50%; transform: translateY(-50%) rotate(-8deg); width: 150px; height: 150px; border-radius: 22px; z-index: 1;
  display: grid; place-items: center; font: 700 96px/1 "Noto Serif SC", var(--zh); color: #fff; background: var(--accent); box-shadow: inset 0 0 0 5px rgba(255,255,255,.25), 0 20px 40px rgba(0,0,0,.3); opacity: .92; }

/* ---------- test cards ---------- */
.test-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.test-card { position: relative; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 16px; min-height: 150px; display: flex; flex-direction: column; transition: .18s; }
.test-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.test-card.done { background: var(--surface); }
.wm { position: absolute; right: 10px; top: 2px; font-size: 46px; font-weight: 800; color: var(--line); pointer-events: none; }
.tc-title { position: relative; font-weight: 700; font-size: 17px; color: var(--ink); }
.tc-sub { position: relative; font-size: 14.5px; color: var(--muted); margin-top: 2px; }
.tc-foot { margin-top: auto; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tc-meta { font-size: 12.5px; color: var(--muted); }
.tc-score { display: flex; align-items: center; gap: 10px; }
.tc-score small { display: block; font-size: 12px; color: var(--muted); }
.tc-ring { --c: var(--ok); width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0); }
.tc-ring.warn { --c: var(--warn); }
.tc-ring span { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 12.5px; font-weight: 800; color: var(--ink); }
.banner-card { display: flex; align-items: center; gap: 18px; justify-content: space-between; background: linear-gradient(90deg, var(--surface) 60%, var(--p3-soft)); }
.lesson-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.lchip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; transition: .15s; }
.lchip:hover { border-color: var(--accent); color: var(--ink); }
.lchip b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 12px; }
[data-theme="dark"] .lchip b { color: var(--ink); }

/* ---------- side boxes ---------- */
.struct-row { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--line); }
.struct-row:first-of-type { border-top: 0; }
.struct-row small { display: block; color: var(--muted); font-size: 13px; }
.struct-n, .tip-n, .qnum { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; flex: none; }
.p1.struct-n, .p1.tip-n, .p1.qnum { background: var(--p1-soft); color: var(--p1); }
.p2.struct-n, .p2.tip-n, .p2.qnum { background: var(--p2-soft); color: var(--p2); }
.p3.struct-n, .p3.tip-n, .p3.qnum { background: var(--p3-soft); color: var(--p3); }
.tip { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--line); font-size: 14.5px; }
.tip:first-of-type { border-top: 0; }
.tip-n { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }
.side .btn.full { margin-top: 8px; }

/* ---------- page header ---------- */
.page-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-top h1 { font-size: 22px; text-align: center; } .page-top .sub { font-size: 15px; font-weight: 500; }
.back { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; color: var(--ink); }
.back:hover { border-color: var(--line-2); }

/* ---------- exam: phase bar ---------- */
.phase-bar { position: sticky; top: 64px; z-index: 15; display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 16px; margin-bottom: 16px; box-shadow: var(--shadow); --pc: var(--muted); transition: border-color .2s; }
.phase-bar.ph-examiner { --pc: var(--brand); } .phase-bar.ph-listen { --pc: var(--listen); } .phase-bar.ph-prep { --pc: var(--prep); }
.phase-bar.ph-speak, .phase-bar.ph-warm { --pc: var(--speak); } .phase-bar.ph-done { --pc: var(--ok); }
[data-theme="dark"] .phase-bar.ph-examiner { --pc: var(--p1); }
.phase-bar:not(.ph-idle) { border-color: color-mix(in srgb, var(--pc) 45%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 14%, transparent), var(--shadow); }
.ph-ring { position: relative; width: 56px; height: 56px; }
.ph-ring svg { width: 56px; height: 56px; transform: rotate(-90deg); }
.ph-ring circle { fill: none; stroke-width: 4; }
.ph-ring .trk { stroke: var(--line); } .ph-ring .val { stroke: var(--pc); stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 119.4; transition: stroke-dashoffset .25s linear; }
.ph-ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ph-label { font-weight: 800; font-size: 17px; color: var(--pc); display: flex; align-items: center; gap: 8px; }
.ph-speak .ph-label::before, .ph-warm .ph-label::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--speak); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.ph-sub { font-size: 13px; color: var(--muted); }
.steps { display: flex; align-items: center; justify-content: center; }
.step { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13.5px; background: var(--surface-3); color: var(--muted); border: 2px solid transparent; transition: .2s; }
.step.p1 { --sc: var(--p1); } .step.p2 { --sc: var(--p2); } .step.p3 { --sc: var(--p3); }
.step:hover { border-color: var(--sc); }
.step.done { background: var(--sc); color: #fff; }
.step.cur { border-color: var(--sc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sc) 22%, transparent); color: var(--ink); }
.step.done.cur { color: #fff; }
.step-line { display: block; width: 22px; height: 2px; background: var(--line); }
.ph-clock { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); padding: 6px 12px; border-radius: 10px; background: var(--surface-3); }

/* ---------- exam: questions ---------- */
.exam-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.side-col { display: grid; gap: 14px; position: sticky; top: 150px; }
.side-col .card { padding: 16px; }
.side-col .btn.full { margin-top: 12px; }
.hint-tg { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.part-mini { padding: 12px 14px !important; }
.pm-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.pm-head small { display: block; color: var(--muted); font-size: 12.5px; }
.part-banner { display: flex; align-items: center; gap: 12px; border-radius: var(--r); padding: 12px 16px; margin: 18px 0 12px; border: 1px solid transparent; }
.part-banner.p1 { background: var(--p1-soft); } .part-banner.p2 { background: var(--p2-soft); } .part-banner.p3 { background: var(--p3-soft); }
.part-banner .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--surface); display: grid; place-items: center; font-size: 18px; flex: none; }
.part-banner .tt { flex: 1; color: var(--ink); } .part-banner small { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.info-btn { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--muted); font-size: 13px; font-weight: 800; color: var(--muted); flex: none; }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px 22px; margin-bottom: 14px; scroll-margin-top: 150px; transition: box-shadow .2s, opacity .2s, border-color .2s; box-shadow: var(--shadow); }
.q-card.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), var(--shadow); }
.q-card.recording { border-color: var(--speak); box-shadow: 0 0 0 3px color-mix(in srgb, var(--speak) 18%, transparent), var(--shadow); }
.q-card.locked { opacity: .5; }
.q-head { display: flex; align-items: center; gap: 10px; }
.q-head .lbl { font-weight: 700; color: var(--ink); }
.qnum { width: 30px; height: 30px; border-radius: 9px; font-size: 14px; }
.spk { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--line-2); display: inline-grid; place-items: center; background: var(--surface); color: var(--ink); vertical-align: middle; transition: .15s; flex: none; }
.spk svg { width: 16px; height: 16px; }
.spk:hover { border-color: var(--brand); color: var(--brand); }
.spk.playing { background: var(--listen); border-color: var(--listen); color: #fff; }
.q-body { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 12px; }
.avatar { width: 150px; height: 150px; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.q-text { font-size: 22px; color: var(--ink); text-align: center; line-height: 1.6; font-weight: 500; }
.q-text.left { text-align: left; width: 100%; }
.q-text .py, .q-text .vi, .q-text .qmeta { display: block; font-family: var(--ui); font-size: 14px; font-weight: 400; }
.q-text .py { color: var(--muted); } .q-text .vi { color: var(--brand); } [data-theme="dark"] .q-text .vi { color: var(--p1); }
.q-text .qmeta { color: var(--muted); font-size: 12.5px; margin-top: 4px; letter-spacing: .02em; }
.notes { width: 100%; min-height: 84px; border: 1.5px dashed var(--line-2); border-radius: var(--r-sm); padding: 10px 12px; font: 15px/1.6 var(--zh); background: var(--surface-2); color: var(--text); resize: vertical; }
.notes:focus { outline: none; border-color: var(--prep); border-style: solid; }
.status { font-size: 14.5px; color: var(--muted); text-align: center; min-height: 22px; }
.status b { color: var(--ink); }
.timebar { width: 100%; max-width: 440px; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.timebar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s linear; }
.timebar.rec i { background: var(--speak); } .timebar.prep i { background: var(--prep); }
.mic { width: 66px; height: 66px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 40%, transparent); transition: .15s; }
.mic:hover:not([disabled]) { transform: scale(1.05); }
.mic svg { width: 27px; height: 27px; }
.mic.sm { width: 42px; height: 42px; } .mic.sm svg { width: 18px; height: 18px; }
.mic.rec { background: var(--speak); animation: pulse 1.3s infinite; }
.mic[disabled] { background: var(--line-2); box-shadow: none; animation: none; color: var(--muted); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--speak) 50%, transparent); } 100% { box-shadow: 0 0 0 20px transparent; } }
.transcript { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 14px; font-size: 17px; min-height: 46px; color: var(--ink); }
.transcript .interim { color: var(--muted); }
.transcript:empty::before { content: attr(data-ph); color: var(--muted); font-family: var(--ui); font-size: 14px; }
.rec-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
audio { height: 38px; max-width: 100%; }
.warm-list { display: grid; gap: 6px; margin: 12px 0; }
.warm-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); font-size: 17px; border: 1px solid var(--line); }
.warm-row.on { border-color: var(--speak); background: color-mix(in srgb, var(--speak) 7%, var(--surface)); }
.warm-row.done { opacity: .5; }
.mode-real .ol-practice { display: none; }
.ol-practice { width: 100%; }

/* ---------- Part 2 pictures + outline ---------- */
.story { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.story figure { margin: 0; position: relative; aspect-ratio: 3 / 2; border-radius: 14px; overflow: hidden; background: var(--surface-3); box-shadow: var(--shadow); }
.story figure img, .story figure svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.story .badge { position: absolute; left: 8px; top: 8px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; font-size: 15px; display: grid; place-items: center; z-index: 1; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.story.small { max-width: 560px; }
.ph-wait { width: 100%; height: 100%; display: grid; align-content: center; gap: 4px; padding: 12px; text-align: center; color: var(--muted); font-size: 13px; }
.ph-wait .zh { color: var(--ink); font-size: 15px; }
.credit { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.credit a { text-decoration: underline dotted; }
.outline { width: 100%; margin-top: 10px; }
.outline summary { cursor: pointer; font-weight: 800; color: #7c3aed; font-size: 16px; margin-bottom: 8px; list-style: none; display: flex; align-items: center; gap: 6px; }
[data-theme="dark"] .outline summary { color: #b794f6; }
.outline summary::before { content: "▸"; transition: .15s; } .outline[open] summary::before { transform: rotate(90deg); }
.ol-row { display: grid; grid-template-columns: 68px 1fr; gap: 12px; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 12px 6px 6px; margin-bottom: 6px; background: var(--surface); text-align: left; }
.ol-tag { background: #7c3aed; color: #fff; border-radius: 8px; padding: 7px 0; text-align: center; font-weight: 700; font-size: 13.5px; }
.ol-tag.end { background: var(--accent); }
.ol-zh { font-size: 16.5px; font-weight: 700; color: var(--ink); }
.ol-vi { font-size: 13px; color: var(--muted); }

/* ---------- learn & bank ---------- */
.lesson-nav { position: sticky; top: 84px; padding: 16px; }
.lesson-list { display: grid; gap: 2px; max-height: calc(100vh - 170px); overflow: auto; margin: 0 -6px; padding: 0 6px; }
.lesson-link { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 8px 10px; border-radius: 12px; align-items: center; }
.lesson-link:hover { background: var(--surface-3); }
.lesson-link.active { background: var(--brand-soft); }
.lesson-link .n { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; font-size: 12.5px; font-weight: 800; }
.lesson-link.active .n { background: var(--accent); color: #fff; }
.lesson-link .zh { font-size: 15px; color: var(--ink); } .lesson-link small { display: block; font-size: 12px; color: var(--muted); }
.lesson-title { font-size: 28px; font-weight: 700; }
.table-wrap { overflow-x: auto; }
.vtable { width: 100%; border-collapse: collapse; }
.vtable th { font-size: 12.5px; color: var(--muted); font-weight: 600; text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--line); text-transform: uppercase; letter-spacing: .04em; }
.vtable td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 15px; vertical-align: top; }
.vtable tr:hover td { background: var(--surface-2); }
.vtable .h { font-size: 21px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.vtable .h:hover { color: var(--accent); }
.sent { display: grid; grid-template-columns: 40px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sent .sp { font-size: 13px; color: var(--accent); font-weight: 700; } .sent .z { font-size: 19px; color: var(--ink); }
.py { font-size: 14px; color: var(--muted); } .vi { font-size: 14px; color: var(--brand); } [data-theme="dark"] .vi { color: var(--p1); }
.no-py .py, .no-vi .vi { display: none !important; }
.gram { padding: 16px 0; border-bottom: 1px solid var(--line); }
.gram h4 { font-size: 19px; } .gram h4 .muted { font-size: 14px; font-weight: 500; }
.struct { display: inline-block; margin: 8px 0 4px; background: var(--brand-soft); color: var(--ink); padding: 5px 12px; border-radius: 10px; }
.text-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 0 4px; flex-wrap: wrap; }
.track { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.qa-list { display: grid; gap: 12px; margin-top: 12px; }
.qa { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.qa-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.qa-q { font-size: 18px; color: var(--ink); font-weight: 500; margin-top: 4px; }
.model-d { margin-top: 8px; }
.model-d summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: 14px; }
.model-zh { font-size: 17px; line-height: 1.85; color: var(--ink); margin-top: 6px; }

/* ---------- result ---------- */
.result-hero { display: grid; grid-template-columns: auto 1fr auto; gap: 24px; align-items: center; }
.ring { width: 130px; height: 130px; }
.ring-trk { fill: none; stroke: var(--line); stroke-width: 11; }
.ring-val { fill: none; stroke-width: 11; stroke-linecap: round; } .ring-val.ok { stroke: var(--ok); } .ring-val.warn { stroke: var(--warn); }
.ring-num { font: 800 30px var(--ui); fill: var(--ink); } .ring-of { font: 600 13px var(--ui); fill: var(--muted); }
.rh-body h2 { font-size: 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.res-parts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.res-part { border-radius: 14px; padding: 10px 14px; }
.res-part.p1 { background: var(--p1-soft); --c: var(--p1); } .res-part.p2 { background: var(--p2-soft); --c: var(--p2); } .res-part.p3 { background: var(--p3-soft); --c: var(--p3); }
.res-part b { font-size: 22px; color: var(--ink); }
.mini-bar { height: 5px; border-radius: 5px; background: color-mix(in srgb, var(--c) 20%, transparent); margin-top: 6px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--c); border-radius: 5px; }
.res-q { margin-top: 14px; }
.res-q .q-text { font-size: 19px; margin-top: 10px; }
.metrics { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.metric { background: var(--surface-3); border-radius: 10px; padding: 6px 12px; font-size: 13.5px; }
.metric b { color: var(--ink); } .metric.warn { background: var(--warn-soft); color: var(--warn); }
.model { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-top: 12px; }
.hl { background: var(--hl); border-radius: 3px; }
.wordchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.wc { padding: 3px 10px; border-radius: 999px; background: var(--surface-3); font-size: 14.5px; }
.wc.hit { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.self { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 14px; }
.self input[type=range] { width: 220px; accent-color: var(--accent); }

/* ---------- modal, forms, toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(10,14,25,.5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; width: min(600px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-card h3 { font-size: 20px; margin-bottom: 12px; }
.field { display: grid; gap: 5px; margin: 12px 0; font-size: 14.5px; }
.field.chk { grid-template-columns: auto 1fr; align-items: start; gap: 10px; }
.field.chk input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.field select, .field input[type=number] { font: inherit; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--line-2); background: var(--surface-2); color: var(--text); }
.field .seg { width: fit-content; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.adv { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.adv summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: 999px; z-index: 60; font-size: 14.5px; font-weight: 500; box-shadow: var(--shadow-lg); animation: up .2s ease-out; }
@keyframes up { from { transform: translate(-50%, 10px); opacity: 0; } }

/* exam in progress: calm the chrome */
body.exam-running .nav, body.exam-running .lang-sw { opacity: .35; pointer-events: none; }

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .layout, .layout.learn, .exam-grid { grid-template-columns: minmax(0, 1fr); }
  .side-col { min-width: 0; }
  .side-col, .lesson-nav { position: static; }
  .side-col { order: -1; }
  .side-col .part-mini { display: none; }
  .phase-bar { grid-template-columns: auto 1fr auto; }
  .phase-bar .steps { grid-column: 1 / -1; order: 3; }
  .result-hero { grid-template-columns: auto 1fr; } .result-hero .toggles { grid-column: 1 / -1; }
  .hero-seal { display: none; }
  .lesson-list { max-height: 240px; }
}
@media (max-width: 640px) {
  main { padding: 14px 14px 70px; }
  .topbar-in { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .logo-t small { display: none; }
  .nav { order: 3; width: 100%; justify-content: space-between; margin: 0; }
  .nav a { padding: 6px 10px; font-size: 14px; }
  .phase-bar { top: 104px; padding: 8px 12px; gap: 10px; }
  .q-card { scroll-margin-top: 220px; }
  .hero { padding: 24px 20px; } .hero h1 { font-size: 24px; }
  .card { padding: 16px; }
  .page-top { grid-template-columns: auto auto; } .page-top h1 { grid-column: 1 / -1; order: -1; font-size: 19px; }
  .story { grid-template-columns: 1fr; }
  .res-parts, .grid2 { grid-template-columns: 1fr; }
  .result-hero { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .banner-card { flex-direction: column; align-items: flex-start; }
  .track { grid-template-columns: 1fr auto; } .track b { grid-column: 1 / -1; }
  .tabs { width: 100%; }
  .step-line { width: 12px; }
}

/* ---------- grammar + writing practice ---------- */
.tiny { font-size: 12px; }
.gram-layout { grid-template-columns: 320px minmax(0, 1fr); }
.gram-nav { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.search { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); font: inherit; }
.glist { display: flex; flex-direction: column; gap: 2px; }
.glink { display: grid; grid-template-columns: 30px 1fr; column-gap: 8px; padding: 6px 8px; border-radius: 10px; }
.glink:hover { background: var(--surface-3); } .glink.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--accent); }
.glink .n { grid-row: span 2; font-size: 12px; font-weight: 700; color: var(--muted); align-self: center; text-align: center; }
.glink small { grid-column: 2; color: var(--muted); font-size: 12px; line-height: 1.3; }
.pchips { display: flex; flex-wrap: wrap; gap: 8px; }
.pchip { display: flex; flex-direction: column; align-items: center; min-width: 78px; padding: 8px 10px; border-radius: 12px; background: var(--surface-3); border: 1.5px solid transparent; transition: .15s; }
.pchip:hover { border-color: var(--brand); } .pchip b { font-size: 13.5px; } .pchip small { color: var(--muted); font-size: 12px; }
.pchip.part { background: var(--p2-soft); } .pchip.full { background: var(--ok-soft); }
.pbar { height: 5px; border-radius: 9px; background: var(--surface-3); overflow: hidden; margin: -4px 0 12px; } .pbar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.pitem .pi-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.pill.ty-mcq, .pill.ty-fill { background: var(--p1-soft); color: var(--p1); } .pill.ty-fix, .pill.ty-combine { background: var(--accent-soft); color: var(--accent); }
.pill.ty-order, .pill.ty-sentence { background: var(--p3-soft); color: var(--p3); } .pill.ty-para { background: var(--p2-soft); color: var(--p2); }
.gtag { font-size: 12.5px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); } .gtag:hover { color: var(--ink); border-color: var(--brand); }
.q-zh { font-size: 20px; line-height: 1.9; color: var(--ink); } .q-vi { font-size: 16px; font-weight: 600; color: var(--ink); }
.gap { color: var(--accent); font-weight: 700; }
.blank { width: 7.5em; padding: 2px 8px; margin: 0 3px; font-size: 18px; border: 0; border-bottom: 2px solid var(--brand); background: var(--brand-soft); border-radius: 6px 6px 0 0; color: var(--ink); text-align: center; }
.blank.good { border-color: var(--ok); background: var(--ok-soft); } .blank.bad { border-color: var(--speak); background: var(--accent-soft); }
.hint-row { margin: 8px 0; font-size: 14px; } .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: 6px; }
.src-box { margin: 10px 0; padding: 10px 14px; border-left: 3px solid var(--brand); background: var(--surface-2); border-radius: 0 10px 10px 0; font-size: 17px; }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.opt { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: 12px; background: var(--surface-2); border: 1.5px solid var(--line); text-align: left; font-size: 17px; transition: .12s; }
.opt b { width: 24px; height: 24px; border-radius: 7px; background: var(--surface-3); display: grid; place-items: center; font-size: 13px; flex: none; }
.opt:hover:not(:disabled) { border-color: var(--brand); } .opt.right { border-color: var(--ok); background: var(--ok-soft); } .opt.wrongc { border-color: var(--speak); background: var(--accent-soft); }
.opt:disabled { cursor: default; }
.built { min-height: 52px; padding: 8px; border-radius: 12px; border: 2px dashed var(--line-2); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.pieces { display: flex; flex-wrap: wrap; gap: 8px; }
.piece { padding: 8px 14px; border-radius: 10px; background: var(--surface-3); border: 1.5px solid var(--line-2); font-size: 17px; }
.piece:hover { border-color: var(--brand); } .piece.used { opacity: .3; pointer-events: none; } .piece.on { background: var(--brand-soft); border-color: var(--brand); }
textarea.ans { width: 100%; margin-top: 10px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface-2); color: var(--ink); font-size: 18px; line-height: 1.8; resize: vertical; }
textarea.ans:focus { outline: none; border-color: var(--brand); }
.meter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 13px; }
.schip { padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 12.5px; } .schip.ok { background: var(--ok-soft); color: var(--ok); }
.pi-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.pi-fb { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.fb { padding: 10px 14px; border-radius: 12px; font-weight: 600; } .fb.ok { background: var(--ok-soft); color: var(--ok); } .fb.bad { background: var(--accent-soft); color: var(--accent); }
.fb.mid { background: var(--p2-soft); color: var(--p2); } .fb.warn { background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.why { margin: 0; padding-left: 18px; font-size: 14px; } .why li { margin: 3px 0; } .expl { font-size: 14px; color: var(--text); }
.model-box { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.model-line { display: flex; gap: 10px; align-items: flex-start; } .model-line .z { font-size: 17px; color: var(--ink); }
.vi-block { font-size: 14px; }
.diff { font-size: 17px; line-height: 1.9; } .diff del { color: var(--speak); background: var(--accent-soft); text-decoration: line-through; } .diff ins { color: var(--ok); background: var(--ok-soft); text-decoration: none; font-weight: 700; }
.ai-box { border: 1.5px solid var(--brand-soft); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.ai-head { display: flex; align-items: center; gap: 10px; }
.ai-score { font-size: 26px; font-weight: 800; } .ai-score small { font-size: 13px; color: var(--muted); } .ai-score.ok { color: var(--ok); } .ai-score.mid { color: var(--p2); } .ai-score.bad { color: var(--speak); }
.ai-row { display: flex; flex-direction: column; gap: 4px; } .ai-row .btn { align-self: flex-start; }
.errs { margin: 0; padding-left: 18px; } .errs li { margin: 4px 0; display: flex; flex-direction: column; } .errs del { color: var(--speak); } .errs ins { color: var(--ok); text-decoration: none; font-weight: 700; }
.self { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-sb { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; } .row-c { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.center-card { text-align: center; } .big-score { font-size: 56px; font-weight: 800; color: var(--ink); } .big-score small { font-size: 22px; color: var(--muted); }
.sum-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.sum-dot { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-3); font-weight: 700; font-size: 13px; } .sum-dot.ok { background: var(--ok-soft); color: var(--ok); } .sum-dot.bad { background: var(--accent-soft); color: var(--accent); }
.plist { display: flex; flex-direction: column; gap: 6px; }
.prow { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.prow:hover { border-color: var(--brand); } .prow .st { font-weight: 700; font-size: 13px; } .prow .st.ok { color: var(--ok); } .prow .st.bad { color: var(--accent); }
.banner-inline { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; background: var(--brand-soft); margin-bottom: 14px; font-size: 14px; }
.gram h4 .btn { margin-left: 6px; vertical-align: middle; }
.outline-d { margin: 8px 0; font-size: 14px; } .outline-d summary { cursor: pointer; font-weight: 600; color: var(--brand); } .outline-d ol { margin: 6px 0 0; padding-left: 20px; }
@media (max-width: 1040px) { .gram-layout { grid-template-columns: minmax(0, 1fr); } .gram-nav { position: static; max-height: 340px; } }
@media (max-width: 640px) {
  .opts { grid-template-columns: 1fr; } .q-zh { font-size: 18px; }
  .nav { overflow-x: auto; justify-content: flex-start; } .nav a { padding: 6px 9px; font-size: 13.5px; white-space: nowrap; }
  .prow { flex-wrap: wrap; } .prow small { width: 100%; }
}
.nav { scrollbar-width: none; } .nav::-webkit-scrollbar { display: none; }
.frame-box { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.frame-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 4px; }
.fstep { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; font-weight: 600; }
.fstep i { width: 20px; height: 20px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-style: normal; font-size: 12px; }
.fstep.ok { background: var(--ok-soft); color: var(--ok); }
.farrow { color: var(--muted); font-size: 12px; }
.frame-tips { margin: 6px 0 0; padding-left: 18px; font-size: 14px; } .frame-tips li { margin: 3px 0; }

/* progress sync indicator (js/sync.js) */
.sync-info { font-size: 15px; color: var(--muted, #888); padding: 0 4px; cursor: default; user-select: none; }
.sync-info.ok { color: var(--ok, #2e9d5b); }
.sync-info.err { color: var(--warn, #d08a1c); }
