:root {
  color-scheme: light;
  /* A-List brand (PROVISIONAL: red and black taken from the logo's description,
     not official brand guidelines; swap --brand-red / --brand-black for the real values) */
  --brand-red: #c8102e;
  --brand-red-dark: #9e0c24;
  --brand-black: #141414;
  --ink: #1a1a1a;
  --muted: #5f5f66;
  --line: #dcdcdf;
  --bg: #f4f4f3;
  --panel: #ffffff;
  --navy: var(--brand-black);
  --accent: var(--brand-red);
  --accent-soft: #fbe9ec;
  --select: #1a1a1a;
  --select-soft: #efeff1;
  --warn: #8a5300;
  --warn-soft: #fff3df;
  --danger: #b42318;
  --highlight: #fde68a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
h1 { font-size: 1.6rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.3rem; margin: 0 0 0.5rem; }
.muted { color: var(--muted); }
.loading { padding: 2rem; text-align: center; color: var(--muted); }

.screen { max-width: 760px; margin: 0 auto; padding: 32px 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-top: 40px; padding: 32px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--muted); margin: 0; }

label { display: block; font-weight: 600; margin: 0 0 16px; }
label input:not([type="checkbox"]) {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  font: inherit; border: 1px solid var(--line); border-radius: 6px;
}
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }

.primary, #back, #return, #open-review, #retry, .navbar button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 10px 18px; border-radius: 999px;
}
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--brand-red-dark); border-color: var(--brand-red-dark); }
.primary.danger { background: var(--danger); border-color: var(--danger); }
.error { color: var(--danger); }
.notice { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 6px; }

/* Test layout */
.topbar {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 12px; padding: 10px 20px; background: var(--navy); color: #fff;
  border-bottom: 3px solid var(--brand-red);
}
.tb-right { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.15rem;
  padding: 4px 14px; border-radius: 6px; background: rgba(255, 255, 255, 0.12);
}
.timer.low { background: #ffe8b8; color: #6b3f00; }
.timer.untimed { font-size: 0.95rem; font-weight: 600; }

.qwrap {
  display: grid; grid-template-columns: 1fr 1fr; min-height: calc(100vh - 116px);
  max-width: 1280px; margin: 0 auto;
}
.qwrap.no-passage { grid-template-columns: 1fr; max-width: 760px; }
.passage-pane, .question-pane { padding: 28px 28px 110px; overflow-y: auto; max-height: calc(100vh - 116px); }
.passage-pane { border-right: 3px solid var(--line); background: var(--panel); }
.question-pane { background: var(--panel); }

.hl-text { white-space: pre-wrap; line-height: 1.65; user-select: text; }
.hl-text mark { background: var(--highlight); color: inherit; cursor: pointer; }
.prompt { font-weight: 600; margin: 16px 0 18px; }

.qhead { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #f0f0f1; border-bottom: 2px dashed var(--line); padding: 6px 8px; }
.qnum { background: var(--ink); color: #fff; min-width: 32px; height: 32px; display: inline-grid; place-items: center; font-weight: 700; }
.flag { background: none; border: none; color: var(--ink); padding: 6px 8px; }
.flag.on { color: var(--warn); font-weight: 600; }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; color: var(--ink);
  background: var(--panel); border: 1.5px solid #9aa4b5; border-radius: 10px; padding: 12px 14px;
}
.choice.selected { border-color: var(--select); box-shadow: 0 0 0 2px var(--select) inset; background: var(--select-soft); }
.letter {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--ink);
  display: grid; place-items: center; font-weight: 700; font-size: 0.9rem;
}
.choice.selected .letter { background: var(--select); border-color: var(--select); color: #fff; }
.choice:hover:not(.selected) { border-color: var(--ink); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 18px; }

.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--panel); border-top: 1px solid var(--line);
}
.navtoggle { background: var(--navy) !important; color: #fff !important; border-color: var(--navy) !important; }

/* Review */
.review { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-top: 24px; padding: 28px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); font-size: 0.9rem; margin: 12px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 10px; margin: 16px 0 24px; }
.tile { position: relative; height: 46px; border: 1.5px dashed #9aa4b5; background: var(--panel); border-radius: 6px; font-weight: 600; }
.tile.answered { border-style: solid; border-color: var(--select); background: var(--select); color: #fff; }
.tile.current { outline: 3px solid var(--ink); outline-offset: 2px; }
.tile.sample { display: inline-block; width: 22px; height: 22px; vertical-align: middle; }
.star { color: var(--warn); }
.tile .star { position: absolute; top: -9px; right: -6px; font-size: 0.95rem; }
.review-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.confirm { color: var(--danger); font-weight: 600; }

/* Preview summary */
.notice.preview { background: var(--select-soft); color: var(--ink); border-left: 3px solid var(--brand-red); }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 18px 0; }
.summary div { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.summary dt { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.summary dd { margin: 4px 0 0; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary dd .muted { font-size: 0.8rem; font-weight: 400; }
.strip-label { margin: 14px 0 6px; font-weight: 600; font-size: 0.9rem; }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 4px; }
.cell { display: inline-grid; place-items: center; min-width: 22px; height: 28px; border-radius: 4px; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.legend .cell { width: 18px; height: 18px; min-width: 0; }
.cell.right { background: #d9f2e3; color: #13653a; }
.cell.wrong { background: #fde2e1; color: var(--danger); }
.cell.blank { background: #efeff1; color: var(--muted); }

@media (max-width: 820px) {
  .qwrap { grid-template-columns: 1fr; }
  .passage-pane, .question-pane { max-height: none; overflow: visible; }
  .passage-pane { border-right: none; border-bottom: 3px solid var(--line); padding-bottom: 28px; }
  .topbar { grid-template-columns: auto auto; }
  .tb-right { display: none; }
  .card { margin-top: 16px; padding: 22px; }
}

/* Math */
.qwrap.math .question-pane { font-size: 1.02rem; }
.math-stem { display: flex; flex-direction: column; gap: 14px; margin: 18px 0 20px; line-height: 1.6; }
.math-stem p { margin: 0; }
.block.q { font-weight: 600; }
.block.eq { text-align: center; font-size: 1.15rem; padding: 4px 0; }
.block.eq p { margin: 4px 0; }
math { font-size: 1.08em; }
.figure { margin: 0; text-align: center; }
.figure img { max-width: 100%; height: auto; max-height: 420px; }
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; margin: 0 auto; font-variant-numeric: tabular-nums; }
table.data th, table.data td { border: 1px solid var(--ink); padding: 6px 18px; text-align: center; }
table.data th { background: #f0f0f1; font-weight: 600; }
.ctext table.data { margin: 0; }
.ctext table.data th, .ctext table.data td { padding: 3px 12px; }
.spr { display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.spr label { margin: 0; }
#spr-input { font: inherit; font-size: 1.3rem; padding: 10px 12px; border: 1.5px solid #9aa4b5; border-radius: 8px; width: 11ch; font-variant-numeric: tabular-nums; }
#spr-input:focus { outline: 3px solid var(--select); outline-offset: 1px; border-color: var(--select); }
.tb-btn { background: rgba(255, 255, 255, 0.12); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; padding: 5px 14px; }
.tb-btn[aria-pressed="true"] { background: #fff; color: var(--navy); }
.tb-right { display: flex; justify-content: flex-end; gap: 8px; }
.calc-panel { position: fixed; top: 64px; right: 16px; bottom: 76px; width: min(420px, calc(100vw - 32px)); z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(20, 30, 50, 0.18);
  display: flex; flex-direction: column; overflow: hidden; }
.calc-panel[hidden] { display: none; }   /* display:flex above would otherwise beat the hidden attribute */
.calc-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--navy); color: #fff; font-weight: 600; }
.calc-close { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.5); color: #fff; font-size: 0.95rem;
  line-height: 1; padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.calc-close:hover { background: rgba(255,255,255,0.3); }
.calc-body { flex: 1; padding: 0; }
.calc-body p { padding: 16px; margin: 0; }
.small { font-size: 0.85rem; }
.plan ol { margin: 4px 0 16px; padding-left: 1.3rem; }
.break-timer { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 12px 0 20px; }
.sum-head { margin-top: 24px; }
math { math-style: normal; }
.figure img { max-height: 460px; }

/* Brand + mode screens */
.brand-line { margin: 0 0 18px; font-size: 0.95rem; letter-spacing: 0.02em; color: var(--muted); }
.brand-mark { font-weight: 800; color: var(--brand-red); letter-spacing: 0; }

/* HubSpot form screen, between sending and the results */
.lead-intro { margin: 0 0 24px; line-height: 1.55; }
.hs-form-frame { min-height: 200px; }
.card { border-top: 4px solid var(--brand-red); }
.ask { margin-top: 26px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 10px; }
.role { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 18px;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px; color: var(--ink); }
.role:hover { border-color: var(--brand-black); }
.role-title { font-size: 1.15rem; font-weight: 700; }
.role-sub { color: var(--muted); font-size: 0.92rem; }
#passcode-row { margin-top: 16px; }
.inline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; }
#passcode { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; }
.linkish { background: none; border: none; color: var(--ink); text-decoration: underline; padding: 8px 4px; }
.t-opt { border-top: 1px solid var(--line); padding-top: 18px; margin: 18px 0 0; }
.t-opt h2 { font-size: 1.15rem; margin-bottom: 4px; }
.t-opt .muted { margin: 0 0 12px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.module-btn { text-align: left; padding: 11px 14px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 8px; color: var(--ink); }
.module-btn:hover { border-color: var(--brand-black); }
.picker { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.picker label { margin: 0 0 6px; font-size: 0.9rem; }
.picker select, .jump select { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
.jump { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.feedback { margin: 16px 0 0; padding: 10px 12px; border-radius: 6px; }
.feedback.right { background: #d9f2e3; color: #13653a; }
.feedback.wrong { background: #fde2e1; color: var(--danger); }
.feedback.blank { background: var(--select-soft); color: var(--ink); }
@media (max-width: 820px) {
  .tb-right { display: flex; }
  .topbar { grid-template-columns: 1fr auto; }
  .topbar .tb-left { display: none; }
}
.tester .eyebrow { margin-bottom: 6px; }
#check-answer { border: 1.5px solid var(--brand-black); border-radius: 999px; padding: 5px 14px; background: var(--panel); font-weight: 600; }
#check-answer:hover { background: var(--brand-black); color: #fff; }

/* ---- bar charts in English questions ---- */
.fg { margin: 0 0 18px; padding: 14px 14px 6px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; }
.fg-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; text-align: center; }
.fg svg { display: block; width: 100%; height: auto; }
.fg-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center;
  margin-bottom: 8px; font-size: 13px; color: var(--ink); }
.fg-key { display: inline-flex; align-items: center; gap: 7px; }
.fg-key i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.fg-grid { stroke: #e4e4e7; stroke-width: 1; }
.fg-axis { stroke: #9a9aa2; stroke-width: 1.5; }
.fg-tick { font-size: 11px; fill: var(--muted); }
.fg-cat { font-size: 11.5px; fill: var(--ink); }
.fg-italic { font-style: italic; }
.fg-axislabel { font-size: 12px; fill: var(--muted); font-weight: 600; }
@media print { .fg { break-inside: avoid; } }

/* while the calculator is open, move the question out from under the panel */
@media (min-width: 900px) {
  body.calc-open .qwrap { margin: 0 452px 0 0; max-width: none; }
  body.calc-open .qwrap.no-passage { max-width: none; }
}

/* the student's own copy of the score report on the finish screen */
.screen.card.wide { max-width: 1000px; }
.reportframe { width: 100%; height: 70vh; min-height: 420px; margin-top: 16px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; }
@media print { .screen.card.wide > *:not(.reportframe) { display: none; } .reportframe { height: auto; border: none; } }

.rule { border: none; border-top: 1px solid var(--line); margin: 18px 0 16px; }
.secname { margin: 2px 0 6px; font-size: 1.35rem; }
