/* =========================================================
   Ôn thi UDCNTT Cơ bản – styles
   ========================================================= */

:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eef1f7;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #5b6475;
  --border: #e2e7f0;
  --border-strong: #cbd3e1;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --primary-border: #c7c9fb;
  --on-primary: #ffffff;

  --success: #047857;
  --success-bg: #ecfdf5;
  --success-border: #6ee7b7;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;
  --warn: #b45309;
  --warn-bg: #fffbeb;

  --explain-bg: #fbf8f1;
  --explain-border: #eadfc6;
  --explain-text: #3d3628;
  --explain-accent: #8a6d2f;

  --m1: #4f46e5;
  --m2: #0284c7;
  --m3: #2563eb;
  --m4: #059669;
  --m5: #ea580c;
  --m6: #db2777;

  --hero-1: #4f46e5;
  --hero-2: #7c3aed;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.18);
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;

  --font-ui: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-explain: "Lora", Georgia, "Times New Roman", serif;

  --header-h: 64px;
  --bottom-h: 68px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020;
    --surface: #121a2e;
    --surface-2: #172036;
    --surface-3: #1d2740;
    --text: #e8ecf5;
    --text-2: #c9d1e2;
    --muted: #97a3bb;
    --border: #243049;
    --border-strong: #33405c;
    --primary: #8b8ff8;
    --primary-hover: #a5a8fb;
    --primary-soft: #1f2453;
    --primary-border: #3c4290;
    --on-primary: #0b1020;
    --success: #34d399;
    --success-bg: #0d2a22;
    --success-border: #1f6b52;
    --danger: #f87171;
    --danger-bg: #2d1418;
    --danger-border: #7f2a33;
    --warn: #fbbf24;
    --warn-bg: #2b2210;
    --explain-bg: #1a1a16;
    --explain-border: #3a3526;
    --explain-text: #e6dcc4;
    --explain-accent: #d9b76a;
    --m1: #8b8ff8; --m2: #38bdf8; --m3: #60a5fa; --m4: #34d399; --m5: #fb923c; --m6: #f472b6;
    --hero-1: #3730a3;
    --hero-2: #6d28d9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #121a2e;
  --surface-2: #172036;
  --surface-3: #1d2740;
  --text: #e8ecf5;
  --text-2: #c9d1e2;
  --muted: #97a3bb;
  --border: #243049;
  --border-strong: #33405c;
  --primary: #8b8ff8;
  --primary-hover: #a5a8fb;
  --primary-soft: #1f2453;
  --primary-border: #3c4290;
  --on-primary: #0b1020;
  --success: #34d399;
  --success-bg: #0d2a22;
  --success-border: #1f6b52;
  --danger: #f87171;
  --danger-bg: #2d1418;
  --danger-border: #7f2a33;
  --warn: #fbbf24;
  --warn-bg: #2b2210;
  --explain-bg: #1a1a16;
  --explain-border: #3a3526;
  --explain-text: #e6dcc4;
  --explain-accent: #d9b76a;
  --m1: #8b8ff8; --m2: #38bdf8; --m3: #60a5fa; --m4: #34d399; --m5: #fb923c; --m6: #f472b6;
  --hero-1: #3730a3;
  --hero-2: #6d28d9;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

.ico { width: 20px; height: 20px; flex: none; }
.ico-sm { width: 16px; height: 16px; }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
@media (min-width: 768px) { .container { padding-left: 24px; padding-right: 24px; } }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  color: #fff; background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 1.02rem; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.brand-text small { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }

.tabs {
  display: inline-flex; gap: 4px; padding: 4px; margin-left: auto;
  background: var(--surface-3); border-radius: 999px; border: 1px solid var(--border);
}
.tab {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent;
  padding: 8px 16px; min-height: 40px; border-radius: 999px; font-weight: 600; font-size: 0.92rem; color: var(--muted);
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.tab .ico { width: 18px; height: 18px; }
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.tab.is-locked { opacity: .55; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; display: inline-grid; place-items: center; flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background-color .2s ease, border-color .2s ease;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ico-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .ico-moon { display: none; }
}

@media (max-width: 767px) {
  .header-inner { flex-wrap: wrap; gap: 8px 12px; padding-top: 8px; padding-bottom: 8px; }
  .brand { flex: 1; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tab { flex: 1; justify-content: center; padding: 8px 8px; font-size: .88rem; white-space: nowrap; gap: 6px; }
  .brand-text small { display: none; }
  html { scroll-padding-top: 132px; }
}
@media (max-width: 359px) { .tab .ico { display: none; } }

/* ---------- Layout ---------- */
.main { padding-top: 24px; padding-bottom: 40px; min-height: 70vh; }
.app-footer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); color: var(--muted); font-size: .82rem; text-align: center; }
body.has-bottom-bar .app-footer { padding-bottom: calc(var(--bottom-h) + 32px + env(safe-area-inset-bottom)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 20px;
}
@media (min-width: 768px) { .card { padding: 24px; } }
.card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1.05rem; font-weight: 700; }
.card-title .ico { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; font-size: .95rem; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .12s ease, box-shadow .2s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------- Home: hero ---------- */
.home-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) {
  .home-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); grid-template-rows: auto 1fr; align-items: start; }
  .home-side { grid-column: 2; grid-row: 1 / span 2; }
  .home-history { grid-column: 1; grid-row: 2; }
}

.hero {
  position: relative; overflow: hidden; border-radius: var(--radius-lg); color: #fff; padding: 24px;
  background: radial-gradient(120% 140% at 100% 0%, rgba(255,255,255,.18) 0%, rgba(255,255,255,0) 45%),
              linear-gradient(135deg, var(--hero-1), var(--hero-2));
  box-shadow: 0 18px 40px rgba(79, 70, 229, 0.28);
}
@media (min-width: 768px) { .hero { padding: 32px; } }
.hero::after {
  content: ""; position: absolute; right: -60px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255,255,255,.08); pointer-events: none;
}
.hero-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .9; }
.hero h1 { margin: 8px 0 10px; font-size: clamp(1.45rem, 3.6vw, 2.1rem); line-height: 1.2; letter-spacing: -0.02em; font-weight: 800; }
.hero p { margin: 0; opacity: .92; max-width: 56ch; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.22); }
.pill .ico { width: 16px; height: 16px; }

.cycle { position: relative; z-index: 1; margin-top: 22px; padding: 14px 16px; border-radius: 14px; background: rgba(15, 12, 60, .22); border: 1px solid rgba(255,255,255,.18); }
.cycle-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; font-size: .88rem; }
.cycle-head strong { font-size: 1rem; white-space: nowrap; }
.cycle-head span { opacity: .9; white-space: nowrap; }
.cycle-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.cycle-step { height: 8px; border-radius: 999px; background: rgba(255,255,255,.22); transition: background-color .3s ease; }
.cycle-step.done { background: rgba(255,255,255,.6); }
.cycle-step.current { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.cycle-note { margin-top: 10px; font-size: .8rem; opacity: .85; line-height: 1.45; }

.hero-actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero .btn-primary { background: #fff; color: #3730a3; box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.hero .btn-primary:hover { background: #f1f2ff; }
.hero .btn-outline { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.4); }
.hero .btn-outline:hover { background: rgba(255,255,255,.2); }
.hero .btn-ghost { color: rgba(255,255,255,.9); }
.hero .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
@media (max-width: 479px) {
  .hero-actions .btn { flex: 1 1 auto; }
  .hero-actions .btn-primary { flex-basis: 100%; }
}

/* composition */
.compo { display: grid; gap: 10px; margin-top: 4px; }
.compo-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.mod-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 52px; height: 28px; padding: 0 8px; border-radius: 8px;
  font-size: .76rem; font-weight: 800; letter-spacing: .02em;
  color: var(--mc, var(--primary)); background: color-mix(in srgb, var(--mc, var(--primary)) 13%, transparent);
}
.compo-name { font-weight: 600; font-size: .92rem; min-width: 0; }
.compo-ids { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.chip-id {
  font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.compo.animate .chip-id { animation: pop .38s cubic-bezier(.2,.8,.2,1) both; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.92); } to { opacity: 1; transform: none; } }

/* history */
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.history-score { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 58px; text-align: center; padding: 6px 8px; border-radius: 10px; }
.history-meta { font-size: .82rem; color: var(--muted); line-height: 1.35; }
.history-meta strong { color: var(--text); font-weight: 600; }
.history-pct { font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.lvl-good { color: var(--success); background: var(--success-bg); }
.lvl-mid { color: var(--warn); background: var(--warn-bg); }
.lvl-low { color: var(--danger); background: var(--danger-bg); }
.empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: 12px; font-size: .9rem; }
.side-stack { display: grid; gap: 20px; }

/* ---------- Exam layout ---------- */
.exam-layout { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .exam-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.exam-aside { display: none; }
@media (min-width: 1024px) {
  .exam-aside { display: grid; gap: 16px; position: sticky; top: calc(var(--header-h) + 20px); max-height: calc(100vh - var(--header-h) - 40px); overflow: auto; padding-bottom: 4px; }
}
.exam-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.exam-head h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
.exam-head .muted { font-size: .88rem; }

.mod-section + .mod-section { margin-top: 28px; }
.mod-header { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: .98rem; font-weight: 700; }
.mod-header .count { margin-left: auto; font-size: .8rem; font-weight: 600; color: var(--muted); }
.q-list { display: grid; gap: 14px; }

/* timer card */
.timer-card { text-align: center; }
.timer-label { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.timer-value { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 6px 0 10px; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 100%; background: var(--primary); border-radius: inherit; transform-origin: left; transition: transform 1s linear, background-color .3s ease; }
.is-warn .timer-value { color: var(--warn); }
.is-warn .progress > span { background: var(--warn); }
.is-danger .timer-value { color: var(--danger); animation: blink 1s steps(2, start) infinite; }
.is-danger .progress > span { background: var(--danger); }
@keyframes blink { 50% { opacity: .55; } }
.answered-line { display: flex; justify-content: space-between; margin: 14px 0 12px; font-size: .9rem; color: var(--muted); }
.answered-line strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* palette */
.palette { display: grid; gap: 8px; }
.palette-row { display: grid; grid-template-columns: 48px repeat(5, minmax(0, 1fr)); gap: 6px; align-items: center; }
.palette-row .mod-badge { min-width: 0; width: 100%; height: 26px; font-size: .68rem; padding: 0 4px; }
.pal {
  height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums; color: var(--text-2);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.pal:hover { border-color: var(--primary-border); }
.pal.answered { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.pal.correct { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.pal.wrong { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.pal.blank { background: var(--surface-3); color: var(--muted); border-style: dashed; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--border); }

/* ---------- Question card ---------- */
.q-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
@media (min-width: 768px) { .q-card { padding: 20px 22px; } }
.q-card.flash { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); }
.q-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.q-num {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 10px; display: inline-grid; place-items: center;
  font-weight: 800; font-size: .9rem; color: var(--primary); background: var(--primary-soft); font-variant-numeric: tabular-nums;
}
.q-ref { font-size: .8rem; font-weight: 600; color: var(--muted); }
.q-status { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.q-status .ico { width: 14px; height: 14px; }
.st-ok { color: var(--success); background: var(--success-bg); }
.st-no { color: var(--danger); background: var(--danger-bg); }
.st-blank { color: var(--muted); background: var(--surface-3); }
.q-text { margin: 0 0 14px; font-size: 1.04rem; font-weight: 600; line-height: 1.55; color: var(--text); }

.opts { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.opt {
  width: 100%; display: flex; align-items: flex-start; gap: 12px; text-align: left;
  padding: 11px 14px; min-height: 48px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  font-size: .97rem; line-height: 1.5; color: var(--text-2);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
button.opt:hover { background: var(--surface-2); border-color: var(--border-strong); }
.opt-letter {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 800; font-size: .85rem; background: var(--surface-3); color: var(--text-2);
  transition: background-color .15s ease, color .15s ease;
}
.opt-letter .ico { width: 16px; height: 16px; }
.opt-text { padding-top: 2px; min-width: 0; overflow-wrap: anywhere; }
.opt.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.opt.selected .opt-letter { background: var(--primary); color: var(--on-primary); }
.opt.correct { border-color: var(--success-border); background: var(--success-bg); color: var(--text); }
.opt.correct .opt-letter { background: var(--success); color: #fff; }
.opt.wrong { border-color: var(--danger-border); background: var(--danger-bg); color: var(--text); }
.opt.wrong .opt-letter { background: var(--danger); color: #fff; }
.opt.dim { opacity: .72; }
.opt-tag { margin-left: auto; flex: none; align-self: center; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.opt.correct .opt-tag { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.opt.wrong .opt-tag { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.opts.locked .opt { cursor: default; }

/* answer summary line */
.answer-line { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: .88rem; color: var(--muted); }
.answer-line b { color: var(--text); }
.answer-line .ok b { color: var(--success); }
.answer-line .no b { color: var(--danger); }

/* ---------- Explanation (font & size khác đáp án) ---------- */
.explain {
  margin-top: 14px; padding: 14px 16px; border-radius: 12px;
  background: var(--explain-bg); border: 1px solid var(--explain-border); border-left: 4px solid var(--explain-accent);
  font-family: var(--font-explain); font-size: .9rem; line-height: 1.6; color: var(--explain-text);
}
.explain-title {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
  font-family: var(--font-ui); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--explain-accent);
}
.explain-title .ico { width: 15px; height: 15px; }
.explain p { margin: 0; font-style: italic; }
.explain ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.explain li { font-style: normal; }
.ex-tag {
  display: inline-block; margin-right: 6px; padding: 0 7px; border-radius: 6px; font-family: var(--font-ui); font-style: normal;
  font-size: .72rem; font-weight: 800; line-height: 1.6; vertical-align: 1px;
}
.ex-ok { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.ex-no { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* ---------- Result ---------- */
.score-card { display: grid; gap: 18px; grid-template-columns: auto minmax(0, 1fr); align-items: center; }
@media (max-width: 479px) { .score-card { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; } }
.ring { position: relative; width: 132px; height: 132px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: var(--ring-c, var(--primary)); stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center strong { font-size: 1.9rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-center span { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.score-info h2 { margin: 0 0 4px; font-size: 1.35rem; letter-spacing: -0.01em; }
.score-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
@media (max-width: 479px) { .score-stats { justify-content: center; } }
.stat { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.stat .ico { width: 15px; height: 15px; }
.stat-time { background: var(--surface-3); color: var(--text-2); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 479px) { .result-actions { justify-content: center; } .result-actions .btn { flex: 1 1 140px; } }

.mod-bars { display: grid; gap: 10px; }
.mod-bar { display: grid; grid-template-columns: 52px minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: .85rem; }
.mod-bar .bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.mod-bar .bar span { display: block; height: 100%; border-radius: inherit; background: var(--mc, var(--primary)); }
.mod-bar b { text-align: right; font-variant-numeric: tabular-nums; }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 22px 0 14px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.fchip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: .88rem; font-weight: 600; color: var(--text-2);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.fchip:hover { border-color: var(--border-strong); }
.fchip .n { font-size: .75rem; font-weight: 700; padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-variant-numeric: tabular-nums; }
.fchip.is-active { background: var(--text); border-color: var(--text); color: var(--surface); }
.fchip.is-active .n { background: color-mix(in srgb, var(--surface) 22%, transparent); color: var(--surface); }
.fchip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mc, var(--primary)); }

/* ---------- Review (ngân hàng câu hỏi) ---------- */
#panel-review { max-width: 980px; margin: 0 auto; }
@media (min-width: 768px) { .mod-filters { flex-wrap: wrap; overflow: visible; } }
.review-toolbar {
  position: sticky; top: calc(var(--header-h) + 8px); z-index: 20; margin-bottom: 18px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px;
}
@media (max-width: 767px) { .review-toolbar { top: 118px; position: static; } }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search { position: relative; flex: 1 1 260px; min-width: 0; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input {
  width: 100%; min-height: 44px; padding: 10px 12px 10px 40px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 16px; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.switches { display: flex; gap: 8px; flex-wrap: wrap; }
.switch {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 14px 6px 8px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); font-size: .88rem; font-weight: 600; color: var(--text-2);
  transition: border-color .15s ease, background-color .15s ease;
}
.switch:hover { border-color: var(--border-strong); }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); transition: background-color .2s ease; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s ease; }
.switch[aria-checked="true"] { border-color: var(--primary-border); background: var(--primary-soft); color: var(--text); }
.switch[aria-checked="true"] .track { background: var(--primary); }
.switch[aria-checked="true"] .track::after { transform: translateX(16px); }
.toolbar-row + .toolbar-row { margin-top: 10px; }
.mod-filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.mod-filters::-webkit-scrollbar { display: none; }
.review-count { margin: 0 0 12px; font-size: .88rem; color: var(--muted); }
.review-mod-head { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.review-mod-head:first-child { margin-top: 0; }
.review-mod-head h3 { margin: 0; font-size: 1.02rem; }
.reveal-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .8rem; font-weight: 600;
}
.reveal-btn:hover { color: var(--text); border-color: var(--border-strong); }
.reveal-btn .ico { width: 15px; height: 15px; }
.answer-key { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: .88rem; font-weight: 700; color: var(--success); }
.answer-key .ico { width: 16px; height: 16px; }
mark { background: color-mix(in srgb, #facc15 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Bottom bar (mobile/tablet during exam) ---------- */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(15, 23, 42, .08);
  padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right));
}
@media (min-width: 1024px) { .bottom-bar { display: none !important; } }
.bb-inner { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; }
.bb-timer { display: flex; flex-direction: column; line-height: 1.1; min-width: 74px; }
.bb-timer strong { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.bb-timer span { font-size: .72rem; color: var(--muted); font-weight: 600; }
.bb-timer.is-warn strong { color: var(--warn); }
.bb-timer.is-danger strong { color: var(--danger); }
.bb-count { font-size: .85rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.bb-count b { color: var(--text); font-variant-numeric: tabular-nums; }
.bb-inner .spacer { flex: 1; }
.bb-inner .btn { min-height: 44px; }

/* ---------- Sheet & modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(8, 12, 28, .48); display: flex; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  margin-top: auto; width: 100%; max-height: 86vh; overflow: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg);
  animation: up .28s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-grip { width: 42px; height: 5px; border-radius: 999px; background: var(--border-strong); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-size: 1.05rem; }
.overlay.center { align-items: center; justify-content: center; padding: 16px; }
.modal {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 20px; padding: 22px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); animation: zoom .22s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes zoom { from { transform: scale(.96); opacity: 0; } }
.modal h3 { margin: 0 0 8px; font-size: 1.15rem; }
.modal p { margin: 0 0 18px; color: var(--text-2); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 140px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 80; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
body.has-bottom-bar .toast-root { bottom: calc(var(--bottom-h) + 20px + env(safe-area-inset-bottom)); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; font-size: .92rem; font-weight: 600;
  background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); animation: up .25s ease both;
}
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease; }

.to-top {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 30;
  width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; box-shadow: var(--shadow);
}
body.has-bottom-bar .to-top { bottom: calc(var(--bottom-h) + 24px + env(safe-area-inset-bottom)); }

.fade-in { animation: fadeUp .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .app-header, .bottom-bar, .to-top, .filters, .result-actions, .review-toolbar, .exam-aside { display: none !important; }
  body { background: #fff; }
  .q-card, .card { box-shadow: none; break-inside: avoid; }
}
