/* ==========================================================================
   Hiring Quiz — design direction
   Candidate side is an exam paper: white sheet, serif questions, bubble-sheet answers.
   Interviewer side is a marking desk: dense tables, plain text, red pen only for flags.

   Colour roles
     ink      #16181c  text, primary buttons, filled bubbles
     graphite #4b515a  secondary text            muted #7c838d  tertiary
     rule     #e2e4e8  hairlines                 desk  #f2f3f5  app background
     red pen  #c42b1c  integrity flags, destructive actions — nothing else
     mark     #13795b  correct answers, healthy state
     pen blue #2557d6  links and focus only
   Type: IBM Plex Sans (UI), Source Serif 4 (questions), IBM Plex Mono (code, numbers)
   ========================================================================== */
:root {
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --ink: #16181c;
  --graphite: #4b515a;
  --muted: #7c838d;
  --rule: #e2e4e8;
  --rule-2: #cdd1d7;
  --desk: #f2f3f5;
  --paper: #ffffff;
  --hover: #f6f7f8;

  --red: #c42b1c;   --red-bg: #fbeceb;
  --mark: #13795b;  --mark-bg: #e7f3ee;
  --amber: #8a5a00; --amber-bg: #fdf3d8;
  --blue: #2557d6;

  --code-bg: #f6f7f9;
  --r: 6px;
  --r-lg: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--desk); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0 0 .75em; }
pre, code, kbd, .mono, .num { font-family: var(--mono); font-variant-ligatures: none; }
.num { font-variant-numeric: tabular-nums; }
pre {
  margin: 0; padding: 14px 16px; background: var(--code-bg); border: 1px solid var(--rule); border-radius: var(--r);
  font-size: 13px; line-height: 1.6; overflow-x: auto; white-space: pre; tab-size: 4; color: var(--ink);
}
kbd { font-size: 11px; padding: 0 5px; border: 1px solid var(--rule-2); border-radius: 4px; background: var(--paper); color: var(--graphite); }
.ti { font-size: 16px; line-height: 1; vertical-align: -2px; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.graphite { color: var(--graphite); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.red { color: var(--red); }
.green { color: var(--mark); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 16px; }
.inline { display: inline; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--ink); border-radius: var(--r); background: var(--ink); color: #fff;
  font: 500 13.5px var(--sans); cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: #2c2f35; border-color: #2c2f35; color: #fff; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn:disabled { background: #b9bdc4; border-color: #b9bdc4; cursor: not-allowed; }
.btn.line { background: var(--paper); color: var(--ink); border-color: var(--rule-2); }
.btn.line:hover { background: var(--hover); }
.btn.text { background: none; border-color: transparent; color: var(--graphite); padding: 0 8px; }
.btn.text:hover { color: var(--ink); background: var(--hover); }
.btn.danger { background: var(--paper); color: var(--red); border-color: #e7b9b4; }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 28px; padding: 0; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn.block { width: 100%; }

label, .label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 5px; color: var(--ink); }
.hint { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], select, textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--rule-2); border-radius: var(--r);
  background: var(--paper); color: var(--ink); font: 14px var(--sans);
}
textarea { height: auto; min-height: 84px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 13px; min-height: 120px; tab-size: 4; white-space: pre; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
input::placeholder, textarea::placeholder { color: #a8adb5; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; margin: 0; padding: 10px 0; border-top: 1px solid var(--rule); cursor: pointer; }
.check:first-child { border-top: 0; }
.check input { margin: 2px 0 0; width: 15px; height: 15px; accent-color: var(--ink); flex: none; }
.check b { display: block; font-weight: 500; }

/* status text: a word with a coloured marker, never a pill */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--graphite); white-space: nowrap; }
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--rule-2); }
.st.ok { color: var(--mark); } .st.ok::before { background: var(--mark); }
.st.bad { color: var(--red); } .st.bad::before { background: var(--red); }
.st.warn { color: var(--amber); } .st.warn::before { background: #d89b00; }
.st.live::before { background: var(--mark); box-shadow: 0 0 0 3px var(--mark-bg); }
.chip { font-size: 12.5px; color: var(--graphite); }
.chip.ok { color: var(--mark); } .chip.bad { color: var(--red); } .chip.warn { color: var(--amber); }
.flag { color: var(--red); font-weight: 500; }

/* ---------------------------------------------------------------- admin frame */
.topbar { background: var(--paper); border-bottom: 1px solid var(--rule); }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: 0 24px; height: 52px; display: flex; align-items: center; gap: 20px; }
.wordmark { font-weight: 600; color: var(--ink); letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.wordmark:hover { text-decoration: none; }
.wordmark .mark { width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 50%; position: relative; }
.wordmark .mark::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--ink); }
.wordmark span { color: var(--muted); font-weight: 400; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { color: var(--graphite); padding: 6px 10px; border-radius: var(--r); font-weight: 500; }
.topnav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.topnav a.active { color: var(--ink); background: var(--desk); }
.who { color: var(--graphite); font-size: 13px; }

.subhead { background: var(--paper); border-bottom: 1px solid var(--rule); }
.subhead-inner { max-width: 1160px; margin: 0 auto; padding: 18px 24px 0; }
.subhead h1 { font-size: 20px; }
.subhead .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tabs { display: flex; gap: 22px; margin-top: 14px; }
.tabs a { color: var(--graphite); padding: 8px 0 10px; border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .count { color: var(--muted); font-weight: 400; margin-left: 4px; }

.page { max-width: 1160px; margin: 0 auto; padding: 24px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); }
.panel + .panel, .panel + form, form + .panel, .section { margin-top: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.panel-body { padding: 16px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--graphite); margin: 28px 0 10px; }

.flash { padding: 9px 12px; border-radius: var(--r); margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.flash.ok { background: var(--mark-bg); color: var(--mark); border-color: #bfdccf; }
.flash.error { background: var(--red-bg); color: var(--red); border-color: #efc4bf; }

.summary-line { display: flex; gap: 28px; flex-wrap: wrap; padding: 2px 0 18px; color: var(--graphite); font-size: 13px; }
.summary-line b { color: var(--ink); font-family: var(--mono); font-weight: 500; font-size: 15px; margin-right: 4px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--paper); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-family: var(--mono); }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--hover); }
td .name { font-weight: 500; color: var(--ink); }
td .sub { font-size: 12.5px; color: var(--muted); }
.empty-row td { text-align: center; color: var(--muted); padding: 36px 16px; }

.new-quiz { display: flex; gap: 8px; align-items: center; }
.new-quiz input[name=title] { width: 300px; }
.new-quiz input[name=duration_min] { width: 80px; }

.copy-link { display: flex; gap: 6px; align-items: center; }
.copy-link input { font-family: var(--mono); font-size: 12.5px; background: var(--desk); }

/* questions list */
.q-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; padding: 16px; border-top: 1px solid var(--rule); }
.q-row:first-child { border-top: 0; }
.q-n { font-family: var(--mono); color: var(--muted); padding-top: 1px; }
.q-row .prompt { white-space: pre-wrap; margin: 0 0 8px; }
.q-row .kind { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.q-row pre { margin: 8px 0; font-size: 12.5px; }
.q-actions { display: flex; gap: 2px; align-items: flex-start; opacity: .55; }
.q-row:hover .q-actions { opacity: 1; }
.answers { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; }
.answers li { display: grid; grid-template-columns: 20px 1fr; gap: 6px; color: var(--graphite); }
.answers li .m { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.answers li.correct { color: var(--mark); font-weight: 500; }
.answers li.correct .m { color: var(--mark); }
.answers li.wrong { color: var(--red); font-weight: 500; }
.answers li.wrong .m { color: var(--red); }

.seg { display: inline-flex; border: 1px solid var(--rule-2); border-radius: var(--r); overflow: hidden; }
.seg label { margin: 0; padding: 6px 12px; cursor: pointer; font-weight: 500; font-size: 13px; color: var(--graphite); border-left: 1px solid var(--rule-2); }
.seg label:first-child { border-left: 0; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; }
.option-row { display: grid; grid-template-columns: 28px 1fr 28px; gap: 8px; align-items: center; margin-bottom: 6px; }
.pick { width: 26px; height: 26px; margin: 0; border: 1.5px solid var(--rule-2); border-radius: 50%; display: grid; place-items: center; cursor: pointer; font: 500 11px var(--mono); color: var(--muted); }
.pick input { display: none; }
.pick:has(input:checked) { background: var(--mark); border-color: var(--mark); color: #fff; }

/* settings as label / control rows */
.form-rows { display: grid; }
.form-row { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding: 16px; border-top: 1px solid var(--rule); }
.form-row:first-child { border-top: 0; }
.form-row > div:first-child b { display: block; font-weight: 500; }
.form-row > div:first-child span { color: var(--muted); font-size: 12.5px; }
.inline-nums { display: flex; gap: 16px; flex-wrap: wrap; }
.inline-nums label { font-weight: 400; color: var(--graphite); }
.inline-nums input { width: 90px; }

/* attempt: marked paper + integrity report */
.detail { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
.side { position: sticky; top: 16px; display: grid; gap: 20px; }
.side > .panel { margin-top: 0; }
.score-line { display: flex; align-items: baseline; gap: 8px; }
.score-line .big { font: 500 34px var(--mono); letter-spacing: -0.02em; }
.score-line .of { color: var(--muted); font-family: var(--mono); }
.verdict { padding: 10px 12px; border-radius: var(--r); margin-top: 12px; font-size: 13px; border-left: 3px solid; }
.verdict b { display: block; font-weight: 600; }
.verdict.clean { background: var(--mark-bg); border-color: var(--mark); color: #0d5a43; }
.verdict.review { background: var(--amber-bg); border-color: #d89b00; color: #6b4600; }
.verdict.high { background: var(--red-bg); border-color: var(--red); color: #8f1f14; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.paper-q { display: grid; grid-template-columns: 56px 1fr; border-top: 1px solid var(--rule); }
.paper-q:first-of-type { border-top: 0; }
.margin { padding: 16px 0 16px 16px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.margin .tick { display: block; font-size: 20px; line-height: 1; margin-bottom: 4px; font-family: var(--sans); }
.margin .tick.right { color: var(--mark); }
.margin .tick.wrong { color: var(--red); }
.paper-q .body { padding: 16px 16px 16px 0; min-width: 0; }
.paper-q .prompt { font-family: var(--serif); font-size: 15.5px; white-space: pre-wrap; margin: 0 0 10px; }
.answer-text { white-space: pre-wrap; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--rule); border-radius: var(--r); }
.grade { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--graphite); }
.grade input { width: 70px; height: 30px; font-family: var(--mono); }

.log { list-style: none; margin: 0; padding: 4px 16px 12px; font-size: 13px; }
.log li { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--rule); }
.log li:last-child { border-bottom: 0; }
.log time { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 1px; }
.log .d { color: var(--muted); font-size: 12px; }
.log li.fatal { color: var(--red); }
.log li.flagged .w { color: var(--red); }

.strip-tabs { display: flex; gap: 16px; padding: 0 16px; border-bottom: 1px solid var(--rule); }
.strip-tabs button { background: none; border: 0; padding: 10px 0; font: 500 13px var(--sans); color: var(--graphite); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.strip-tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 12px 16px 16px; }
.shots.wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.shot { display: block; text-decoration: none !important; color: var(--graphite); font-size: 11.5px; }
.shot img { width: 100%; display: block; border: 1px solid var(--rule); border-radius: 4px; background: #e9ebee; aspect-ratio: 4/3; object-fit: cover; }
.shots.wide .shot img { aspect-ratio: 16/10; object-fit: contain; background: #1b1d21; }
.shot span { display: flex; justify-content: space-between; padding-top: 3px; font-family: var(--mono); }
.shot.flagged img { border: 2px solid var(--red); }
.shot.flagged b { color: var(--red); font-family: var(--sans); font-weight: 500; }

/* live wall */
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.tile { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; color: inherit; text-decoration: none !important; display: block; }
.tile:hover { border-color: var(--rule-2); }
.tile.away { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.tile-media { display: grid; grid-template-columns: 2fr 1fr; gap: 1px; background: #1b1d21; height: 180px; }
.tile-media > div { height: 180px; overflow: hidden; display: grid; place-items: center; color: #6d727b; font-size: 12px; }
.tile-media img { width: 100%; height: 100%; display: block; object-fit: cover; }
.tile-media .scr img { object-fit: contain; }
.tile-body { padding: 10px 12px; display: grid; gap: 4px; }
.tile-body .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.tile-body .name { font-weight: 500; }
.tile-facts { display: flex; gap: 14px; font-size: 12.5px; color: var(--graphite); font-family: var(--mono); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 340px; }
.login .wordmark { margin-bottom: 28px; }

/* ---------------------------------------------------------------- candidate: exam paper */
body.exam { background: var(--desk); user-select: none; -webkit-user-select: none; }
body.exam textarea, body.exam input { user-select: text; -webkit-user-select: text; }
.screen { min-height: 100vh; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.sheet { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); width: 100%; max-width: 640px; }
.sheet-pad { padding: 36px 40px; }
.cover { padding: 48px 24px; }
.cover .sheet { margin: 0 auto; }
.cover-head { padding: 36px 40px 28px; border-bottom: 1px solid var(--rule); }
.cover-head .org { font-size: 12.5px; color: var(--muted); margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.cover-head h1 { font: 600 30px/1.15 var(--serif); letter-spacing: -0.015em; }
.cover-head .lede { color: var(--graphite); margin: 12px 0 0; white-space: pre-wrap; font-size: 15px; }
.facts { display: flex; gap: 24px; margin-top: 18px; font-size: 13px; color: var(--graphite); }
.facts b { color: var(--ink); font-family: var(--mono); font-weight: 500; }
.cover-body { padding: 28px 40px 36px; }
.part { padding: 0 0 22px; }
.part + .part { padding-top: 22px; border-top: 1px solid var(--rule); }
.part-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.part-title h2 { font-size: 14px; }
.part-title h2 .n { font-family: var(--mono); color: var(--muted); font-weight: 400; margin-right: 8px; }
.part.done .part-title h2 .n { color: var(--mark); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.devices { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; }
.cam-box { position: relative; border-radius: var(--r); overflow: hidden; background: #1b1d21; aspect-ratio: 4/3; }
.cam-box video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam-box .overlay-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #9aa0a8; font-size: 12px; padding: 12px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.checks li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.checks li:first-child { padding-top: 0; }
.face-tag { position: absolute; left: 8px; bottom: 6px; color: #fff !important; font-size: 11.5px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.consent { font-size: 12.5px; color: var(--muted); margin: 14px 0 0; }
.error-box { background: var(--red-bg); color: var(--red); border: 1px solid #efc4bf; padding: 9px 12px; border-radius: var(--r); font-size: 13.5px; margin-top: 14px; }
.error-box .ti { display: none; }

/* exam */
.exam-top { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 1px solid var(--rule); }
.exam-bar { height: 56px; padding: 0 20px; display: flex; align-items: center; gap: 16px; max-width: 1100px; margin: 0 auto; }
.exam-bar .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-bar .title small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.bar-cam { width: 48px; height: 36px; border-radius: 4px; overflow: hidden; background: #1b1d21; position: relative; flex: none; }
.bar-cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.bar-cam::after { content: ""; position: absolute; right: 3px; top: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.timer { font: 500 18px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); min-width: 64px; text-align: right; }
.timer .ti { display: none; }
.timer.low { color: var(--red); }
.save-state { font-size: 12.5px; color: var(--muted); }
.save-state .ti { display: none; }
.progress { height: 2px; background: var(--rule); }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .25s; }

.paper-wrap { max-width: 760px; margin: 0 auto; padding: 28px 20px 40px; }
.qcard { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 36px 44px 40px; min-height: 380px; }
.q-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 18px; font-family: var(--mono); }
.q-meta .chip { font-family: var(--sans); }
.qcard .prompt { font: 400 21px/1.45 var(--serif); letter-spacing: -0.005em; white-space: pre-wrap; margin-bottom: 22px; color: var(--ink); }
.qcard pre { margin-bottom: 24px; font-size: 13.5px; }
.options { display: grid; gap: 2px; }
.opt { display: grid; grid-template-columns: 32px 1fr; gap: 14px; align-items: center; padding: 10px 12px; margin: 0 -12px; border-radius: var(--r); cursor: pointer; font-weight: 400; font-size: 16px; }
.opt:hover { background: var(--hover); }
.opt input { display: none; }
.opt .key { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--rule-2); display: grid; place-items: center; font: 500 12px var(--mono); color: var(--graphite); transition: background .1s, border-color .1s; }
.opt .txt { white-space: pre-wrap; }
.opt.selected .key { background: var(--ink); border-color: var(--ink); color: #fff; }
.opt.selected .txt { font-weight: 500; }
.editor { border: 1px solid var(--rule-2); border-radius: var(--r); overflow: hidden; }
.editor-head { padding: 6px 12px; border-bottom: 1px solid var(--rule); background: var(--code-bg); color: var(--muted); font-size: 12px; font-family: var(--mono); }
.editor-head .lights { display: none; }
.editor textarea { border: 0; border-radius: 0; min-height: 280px; padding: 12px 14px; font: 13.5px/1.65 var(--mono); white-space: pre; tab-size: 4; }
.answer-area { min-height: 180px; font: 16px/1.6 var(--serif); padding: 12px 14px; }
.qfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.kbd-hint { font-size: 12px; color: var(--muted); }
.qnav { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 22px; }
.qnav button { width: 30px; height: 30px; border: 1px solid var(--rule-2); border-radius: 50%; background: var(--paper); font: 500 12px var(--mono); color: var(--graphite); cursor: pointer; }
.qnav button:hover { border-color: var(--ink); }
.qnav button.answered { background: var(--ink); border-color: var(--ink); color: #fff; }
.qnav button.current { outline: 2px solid var(--ink); outline-offset: 2px; }
.nav-caption { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

.watermark { position: fixed; inset: 0; pointer-events: none; z-index: 15; opacity: .05; background-repeat: repeat; }
.shield { position: fixed; inset: 0; z-index: 60; background: var(--paper); color: var(--graphite); display: grid; place-items: center; text-align: center; }
.shield p { font: 600 clamp(24px, 4vw, 36px)/1.3 var(--serif); color: var(--ink); padding: 0 24px; }
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(22, 24, 28, .4); display: grid; place-items: center; padding: 20px; }
.modal { background: var(--paper); border-radius: var(--r-lg); padding: 24px; max-width: 400px; width: 100%; box-shadow: 0 20px 50px -20px rgba(0,0,0,.35); }
.modal h2 { font-size: 17px; margin-bottom: 6px; }
.modal p { color: var(--graphite); }
.modal .row { margin-top: 18px; }
.modal .icon-circle { display: none; }

.done-sheet { max-width: 460px; text-align: center; }
.done-sheet .sheet-pad { padding: 44px 36px; }
.done-sheet .tick-big { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--mark); color: var(--mark); display: grid; place-items: center; margin: 0 auto 18px; font-size: 22px; }
.done-sheet h1 { font: 600 24px var(--serif); margin-bottom: 8px; }
.done-sheet p { color: var(--graphite); }

@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  .side { position: static; }
  .form-row { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 640px) {
  .topbar-inner, .subhead-inner, .page { padding-left: 16px; padding-right: 16px; }
  .new-quiz { flex-wrap: wrap; }
  .new-quiz input[name=title] { width: 100%; }
  .cover { padding: 16px; }
  .cover-head, .cover-body { padding-left: 20px; padding-right: 20px; }
  .two, .devices { grid-template-columns: 1fr; }
  .qcard { padding: 24px 20px; }
  .exam-bar .title small { display: none; }
  .wordmark span, .who { display: none; }
  .topbar-inner { gap: 10px; }
  .copy-link input { width: 100% !important; }
  .subhead .row.between { gap: 12px; }
}

/* ==========================================================================
   App feel + mobile
   ========================================================================== */
html { -webkit-tap-highlight-color: transparent; }
body.exam { overscroll-behavior: none; }           /* no pull-to-refresh mid-test */
body.is-mobile .desktop-only { display: none !important; }
.qcard.enter { animation: q-in .22s ease-out; }
@keyframes q-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .qcard.enter { animation: none; } }
.btn, .opt, .qnav button { touch-action: manipulation; }

@media (max-width: 640px) {
  /* inputs at 16px so iOS doesn't zoom in on focus */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], select, textarea { font-size: 16px; height: 44px; }
  textarea { height: auto; }
  .btn { height: 42px; }
  .btn.sm { height: 34px; }

  /* cover sheet becomes a full-screen page */
  body.exam .cover { padding: 0; }
  body.exam .sheet { border: 0; border-radius: 0; max-width: none; min-height: 100vh; }
  .cover-head { padding: calc(28px + env(safe-area-inset-top)) 20px 22px; }
  .cover-head h1 { font-size: 26px; }
  .facts { gap: 16px; }
  .cover-body { padding: 22px 20px calc(28px + env(safe-area-inset-bottom)); }
  .devices { grid-template-columns: 1fr; }
  .cam-box { aspect-ratio: 16/10; }
  #btn-start { height: 52px; font-size: 16px; }

  /* exam: native-app layout — slim top bar, full-bleed paper, fixed bottom actions */
  .exam-top { padding-top: env(safe-area-inset-top); }
  .exam-bar { height: 52px; padding: 0 16px; gap: 10px; }
  .exam-bar .title { font-size: 13px; }
  .exam-bar .title small, .save-state { display: none; }
  .bar-cam { width: 40px; height: 30px; }
  .timer { font-size: 17px; min-width: 0; }
  #btn-submit { height: 34px; padding: 0 12px; }
  .paper-wrap { padding: 0 0 calc(84px + env(safe-area-inset-bottom)); }
  .qcard { border: 0; border-radius: 0; padding: 22px 20px 28px; min-height: calc(100vh - 220px); }
  .qcard .prompt { font-size: 19px; }
  .qcard pre { margin-left: -20px; margin-right: -20px; border-radius: 0; border-left: 0; border-right: 0; font-size: 12.5px; }
  .opt { margin: 0; padding: 12px 14px; min-height: 56px; border: 1px solid var(--rule); border-radius: 10px; font-size: 16px; }
  .options { gap: 8px; }
  .opt:hover { background: transparent; }
  .opt:active { background: var(--hover); }
  .opt.selected { border-color: var(--ink); }
  .editor textarea { min-height: 220px; font-size: 14px; }
  .qnav { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 14px 20px 4px; margin: 0; scrollbar-width: none; }
  .qnav::-webkit-scrollbar { display: none; }
  .qnav button { flex: none; width: 36px; height: 36px; }
  .nav-caption { text-align: left; padding: 0 20px; }
  .qfoot {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 12; margin: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--rule);
  }
  .qfoot .btn { flex: 1; height: 48px; font-size: 15px; }
  .kbd-hint { display: none; }
  .modal { position: fixed; left: 0; right: 0; bottom: 0; max-width: none; border-radius: 16px 16px 0 0; padding: 24px 20px calc(20px + env(safe-area-inset-bottom)); animation: sheet-up .2s ease-out; }
  .modal .row .btn { flex: 1; height: 48px; }
  @keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
  .center { padding: 0; }
  .done-sheet { min-height: 100vh; display: grid; place-items: center; }

  /* admin: tables turn into stacked rows */
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 0; text-align: left; }
  table.stack td.primary { grid-column: 1 / -1; }
  table.stack td.right { text-align: right; }
  table.stack td.hide-sm { display: none; }
  table.stack td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font: 12px var(--sans); }
  .empty-row td { grid-column: 1 / -1; }
  .tabs { overflow-x: auto; scrollbar-width: none; gap: 18px; }
  .subhead .row.between { flex-direction: column; align-items: stretch; }
  .copy-link { width: 100%; }
  .page-head { flex-direction: column; align-items: stretch; }
  .new-quiz { width: 100%; }
  .new-quiz input[name=title] { flex: 1 1 100%; }
  .q-row { grid-template-columns: 22px 1fr; }
  .q-actions { grid-column: 2; opacity: 1; }
  .paper-q { grid-template-columns: 44px 1fr; }
  .wall { grid-template-columns: 1fr; }
  .summary-line { gap: 14px; }
  .form-row { padding: 14px 16px; }
}

/* review & submit */
.review-head h2 { font: 600 22px var(--serif); margin-bottom: 4px; }
.review-head p { margin: 0 0 18px; font-size: 13.5px; }
.review-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.review-item { padding: 16px 0 18px; border-bottom: 1px solid var(--rule); }
.ri-head { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: start; }
.ri-head .rn { font: 500 12px var(--mono); color: var(--muted); padding-top: 3px; }
.ri-head .rq { font-family: var(--serif); font-size: 16px; line-height: 1.45; white-space: pre-wrap; }
.redit { background: none; border: 0; padding: 2px 0; font: 500 12.5px var(--sans); color: var(--blue); cursor: pointer; }
.redit:hover { text-decoration: underline; }
.ri-opts { display: grid; gap: 2px; margin: 10px 0 0 40px; }
.ri-opt { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: center; text-align: left; width: 100%;
  background: none; border: 0; border-radius: var(--r); padding: 6px 8px; margin-left: -8px; font: 14.5px var(--sans); color: var(--graphite); cursor: pointer; }
.ri-opt:hover { background: var(--hover); }
.ri-opt .key { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--rule-2); display: grid; place-items: center; font: 500 11px var(--mono); color: var(--graphite); }
.ri-opt .txt { white-space: pre-wrap; }
.ri-opt.selected { color: var(--ink); font-weight: 500; }
.ri-opt.selected .key { background: var(--ink); border-color: var(--ink); color: #fff; }
.review-item .ra { margin: 8px 0 0 40px; font-size: 13.5px; color: var(--graphite); white-space: pre-wrap; }
.review-item .ra.mono { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); border: 1px solid var(--rule); border-radius: var(--r); padding: 8px 10px; }
.review-item.open .rn, .review-item.open > .ra { color: var(--red); }
.review-item.open > .ra { font-weight: 500; margin-bottom: 0; }
@media (max-width: 640px) {
  .ri-opts, .review-item .ra { margin-left: 0; }
  .ri-opt { min-height: 44px; margin-left: 0; border: 1px solid var(--rule); border-radius: 10px; padding: 8px 12px; }
  .ri-opts { gap: 6px; }
  .ri-opt.selected { border-color: var(--ink); }
}
.test-tag { display: inline-block; font: 500 11px var(--mono); color: var(--amber); border: 1px solid #e6c66f; background: var(--amber-bg); border-radius: 4px; padding: 0 5px; vertical-align: 2px; }

/* score summary on the attempt page */
.scorecard { display: grid; grid-template-columns: 1.1fr 1fr 1.2fr; margin-bottom: 20px; }
.scorecard > div { padding: 20px 22px; }
.scorecard > div + div { border-left: 1px solid var(--rule); }
.sc-num { display: flex; align-items: baseline; gap: 8px; }
.sc-num b { font: 500 44px/1 var(--mono); letter-spacing: -0.03em; }
.sc-num span { font: 400 18px var(--mono); color: var(--muted); }
.sc-pct { font-size: 13px; color: var(--graphite); margin: 6px 0 14px; }
.meter { position: relative; height: 10px; background: #eceef1; border-radius: 99px; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); border-radius: 99px; }
.meter > i.pend, .sec-bar > i.pend {
  background: repeating-linear-gradient(45deg, #d89b00 0 2px, transparent 2px 5px); border-radius: 0 99px 99px 0; opacity: .7;
}
.meter .avg { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1.5px; background: var(--graphite); border-radius: 2px; cursor: help; box-shadow: 0 0 0 2px var(--paper); }
.meter .avg::before { content: ""; position: absolute; inset: -4px -8px; }   /* bigger hover target */
.sc-cap { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; color: var(--graphite); flex-wrap: wrap; }
.sc-cap b { color: var(--ink); font-weight: 600; }
.avg-key { display: inline-block; width: 2px; height: 12px; background: var(--graphite); vertical-align: -2px; margin-right: 6px; }
.sc-pending { margin-top: 10px; font-size: 12.5px; color: var(--amber); }
.sc-block h3 { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 12px; }

.sec-row { display: grid; grid-template-columns: 110px 1fr 46px; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; position: relative; }
.sec-label { color: var(--graphite); }
.sec-bar { position: relative; height: 8px; background: #eceef1; border-radius: 99px; }
.sec-bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); border-radius: 99px; }
.sec-val { font-family: var(--mono); text-align: right; }

.qstrip { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.qcell { position: relative; display: grid; place-items: center; height: 46px; border-radius: 6px; border: 1px solid transparent; text-decoration: none !important; line-height: 1.1; }
.qcell .sym { font-size: 15px; font-weight: 600; }
.qcell .n { font: 500 10.5px var(--mono); opacity: .8; }
.qcell.right { background: #e3f3eb; color: #0b8a5a; border-color: #b9e0cc; }
.qcell.wrong { background: var(--red-bg); color: var(--red); border-color: #efc4bf; }
.qcell.partial { background: #e8f1ed; color: #0b8a5a; border-color: #b9e0cc; border-style: dashed; }
.qcell.pending { background: var(--amber-bg); color: #8a5a00; border-color: #ecd38f; }
.qcell.skipped { background: var(--paper); color: var(--muted); border-color: var(--rule-2); border-style: dashed; }
.qcell:hover { filter: brightness(.96); }
.qlegend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 12px; color: var(--graphite); }
.qlegend b { margin-right: 4px; }
.qlegend .right b { color: #0b8a5a; } .qlegend .wrong b { color: var(--red); } .qlegend .partial b { color: #0b8a5a; }
.qlegend .pending b { color: #8a5a00; } .qlegend .skipped b { color: var(--muted); }
.paper-q { scroll-margin-top: 16px; }
.paper-q:target { background: #fffbea; }

/* tooltips for chart marks */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: #fff; font: 12px/1.4 var(--sans); padding: 5px 8px; border-radius: 5px; white-space: nowrap; pointer-events: none;
}

@media (max-width: 900px) {
  .scorecard { grid-template-columns: 1fr; }
  .scorecard > div + div { border-left: 0; border-top: 1px solid var(--rule); }
}
