/* ExamShield candidate client: a calm, white test player with a header bar, the
   question in the middle and a numbered navigation bar along the bottom. */
:root {
  --bg: #ffffff;
  --page: #f4f5f6;
  --ink: #222629;
  --ink-2: #555b61;
  --ink-3: #868d93;
  --line: #d9dcdf;
  --line-2: #c4c8cc;
  --cell: #e9ebed;
  --cell-hover: #dde0e3;
  --primary: #1f6aa5;
  --primary-ink: #ffffff;
  --primary-dark: #17547f;
  --focus: #1f6aa5;
  --select: #e7f0f8;
  --answered: #3a3f44;
  --flag: #c9302c;
  --ok: #2e7d32;
  --warn: #b26a00;
  --bad: #c62828;
  --offline: #fdecea;
  --radius: 4px;
  --font: "Segoe UI", "Open Sans", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-h: 56px;
  --nav-h: 64px;
  font-size: 16px;
}
html.text-small { font-size: 14px; }
html.text-large { font-size: 19px; }
html.text-xlarge { font-size: 22px; }
html.contrast-dark {
  --bg: #000; --page: #000; --ink: #fff; --ink-2: #e0e0e0; --ink-3: #bdbdbd; --line: #8a8a8a; --line-2: #bdbdbd;
  --cell: #1c1c1c; --cell-hover: #2b2b2b; --primary: #ffd600; --primary-ink: #000; --primary-dark: #ffea00; --select: #1d2a36;
  --answered: #fff; --focus: #ffd600; --offline: #3a0d0d;
}
html.contrast-yellow {
  --bg: #000; --page: #000; --ink: #ffeb3b; --ink-2: #ffeb3b; --ink-3: #fff59d; --line: #ffeb3b; --line-2: #ffeb3b;
  --cell: #111; --cell-hover: #222; --primary: #ffeb3b; --primary-ink: #000; --primary-dark: #fff176; --select: #333000;
  --answered: #ffeb3b; --focus: #fff; --offline: #3a0d0d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--page); line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--primary); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 18px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); font-weight: 600; font-size: .95rem; text-decoration: none; }
.btn:hover { background: var(--cell); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg, .icon-btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--radius); background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--cell); color: var(--ink); }
.badge { position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--flag); color: #fff; font-size: 11px; font-weight: 700; line-height: 17px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(420px, 100%); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 36px 32px 30px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }
.brand svg { width: 28px; height: 28px; color: var(--primary); }
.login h1 { font-size: 1.45rem; margin: 26px 0 4px; font-weight: 600; }
.login p.lead { margin: 0 0 22px; color: var(--ink-2); }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: .92rem; }
.input { width: 100%; height: 44px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg); }
.input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.form-error { color: var(--bad); font-size: .92rem; margin: -4px 0 14px; min-height: 1.2em; }
.login .btn-primary { width: 100%; min-height: 46px; }
.login small { display: block; margin-top: 18px; color: var(--ink-3); }

/* ---------- top header ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--header-h); z-index: 30; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 18px;
  background: var(--bg); border-bottom: 1px solid var(--line); transition: background .3s; }
.topbar.offline { background: var(--offline); }
.topbar .who { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.conn.saving { background: var(--warn); }
.conn.offline { background: var(--bad); }
.topbar .title { flex: 1; min-width: 0; text-align: center; font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .right { display: flex; align-items: center; gap: 4px; }
.save-state { font-size: .85rem; color: var(--ink-3); margin-right: 8px; white-space: nowrap; }
.timer { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.timer svg { width: 16px; height: 16px; color: var(--ink-3); }
.timer.low { color: var(--bad); border-color: var(--bad); }
.timer.hidden-time .t { display: none; }
.menu { position: absolute; top: calc(var(--header-h) - 6px); right: 10px; z-index: 40; min-width: 260px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.16); padding: 6px 0; }
.menu button, .menu .row { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 16px; border: 0; background: none; text-align: left; }
.menu button:hover { background: var(--cell); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu .label { padding: 8px 16px 2px; font-size: .78rem; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.menu .seg { display: flex; gap: 4px; padding: 4px 16px 8px; }
.menu .seg button { flex: 1; justify-content: center; padding: 6px 4px; border: 1px solid var(--line-2); border-radius: var(--radius); font-size: .85rem; }
.menu .seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ---------- dashboard ---------- */
.dash { padding: calc(var(--header-h) + 28px) 16px 48px; }
.dash-inner { max-width: 980px; margin: 0 auto; }
.dash h1 { font-size: 1.6rem; font-weight: 600; margin: 0 0 4px; }
.dash .sub { color: var(--ink-2); margin: 0 0 24px; }
.dash h2 { font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin: 30px 0 10px; }
.test-card { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; margin-bottom: 10px; }
.test-card h3 { margin: 0 0 4px; font-size: 1.1rem; font-weight: 600; }
.test-card .meta { color: var(--ink-2); font-size: .92rem; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.status { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--cell); color: var(--ink-2); margin-left: 8px; vertical-align: 2px; }
.status.open, .status.inprogress { background: #e3f1e5; color: var(--ok); }
.status.submitted { background: #e7f0f8; color: var(--primary); }
.status.closed, .status.missed { background: var(--cell); color: var(--ink-3); }
.status.upcoming { background: #fff4e0; color: var(--warn); }
.test-card .actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.test-card .when { font-size: .88rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.receipt { margin-top: 8px; font-size: .88rem; color: var(--ink-2); }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 6px; border: 1px solid #b7d3ea; background: #eef5fb; margin-bottom: 18px; }
.banner.ok { border-color: #b9dcbc; background: #eef7ef; }
.banner svg { width: 22px; height: 22px; color: var(--ok); flex: none; margin-top: 1px; }
.empty { padding: 26px; text-align: center; color: var(--ink-3); background: var(--bg); border: 1px dashed var(--line-2); border-radius: 6px; }

/* ---------- player ---------- */
.player-main { position: fixed; inset: var(--header-h) 0 var(--nav-h) 0; overflow: auto; background: var(--bg); }
.page { max-width: 880px; margin: 0 auto; padding: 34px 28px 60px; }
.q-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 14px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.q-head h1 { font-size: 1.35rem; font-weight: 600; margin: 0; }
.q-head .pts { color: var(--ink-3); font-weight: 400; font-size: 1rem; margin-left: 8px; }
.flag-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--ink-2); font-size: .9rem; }
.flag-btn svg { width: 18px; height: 18px; }
.flag-btn[aria-pressed="true"] { color: var(--flag); border-color: var(--flag); }
.flag-btn[aria-pressed="true"] svg { fill: currentColor; }
.stem { font-size: 1.05rem; margin: 0 0 24px; white-space: pre-wrap; }
.prompt { font-weight: 600; font-size: .95rem; color: var(--ink-2); margin: 0 0 10px; }
.choices { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.choice { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer; }
.choice:hover { border-color: var(--line-2); background: var(--page); }
.choice.on { border-color: var(--primary); background: var(--select); }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); flex: none; }
.choice .letter { font-weight: 700; color: var(--ink-3); width: 18px; }
.num-input { max-width: 260px; }
.short-input { width: 100%; min-height: 90px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--radius); resize: vertical; background: var(--bg); }
.hint { font-size: .85rem; color: var(--ink-3); margin-top: 6px; }
.hint.bad { color: var(--bad); }

/* essay editor */
.editor { border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg); display: flex; flex-direction: column; }
.editor.full { position: fixed; inset: var(--header-h) 0 var(--nav-h) 0; z-index: 25; border-radius: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); background: var(--page); position: relative; }
.toolbar select { height: 30px; border: 1px solid var(--line-2); border-radius: 3px; background: var(--bg); padding: 0 6px; font-size: .85rem; }
.toolbar button { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 5px; border: 1px solid transparent; border-radius: 3px; background: none; color: var(--ink-2); font-size: .9rem; }
.toolbar button:hover { background: var(--cell-hover); color: var(--ink); }
.toolbar button.on { background: var(--cell-hover); border-color: var(--line-2); color: var(--ink); }
.toolbar button svg { width: 16px; height: 16px; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 4px; }
.toolbar .pop { position: absolute; top: 38px; z-index: 5; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 8px; }
.chars { display: grid; grid-template-columns: repeat(10, 30px); gap: 3px; }
.chars button { border: 1px solid var(--line); }
.snaps { width: 320px; max-height: 300px; overflow: auto; }
.snaps button { display: block; width: 100%; text-align: left; height: auto; padding: 8px; border-bottom: 1px solid var(--line); border-radius: 0; color: var(--ink); }
.snaps small { color: var(--ink-3); display: block; }
.ed-area { min-height: 320px; padding: 14px 16px; outline: none; overflow: auto; flex: 1; line-height: 1.6; }
.ed-area:empty::before { content: attr(data-placeholder); color: var(--ink-3); }
.ed-area h1 { font-size: 1.5rem; } .ed-area h2 { font-size: 1.25rem; } .ed-area h3 { font-size: 1.1rem; }
.ed-foot { display: flex; justify-content: space-between; padding: 6px 12px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--ink-3); }

/* intro + submission pages */
.intro h1 { font-size: 1.7rem; font-weight: 600; margin: 0 0 8px; }
.facts { display: flex; flex-wrap: wrap; gap: 10px 28px; color: var(--ink-2); margin: 14px 0 24px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts b { color: var(--ink); }
.instructions { white-space: pre-wrap; }
.submit-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.submit-top p { margin: 0; }
.submit-top .big { font-size: 1.15rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 0; }
.tabs button { border: 0; background: none; padding: 10px 14px; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--primary); }
.q-list { list-style: none; margin: 0; padding: 0; }
.q-list li button { display: grid; grid-template-columns: 44px 1fr auto 24px; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 12px 6px; border: 0; border-bottom: 1px solid var(--line); background: none; }
.q-list li button:hover { background: var(--page); }
.q-list .n { font-weight: 700; color: var(--ink-2); }
.q-list .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-list .s { font-size: .85rem; color: var(--ink-3); }
.q-list .s.done { color: var(--ok); }
.q-list .f svg { width: 16px; height: 16px; color: var(--flag); fill: currentColor; }

/* ---------- bottom navigation bar ---------- */
.navbar { position: fixed; inset: auto 0 0 0; height: var(--nav-h); z-index: 30; display: flex; align-items: stretch; background: var(--page); border-top: 1px solid var(--line); }
.navbar .side-btn { width: 56px; border: 0; border-right: 1px solid var(--line); background: var(--page); color: var(--ink-2); display: grid; place-items: center; }
.navbar .side-btn:hover { background: var(--cell-hover); }
.navbar .side-btn svg { width: 22px; height: 22px; }
.cells { flex: 1; display: flex; overflow-x: auto; scrollbar-width: thin; }
.cell { position: relative; flex: 1 0 52px; max-width: 120px; border: 0; border-right: 1px solid var(--bg); background: var(--cell); color: var(--ink-3); font-size: 1.05rem; font-weight: 600; }
.cell:hover { background: var(--cell-hover); }
.cell.answered { color: var(--answered); }
.cell.answered::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 9px; height: 3px; border-radius: 2px; background: var(--answered); }
.cell.current { background: var(--bg); color: var(--primary); box-shadow: inset 0 3px 0 var(--primary); }
.cell .flag { position: absolute; top: 5px; left: 50%; transform: translateX(-50%); width: 12px; height: 12px; color: var(--flag); }
.cell .flag svg { width: 12px; height: 12px; fill: currentColor; }
.cell.info, .cell.sub { flex: 0 0 64px; }
.cell svg.ic { width: 20px; height: 20px; }
.navbar .arrows { display: flex; border-left: 1px solid var(--line); }
.navbar .arrows button { width: 56px; border: 0; background: var(--page); color: var(--ink-2); display: grid; place-items: center; }
.navbar .arrows button:hover:not(:disabled) { background: var(--cell-hover); }
.navbar .arrows button:disabled { opacity: .35; cursor: default; }
.navbar .arrows svg { width: 24px; height: 24px; }

/* table of contents drawer */
.toc { position: fixed; top: var(--header-h); bottom: var(--nav-h); left: 0; z-index: 28; width: min(380px, 90vw); background: var(--bg); border-right: 1px solid var(--line);
  box-shadow: 6px 0 20px rgba(0,0,0,.08); overflow: auto; transform: translateX(-102%); transition: transform .2s; }
.toc.open { transform: none; }
.toc h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 18px 18px 6px; margin: 0; }
.toc button { display: grid; grid-template-columns: 34px 1fr 18px; gap: 10px; align-items: center; width: 100%; padding: 11px 18px; border: 0; background: none; text-align: left; }
.toc button:hover { background: var(--page); }
.toc button.current { background: var(--select); box-shadow: inset 3px 0 0 var(--primary); }
.toc .n { font-weight: 700; color: var(--ink-3); }
.toc .n.done { color: var(--answered); text-decoration: underline 2px; text-underline-offset: 4px; }
.toc .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc svg { width: 14px; height: 14px; color: var(--flag); fill: currentColor; }

/* ---------- modal, overlays, toasts ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(20, 24, 28, .45); display: grid; place-items: center; padding: 16px; }
.modal { width: min(520px, 100%); background: var(--bg); border-radius: 6px; box-shadow: 0 20px 50px rgba(0,0,0,.3); padding: 26px 26px 22px; }
.modal h2 { margin: 0 0 10px; font-size: 1.3rem; font-weight: 600; }
.modal p { margin: 0 0 12px; color: var(--ink-2); }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.lock { position: fixed; inset: 0; z-index: 70; background: var(--page); display: grid; place-items: center; padding: 24px; text-align: center; }
.lock .box { max-width: 520px; }
.lock svg { width: 54px; height: 54px; color: var(--primary); }
.lock h2 { font-size: 1.5rem; margin: 14px 0 8px; font-weight: 600; }
.lock p { color: var(--ink-2); margin: 0 0 20px; }
.toasts { position: fixed; z-index: 80; bottom: calc(var(--nav-h) + 14px); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(460px, calc(100vw - 32px)); pointer-events: none; }
body:not(:has(.navbar)) .toasts { bottom: 20px; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: .95rem; animation: tin .2s ease-out; }
.toast.warn { background: var(--warn); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.msg-list { max-height: 50vh; overflow: auto; }
.msg { border-bottom: 1px solid var(--line); padding: 10px 0; }
.msg small { color: var(--ink-3); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .topbar .title, .save-state { display: none; }
  .page { padding: 22px 16px 40px; }
  .test-card { grid-template-columns: 1fr; }
  .test-card .actions { align-items: stretch; }
  .cell { flex-basis: 44px; }
  .navbar .side-btn, .navbar .arrows button { width: 46px; }
}
@media print { body * { display: none !important; } }
