:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --ink: #111214;
  --muted: var(--ink); /* all text is black (was grey) */
  --faint: var(--ink);
  --sep: 2px solid #b4b8c0; /* separator between panel sections */
  --line: #e1e1dc;
  --soft: #f3f4f6;
  --accent: #2456d3;
  --accent-soft: #e8eefc;
  --accent-ink: #ffffff;
  --ok: #1d7f48;
  --ok-soft: #e5f4ec;
  --warn: #9a4a10;
  --warn-soft: #fdf0e3;
  --stage: #26282c;
  --stage-ink: #d9dbe0;
  --radius: 0.625rem;
  --topbar: 2.875rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
/* Everything is sized in rem, and the root size follows the window: 17px on a 1440x900 window, larger on big
   screens (capped by the window height so a wide but short window does not blow the text up). */
html { font-size: clamp(17px, min(1.2vw, 1.9vh), 30px); }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 0.9375rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
.noscript { padding: 1.5rem; }

/* ---------- generic ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.5rem; padding: 0 1.125rem;
  border-radius: 0.5rem; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { border-color: #c4c6cc; background: #fafafa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #1d49b8; border-color: #1d49b8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { min-height: 2rem; padding: 0 0.75rem; font-size: 0.8438rem; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--soft); border-color: transparent; }
:focus-visible { outline: 3px solid #8fb0ff; outline-offset: 2px; }

.preview-ribbon {
  background: #fff6d6; color: #6b5200; border-bottom: 1px solid #f0dc94;
  font-size: 0.8125rem; padding: 0.3125rem 1rem; text-align: center;
}

/* ---------- centred pages (welcome, instructions, finish) ---------- */
.screen-center {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1rem;
}
.card {
  width: 100%; max-width: 45rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 0.875rem;
  padding: 2.25rem 2.5rem; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 0.5rem 1.75rem rgba(0,0,0,.05);
}
.card h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }
.card .kicker { color: var(--muted); font-size: 0.8125rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 1.125rem; }
.card p { margin: 0 0 0.875rem; }
.card .actions { display: flex; gap: 0.625rem; justify-content: flex-end; margin-top: 1.625rem; flex-wrap: wrap; }
.notice { border-radius: 0.5rem; padding: 0.75rem 0.875rem; margin: 0 0 1rem; font-size: 0.875rem; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--accent-soft); color: var(--ink); }
.consent { border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.875rem 1rem; margin: 1.125rem 0 0; max-height: 16.25rem; overflow: auto; font-size: 0.875rem; }
.consent-check { display: flex; gap: 0.625rem; align-items: flex-start; margin-top: 0.75rem; font-weight: 600; cursor: pointer; }
.consent-check input { margin-top: 4px; width: 1.0625rem; height: 1.0625rem; }

.richtext p { margin: 0 0 0.75rem; }
.richtext ul { margin: -4px 0 0.75rem; padding-left: 1.375rem; }
.richtext li { margin: 2px 0; }
.richtext .lead { font-weight: 700; font-size: 1.0312rem; }
.richtext .example { background: var(--soft); border: 1px solid #d5d8de; border-radius: 0.5rem; padding: 0.75rem 0.875rem; }
.richtext .example strong { font-weight: 750; }

.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  border: 1px dashed #b9bdc6; border-radius: 0.625rem; padding: 0.75rem 1rem; margin: 0.375rem 0 1rem;
}
.code-box .code { font: 700 1.25rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; }
.fallback-data { width: 100%; height: 6.875rem; font: 0.75rem/1.4 ui-monospace, Menlo, Consolas, monospace; border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.5rem; resize: vertical; }

.spinner { width: 2.125rem; height: 2.125rem; border: 3px solid #d6d8dd; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- question screen ---------- */
.qscreen { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  flex: 0 0 var(--topbar); height: var(--topbar);
  display: flex; align-items: center; gap: 1.125rem; padding: 0 1rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .count { font-weight: 700; white-space: nowrap; }
.progress { flex: 1; max-width: 22.5rem; height: 0.375rem; border-radius: 3px; background: #e7e8eb; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .25s; }
.topbar .spacer { flex: 1; }
.topbar .ref { color: var(--faint); font-size: 0.7812rem; font-variant-numeric: tabular-nums; }

.qmain { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(23.75rem, 36vw, 35rem); }

.stage {
  position: relative; min-width: 0; min-height: 0;
  background: var(--stage); padding: 0.5rem 0.75rem;
  display: flex; align-items: center; justify-content: center; gap: 0.625rem;
  overflow: hidden;
}
.stage[data-mode="side"] { flex-direction: row; }
.stage[data-mode="stacked"], .stage[data-mode="single"] { flex-direction: column; }
.pic { margin: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.pic figcaption {
  height: 1.25rem; line-height: 1.25rem; color: var(--stage-ink);
  font-size: 0.8125rem; font-weight: 700; letter-spacing: .03em;
}
.stage[data-cap="left"] .pic { flex-direction: row; align-items: center; }
.stage[data-cap="left"] .pic figcaption { writing-mode: vertical-rl; transform: rotate(180deg); height: auto; width: 1.25rem; text-align: center; }
.stage[data-cap="left"] .pic figcaption .zoom-hint { display: none; }
.pic figcaption .zoom-hint { font-weight: 500; letter-spacing: 0; text-transform: none; color: #9a9ea6; margin-left: 0.5rem; }
.imgbox { position: relative; background: #3a3d42; border-radius: 4px; overflow: hidden; cursor: zoom-in; }
.imgbox.loading { background: linear-gradient(90deg, #34373c 0%, #41444a 50%, #34373c 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.imgbox img { display: block; width: 100%; height: 100%; object-fit: contain; }
.imgbox .img-error {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 0.625rem;
  align-items: center; justify-content: center; color: #eee; background: rgba(30,30,30,.85); font-size: 0.875rem; cursor: default;
}

.panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 1.125rem 1.25rem 0.75rem; }
.panel-foot {
  flex: 0 0 auto; display: flex; align-items: center; gap: 0.625rem;
  padding: 0.75rem 1.25rem; border-top: 1px solid var(--line); background: var(--panel);
}
.panel-foot .hint { flex: 1; text-align: right; color: var(--muted); font-size: 0.8125rem; line-height: 1.3; }
.panel-foot .hint.done { color: var(--ok); font-weight: 600; }

.sec-label { font-size: 0.75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.375rem; }
.brief-label { font-weight: 800; font-size: 1.2rem; color: var(--ink); margin: 0 0 0.25rem; }
.brief { margin: 0 0 0.75rem; font-size: 0.9688rem; line-height: 1.5; }
.brief strong.goal { font-weight: 750; }
.objective-callout { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 0.5rem 0.5rem 0; padding: 0.5625rem 0.75rem; margin: 0 0 0.75rem; }
.objective-callout .k { display: block; font-size: 0.7812rem; font-weight: 700; color: var(--ink); }
.objective-callout .v { font-weight: 650; }
/* collapsible sections: "About the photos" (all parts) and "How to answer" (U2) */
.fold { margin: 0 0 0.875rem; }
.fold summary { cursor: pointer; font-weight: 800; font-size: 1.0625rem; color: var(--ink); list-style-position: inside; }
.fold summary:hover { color: var(--accent); }
.fold:not([open]) summary::after { content: "  (click to show)"; font-weight: 500; font-size: 0.8125rem; color: var(--muted); }
.fold-body { margin-top: 0.3125rem; font-size: 0.875rem; line-height: 1.45; }
.fold-body p { margin: 0 0 4px; }
.fold-body p:last-child { margin: 0; }
.photo-notes { padding-bottom: 0.875rem; border-bottom: var(--sep); }
.photo-notes .fold-body { color: var(--ink); }
.how-box { margin-top: -2px; padding-bottom: 0.875rem; border-bottom: var(--sep); }
.how-box .fold-body { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 0 0.5rem 0.5rem 0; padding: 0.5rem 0.75rem 0.5rem 0.625rem; }
.how-box ol { margin: 0; padding-left: 1.25rem; color: var(--ink); font-weight: 600; }
.how-box li { margin: 2px 0; }
.ask { margin: 0 0 0.875rem; padding-bottom: 0.875rem; border-bottom: var(--sep); font-size: 0.9062rem; line-height: 1.5; }
.ask strong { font-weight: 800; }

/* sample question: confirmation before the questions start */
.confirm { display: flex; gap: 0.625rem; align-items: flex-start; margin: 1rem 0 4px; padding: 0.75rem 0.875rem; border: 2px solid var(--accent); border-radius: 0.625rem; background: var(--accent-soft); cursor: pointer; font-size: 0.9062rem; line-height: 1.4; }
.confirm input { width: 1.125rem; height: 1.125rem; margin-top: 1px; flex: 0 0 1.125rem; accent-color: var(--accent); }
.confirm.flash { animation: confirmflash .9s ease-out; }
@keyframes confirmflash { 0%, 40% { box-shadow: 0 0 0 0.3125rem rgba(36, 86, 211, .35); } 100% { box-shadow: 0 0 0 0 rgba(36, 86, 211, 0); } }
.btn.primary.is-disabled { opacity: .45; }

.ans-head { font-weight: 700; margin: 0 0 0.625rem; }
.ans-sub { color: var(--muted); font-weight: 500; font-size: 0.8438rem; }

/* multi-select boxes (U1, U3) */
.boxgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.875rem, 1fr)); gap: 0.5rem; }
.chip { position: relative; display: block; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: flex; align-items: center; justify-content: center; gap: 0.375rem; white-space: nowrap;
  min-height: 2.75rem; padding: 0 0.625rem; border: 1.5px solid var(--line); border-radius: 0.5rem;
  font-weight: 600; background: var(--panel); user-select: none;
  transition: background .1s, border-color .1s, color .1s;
}
.chip span::before {
  content: ""; width: 0.9375rem; height: 0.9375rem; flex: 0 0 0.9375rem; border-radius: 4px; border: 1.5px solid #b3b7bf; background: #fff;
}
.chip:hover span { border-color: #b9c6ea; }
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.chip input:checked + span::before {
  border-color: var(--accent); background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/0.75rem no-repeat;
}
.chip input:focus-visible + span { outline: 3px solid #8fb0ff; outline-offset: 2px; }
.chip.none { margin-top: 0.625rem; }
.chip.none span { justify-content: flex-start; padding: 0 0.875rem; }

/* per-box assignment (U2) */
.boxstrip { display: flex; flex-wrap: wrap; gap: 0.3125rem; margin: 0 0 0.75rem; }
.bchip {
  width: 2.625rem; height: 2.75rem; padding: 0; border-radius: 0.5rem; border: 1.5px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; cursor: pointer;
}
.bchip .n { font-size: 0.6562rem; color: var(--muted); font-weight: 600; }
.bchip .v { font-size: 1rem; font-weight: 800; color: var(--faint); }
.bchip.answered { background: var(--ok-soft); border-color: #b9dcc7; }
.bchip.answered .v { color: var(--ok); }
.bchip.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; background: var(--accent-soft); }
.bchip.current .v { color: var(--accent); }
.boxq { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 0.75rem 0.625rem; }
.boxq-title { display: flex; align-items: baseline; gap: 0.5rem; margin: 0 0 0.5rem; }
.boxq-title .big { font-size: 1.1875rem; font-weight: 800; }
.boxq-title .of { color: var(--muted); font-size: 0.8125rem; }
.boxq-title .nav { margin-left: auto; display: flex; gap: 4px; }
.boxq.flash { animation: flash .45s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.opts { display: flex; flex-direction: column; gap: 0.3125rem; }
.opt { position: relative; display: block; cursor: pointer; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt > span {
  display: flex; align-items: flex-start; gap: 0.625rem; padding: 0.375rem 0.625rem;
  border: 1.5px solid var(--line); border-radius: 0.5rem; background: var(--panel); line-height: 1.32; font-size: 0.9062rem;
  transition: background .1s, border-color .1s;
}
.opt .letter {
  flex: 0 0 1.5rem; height: 1.5rem; border-radius: 0.375rem; background: var(--soft); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8438rem; margin-top: -1px;
}
.opt .txt { padding-top: 1px; }
.opt.special .txt { font-style: italic; color: var(--ink); }
.opt:hover > span { border-color: #b9c6ea; }
.opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.opt input:checked + span .letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt input:focus-visible + span { outline: 3px solid #8fb0ff; outline-offset: 2px; }

.kbd-hint { color: var(--faint); font-size: 0.75rem; margin: 0.75rem 0 0; }
kbd { font: 600 0.6875rem/1 ui-monospace, Menlo, Consolas, monospace; border: 1px solid #d3d5da; border-bottom-width: 2px; border-radius: 4px; padding: 2px 0.3125rem; background: #fafafa; color: var(--muted); }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(12,13,15,.9); display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; max-width: 100%; max-height: 100%; }
.lightbox figcaption { color: #e3e5e9; font-size: 0.8438rem; }
.lightbox img { max-width: calc(100vw - 2.5rem); max-height: calc(100vh - 5rem); max-height: calc(100dvh - 5rem); object-fit: contain; display: block; }
.modal { background: rgba(12,13,15,.55); }
.modal .card { max-height: calc(100vh - 2.5rem); max-height: calc(100dvh - 2.5rem); overflow: auto; }

/* ---------- narrow windows: stack image area above the panel and let the page scroll ---------- */
@media (max-width: 899px) {
  .qscreen { height: auto; min-height: 100dvh; overflow: visible; }
  .qmain { grid-template-columns: 1fr; }
  .stage { padding: 0.75rem 1rem; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .panel-scroll { overflow: visible; }
  .panel-foot { position: sticky; bottom: 0; }
  .card { padding: 1.625rem 1.25rem; }
  .topbar { gap: 0.625rem; }
  .topbar .ref { display: none; }
}

/* ---------- short windows (small laptops): tighten vertical spacing ---------- */
@media (min-width: 900px) and (max-height: 800px) {
  :root { --topbar: 2.625rem; }
  .panel-scroll { padding: 0.875rem 1.125rem 0.625rem; }
  .panel-foot { padding: 0.5625rem 1.125rem; }
  .brief { font-size: 0.9062rem; line-height: 1.45; margin-bottom: 0.625rem; }
  .objective-callout { padding: 0.4375rem 0.6875rem; margin-bottom: 0.625rem; }
  .fold { margin-bottom: 0.625rem; }
  .photo-notes { padding-bottom: 0.5625rem; }
  .ask { margin-bottom: 0.625rem; padding-bottom: 0.625rem; font-size: 0.875rem; }
  .ans-head { margin-bottom: 0.5rem; }
  .boxstrip { margin-bottom: 0.5625rem; }
  .bchip { height: 2.5rem; }
  .boxq { padding: 0.5625rem 0.625rem 0.5rem; }
  .opts { gap: 4px; }
  .opt > span { padding: 0.3125rem 0.5625rem; font-size: 0.875rem; line-height: 1.28; }
  .chip span { min-height: 2.5rem; }
  .kbd-hint { margin-top: 0.5rem; }
  .stage { padding: 0.375rem 0.625rem; gap: 0.5rem; }
}

/* ---------- sample question: answer frames and explanations ---------- */
.pill { font-size: 0.75rem; font-weight: 700; color: #6b5200; background: #fff1c2; border-radius: 62.4375rem; padding: 2px 0.625rem; }
.ov { position: absolute; border: 3px solid; border-radius: 3px; pointer-events: none; }
.ov.hit { border-color: #16a34a; background: rgba(22, 163, 74, .14); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.ov.miss { border-color: transparent; }
.ov .tag {
  position: absolute; top: 4px; right: 4px; color: #fff; font: 700 0.75rem/1 var(--font); letter-spacing: .01em;
  padding: 4px 0.4375rem; border-radius: 0.3125rem; white-space: nowrap; box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.ov.hit .tag { background: #16a34a; }
.ov.miss .tag { background: rgba(55, 60, 68, .88); }
.fb-score { font-weight: 700; margin: 0.875rem 0 0.625rem; padding: 0.625rem 0.75rem; border-radius: 0.5rem; background: var(--ok-soft); color: var(--ok); }
.fb-score span { color: var(--ink); }
.fb-list { display: flex; flex-direction: column; gap: 0.4375rem; }
.fb-row { display: flex; gap: 0.625rem; align-items: flex-start; padding: 0.5rem 0.625rem; border-radius: 0.5rem; border: 1px solid var(--line); font-size: 0.875rem; line-height: 1.4; }
.fb-row.hit { border-color: #b9dcc7; background: #f4fbf7; }
.fb-mark { flex: 0 0 1.375rem; height: 1.375rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 0.7812rem; background: #16a34a; margin-top: 1px; }
.fb-row.miss .fb-mark { background: #8a9099; }
.fb-why { color: var(--ink); }
.fb-rule { margin-top: 0.75rem; padding: 0.625rem 0.75rem; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 0.5rem 0.5rem 0; font-size: 0.875rem; }
.exfigs { display: grid; grid-template-columns: repeat(auto-fit, minmax(16.25rem, 1fr)); gap: 0.75rem; background: var(--stage); padding: 0.75rem; border-radius: 0.625rem; margin: 0.375rem 0 4px; }
.exfigs .imgbox { width: 100%; height: auto; cursor: default; }
.modal .card.wide { max-width: 66.25rem; }
.chip:has(input:disabled), .opt:has(input:disabled) { cursor: default; }
.chip:has(input:disabled):hover span, .opt:has(input:disabled):hover > span { border-color: var(--line); }
.chip:has(input:disabled:checked):hover span, .opt:has(input:disabled:checked):hover > span { border-color: var(--accent); }

/* combined instructions + sample page */
.sec-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; margin: 0 0 0.625rem; }
.instr-block .richtext { font-size: 0.9062rem; line-height: 1.5; }
.instr-block .richtext .lead { font-size: 0.9688rem; }
.instr-note { color: var(--muted); font-size: 0.8125rem; margin: 4px 0 0; }
.sample-title { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 3px solid #b4b8c0; }
