/* Shared styles for every IAUA exam screen. Big type, big targets, works from 360 px. */
:root {
  --ink: #17212f;
  --muted: #55606e;
  --line: #c3cad4;
  --bg: #f4f6f9;
  --card: #ffffff;
  --brand: #1f4e79;
  --brand-ink: #ffffff;
  --ok: #1b6e3a;
  --ok-bg: #e3f4e8;
  --warn: #8a5300;
  --warn-bg: #fff1d6;
  --bad: #a4161a;
  --bad-bg: #fde4e4;
  --focus: #ffbf00;
  --radius: 12px;
  font-size: 18px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; outline: none; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 8px 0 16px; }
h2 { font-size: 1.25rem; line-height: 1.3; }
p { margin: 0 0 12px; }
.lead { font-size: 1.3rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 16px; margin-bottom: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons and inputs */
button, .btn {
  font: inherit; min-height: 52px; padding: 10px 20px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--brand); background: var(--card); color: var(--brand); font-weight: 600;
}
button.primary { background: var(--brand); color: var(--brand-ink); }
button.big { width: 100%; font-size: 1.15rem; min-height: 60px; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
input[type=number], textarea { font: inherit; width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 80px; }
label.field { display: block; font-weight: 600; margin-bottom: 14px; }
label.field input, label.field textarea { margin-top: 6px; font-weight: 400; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

/* Status chips: colour AND icon/label, never colour alone */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.chip.ok { color: var(--ok); background: var(--ok-bg); }
.chip.warn { color: var(--warn); background: var(--warn-bg); }
.chip.bad { color: var(--bad); background: var(--bad-bg); }
.chip.info { color: var(--brand); background: #e5eef7; }

/* Messages */
.msg { border-radius: var(--radius); padding: 16px; margin: 12px 0; border-left: 6px solid; }
.msg.warn { background: var(--warn-bg); border-color: var(--warn); }
.msg.bad { background: var(--bad-bg); border-color: var(--bad); }
.msg.ok { background: var(--ok-bg); border-color: var(--ok); }
.spinner { display: inline-block; width: 1em; height: 1em; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Exam top bar */
.bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.bar .navbtn { min-height: 48px; padding: 6px 12px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.pause { margin: 0; border-radius: 0; font-size: 1.1rem; }
.urgent { flex-basis: calc(100% + 24px); margin: 4px -12px -8px; background: var(--bad); color: #fff; text-align: center; padding: 10px 12px; font-size: 1rem; font-weight: 700; }
.urgent .clock { font-size: 2rem; font-variant-numeric: tabular-nums; display: block; }

/* Agreements */
.agree { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 12px; cursor: pointer; }
.agree input { width: 28px; height: 28px; flex: none; margin-top: 2px; accent-color: var(--brand); }
.agree:has(input:checked) { border-color: var(--ok); background: var(--ok-bg); }

/* Question screen */
.qnum { color: var(--muted); font-weight: 600; margin: 4px 0 8px; }
.stem { font-size: 1.25rem; font-weight: 600; margin: 0 0 16px; white-space: pre-line; }
.qimg { display: block; padding: 0; border: 1px solid var(--line); background: #fff; margin: 0 0 6px; width: 100%; min-height: 0; }
.qimg img { display: block; max-width: 100%; max-height: 50vh; margin: 0 auto; }
.options { border: 0; padding: 0; margin: 16px 0; }
.opt { position: relative; display: flex; gap: 14px; align-items: center; min-height: 60px; padding: 12px 16px; margin-bottom: 10px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); cursor: pointer; }
.opt input { position: absolute; opacity: 0; }
.opt .letter { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--brand); display: grid; place-items: center; font-weight: 700; color: var(--brand); }
.opt:has(input:checked) { border-color: var(--brand); background: #e5eef7; }
.opt:has(input:checked) .letter { background: var(--brand); color: #fff; }
.opt:has(input:focus-visible) { outline: 4px solid var(--focus); outline-offset: 2px; }
.toggles { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 20px; }
.toggles > div { flex: 1 1 220px; }
.toggle { width: 100%; text-align: left; border-color: var(--line); color: var(--ink); font-weight: 600; }
.toggle[aria-pressed=true] { border-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.toggle .hint { display: block; font-weight: 400; }
.prevnext { display: flex; gap: 12px; }
.prevnext button { flex: 1; }

/* Navigator grid: answered = filled + check, blank = dashed outline, flagged = flag badge */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; margin: 12px 0; }
.cell { position: relative; min-height: 52px; padding: 0; border-radius: 8px; border: 2px dashed var(--muted); background: #fff; color: var(--ink); font-weight: 700; }
.cell.answered { border-style: solid; border-color: var(--brand); background: var(--brand); color: #fff; }
.cell.answered::after { content: "✓"; position: absolute; bottom: 1px; right: 4px; font-size: .7rem; }
.cell.flagged::before { content: "⚑"; position: absolute; top: -9px; right: -7px; width: 22px; height: 22px; border-radius: 50%; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); font-size: .8rem; line-height: 20px; }
.cell.current { box-shadow: 0 0 0 3px var(--focus); }
.legend { display: flex; flex-wrap: wrap; gap: 14px 16px; padding-top: 8px !important; font-size: .9rem; color: var(--muted); margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .cell { min-height: 28px; width: 34px; font-size: .75rem; pointer-events: none; }
.legend .cell.flagged::before { top: -7px; right: -7px; width: 18px; height: 18px; line-height: 16px; font-size: .65rem; }

dialog { border: 0; border-radius: var(--radius); padding: 16px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
dialog .dlg-head h2 { margin: 0; }
#zoomDlg { width: calc(100vw - 16px); max-width: none; padding: 8px; }
#zoomDlg { overflow: auto; }
#zoomDlg .dlg-head { position: sticky; top: -8px; left: 0; background: #fff; padding: 4px 0; }
#zoomDlg img { display: block; width: auto; min-width: 100%; max-width: none; height: auto; } /* natural size: wider than a phone, so it scrolls */

/* Admin tables/cards */
dl.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 12px 0; }
dl.settings dt { color: var(--muted); font-size: .9rem; }
dl.settings dd { margin: 0; font-size: 1.5rem; font-weight: 700; }
#app:focus, #app:focus-visible { outline: none; }

/* Chips you can tap for the explanation (js/chips.js) */
button.chip-btn { min-height: 0; padding: 4px 10px; font-size: .85rem; border-width: 1px; }
.chip-btn.ok { color: var(--ok); background: var(--ok-bg); }
.chip-btn.warn { color: var(--warn); background: var(--warn-bg); }
.chip-btn.bad { color: var(--bad); background: var(--bad-bg); }
.chip-btn.info { color: var(--brand); background: #e5eef7; }
.chip-pop { position: absolute; z-index: 20; max-width: min(320px, calc(100vw - 16px)); padding: 10px 12px; border-radius: 10px; background: var(--ink); color: #fff; font-size: .95rem; box-shadow: 0 4px 16px rgb(0 0 0 / .3); }

/* Admin pages: wider, with a roster that becomes cards on narrow screens */
main.wide { max-width: 1040px; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.head h1 { margin: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
input[type=text], input[type=search], select { font: inherit; width: 100%; min-height: 52px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
label.field select, label.field input[type=text] { margin-top: 6px; font-weight: 400; }
table.roster { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.roster th { text-align: left; font-size: .85rem; color: var(--muted); padding: 8px 12px; border-bottom: 2px solid var(--line); }
table.roster td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.group h3 { margin: 0 0 8px; display: flex; gap: 10px; align-items: center; }
.count { font-weight: 700; }
@media (max-width: 700px) {
  table.roster, table.roster tbody, table.roster tr, table.roster td { display: block; }
  table.roster thead { display: none; }
  table.roster tr { padding: 10px 4px; border-bottom: 6px solid var(--bg); }
  table.roster td { border: 0; padding: 3px 12px; }
  table.roster td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; }
  table.roster td.who { font-weight: 700; font-size: 1.1rem; }
}
/* M3 fixes: chips wrap on narrow screens; removed registrants are greyed */
.chip-btn { white-space: normal; text-align: left; max-width: 100%; }
.chips { min-width: 0; }
table.roster tr.gone { opacity: .55; }

/* Find yourself */
.match { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 64px; margin-bottom: 10px; text-align: left; font-size: 1.2rem; color: var(--ink); border-color: var(--line); }
.match:active { border-color: var(--brand); background: #e5eef7; }
.code { font-size: 6rem; line-height: 1; font-weight: 800; letter-spacing: .12em; margin: 8px 0 16px; font-variant-numeric: tabular-nums; color: var(--brand); }

/* Proctor console */
.chip.idle { color: var(--muted); background: #eceff3; }
a.evt { display: flex; gap: 12px; justify-content: space-between; align-items: center; color: var(--ink); text-decoration: none; font-size: 1.15rem; min-height: 72px; }
.gate { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: var(--radius); border: 3px solid; margin-bottom: 12px; }
.gate.open { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.gate.closed { background: #eceff3; border-color: var(--muted); color: var(--ink); }
.gate-state { font-size: 1.6rem; font-weight: 800; }
.gate button { min-width: 200px; min-height: 60px; font-size: 1.15rem; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.tools button { flex: 1 1 200px; }
.qrcard { display: flex; gap: 16px; align-items: center; padding: 12px 16px; }
.qrcard img { background: #fff; flex: none; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.fbtn { min-height: 48px; padding: 6px 14px; }
.fbtn[aria-pressed=true] { background: var(--brand); color: #fff; }
.count { font-weight: 700; }
.qrow { display: flex; gap: 16px; align-items: center; border-width: 2px; border-color: var(--brand); }
.qrow.see { border-color: var(--bad); background: var(--bad-bg); }
.qcode { flex: none; font-size: 3.4rem; line-height: 1; font-weight: 800; letter-spacing: .06em; color: var(--brand); font-variant-numeric: tabular-nums; min-width: 4.2ch; text-align: center; }
.qmain { flex: 1; min-width: 0; }
.qgo { flex: none; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.qgo .big { width: auto; min-width: 150px; }
button.link { border: 0; background: none; min-height: 44px; text-decoration: underline; font-weight: 400; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.acts button { min-height: 48px; padding: 6px 14px; font-size: .95rem; }
tr.gone { opacity: .55; }
.presets { display: flex; flex-wrap: wrap; gap: 10px; }
.reason { min-height: 56px; flex: 1 1 160px; }
.reason[aria-pressed=true] { background: var(--brand); color: #fff; }
.screen { position: fixed; inset: 0; z-index: 50; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px; text-align: center; cursor: pointer; }
.screen img { width: min(80vh, 90vw); height: min(80vh, 90vw); }
.screen .url { font-size: clamp(1.6rem, 5vw, 3.2rem); font-weight: 800; margin: 0; word-break: break-all; }
@media (max-width: 560px) {
  .qrow { flex-wrap: wrap; }
  .qgo { flex-direction: row; width: 100%; }
  .qgo .big { flex: 1; }
}
/* M5 review page */
.sumgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.sumgrid .card { margin-bottom: 0; }
.passmark { font-size: 1.5rem; font-weight: 700; margin: 4px 0 10px; }
.rlist { list-style: none; margin: 0 0 16px; padding: 0; }
.rrow { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.rhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 6px 12px; }
.rhead input.sel, label.check input { width: 28px; height: 28px; flex: none; accent-color: var(--brand); }
.rbtn { flex: 1 1 220px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; text-align: left; border: 0; background: none; color: var(--ink); min-height: 56px; padding: 6px 4px; }
.rbtn .nm { font-weight: 700; font-size: 1.1rem; }
.rbtn .sc { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }
.rbtn::after { content: "▾"; }
.rbtn[aria-expanded=true]::after { content: "▴"; }
label.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; min-height: 44px; }
.exp { border-top: 1px solid var(--line); padding: 12px; background: #fafbfd; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 12px; }
.item .stem { font-size: 1.05rem; }
.qi { max-width: 100%; max-height: 260px; display: block; margin: 0 0 10px; border: 1px solid var(--line); }
.opts { list-style: none; margin: 0; padding: 0; }
.o { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 8px 10px; margin-bottom: 6px; border: 2px solid var(--line); border-radius: 8px; }
.o .letter { font-weight: 700; width: 1.5em; }
.o .ot { flex: 1 1 200px; }
.o .mk { font-size: .9rem; }
.o.right { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.o.wrong { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }

/* Approval queue stays in view while scrolling the roster */
#queue { position: sticky; top: 0; z-index: 8; max-height: 50vh; overflow-y: auto; background: var(--bg); padding-top: 4px; }
#queue:empty { display: none; }
