:root {
  --bg: #0a0d13;
  --bg-2: #0e131c;
  --surface: #131926;
  --surface-2: #1a2232;
  --surface-3: #212b3e;
  --line: #263248;
  --line-soft: #1d2637;
  --text: #e8edf6;
  --text-dim: #b3bfd2;
  --muted: #7d8aa0;
  --accent: #5b8dff;
  --accent-soft: #1c2a4a;
  --ok: #34d399;
  --ok-soft: #102c22;
  --bad: #fb7185;
  --bad-soft: #33141c;
  --warn: #fbbf24;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --pad: clamp(12px, 3.2vw, 24px);
  --gap: clamp(8px, 1.6vw, 14px);

  --fs-body: clamp(14px, 0.35vw + 13.2px, 16px);
  --fs-small: clamp(11.5px, 0.2vw + 11px, 13px);
  --fs-h1: clamp(13px, 0.5vw + 11.6px, 15px);
  --fs-h2: clamp(17px, 0.7vw + 15px, 22px);
  --fs-stem: clamp(15px, 0.45vw + 13.8px, 17px);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --rail-space: 74px;
}

body.rail-open { --rail-space: 208px; }

* { box-sizing: border-box; }

/* Author rules below set display on flex/grid components, which would beat the
   user-agent [hidden] rule. Keep hidden authoritative. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ============================ top bar ============================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: calc(10px + var(--safe-t)) var(--pad) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  flex: 0 0 auto;
}

.brand-txt { min-width: 0; }

.brand h1 {
  margin: 0;
  font-size: var(--fs-h1);
  font-weight: 650;
  letter-spacing: -.012em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand p {
  margin: 1px 0 0;
  font-size: var(--fs-small);
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score {
  display: flex;
  gap: 5px;
  flex: 0 0 auto;
}

.score-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: clamp(38px, 8vw, 52px);
  padding: 5px 7px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}

.score-cell b {
  font-size: clamp(13px, 0.4vw + 12px, 16px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.score-cell span {
  margin-top: 3px;
  font-size: clamp(8.5px, 0.15vw + 8px, 10px);
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  line-height: 1;
}

#sBenar { color: var(--ok); }
#sSalah { color: var(--bad); }
#sSisa  { color: var(--text-dim); }

.progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--line-soft);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  transition: width .3s cubic-bezier(.4, 0, .2, 1);
}

/* ============================ layout ============================ */

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--pad);
  padding-bottom: calc(var(--rail-space) + var(--safe-b) + 20px);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: clamp(16px, 3vw, 26px);
}

.card + .card { margin-top: var(--gap); }

h2 {
  margin: 0 0 10px;
  font-size: var(--fs-h2);
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.25;
}

p { margin: 0 0 12px; line-height: 1.65; }
p:last-child { margin-bottom: 0; }

.muted { color: var(--muted); }
.tiny { font-size: var(--fs-small); line-height: 1.55; }

.facts {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.facts li {
  padding: 6px 11px;
  font-size: var(--fs-small);
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  white-space: nowrap;
}

.facts b { color: var(--text); font-weight: 650; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

/* ============================ buttons ============================ */

.btn {
  appearance: none;
  font-family: inherit;
  font-size: clamp(13.5px, 0.3vw + 12.8px, 15px);
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: clamp(11px, 2.4vw, 13px) clamp(16px, 3.4vw, 22px);
  min-height: 46px;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease,
              transform .07s ease, opacity .14s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.btn:active:not(:disabled) { transform: scale(.977); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 14px -4px var(--accent);
}

.btn.primary:hover:not(:disabled) { background: #4a7ff5; }

.btn.ghost:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--line);
}

.btn.tiny-btn {
  padding: 7px 13px;
  min-height: 34px;
  font-size: var(--fs-small);
  border-radius: var(--r-sm);
}

/* ============================ question ============================ */

.qhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: clamp(12px, 2.4vw, 18px);
  flex-wrap: wrap;
}

.qnum {
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.qtype {
  padding: 4px 10px;
  font-size: clamp(9.5px, 0.15vw + 9px, 11px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  white-space: nowrap;
}

.stimulus {
  padding: clamp(13px, 2.6vw, 18px);
  margin-bottom: clamp(14px, 2.8vw, 20px);
  background: var(--surface-2);
  border-left: 3px solid var(--line);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: var(--fs-body);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.stimulus:empty { display: none; }

.stem {
  margin-bottom: clamp(16px, 3vw, 22px);
  font-size: var(--fs-stem);
  line-height: 1.68;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.stimulus p, .stem p { margin: 0 0 10px; }
.stimulus p:last-child, .stem p:last-child { margin-bottom: 0; }

.stimulus ul, .stem ul, .stimulus ol, .stem ol { margin: 10px 0; padding-left: 22px; }
.stimulus li, .stem li { margin-bottom: 6px; }

.stimulus img, .stem img, .pembahasan img, .opt img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px 0;
  padding: 8px;
  background: #fff;
  border-radius: var(--r-sm);
}

.stimulus table, .stem table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: .95em;
}

.stimulus th, .stimulus td,
.stem th, .stem td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
}

/* ============================ options ============================ */

.opts {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.5vw, 10px);
}

.opt {
  display: flex;
  align-items: flex-start;
  gap: clamp(10px, 2vw, 13px);
  padding: clamp(12px, 2.4vw, 15px) clamp(12px, 2.4vw, 16px);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 48px;
}

.opt:hover { border-color: #35435d; }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }

.opt .tick {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  background: transparent;
  border: 1.5px solid #3b4a63;
  border-radius: 50%;
  transition: all .14s ease;
}

.opt.multi .tick { border-radius: 6px; }

.opt.selected .tick {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.opt.correct .tick {
  color: #06281c;
  background: var(--ok);
  border-color: var(--ok);
}

.opt.wrong .tick {
  color: #2d060d;
  background: var(--bad);
  border-color: var(--bad);
}

.opt .body {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-body);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.opt .body p { margin: 0 0 6px; }
.opt .body p:last-child { margin-bottom: 0; }
.opt .body img { margin: 6px 0; padding: 4px; }

/* ============================ table match ============================ */

.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * clamp(4px, 1vw, 8px));
  padding: 0 clamp(4px, 1vw, 8px);
  border-radius: var(--r-md);
}

table.match {
  width: 100%;
  min-width: 320px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: clamp(13px, 0.3vw + 12.3px, 14.5px);
}

table.match th,
table.match td {
  padding: clamp(9px, 2vw, 13px) clamp(8px, 1.8vw, 12px);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line-soft);
}

table.match thead th {
  position: sticky;
  top: 0;
  font-size: clamp(10.5px, 0.2vw + 10px, 12px);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: var(--surface-2);
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

table.match thead th.rowhead { text-align: left; }

table.match tbody tr:last-child td { border-bottom: none; }

table.match td.rowtext {
  line-height: 1.58;
  overflow-wrap: anywhere;
}

table.match td.rowtext .placeholder {
  color: var(--muted);
  font-style: italic;
}

table.match td.choice {
  width: clamp(56px, 14vw, 92px);
  text-align: center;
}

.radio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1.5px solid #3b4a63;
  border-radius: 50%;
  cursor: pointer;
  transition: all .14s ease;
  -webkit-tap-highlight-color: transparent;
}

.radio:hover { border-color: #35435d; background: rgba(91, 141, 255, .1); }

.radio.on { background: var(--accent); border-color: var(--accent); }
.radio.on::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

.radio.ok { background: var(--ok); border-color: var(--ok); }
.radio.ok::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #06281c; }
.radio.no { background: var(--bad); border-color: var(--bad); }
.radio.no::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #2d060d; }

tr.row-ok td { background: rgba(52, 211, 153, .06); }
tr.row-no td { background: rgba(251, 113, 133, .06); }

/* ============================ verdict ============================ */

.verdict {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: clamp(14px, 2.6vw, 18px);
  padding: clamp(12px, 2.4vw, 15px) clamp(13px, 2.6vw, 17px);
  border-radius: var(--r-md);
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.5;
}

.verdict.ok {
  color: #7df0c0;
  background: var(--ok-soft);
  border: 1px solid rgba(52, 211, 153, .45);
}

.verdict.no {
  color: #ffa6b4;
  background: var(--bad-soft);
  border: 1px solid rgba(251, 113, 133, .45);
}

.verdict .icon {
  flex: 0 0 auto;
  font-size: 1.05em;
  line-height: 1.45;
}

.pembahasan {
  margin-top: var(--gap);
  padding: clamp(13px, 2.6vw, 18px);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: var(--fs-body);
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.pembahasan h4 {
  margin: 0 0 10px;
  font-size: clamp(10px, 0.15vw + 9.5px, 11.5px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
}

.pembahasan p { margin: 0 0 10px; }
.pembahasan p:last-child { margin-bottom: 0; }

.note {
  margin-top: var(--gap);
  padding: 12px 14px;
  font-size: var(--fs-small);
  line-height: 1.6;
  color: #f0cf8a;
  background: rgba(251, 191, 36, .07);
  border: 1px solid rgba(251, 191, 36, .28);
  border-radius: var(--r-sm);
}

/* ============================ footer nav ============================ */

.qfoot {
  display: flex;
  gap: var(--gap);
  margin-top: clamp(18px, 3.2vw, 24px);
}

.qfoot .btn { flex: 1 1 0; min-width: 0; }

/* ============================ grid rail ============================ */

.rail {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  padding: 8px var(--pad) calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid var(--line-soft);
}

/* Collapsed handle — the only part of the rail visible on a phone by default.
   It keeps the current position and the answered count readable without
   parking 200px of number grid over the question. */
.rail-handle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 9px 12px;
  font-family: inherit;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.rail-handle:active { transform: scale(.99); }

.rail-handle-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rail-handle-title {
  font-size: var(--fs-small);
  font-weight: 650;
  letter-spacing: -.005em;
  line-height: 1.25;
}

.rail-handle-meta {
  font-size: clamp(10px, 0.15vw + 9.5px, 11.5px);
  color: var(--muted);
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.rail-handle-now {
  flex: 0 0 auto;
  padding: 4px 9px;
  font-size: clamp(10px, 0.15vw + 9.5px, 11.5px);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  white-space: nowrap;
}

.rail-chev {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--muted);
  transition: transform .2s ease;
}

.rail.open .rail-chev { transform: rotate(180deg); }

.rail-panel {
  max-width: 760px;
  margin: 0 auto;
  overflow: hidden;
}

/* Mobile default: panel closed. */
.rail-panel { display: none; }
.rail.open .rail-panel { display: block; }

.rail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(4, 6, 10, .55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(34px, 8vw, 42px), 1fr));
  gap: clamp(5px, 1.2vw, 7px);
  margin: 10px 0 9px;
  max-height: min(38vh, 240px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.grid button {
  aspect-ratio: 1;
  min-height: clamp(34px, 8vw, 42px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: clamp(11px, 0.2vw + 10.5px, 12.5px);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all .13s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.grid button:hover { border-color: var(--line); color: var(--text-dim); }
.grid button.answered { color: var(--text-dim); background: var(--surface-2); border-color: var(--line); }
.grid button.ok { color: #7df0c0; background: var(--ok-soft); border-color: rgba(52, 211, 153, .5); }
.grid button.no { color: #ffa6b4; background: var(--bad-soft); border-color: rgba(251, 113, 133, .5); }

.grid button.current {
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}

.rail-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 2px;
}

/* ============================ summary ============================ */

.summary { text-align: center; }

.summary-score {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin: 6px 0 2px;
  font-variant-numeric: tabular-nums;
}

.summary-score b {
  font-size: clamp(46px, 13vw, 72px);
  font-weight: 750;
  line-height: 1;
  letter-spacing: -.04em;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.summary-score span {
  font-size: clamp(18px, 4.5vw, 24px);
  font-weight: 600;
  color: var(--muted);
}

.summary-bar {
  display: flex;
  height: 10px;
  margin: 18px 0 12px;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: 999px;
}

.summary-bar i { display: block; height: 100%; }
.summary-bar i.ok { background: var(--ok); }
.summary-bar i.no { background: var(--bad); }
.summary-bar i.skip { background: #3a465e; }

.summary-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(10px, 3vw, 22px);
  margin-bottom: 22px;
  font-size: var(--fs-small);
  color: var(--muted);
}

.summary-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.summary-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
}

.summary-legend i.ok { background: var(--ok); }
.summary-legend i.no { background: var(--bad); }
.summary-legend i.skip { background: #3a465e; }

.summary .row { justify-content: center; }
.summary .row .btn { flex: 0 1 auto; min-width: 150px; }

/* ============================ toast ============================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--rail-space) + var(--safe-b) + 12px);
  z-index: 40;
  transform: translateX(-50%) translateY(10px);
  padding: 11px 18px;
  font-size: var(--fs-small);
  font-weight: 550;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 8px 28px -8px rgba(0, 0, 0, .7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================ breakpoints ============================ */

/* Narrow phones */
@media (max-width: 380px) {
  .score-cell { min-width: 34px; padding: 4px 5px; }
  .score-cell span { letter-spacing: .03em; }
  .facts li { font-size: 11px; padding: 5px 9px; }
  .qfoot .btn { padding: 11px 12px; font-size: 13px; }
  table.match { min-width: 280px; }
  table.match td.choice { width: 48px; }
  .radio { width: 22px; height: 22px; }
}

/* Short landscape — the handle is already compact; keep the panel from
   swallowing the whole screen when it opens. */
@media (max-height: 480px) and (orientation: landscape) {
  .rail { padding: 6px var(--pad) calc(6px + var(--safe-b)); }
  .rail-handle { padding: 7px 11px; }
  .grid { max-height: 30vh; margin: 8px 0 6px; }
  .rail-foot { display: none; }
}

/* Tablet */
@media (min-width: 700px) {
  .shell { max-width: 820px; }
  .rail-handle { max-width: 820px; }
  .rail-panel { max-width: 820px; }
  .grid { max-height: min(34vh, 220px); }
}

/* Wide desktop — rail moves out of the way, becomes a right column. The
   collapse handle is a phone affordance; on desktop the panel is always open. */
@media (min-width: 1100px) {
  :root { --rail-space: 40px; }
  body.rail-open { --rail-space: 40px; }

  .rail-backdrop { display: none !important; }

  .rail-handle { display: none; }
  .rail-panel { display: block !important; }
  .rail-chev { display: none; }

  .shell {
    max-width: 1180px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-areas: "main rail";
    gap: 26px;
    align-items: start;
    padding-bottom: 40px;
  }

  .shell > main { grid-area: main; min-width: 0; }

  .rail {
    position: sticky;
    top: 86px;
    grid-area: rail;
    align-self: start;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-lg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .grid {
    max-width: none;
    max-height: none;
    grid-template-columns: repeat(5, 1fr);
    margin-bottom: 14px;
  }

  .grid button { min-height: 42px; font-size: 13px; }

  .rail-foot { max-width: none; flex-direction: column; align-items: stretch; }
  .rail-foot .tiny { text-align: center; }
  .rail-foot .btn { width: 100%; }

  .toast { bottom: 40px; }

  .card { padding: 30px; }
  .stem { font-size: 17px; }
  .opt .body { font-size: 15.5px; }
}

/* Very wide */
@media (min-width: 1500px) {
  .shell { max-width: 1320px; grid-template-columns: minmax(0, 1fr) 340px; }
  .grid { grid-template-columns: repeat(6, 1fr); }
}

/* Motion / contrast preferences */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #3b4a63;
    --line-soft: #33405a;
    --muted: #9aa8bf;
  }
}

/* Print — a clean paper copy of the current question */
@media print {
  .topbar, .rail, .qfoot, .toast, .progress-track { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ccc; }
  .shell { display: block; max-width: none; padding: 0; }
}
