/*
  SAMSAT theme. Everything visual hangs off the tokens below, so changing the
  look to match a reference site means editing this block (and the font link
  in index.html), not the components.
*/
:root {
  /* colour */
  --bg: #0a0d14;
  --bg-raise: #111623;
  --bg-input: #0d121d;
  --line: #222b3d;
  --fg: #e8ecf5;
  --fg-dim: #8d98b0;
  --accent: #5b8cff;
  --accent-ink: #06122e;
  --good: #3ecf8e;
  --warn: #f5b84b;
  --bad: #ff6b6b;
  /* type */
  --font-display: "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* shape */
  --radius: 10px;
  --gutter: 20px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; margin: 0; text-wrap: balance; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding-block: 40px 80px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.hero { padding-top: 12vh; gap: 20px; max-width: 720px; }
.lede { font-size: 1.15rem; color: var(--fg-dim); max-width: 56ch; }
.muted { color: var(--fg-dim); }
.err { color: var(--bad); }
.eyebrow { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-dim); }
.grow { flex: 1; }

/* header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding-block: 14px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.14em; text-decoration: none; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--fg-dim); border: 0; background: none; cursor: pointer; }
.nav-link:hover, .nav-link.on { color: var(--fg); background: var(--bg-raise); }
.top.test { position: sticky; top: 0; background: var(--bg); z-index: 5; }
.test-title { color: var(--fg-dim); flex: 1; min-width: 0; }
.clock { font-family: var(--font-mono); font-size: 1.2rem; font-variant-numeric: tabular-nums; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; }
.clock.low { color: var(--warn); border-color: var(--warn); }

/* controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--bg-raise); text-decoration: none; cursor: pointer; font-weight: 500;
}
.btn:hover:not(:disabled) { border-color: var(--fg-dim); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #2a0707; }
.btn.danger-outline:hover { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 6px 12px; font-size: 0.9rem; }
.pill { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--fg-dim); font-size: 0.9rem; white-space: nowrap; }
.pill.ok { color: var(--good); border-color: var(--good); }

input[type="text"], input[type="email"], input[type="number"], textarea {
  width: 100%; padding: 10px 12px; background: var(--bg-input); border: 1px solid var(--line); border-radius: var(--radius);
}
input.narrow { width: 5.5rem; }
input.code { width: 12ch; font-family: var(--font-mono); font-size: 1.3rem; letter-spacing: 0.15em; }
textarea { resize: vertical; }
label { color: var(--fg-dim); font-size: 0.9rem; }

/* layout blocks */
.cards { display: grid; gap: 12px; }
.card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 20px; background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius);
}
.card.col { flex-direction: column; align-items: stretch; }
.card > div { min-width: 0; }
.panel { padding: 24px; background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row .label { color: var(--fg-dim); min-width: 4.5rem; }
.login { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }

/* test taking */
.test-wrap { gap: 20px; }
.qnav { display: flex; flex-wrap: wrap; gap: 6px; }
.qdot { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-raise); cursor: pointer; font-variant-numeric: tabular-nums; }
.qdot.done { border-color: var(--accent); color: var(--accent); }
.qdot.now { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.qstage { display: flex; flex-direction: column; gap: 18px; }
.qimg, .thumb { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.stem { white-space: pre-wrap; max-width: 70ch; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; padding: 12px 14px;
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.opt:hover { border-color: var(--fg-dim); }
.opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg-raise)); }
.letter { font-family: var(--font-mono); color: var(--fg-dim); min-width: 1.2em; }
.opt.sel .letter { color: var(--accent); }
.prompt { margin: 0; padding: 16px 20px; border-left: 3px solid var(--accent); font-family: var(--font-display); font-size: 1.35rem; line-height: 1.35; background: var(--bg-raise); border-radius: 0 var(--radius) var(--radius) 0; }
.prompt.small { font-size: 1.05rem; }
.essay { min-height: 45vh; font-size: 1.05rem; line-height: 1.6; }
.essay-text { white-space: pre-wrap; padding: 14px; background: var(--bg-input); border: 1px solid var(--line); border-radius: var(--radius); max-height: 360px; overflow: auto; }

/* tables */
.scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-dim); font-weight: 500; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 600; }
.table tr.me td { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* admin */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: none; cursor: pointer; color: var(--fg-dim); }
.tab.on { background: var(--bg-raise); color: var(--fg); border-color: var(--fg-dim); }
.qform { align-items: stretch; }
.preview { min-height: 140px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.preview img { max-width: 100%; max-height: 420px; border-radius: 6px; }
.optrow { display: flex; align-items: center; gap: 10px; }
.optrow input[type="text"] { flex: 1; min-width: 0; }
.correct { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.answers { margin: 0; padding-left: 1.5rem; display: grid; gap: 4px; }
.answers .right { color: var(--good); font-weight: 600; }
.answers .wrong { color: var(--bad); text-decoration: line-through; }
.explain { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; }
.explain .eyebrow { margin: 0 0 4px; }

@media (max-width: 560px) {
  .wrap { padding-block: 24px 60px; }
  .optrow { flex-wrap: wrap; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* PDF import on the admin question form */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
label.btn { display: inline-flex; align-items: center; cursor: pointer; color: var(--fg); }
.pdfpick { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raise); }
.pdfbody { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; align-items: start; }
.pdfstrip { position: relative; display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; padding-right: 4px; }
.pdfview { max-height: 70vh; overflow: auto; border-radius: 4px; }
.zoomlabel { min-width: 3.5em; text-align: center; font-variant-numeric: tabular-nums; }
.pdfthumb { flex: none; width: 76px; padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 1px solid var(--line); border-radius: 6px; color: var(--fg-dim); font-size: 0.8rem; cursor: pointer; }
.pdfthumb img { width: 100%; display: block; background: #fff; }
.pdfthumb.on { border-color: var(--accent); color: var(--fg); }
.pdfstage { position: relative; margin: 0 auto; touch-action: none; user-select: none; cursor: crosshair; line-height: 0; }
.pdfpage { width: 100%; height: auto; display: block; background: #fff; border-radius: 4px; }
.cropbox { position: absolute; border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); pointer-events: none; }

/* My stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.stat .eyebrow, .stat p { margin: 0; }
.stat-value { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.small { font-size: 0.85rem; }
.col-gap { display: flex; flex-direction: column; gap: 6px; }
.res-right { color: var(--good); }
.res-wrong { color: var(--bad); }

/* Test screen: image left, question right (like the real exam platform) */
.test-wrap { max-width: 1440px; padding-block: 16px 24px; gap: 14px; }
.qsplit { display: grid; grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr); gap: 20px; align-items: start; }
.qsplit.noimg { grid-template-columns: minmax(0, 1fr); max-width: 760px; }
.qsplit.noimg .qleft { display: none; }
.qleft, .qright { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.qleft .imgscroll { max-height: calc(100dvh - 210px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.qleft .qimg { display: block; max-width: none; height: auto; border: 0; border-radius: 0; }
.qright { gap: 16px; max-height: calc(100dvh - 170px); overflow: auto; padding: 16px; background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); }
.imgbar { gap: 6px; }
@media (max-width: 900px) {
  .qsplit { grid-template-columns: minmax(0, 1fr); }
  .qleft .imgscroll, .qright { max-height: none; }
}

/* Answer choices styled like the exam platform: full-width rows, divider lines, radio on the left */
.qright .opts { gap: 0; border-top: 1px solid var(--line); }
.qright .opt {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 12px;
  width: 100%; padding: 18px 8px; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
}
.qright .opt:hover { background: color-mix(in srgb, var(--fg) 4%, transparent); }
.qright .opt.sel { background: none; }
.radio {
  justify-self: center; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--fg-dim); display: grid; place-items: center;
}
.radio::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: transparent; }
.opt:hover .radio { border-color: var(--fg); }
.opt.sel .radio { border-color: var(--accent); }
.opt.sel .radio::after { background: var(--accent); }
.opt-text { line-height: 1.4; }

/* Essay screen, modelled on the exam platform: instructions left, comments and writing panel right */
.essay-split { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 3fr); gap: 32px; align-items: start; }
.essay-instructions { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 90px; }
.essay-instructions h2 { margin: 0 0 8px; padding-bottom: 12px; border-bottom: 1px solid var(--fg); font-size: 2rem; }
.essay-instructions p { margin: 0; font-weight: 600; line-height: 1.5; }
.essay-instructions p.muted { font-weight: 400; font-size: 0.9rem; }
.essay-panel { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.comments { display: flex; flex-direction: column; gap: 10px; padding: 20px 24px; background: var(--bg-raise); border-bottom: 1px solid var(--line); }
.comment { display: grid; grid-template-columns: 9em minmax(0, 1fr); gap: 12px; line-height: 1.5; }
.comment-label { font-style: italic; color: var(--fg-dim); }
.essay-body { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px; }
.essay-tools { display: flex; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.tool { display: inline-flex; flex-direction: column; align-items: center; min-width: 64px; padding: 6px 10px; font-size: 0.85rem; background: var(--bg-raise); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.tool span { font-size: 1.1rem; line-height: 1; }
.tool:hover { border-color: var(--fg-dim); }
.essay-body .essay { min-height: max(240px, calc(100dvh - 450px)); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 8px 4px; }
.essay-body .essay:focus-visible { outline: none; border-bottom-color: var(--accent); }
@media (max-width: 900px) {
  .essay-split { grid-template-columns: minmax(0, 1fr); }
  .essay-instructions { position: static; }
  .comment { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* Section intro page (before the timer starts) */
.intro { display: flex; flex-direction: column; gap: 20px; max-width: 860px; }
.intro-banner { padding: 36px 32px; border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 18%, var(--bg-raise)); border: 1px solid var(--line); }
.intro-brand { margin: 0; font-family: var(--font-display); font-size: clamp(2.6rem, 8vw, 4.5rem); font-weight: 700; letter-spacing: 0.06em; line-height: 1; color: var(--accent); }
.intro-sub { margin: 10px 0 0; font-size: 1.15rem; color: var(--fg-dim); }
.intro-title { font-size: 1.5rem; margin: 8px 0 0; }
.intro-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 24px; margin: 0; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); }
.intro-facts dt { font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-dim); padding-top: 2px; }
.intro-facts dd { margin: 0; }
.intro h2 { margin: 8px 0 0; font-size: 1.15rem; }
.intro-rules { margin: 0; padding-left: 1.2rem; display: grid; gap: 8px; line-height: 1.5; }
.intro-warn { padding: 14px 18px; border-left: 3px solid var(--accent); background: var(--bg-raise); border-radius: 0 var(--radius) var(--radius) 0; font-weight: 600; }
.intro-warn p { margin: 4px 0; }
.intro-foot { display: flex; align-items: center; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 560px) { .intro-facts { grid-template-columns: minmax(0, 1fr); gap: 2px 0; } .intro-facts dd { margin-bottom: 10px; } }

/* Sittings and lobby */
.actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.sitting-group { display: flex; flex-direction: column; gap: 10px; }
.sitting-group h2, .sitting-group h3 { margin: 8px 0 0; }
.sitting h3 { margin: 0; font-size: 1.05rem; }
.sitting.mine { border-color: var(--accent); }
.lobby { display: flex; flex-direction: column; gap: 14px; }
.lobby h2 { margin: 6px 0 0; font-size: 1.15rem; }
.lobby-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lobby-people li { display: flex; align-items: center; gap: 10px; }
.lobby-people .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.lobby-people li.ready .dot { background: var(--good); }
input[type="date"], input[type="time"], input[type="datetime-local"], select { padding: 8px 10px; background: var(--bg-input); border: 1px solid var(--line); border-radius: var(--radius); }
