/* ==========================================================================
   ExamDesk — interface styles
   Palette: exam-board green on a cool, quiet paper. One loud element: the
   exam timer. Typeface: Atkinson Hyperlegible (built for legibility under
   pressure) with Newsreader for headings and certificates.
   ========================================================================== */
:root {
  --ink: #18212b;
  --ink-soft: #4a5560;
  --paper: #ffffff;
  --wash: #f1f4f2;
  --line: #d6ddd9;
  --primary: #1f5c4a;
  --primary-dark: #164536;
  --primary-tint: #e3eee9;
  --amber: #b7791f;
  --amber-tint: #fbf1e0;
  --bad: #a8322d;
  --bad-tint: #f8e5e3;
  --ok: #2c7a4b;
  --ok-tint: #e2f1e8;
  --info: #2b5d8a;
  --info-tint: #e4edf6;
  --radius-sm: 6px;
  --radius: 10px;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --shadow: 0 1px 2px rgba(24, 33, 43, .06), 0 4px 16px rgba(24, 33, 43, .05);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.55 var(--font); color: var(--ink); background: var(--wash);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.005em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.12rem; }
p { margin: 0 0 1em; max-width: 72ch; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid #7fb8a3; outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; gap: 1rem; justify-content: space-between; align-items: center; flex-wrap: wrap; }

/* ---------- Admin shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--primary-dark); color: #dfe9e4; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.3rem; font-weight: 600; color: inherit; text-decoration: none; padding: 4px 10px 22px; }
.brand-mark { width: 22px; height: 22px; border: 3px solid currentColor; border-radius: 50%; position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 7px; top: 1px; width: 3px; height: 9px; background: currentColor; transform-origin: bottom; transform: rotate(40deg); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: #dfe9e4; text-decoration: none; padding: 9px 12px; border-radius: var(--radius-sm); }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.on { background: #fff; color: var(--primary-dark); font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(255,255,255,.15); display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.sidebar-foot span { opacity: .75; margin-bottom: 6px; }
.sidebar-foot a, .sidebar-foot .linklike { color: #dfe9e4; }
.shell-main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: 18px 32px; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 1.45rem; flex: 1; }
.topbar-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.content { padding: 28px 32px 48px; max-width: 1280px; width: 100%; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 12px; font: inherit; color: inherit; cursor: pointer; }

/* ---------- Student bar ---------- */
.student-bar { display: flex; align-items: center; gap: 1rem; padding: 0 24px; background: var(--paper); border-bottom: 1px solid var(--line); min-height: 64px; flex-wrap: wrap; }
.student-bar .brand { padding: 0; color: var(--primary-dark); }
.student-bar nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.student-bar nav a { text-decoration: none; color: var(--ink); padding: 8px 12px; border-radius: var(--radius-sm); }
.student-bar nav a.on { background: var(--primary-tint); color: var(--primary-dark); font-weight: 700; }
.student-bar nav form { margin-left: 8px; }
.page { max-width: 1080px; margin: 0 auto; padding: 32px 24px 56px; }
.page-title { font-size: 2rem; margin-bottom: 1.2rem; }

/* ---------- Panels ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.panel + .panel { margin-top: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Stat row: plain figures separated by rules, not cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 24px; }
.stat { padding: 18px 22px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat b { display: block; font-family: var(--serif); font-size: 2rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-soft); font-size: .92rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data th, .data td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data th { font-weight: 700; color: var(--ink-soft); font-size: .86rem; background: #fafbfa; white-space: nowrap; }
.data tbody tr:hover { background: #f8faf9; }
.data td.actions { white-space: nowrap; text-align: right; }
.data td.actions form { display: inline; }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.empty p { margin: 0 auto 1rem; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .95rem; }
.hint { display: block; font-weight: 400; color: var(--ink-soft); font-size: .86rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel],
input[type=datetime-local], input[type=date], input[type=search], input[type=file], select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--paper);
  border: 1px solid #b9c3be; border-radius: var(--radius-sm); padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 3px solid rgba(31,92,74,.18); outline-offset: 0; }
.field { margin-bottom: 18px; }
.field-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--primary); flex: none; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters > * { flex: 1 1 160px; }
.filters .btn { flex: 0 0 auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 6px; margin: 0 0 18px; }
legend { font-weight: 700; padding: 0 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
  padding: 9px 18px; border-radius: var(--radius-sm); border: 1px solid var(--primary);
  background: var(--primary); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: background-color .15s;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-quiet { background: var(--paper); color: var(--primary-dark); border-color: #b9c3be; }
.btn-quiet:hover { background: var(--primary-tint); color: var(--primary-dark); }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: #8a2824; }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: .88rem; }
.btn-lg { min-height: 52px; padding: 12px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); text-decoration: underline; cursor: pointer; text-align: left; }
.linklike.danger { color: var(--bad); }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-tint); color: var(--ok); }
.badge-bad { background: var(--bad-tint); color: var(--bad); }
.badge-warn { background: var(--amber-tint); color: #8a5a12; }
.badge-info { background: var(--info-tint); color: var(--info); }
.badge-muted { background: #eceeed; color: var(--ink-soft); }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border-left: 4px solid; background: var(--paper); }
.alert-success { border-color: var(--ok); background: var(--ok-tint); }
.alert-danger { border-color: var(--bad); background: var(--bad-tint); }
.alert-warning { border-color: var(--amber); background: var(--amber-tint); }
.alert-info { border-color: var(--info); background: var(--info-tint); }

.pager { display: flex; gap: 4px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.pager a, .pager span.current { min-width: 36px; text-align: center; padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); text-decoration: none; background: var(--paper); }
.pager span.current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager-total { margin-left: 10px; color: var(--ink-soft); font-size: .9rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
dl.facts dt { color: var(--ink-soft); }
dl.facts dd { margin: 0; font-weight: 700; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(24,33,43,.55); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 1000; }
.modal.open { display: flex; }
.modal-box { background: var(--paper); border-radius: var(--radius); max-width: 480px; width: 100%; padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-box h2 { margin-bottom: .4em; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--radius-sm); z-index: 1100; max-width: calc(100% - 32px); }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr minmax(320px, 460px); }
.auth-side { background: var(--primary-dark); color: #e6efea; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { color: #fff; padding: 0; }
.auth-side h1 { font-size: clamp(2rem, 3.4vw, 3rem); color: #fff; max-width: 14ch; font-weight: 500; }
.auth-side p { color: #c9d9d1; }
.auth-form { background: var(--paper); padding: 56px 44px; display: flex; flex-direction: column; justify-content: center; }
.auth-form h2 { font-size: 1.6rem; }
.auth-switch { margin-top: 24px; font-size: .93rem; color: var(--ink-soft); }

/* Landing */
.landing { max-width: 960px; margin: 0 auto; padding: 72px 24px; }
.landing h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 500; max-width: 16ch; margin-bottom: .4em; }
.landing .lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 52ch; }
.landing-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 40px; }
.landing-actions a { display: block; padding: 22px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); text-decoration: none; color: var(--ink); }
.landing-actions a:hover { border-color: var(--primary); }
.landing-actions strong { display: block; font-family: var(--serif); font-size: 1.25rem; color: var(--primary-dark); margin-bottom: 4px; }

/* ---------- Student exam list ---------- */
.exam-list { display: flex; flex-direction: column; gap: 14px; }
.exam-item { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 18px 22px; }
.exam-item.blocked { border-left-color: #b9c3be; }
.exam-item h2 { font-size: 1.2rem; margin: 0 0 4px; }
.exam-meta { display: flex; gap: 6px 18px; flex-wrap: wrap; color: var(--ink-soft); font-size: .92rem; }
.exam-item .why { font-size: .9rem; color: var(--ink-soft); margin-top: 6px; }

/* ---------- Pre-exam check ---------- */
.precheck { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: start; }
.cam-frame { aspect-ratio: 4 / 3; background: #0f1a16; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; color: #c9d9d1; text-align: center; position: relative; }
.cam-frame video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-frame .cam-msg { position: absolute; padding: 20px; }
.checklist { list-style: none; padding: 0; margin: 0 0 18px; }
.checklist li { padding: 8px 0 8px 30px; position: relative; border-bottom: 1px solid var(--line); }
.checklist li::before { content: ""; position: absolute; left: 4px; top: 14px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #b9c3be; }
.checklist li.done::before { background: var(--ok); border-color: var(--ok); }
.checklist li.fail::before { background: var(--bad); border-color: var(--bad); }
.instructions { white-space: pre-line; }

/* ---------- Exam room ---------- */
body.exam-room { background: #e9eeeb; user-select: none; -webkit-user-select: none; }
.exam-top {
  position: sticky; top: 0; z-index: 50; display: grid; grid-template-columns: 1fr auto auto; gap: 18px; align-items: center;
  background: var(--paper); border-bottom: 1px solid var(--line); padding: 10px 20px;
}
.exam-top h1 { font-size: 1.1rem; margin: 0; }
.exam-top .who { font-size: .88rem; color: var(--ink-soft); }
/* The timer is the one loud element */
.timer { font-family: var(--serif); font-size: 2.1rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; line-height: 1; padding: 6px 16px; border-radius: var(--radius-sm); background: var(--primary-tint); color: var(--primary-dark); min-width: 7.2ch; text-align: center; }
.timer.warn { background: var(--amber-tint); color: #8a5a12; }
.timer.danger { background: var(--bad); color: #fff; animation: pulse 1s steps(2) infinite; }
@keyframes pulse { 50% { opacity: .82; } }
.cam-pip { width: 120px; aspect-ratio: 4/3; border-radius: var(--radius-sm); overflow: hidden; background: #0f1a16; position: relative; }
.cam-pip video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-pip .rec { position: absolute; left: 6px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: #e04a3f; box-shadow: 0 0 0 2px rgba(255,255,255,.7); }

.exam-body { display: grid; grid-template-columns: 1fr 280px; gap: 20px; max-width: 1200px; margin: 0 auto; padding: 22px 20px 120px; }
.q-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 30px; min-height: 360px; }
.q-head { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-soft); font-size: .92rem; margin-bottom: 14px; flex-wrap: wrap; }
.q-text { font-size: 1.2rem; line-height: 1.55; margin-bottom: 22px; white-space: pre-wrap; max-width: 70ch; }
.q-hint { font-size: .9rem; color: var(--ink-soft); margin: -10px 0 14px; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-weight: 400; margin: 0; background: var(--paper); }
.opt:hover { border-color: #9fb4ab; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .key { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid #9fb4ab; display: grid; place-items: center; font-weight: 700; color: var(--ink-soft); }
.opt.multi .key { border-radius: 6px; }
.opt.sel { border-color: var(--primary); background: var(--primary-tint); }
.opt.sel .key { background: var(--primary); border-color: var(--primary); color: #fff; }
.opt:has(input:focus-visible) { outline: 3px solid #7fb8a3; outline-offset: 2px; }
.q-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.save-state { font-size: .86rem; color: var(--ink-soft); min-height: 1.2em; }
.save-state.err { color: var(--bad); font-weight: 700; }

.palette { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; position: sticky; top: 92px; }
.palette h2 { font-size: 1rem; font-family: var(--font); font-weight: 700; margin-bottom: 12px; }
.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.pal-grid button { aspect-ratio: 1; border: 1.5px solid var(--line); background: var(--paper); border-radius: var(--radius-sm); font: inherit; font-weight: 700; cursor: pointer; color: var(--ink); font-variant-numeric: tabular-nums; position: relative; }
.pal-grid button.answered { background: var(--primary); border-color: var(--primary); color: #fff; }
.pal-grid button.review::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.pal-grid button.current { outline: 3px solid var(--ink); outline-offset: 1px; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; color: var(--ink-soft); margin: 14px 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; border: 1.5px solid var(--line); }
.legend i.a { background: var(--primary); border-color: var(--primary); }
.legend i.r { background: var(--amber); border-color: var(--amber); border-radius: 50%; }
.violations { font-size: .86rem; padding: 8px 10px; border-radius: var(--radius-sm); background: #f3f4f3; margin-bottom: 12px; }
.violations.hot { background: var(--bad-tint); color: var(--bad); font-weight: 700; }

/* Face warning: sticks under the exam header while it applies */
.face-alert { position: sticky; top: 66px; z-index: 45; max-width: 1200px; margin: 12px auto 0; padding: 14px 18px;
  background: var(--bad); color: #fff; border-radius: var(--radius-sm); display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: baseline;
  box-shadow: 0 6px 20px rgba(168, 50, 45, .35); }
.face-alert[hidden] { display: none; }
.face-alert strong { font-size: 1.05rem; }
.cam-pip.no-face { outline: 3px solid var(--bad); outline-offset: 2px; }
.exam-body .face-alert ~ * { scroll-margin-top: 140px; }
@media (max-width: 720px) { .face-alert { top: 58px; margin: 8px 10px 0; } }

/* Full-screen blockers in the exam room */
.blocker { position: fixed; inset: 0; background: rgba(15, 26, 22, .94); color: #e6efea; z-index: 900; display: none; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.blocker.open { display: flex; }
.blocker > div { max-width: 460px; }
.blocker h2 { color: #fff; font-size: 1.6rem; }
.blocker p { color: #c9d9d1; margin-left: auto; margin-right: auto; }
.blocker .btn { background: #fff; color: var(--primary-dark); border-color: #fff; }

/* ---------- Result ---------- */
.verdict { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; }
.verdict-figure { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; text-align: center; border: 10px solid var(--ok-tint); }
.verdict-figure.fail { border-color: var(--bad-tint); }
.verdict-figure b { font-family: var(--serif); font-size: 2.3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.verdict h2 { font-size: 2rem; margin-bottom: .2em; }
.verdict.pass h2 { color: var(--ok); } .verdict.fail h2 { color: var(--bad); }

.recordings { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.recordings video { width: 100%; aspect-ratio: 4/3; background: #0f1a16; border-radius: var(--radius-sm); display: block; }
.recordings figcaption { font-size: .85rem; color: var(--ink-soft); margin-top: 4px; }
.recordings figure { margin: 0; }
.snapshots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.snapshots figure { margin: 0; font-size: .8rem; color: var(--ink-soft); }
.snapshots img { width: 100%; border-radius: var(--radius-sm); display: block; aspect-ratio: 4/3; object-fit: cover; background: #ddd; }
.answer-review .opt-line { padding: 4px 0 4px 26px; position: relative; }
.answer-review .opt-line.correct { color: var(--ok); font-weight: 700; }
.answer-review .opt-line.chosen-wrong { color: var(--bad); text-decoration: line-through; }
.answer-review .opt-line::before { content: "○"; position: absolute; left: 4px; }
.answer-review .opt-line.chosen::before { content: "●"; }
.q-review { padding: 16px 0; border-bottom: 1px solid var(--line); }

.option-rows .opt-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin-bottom: 10px; }
.option-rows .opt-row label { margin: 0; font-weight: 400; display: flex; gap: 6px; align-items: center; white-space: nowrap; font-size: .9rem; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 200; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .menu-btn { display: inline-block; }
  .topbar { padding: 14px 18px; flex-wrap: wrap; }
  .content { padding: 20px 16px 40px; }
  .grid-2, .grid-3, .precheck { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 32px 24px; }
  .auth-side h1 { font-size: 1.9rem; }
  .auth-form { padding: 32px 24px; }
  .exam-body { grid-template-columns: 1fr; padding-bottom: 60px; }
  .palette { position: static; order: -1; }
}
@media (max-width: 720px) {
  .student-bar { padding: 10px 16px; }
  .student-bar .menu-btn { margin-left: auto; }
  .student-bar nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 10px; }
  .student-bar nav.open { display: flex; }
  .student-bar nav form { margin: 6px 12px; }
  .page { padding: 22px 16px 40px; }
  .page-title { font-size: 1.6rem; }
  .exam-item { grid-template-columns: 1fr; }
  .exam-top { grid-template-columns: 1fr auto; padding: 8px 12px; gap: 10px; }
  .exam-top .cam-pip { position: fixed; right: 10px; bottom: 10px; width: 96px; z-index: 60; box-shadow: var(--shadow); }
  .timer { font-size: 1.6rem; padding: 6px 10px; }
  .q-card { padding: 20px 16px; }
  .q-text { font-size: 1.08rem; }
  .verdict { grid-template-columns: 1fr; justify-items: start; }
  .stat { border-left: 0; border-top: 1px solid var(--line); }
  .stat:first-child { border-top: 0; }
  .data { font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .student-bar, .no-print { display: none !important; }
  body { background: #fff; }
}

/* Password fields: eye button to show / hide */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 48px !important; }
.pw-wrap input::-ms-reveal, .pw-wrap input::-ms-clear { display: none; }
.pw-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: #4b5563; cursor: pointer; padding: 0; }
.pw-toggle:hover { background: rgba(0, 0, 0, .06); color: #111827; }
.pw-toggle:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 1px; }
.pw-toggle .pw-off { display: none; }
.pw-toggle[aria-pressed="true"] .pw-eye { display: none; }
.pw-toggle[aria-pressed="true"] .pw-off { display: inline; }

/* ===================== Quizzes ===================== */
[hidden] { display: none !important; }
.badge-practice { background: #efe7fb; color: #5b2b80; margin-left: 6px; vertical-align: middle; font-family: inherit; font-size: .74rem; }
.badge-live { background: #fff1d6; color: #8a5a12; margin-left: 6px; vertical-align: middle; font-family: inherit; font-size: .74rem; }
.alert-live { background: #fff7e6; border: 1px solid #f3d08a; color: #6b4a10; }
.row-highlight td { background: #fffbea; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Practice: instant feedback */
.practice-check { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.practice-feedback { font-weight: 700; }
.practice-feedback.ok { color: var(--ok); }
.practice-feedback.bad { color: var(--bad); }
.opts .opt.ok { border-color: var(--ok); background: var(--ok-tint); }
.opts .opt.bad { border-color: var(--bad); background: var(--bad-tint); }
.opts .opt input:disabled { cursor: default; }

/* Live quiz: shared */
.live-big { font-size: clamp(1.6rem, 3.5vw, 2.4rem); margin: 8px 0; }
.live-qbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--ink-soft); font-weight: 700; flex-wrap: wrap; }
.live-timer { font-size: 1.6rem; color: var(--primary-dark); min-width: 4ch; text-align: center; }
.live-timer.low { color: var(--bad); }
.live-qtext { font-size: clamp(1.3rem, 2.6vw, 1.9rem); margin: 14px 0 18px; line-height: 1.3; }
.live-board ol { list-style: none; margin: 0; padding: 0; counter-reset: rank; display: grid; gap: 6px; }
.live-board li { counter-increment: rank; display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: #f4f6f5; }
.live-board li::before { content: counter(rank); font-weight: 700; width: 1.6em; color: var(--ink-soft); }
.live-board li:nth-child(1)::before { content: "🥇"; } .live-board li:nth-child(2)::before { content: "🥈"; } .live-board li:nth-child(3)::before { content: "🥉"; }
.live-board li.me { background: var(--primary-tint); outline: 2px solid var(--primary); }
.live-board .who { flex: 1; } .live-board .pts { font-weight: 700; }
.live-err { color: var(--bad); font-weight: 700; margin: 8px 0 0; min-height: 1em; }
.live-thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #dfe4e2; display: inline-grid; place-items: center; font-size: .65rem; color: var(--ink-soft); margin-right: 4px; vertical-align: middle; }

/* Live quiz: host */
.live-host { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.live-host .panel + .panel { margin-top: 0; }
.live-join { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-radius: 12px; background: var(--primary-tint); margin-bottom: 18px; }
.live-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700; letter-spacing: .18em; color: var(--primary-dark); }
.live-opts { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.live-opts li { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-radius: 12px; color: #fff; font-size: 1.1rem; font-weight: 700; }
.live-opts li:nth-child(4n+1) { background: #c0392b; } .live-opts li:nth-child(4n+2) { background: #2f6fb0; }
.live-opts li:nth-child(4n+3) { background: #b7861b; } .live-opts li:nth-child(4n+4) { background: #2e8b57; }
.live-opts li.dim { opacity: .35; }
.live-opts li.ok { outline: 4px solid #111; outline-offset: 2px; }
.live-opts .key { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: rgba(255, 255, 255, .25); flex: none; }
.live-opts .t { flex: 1; } .live-opts .n { font-size: .95rem; background: rgba(0, 0, 0, .2); padding: 2px 10px; border-radius: 999px; }
.live-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.live-players ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; max-height: 60vh; overflow: auto; }
.live-players li { display: flex; align-items: center; gap: 8px; }
.live-players .dot { width: 9px; height: 9px; border-radius: 50%; background: #b9c3be; flex: none; } .live-players .dot.on { background: var(--ok); }
.live-players .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .live-players .pts { font-weight: 700; }

/* Live quiz: student */
.live-entry { max-width: 620px; }
.live-code-form { display: flex; gap: 10px; margin: 14px 0 6px; }
.live-code-form input { flex: 1; font-size: 1.5rem; letter-spacing: .2em; text-transform: uppercase; text-align: center; font-weight: 700; min-height: 52px; }
.live-open { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.live-open li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.live-play { max-width: 820px; margin: 0 auto; }
.live-preview { width: min(420px, 100%); aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: #1d2421; margin: 14px 0; }
.live-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.live-me { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: space-between; color: var(--ink-soft); margin-bottom: 8px; }
.live-me video { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; background: #1d2421; transform: scaleX(-1); }
.live-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.live-opt { display: flex; align-items: center; gap: 12px; text-align: left; padding: 18px; min-height: 72px; border-radius: 12px; border: 3px solid transparent; color: #fff; font-family: inherit; font-size: 1.05rem; font-weight: 700; line-height: 1.3; cursor: pointer; }
.live-opt:nth-child(4n+1) { background: #c0392b; } .live-opt:nth-child(4n+2) { background: #2f6fb0; }
.live-opt:nth-child(4n+3) { background: #b7861b; } .live-opt:nth-child(4n+4) { background: #2e8b57; }
.live-opt .key { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: rgba(255, 255, 255, .25); flex: none; }
.live-opt.picked { border-color: #111; box-shadow: 0 0 0 3px #fff inset; }
.live-opt:disabled { cursor: default; opacity: .55; }
.live-opt:disabled.picked, .live-opt.ok { opacity: 1; }
.live-opt.ok { border-color: #111; box-shadow: 0 0 0 4px #fff inset; } .live-opt.ok::after { content: "✓"; margin-left: auto; font-size: 1.4rem; }
.live-opt.bad::after { content: "✕"; margin-left: auto; font-size: 1.4rem; }
.live-feedback { font-size: 1.2rem; font-weight: 700; margin: 16px 0 0; min-height: 1.4em; }
.live-feedback.ok { color: var(--ok); } .live-feedback.bad { color: var(--bad); }
#p-submit { margin-top: 14px; }
@media (max-width: 900px) { .live-host { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .live-opts, .live-answers { grid-template-columns: 1fr; } .live-code-form { flex-direction: column; } }
