/* Student exam UI — minimal navy theme (default), light, and high contrast.
   All sizes are rem so the text-size setting (--fs) scales text and touch targets together. */
html { font-size: calc(16px * var(--fs, 1)); }
body { font-size: 1rem; }

:root[data-theme="navy"] {
  --bg: #0a182b; --surface: #0f2440; --surface-2: #15304f; --ink: #eef3fa; --ink-2: #b4c3d6; --ink-3: #93a7bf;
  --line: #ffffff26; --brand: #2f6fed; --brand-ink: #fff; --gold: #f5b942; --gold-soft: #f5b94226;
  --ok: #4ade80; --ok-soft: #4ade8024; --warn: #fbbf24; --warn-soft: #fbbf2424; --bad: #f87171; --bad-soft: #f8717124;
  --info: #93c5fd; --info-soft: #93c5fd22; --focus: #93c5fd; --shadow: 0 10px 30px #0006; color-scheme: dark;
}
:root[data-theme="contrast"] {
  --bg: #000; --surface: #000; --surface-2: #141414; --ink: #fff; --ink-2: #fff; --ink-3: #f0f0f0;
  --line: #fff; --brand: #ffd60a; --brand-ink: #000; --gold: #ffd60a; --gold-soft: #ffd60a33;
  --ok: #7CFF8A; --ok-soft: #003b0a; --warn: #ffd60a; --warn-soft: #332b00; --bad: #ff6b6b; --bad-soft: #3a0000;
  --info: #fff; --info-soft: #222; --focus: #ffd60a; --shadow: none; color-scheme: dark;
}
:root[data-theme="navy"] body { background: radial-gradient(900px 600px at 80% -10%, #1d4f8a55, transparent 60%), var(--bg); background-attachment: fixed; }
:root[data-theme="contrast"] .card, :root[data-theme="contrast"] .opt, :root[data-theme="contrast"] .btn { border-width: 2px; border-color: #fff; }
:root[data-theme="contrast"] a, :root[data-theme="contrast"] .stem strong { text-decoration: underline; }

.btn { font-size: 1rem; min-height: 2.9rem; border-radius: .8rem; }
.btn.sm { font-size: .875rem; min-height: 2.2rem; }
.card { border-radius: 1rem; }
.icon-btn { width: 2.75rem; height: 2.75rem; border-radius: .8rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg.ic { width: 1.3rem; height: 1.3rem; }
.icon-btn.on { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }

/* Entry screens */
.center-wrap { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: calc(1.5rem + var(--safe-t)) 1rem calc(1.5rem + var(--safe-b)); position: relative; }
.center-wrap input { min-width: 0; }
.corner { position: absolute; top: calc(.75rem + var(--safe-t)); inset-inline-start: 1rem; }
.panel { width: min(30rem, 100%); padding: 1.75rem 1.4rem; }
.brandmark { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--ink-2); }
.brandmark .dot { width: 2rem; height: 2rem; border-radius: .6rem; background: var(--brand); display: grid; place-items: center; color: var(--brand-ink); }
h1.big { font-size: 1.6rem; line-height: 1.25; margin: 1rem 0 .3rem; }
.code-input { font-size: 1.65rem !important; letter-spacing: .18em; text-align: center; text-transform: uppercase; font-weight: 700; font-family: ui-monospace, 'SF Mono', Menlo, monospace !important; direction: ltr; min-height: 3.5rem !important; }
.pin-input { font-size: 1.4rem !important; letter-spacing: .3em; text-align: center; font-weight: 700; direction: ltr; }
.err { color: var(--bad); font-weight: 600; min-height: 1.4em; }
.whoami { display: grid; place-items: center; text-align: center; gap: .25rem; padding: 1.1rem; border-radius: 1rem; background: var(--surface-2); margin: 1rem 0; }
.whoami .avatar { width: 4rem; height: 4rem; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 1.5rem; font-weight: 700; }
.whoami .name { font-size: 1.35rem; font-weight: 700; }
.checklist { list-style: none; padding: 0; margin: .9rem 0; display: grid; gap: .6rem; }
.checklist li { display: flex; gap: .6rem; align-items: flex-start; }
.checklist .ico { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; background: var(--surface-2); }
.big-ic svg.ic { width: 3.2rem; height: 3.2rem; }
.lowvision { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; border-radius: .9rem; background: var(--surface-2); cursor: pointer; font-weight: 600; }
.lowvision svg.ic { width: 1.4rem; height: 1.4rem; flex: none; }

/* Switch */
.switch { position: relative; width: 3.2rem; height: 1.8rem; flex: none; margin-inline-start: auto; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: .2rem; inset-inline-start: .2rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { inset-inline-start: 1.6rem; }
.switch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Exam shell: header, navigation and footer never scroll away */
.shell { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
html:has(.shell), html:has(.shell) body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.shell > * { flex: none; }
.xbar { display: flex; align-items: center; gap: .75rem; padding: calc(.6rem + var(--safe-t)) 1rem .5rem; }
.xbar .ttl { flex: 1; min-width: 0; text-align: center; }
.xbar .ttl b { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xbar .ttl small { color: var(--ink-3); font-size: .78rem; }
.qnav { margin: 0 1rem; padding: .55rem .75rem .6rem; }
.qnav .lbl { font-size: .75rem; color: var(--ink-3); margin-bottom: .35rem; display: flex; gap: .5rem; }
.qnav .dots { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; padding: .15rem .1rem .25rem; }
.qnav .dots::-webkit-scrollbar { display: none; }
.qd { flex: none; width: 1.9rem; height: 1.9rem; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; color: var(--ink-2); font-size: .78rem; font-weight: 700; cursor: pointer; position: relative; font-variant-numeric: tabular-nums; padding: 0; }
.qd.done { background: var(--surface-2); border-color: var(--brand); color: var(--ink); }
.qd.cur { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.qd.flagged::after { content: ''; position: absolute; top: -.15rem; inset-inline-end: -.15rem; width: .6rem; height: .6rem; border-radius: 50%; background: var(--gold); border: 2px solid var(--bg); }
.qd-sep { flex: none; width: 1px; background: var(--line); margin: .2rem .15rem; }
.ctl { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem .2rem; }
.timer { display: inline-flex; align-items: center; gap: .4rem; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; padding: .3rem .8rem; border-radius: .7rem; background: var(--surface); border: 1px solid var(--line); direction: ltr; }
.timer.warn { color: var(--warn); border-color: var(--warn); }
.timer.bad { color: var(--bad); border-color: var(--bad); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.savestate { font-size: .78rem; font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.savestate.ok { color: var(--ok); } .savestate.busy { color: var(--ink-2); } .savestate.off { color: var(--warn); } .savestate.err { color: var(--bad); }
.prog { padding: .35rem 1rem .5rem; font-size: .8rem; color: var(--ink-3); }
.prog .row { justify-content: space-between; margin-bottom: .3rem; }
.prog .track { height: .3rem; border-radius: 99px; background: var(--surface-2); position: relative; }
.prog .track i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 99px; background: var(--brand); }
.prog .track i::after { content: ''; position: absolute; inset-inline-end: -.35rem; top: 50%; width: .7rem; height: .7rem; margin-top: -.35rem; border-radius: 50%; background: var(--ink); }

.exam-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.exam-main { max-width: 52rem; margin: 0 auto; padding: .5rem 1rem 1.5rem; display: grid; gap: .9rem; }
.split { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.split .pane { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.passage-pane { flex: 0 0 44%; margin: .25rem 1rem .5rem; padding: 1rem 1.1rem; line-height: 1.8; background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; }
.passage-pane h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.passage-pane p { margin: 0 0 .75rem; }
.q-pane { flex: 1 1 auto; padding: 0 1rem 1.25rem; display: grid; gap: .9rem; align-content: start; }
@media (min-width: 920px) {
  .split { flex-direction: row; padding: .25rem 1rem 0; gap: 1rem; }
  .passage-pane { flex: 0 0 50%; margin: 0 0 1rem; }
  .q-pane { padding: 0 0 1.25rem; }
}

.qcard { padding: 1.1rem 1.1rem 1.2rem; }
.qhead { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: .4rem; }
.qhead .qno { font-weight: 700; font-size: .95rem; }
.qhead .qsec { display: block; color: var(--ink-3); font-size: .75rem; font-weight: 500; }
.group-label { font-size: .8rem; font-weight: 700; color: var(--gold); margin-bottom: .4rem; }
.stem { font-size: 1.15rem; line-height: 1.55; font-weight: 600; margin: .2rem 0 .8rem; }
.extra { padding: .75rem .9rem; background: var(--surface-2); border-radius: .7rem; font-style: italic; margin-bottom: .9rem; line-height: 1.6; }
.opts { display: grid; gap: .55rem; margin: 0; padding: 0; list-style: none; }
.opt { display: flex; align-items: center; gap: .8rem; padding: .75rem .9rem; border-radius: .8rem; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; transition: border-color .12s, background .12s; min-height: 3.2rem; line-height: 1.45; }
.opt:hover { border-color: var(--ink-3); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .radio { flex: none; width: 1.15rem; height: 1.15rem; border-radius: 50%; border: 2px solid var(--ink-3); position: relative; }
.opt.sel { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 16%, var(--surface)); }
.opt.sel .radio { border-color: var(--brand); }
.opt.sel .radio::after { content: ''; position: absolute; inset: .17rem; border-radius: 50%; background: var(--brand); }
:root[data-theme="contrast"] .opt.sel { background: var(--brand); color: #000; }
:root[data-theme="contrast"] .opt.sel .radio { border-color: #000; } :root[data-theme="contrast"] .opt.sel .radio::after { background: #000; }
.opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.textans { font-size: 1.1rem; }

.audio-bar { display: flex; align-items: center; gap: .75rem; margin: .25rem 1rem .5rem; padding: .55rem .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; }
.playbtn { width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); cursor: pointer; flex: none; display: grid; place-items: center; }
.playbtn:disabled { opacity: .45; cursor: not-allowed; }
.audio-mid { flex: 1; min-width: 0; display: grid; gap: .2rem; }
.audio-mid .tiny { font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: .35rem; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s linear; }
.plays { display: flex; gap: .3rem; }
.plays i { width: .65rem; height: .65rem; border-radius: 50%; background: var(--brand); }
.plays i.used { background: var(--line); }

.bottombar { background: transparent; border-top: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.navrow { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; max-width: 52rem; margin: 0 auto; }
.navrow .btn { width: 100%; }

.banner { margin: .25rem 1rem; padding: .6rem .9rem; font-weight: 600; font-size: .9rem; text-align: center; border-radius: .8rem; display: flex; gap: .5rem; align-items: center; justify-content: center; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--info-soft); color: var(--info); }

/* Submit dialog (reference: icon, counts, Continue / Submit) */
.modal-back { background: #020a14b3; }
.modal { border-radius: 1.2rem; }
.sub-dialog { text-align: center; }
.sub-dialog .warn-ic { width: 3.2rem; height: 3.2rem; border-radius: 50%; margin: 0 auto .6rem; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); border: 2px solid var(--warn); }
.sub-dialog .warn-ic svg.ic { width: 1.6rem; height: 1.6rem; }
.sub-dialog h3 { font-size: 1.25rem; margin: 0 0 .3rem; }
.sub-dialog .miss { color: var(--bad); font-weight: 700; }
.sub-dialog .jump { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin: .8rem 0 .2rem; }
.sub-dialog .actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1rem; }

/* Settings sheet */
.set-row { display: grid; gap: .45rem; margin-top: 1rem; }
.set-row > label, .set-row > .lbl { font-weight: 700; font-size: .95rem; margin: 0; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .3rem; padding: .3rem; border-radius: .9rem; background: var(--surface-2); }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: .6rem .4rem; border-radius: .65rem; font-weight: 600; cursor: pointer; font-size: .95rem; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }

.result-big { font-size: 3.5rem; font-weight: 800; color: var(--brand); line-height: 1; font-variant-numeric: tabular-nums; direction: ltr; }
.sec-res { display: grid; gap: .6rem; text-align: start; margin-top: 1rem; }
.sec-res .row { justify-content: space-between; }

/* Timed announcements: on-screen callout that fades out */
.callout { position: fixed; z-index: 160; bottom: calc(5.5rem + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; gap: .75rem; align-items: center;
  width: min(32rem, calc(100vw - 2rem)); padding: 1rem 1.25rem; border-radius: 1rem; background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow);
  font-size: 1.1rem; font-weight: 700; animation: calloutIn .3s ease-out; transition: opacity .5s, transform .5s; }
.callout svg.ic { width: 1.75rem; height: 1.75rem; }
.callout.out { opacity: 0; transform: translate(-50%, 10px); }
@keyframes calloutIn { from { opacity: 0; transform: translate(-50%, 12px); } }

/* Light theme: darker secondary text and gold so small text passes 4.5:1 */
:root[data-theme="light"] { --ink-3: #56636b; --gold: #84600f; --line: #b9b2a1; }
.voice-stop { position: fixed; z-index: 170; top: calc(.75rem + var(--safe-t)); left: 50%; transform: translateX(-50%); background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
