/* Thi thử: exam home, runner (timer bar, navigator grid), results (score ring, bars, review), mock defense.
   Colors only via tokens (dark mode follows). Every state carries text or an icon, never color alone. */

/* ---------- header link + home CTA ---------- */
.hdr-exam { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: 15px; font-weight: 700;
  background: var(--c-primary); color: var(--c-primary-ink); text-decoration: none; border: 1px solid var(--c-primary); }
.hdr-exam:hover { filter: brightness(1.06); }
@media (max-width: 640px) { .hdr-exam { padding: 4px 9px; } .hdr-exam .t { display: none; } }
@media (max-width: 380px) { .hdr-exam { padding: 4px 7px; } }

.exam-cta { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; margin-top: 20px; padding: 18px 22px; border-radius: 18px; text-decoration: none; color: var(--c-text);
  background: linear-gradient(120deg, var(--c-primary-soft), color-mix(in srgb, var(--c-energy) 16%, var(--c-surface))); border: 2px solid var(--c-primary); box-shadow: var(--shadow); }
.exam-cta:hover { box-shadow: var(--shadow-lg); }
.exam-cta-icon { font-size: 40px; }
.exam-cta strong { display: block; font-size: 20px; }
.exam-cta small { color: var(--c-muted); font-size: 15px; }
.exam-cta .btn { pointer-events: none; }
@media (max-width: 560px) { .exam-cta { grid-template-columns: auto 1fr; padding: 16px; } .exam-cta .btn { grid-column: 1 / -1; width: 100%; } .exam-cta-icon { font-size: 32px; } }

/* ---------- exam home ---------- */
.exam-hero { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 20px; padding: 24px 28px; box-shadow: var(--shadow);
  background-image: radial-gradient(circle at 100% 0, var(--c-primary-soft), transparent 60%); }
.exam-hero h1 { font-size: clamp(28px, 5vw, 38px); }
.exam-hero .lead { margin: 0; max-width: 620px; }
@media (max-width: 640px) { .exam-hero { grid-template-columns: 1fr; padding: 20px; } .exam-hero-art { display: none; } }
.exam-resume { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 16px; padding: 14px 18px; border-radius: var(--radius); background: var(--c-warn-bg); border: 2px solid var(--c-warn); }
.exam-resume > div { flex: 1; min-width: 200px; }
.exam-resume p { margin: 0; color: var(--c-text); }
.exam-resume-icon { font-size: 28px; }
.exam-modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.exam-mode { display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: 16px; background: var(--c-surface); border: 1px solid var(--c-border); box-shadow: var(--shadow); color: var(--c-text); text-decoration: none; }
a.exam-mode:hover { border-color: var(--c-primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
a.exam-mode { transition: transform .15s, box-shadow .15s; }
.exam-mode.featured { border: 2px solid var(--c-primary); background-image: linear-gradient(160deg, var(--c-primary-soft), transparent 55%); }
.exam-mode h2 { font-size: 20px; margin: 4px 0 0; }
.exam-mode p { color: var(--c-muted); font-size: 15px; margin: 0; }
.exam-mode-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.exam-mode-icon { font-size: 30px; }
.exam-mode-go { margin-top: auto; padding-top: 8px; font-weight: 700; color: var(--c-primary); }
.exam-unit-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.exam-unit-pick .chip { min-height: 40px; padding: 0 10px; font-size: 14px; border-left: 4px solid var(--unit); }
.exam-hist-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.exam-trend { margin: 0 0 14px; padding: 14px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); }
.exam-trend svg { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; }
.exam-trend figcaption, .exam-bars figcaption { font-size: 13px; color: var(--c-muted); text-align: center; margin-top: 6px; }
.exam-hist-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.exam-hist-list li { margin: 0; }
.exam-hist-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-radius: var(--radius); background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text); text-decoration: none; min-height: 56px; }
.exam-hist-row:hover { border-color: var(--c-primary); }
.xh-score { font-weight: 700; font-size: 18px; text-align: center; border-radius: 10px; padding: 6px 0; background: var(--c-surface-2); }
.xh-score.xb-good { background: var(--c-success-bg); color: var(--c-success); }
.xh-score.xb-mid { background: var(--c-warn-bg); color: var(--c-warn); }
.xh-score.xb-low { background: var(--c-danger-bg); color: var(--c-danger); }
.xh-main strong { display: block; }
.xh-main small { color: var(--c-muted); }
.xh-go { font-size: 24px; color: var(--c-muted); }

/* ---------- charts (SVG classes) ---------- */
.xb-chart { display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto; }
.xb-label, .xb-val { fill: var(--c-text); }
.xb-track { fill: var(--c-surface-2); stroke: var(--c-border); }
.xb-good .xb-fill { fill: var(--c-success); }
.xb-mid .xb-fill { fill: var(--c-energy); }
.xb-low .xb-fill { fill: var(--c-danger); }
.xb-goal { stroke: var(--c-muted); stroke-width: 1.5; }
.xb-goal-t, .xt-axis { fill: var(--c-muted); }
.xt-grid { stroke: var(--c-border); stroke-width: 1; }
.xt-line { stroke: var(--c-primary); stroke-width: 3; stroke-linejoin: round; }
.xt-dot { stroke: var(--c-surface); stroke-width: 2; }
.xt-dot.xb-good { fill: var(--c-success); } .xt-dot.xb-mid { fill: var(--c-energy); } .xt-dot.xb-low { fill: var(--c-danger); }
.xt-last { fill: var(--c-text); }
.xr-bg { stroke: var(--c-surface-2); }
.xr-fg { stroke: var(--c-primary); transition: stroke-dasharray .8s ease; }
.xr-ring.xb-good .xr-fg { stroke: var(--c-success); }
.xr-ring.xb-mid .xr-fg { stroke: var(--c-energy); }
.xr-ring.xb-low .xr-fg { stroke: var(--c-danger); }
.xr-text { fill: var(--c-text); font-family: inherit; }

/* ---------- intro (exam + defense) ---------- */
.exam-intro { max-width: var(--content); margin: 0 auto; text-align: center; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); }
.exam-intro-badge { display: inline-grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; font-size: 42px; background: var(--c-primary-soft); margin-bottom: 8px; }
.exam-intro-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.exam-rules { list-style: none; padding: 0; margin: 18px auto; max-width: 520px; text-align: left; display: grid; gap: 10px; }
.exam-rules li { display: grid; grid-template-columns: 36px 1fr; gap: 8px; align-items: start; margin: 0; }
.exam-rule-icon { font-size: 22px; text-align: center; }
.exam-cover { margin: 8px 0 4px; }
.exam-cover-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.exam-conflict { background: var(--c-warn-bg); border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 12px; }
.exam-unit-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 18px; }
.exam-unit-card { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: var(--c-surface); border: 1px solid var(--c-border); border-left: 6px solid var(--unit); color: var(--c-text); text-decoration: none; min-height: 60px; }
.exam-unit-card:hover { border-color: var(--c-primary); border-left-color: var(--unit); }
.exam-unit-card small { display: block; color: var(--c-muted); font-weight: 600; }
.exam-unit-icon { font-size: 26px; }

/* ---------- runner ---------- */
.page.exam-run { max-width: var(--wide); padding-top: 0; padding-bottom: 80px; }
.exam-bar { position: sticky; top: var(--header-h); z-index: 30; margin: 0 -16px 16px; background: color-mix(in srgb, var(--c-surface) 95%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--c-border); }
.exam-bar-inner { display: flex; align-items: center; gap: 10px; padding: 8px 16px; max-width: var(--wide); margin: 0 auto; }
.exam-bar-title { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-clock { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-family: var(--mono); font-weight: 700; font-size: 18px; background: var(--c-surface-2); border: 2px solid var(--c-border); min-height: 38px; }
.exam-clock.warn { background: var(--c-warn-bg); border-color: var(--c-warn); }
.exam-clock.danger { background: var(--c-danger-bg); border-color: var(--c-danger); color: var(--c-danger); animation: tickPulse 1s ease infinite; }
@keyframes tickPulse { 50% { transform: scale(1.05); } }
.reduce-motion .exam-clock.danger { animation: none; }
.exam-count { font-weight: 700; color: var(--c-muted); white-space: nowrap; }
.exam-timebar { height: 4px; background: var(--c-surface-2); }
.exam-timebar > div { height: 100%; background: var(--c-primary); transition: width 1s linear; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.exam-main { min-width: 0; }
.exam-qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.exam-qhead > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.exam-qtitle { font-size: 24px; margin: 0; }
.exam-flag.on { background: var(--c-warn-bg); border-color: var(--c-warn); }
.exam-stage .ex { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 16px; box-shadow: var(--shadow); padding: 20px; }
.exam-qnav { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.exam-nav { position: sticky; top: calc(var(--header-h) + 70px); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.exam-nav h2 { font-size: 17px; margin-bottom: 8px; }
.exam-legend { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--c-muted); }
.exam-legend li { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.exam-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.exam-cell { position: relative; display: grid; place-items: center; width: 100%; min-height: 44px; border-radius: 10px; border: 2px solid var(--c-border); background: var(--c-surface); color: var(--c-text); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; }
.exam-cell:hover { border-color: var(--c-primary); }
.exam-cell.answered { background: var(--c-primary-soft); border-color: var(--c-primary); }
.exam-cell.flagged::after { content: "🚩"; position: absolute; top: -8px; right: -6px; font-size: 13px; }
.exam-cell.current { outline: 3px solid var(--c-text); outline-offset: 1px; }
.exam-cell.sample { display: inline-block; width: 18px; min-height: 18px; height: 18px; border-radius: 5px; cursor: default; }
.exam-cell.sample.flagged::after { top: -9px; right: -9px; font-size: 11px; }
.exam-nav-stats { font-size: 14px; color: var(--c-muted); margin: 10px 0; }
.exam-nav-submit { width: 100%; }
.exam-nav-toggle { display: none; }
@media (max-width: 960px) {
  .exam-layout { grid-template-columns: minmax(0, 1fr); }
  .exam-nav { display: none; position: fixed; z-index: 35; left: 8px; right: 8px; top: calc(var(--header-h) + 58px); max-height: calc(100vh - var(--header-h) - 74px); overflow: auto; box-shadow: var(--shadow-lg); }
  .exam-nav.open { display: block; }
  .exam-nav-toggle { display: inline-flex; }
  .exam-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 560px) {
  .exam-bar-title { display: none; }
  .exam-bar-inner { gap: 6px; padding: 8px 12px; justify-content: space-between; }
  .exam-bar { margin: 0 -16px 12px; }
  .exam-clock { font-size: 16px; padding: 4px 8px; }
  .exam-count { font-size: 14px; }
  .exam-stage .ex { padding: 14px; border-radius: 12px; }
  .exam-grid { grid-template-columns: repeat(5, 1fr); }
  .exam-qnav .btn { flex: 1; padding: 0 12px; }
  .exam-count, .exam-nav-toggle { min-width: 0; }
}
/* Phones: the question title already says "Câu n" and the ☰ toggle shows n/N, so drop the counter to keep
   clock + toggle + "Nộp bài" inside the 16px gutter even with two-digit counts. */
@media (max-width: 420px) {
  .exam-count { display: none; }
  .exam-bar-inner { gap: 6px; }
  .exam-bar-inner .btn.sm { padding-left: 10px; padding-right: 10px; }
}

/* ---------- results ---------- */
.page.exam-result { max-width: var(--content); }
.exam-score { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.exam-score .complete-actions { grid-column: 1 / -1; justify-content: flex-start; margin-top: 4px; }
.exam-score h1 { margin-bottom: 4px; }
.exam-score-big { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.exam-score .lead { font-size: 17px; margin-bottom: 8px; }
.exam-score-pills { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 560px) { .exam-score { grid-template-columns: 1fr; text-align: center; padding: 20px 16px; } .exam-score-ring { justify-self: center; } .exam-score-pills, .exam-score .complete-actions { justify-content: center; } }
.exam-units, .exam-weak-sec, .exam-review-sec { margin-top: 28px; }
.exam-bars { margin: 0; padding: 14px; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); }
.exam-weak-list { display: grid; gap: 10px; }
.exam-weak { background: var(--c-surface); border: 1px solid var(--c-border); border-left: 6px solid var(--c-energy); border-radius: var(--radius); padding: 14px 16px; }
.exam-weak.xb-low { border-left-color: var(--c-danger); }
.exam-weak-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.exam-weak-head small { display: block; color: var(--c-muted); }
.exam-weak-icon { font-size: 26px; }
.exam-weak-lessons { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.exam-weak-lessons li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.exam-weak-lessons a { font-weight: 600; }
.exam-allgood, .exam-note { margin-top: 20px; padding: 14px 16px; border-radius: var(--radius); background: var(--c-success-bg); }
.exam-note { background: var(--c-surface-2); }
.exam-review { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.exam-review > li { margin: 0; }
/* Grid items default to min-width:auto, so a long code line in a reviewed predict question widened the page. */
.exam-review > li { min-width: 0; }
.exam-rv { min-width: 0; background: var(--c-surface); border: 1px solid var(--c-border); border-left: 6px solid var(--c-success); border-radius: var(--radius); }
.exam-rv.rv-bad { border-left-color: var(--c-danger); }
.exam-rv > summary { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 12px 14px; cursor: pointer; list-style: none; min-height: 52px; }
.exam-rv > summary::-webkit-details-marker { display: none; }
.exam-rv > summary:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; border-radius: var(--radius); }
.rv-mark { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 4px; border-radius: 8px; font-weight: 700; background: var(--c-success-bg); color: var(--c-success); }
.rv-bad .rv-mark { background: var(--c-danger-bg); color: var(--c-danger); }
.rv-num { font-weight: 700; white-space: nowrap; }
.rv-prompt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-muted); }
.exam-rv[open] .rv-prompt { white-space: normal; color: var(--c-text); }
.rv-body { padding: 0 14px 14px; }
.rv-body .ex { border-top: 1px solid var(--c-border); padding-top: 12px; }
.rv-body .ex-prompt { display: none; }
.rv-body .order-btns, .rv-body .order-handle, .rv-body .order .ex-sub, .rv-body .match .ex-sub, .rv-body .unpair { display: none !important; }
.exam-weak-more { margin-top: 10px; }
.exam-weak-more > summary { cursor: pointer; font-weight: 700; color: var(--c-primary); min-height: 44px; display: flex; align-items: center; }
.rv-skipped { margin: 4px 0 8px; font-weight: 600; color: var(--c-muted); }
.rv-correct { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--c-surface-2); }
.rv-correct p { margin: 0 0 6px; overflow-wrap: anywhere; }
.rv-correct .ok { color: var(--c-success); font-weight: 600; }
.rv-correct .bad { color: var(--c-danger); font-weight: 600; }
.rv-correct-view { margin-top: 10px; }
.rv-lesson { margin: 10px 0 0; font-weight: 600; }
.rv-notes { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--c-surface-2); margin-bottom: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .exam-rv > summary { grid-template-columns: auto minmax(0, 1fr) auto; }
  .exam-rv > summary .rv-prompt { grid-column: 1 / -1; grid-row: 2; }
  .exam-rv > summary .tag { display: none; }
}

/* ---------- mock defense ---------- */
.def-panel-art svg, .def-panel svg { display: block; width: 100%; max-width: 360px; height: auto; margin: 0 auto; }
.def-table { fill: color-mix(in srgb, var(--u-amber) 30%, var(--c-surface-2)); stroke: var(--c-border); }
.def-head-c { fill: color-mix(in srgb, var(--u-orange) 25%, var(--c-surface)); stroke: var(--c-text); stroke-width: 2; }
.def-eye { fill: var(--c-text); }
.def-mouth { fill: none; stroke: var(--c-text); stroke-width: 2.5; stroke-linecap: round; }
.def-body { fill: var(--c-surface-2); stroke: var(--c-text); stroke-width: 2; }
.def-plate { fill: var(--c-surface); stroke: var(--c-border); }
.def-plate-t { fill: var(--c-text); font-weight: 700; }
.def-halo { fill: var(--c-primary-soft); stroke: var(--c-primary); stroke-width: 3; }
.def-judge.on .def-body { fill: var(--c-primary-soft); stroke: var(--c-primary); }
.def-judge.on .def-halo { animation: halo 1.6s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes halo { 50% { transform: scale(1.08); } }
.reduce-motion .def-judge.on .def-halo { animation: none; }
.def-time { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; margin-bottom: 8px; }
.def-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0 12px; }
.def-head .practice-progress { flex-basis: 100%; margin: 0; }
.def-bubble { position: relative; background: var(--c-surface); border: 2px solid var(--c-primary); border-radius: 18px; padding: 16px 18px; margin: 10px 0 16px; box-shadow: var(--shadow); }
.def-bubble::before { content: ""; position: absolute; top: -12px; left: 50%; margin-left: -10px; border: 10px solid transparent; border-top: 0; border-bottom-color: var(--c-primary); }
.def-bubble.follow { border-color: var(--c-streak); margin-top: 16px; }
.def-bubble.follow::before { border-bottom-color: var(--c-streak); }
.def-who { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); margin-bottom: 4px; }
.def-q { font-size: 21px; margin: 0; line-height: 1.4; }
.def-fq { font-size: 18px; font-weight: 600; margin: 0; }
.def-answer { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 16px; padding: 18px; }
.def-timer { display: grid; place-items: center; }
.def-ring-fg { stroke: var(--c-primary); transition: stroke-dasharray .25s linear; }
.def-timer.danger .def-ring-fg { stroke: var(--c-danger); }
.def-say { margin-bottom: 8px; }
.def-notes { width: 100%; resize: vertical; min-height: 80px; }
.def-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
@media (max-width: 560px) { .def-answer { grid-template-columns: 1fr; justify-items: center; padding: 14px; } .def-answer-side { width: 100%; } .def-actions .btn { width: 100%; } .def-q { font-size: 19px; } }
.def-timeup { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--c-warn-bg); font-weight: 600; }
.def-points { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.def-points li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 2px solid var(--c-border); border-radius: 12px; background: var(--c-surface); margin: 0; }
.def-points li:has(input:checked) { border-color: var(--c-success); background: var(--c-success-bg); }
.def-points input { width: 22px; height: 22px; margin-top: 3px; accent-color: var(--c-success); flex: none; }
.def-points label { cursor: pointer; flex: 1; }
.def-points.readonly li.on { border-color: var(--c-success); background: var(--c-success-bg); }
.def-score { font-weight: 700; font-size: 18px; }
.def-follow-btn { margin-top: 8px; border-color: var(--c-streak); }
.def-follow-t { display: inline-block; font-family: var(--mono); font-weight: 700; margin-right: 10px; }
.def-follow-ans { margin-top: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--c-surface-2); }
