/* Analyst Arena
   Palette: "ledger paper". Pale sage page, white work surfaces, deep green-black ink,
   one indigo accent (neel) for actions, links and focus. Green/red/amber appear only
   when the grader has something to say.
   Type: Atkinson Hyperlegible Next for reading, Atkinson Hyperlegible Mono for SQL,
   result tables and the grader line (0/O and 1/l/I never look alike). */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --bg: #f2f4ef;
  --surface: #ffffff;
  --sunk: #edf0e9;
  --ink: #17201b;
  --ink-2: #46514a;
  --ink-3: #5c675f;
  --rule: #dde2d8;
  --rule-strong: #c3cabe;
  --field: #858f88;          /* input borders: 3:1 against surface */
  --track: #d6dcd1;
  --accent: #3442a8;
  --accent-hover: #27338e;
  --accent-soft: #e8eaf7;
  --accent-ink: #2b3893;     /* accent text on accent-soft */
  --on-accent: #ffffff;
  --strong: #17201b;         /* filled neutral button, toast */
  --on-strong: #ffffff;
  --pass: #17703f;
  --pass-soft: #e1f0e6;
  --fail: #b3261e;
  --fail-soft: #fbe8e6;
  --warn: #835800;
  --warn-soft: #f9efd2;
  --on-state: #ffffff;
  --syn-kw: #3442a8;
  --syn-fn: #7b3b8f;
  --syn-str: #1f6b42;
  --syn-num: #9a4a0b;
  --syn-com: #66726a;
  --lift: 0 1px 2px rgba(23, 32, 27, .05), 0 18px 40px -20px rgba(23, 32, 27, .22);
  --shade: rgba(23, 32, 27, .16);

  --f-sans: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --r-lg: 14px;   /* panels */
  --r: 10px;      /* controls */
  --r-sm: 7px;    /* chips, ids */
  --r-xs: 4px;    /* badges, inline code */
  --gutter: 16px;
  --header-h: 60px;

  --i-chev-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-chev-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 4l4 4-4 4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111613;
    --surface: #191f1b;
    --sunk: #141a16;
    --ink: #e4eae5;
    --ink-2: #b0bab2;
    --ink-3: #909b93;
    --rule: #2b332e;
    --rule-strong: #3c4741;
    --field: #6b766f;
    --track: #2f3833;
    --accent: #a7b1f5;
    --accent-hover: #c0c7f8;
    --accent-soft: #252b48;
    --accent-ink: #c6ccf8;
    --on-accent: #111613;
    --strong: #e4eae5;
    --on-strong: #111613;
    --pass: #6fcb95;
    --pass-soft: #17301f;
    --fail: #f2968d;
    --fail-soft: #3a1d1a;
    --warn: #e2b85a;
    --warn-soft: #32290f;
    --on-state: #111613;
    --syn-kw: #a7b1f5;
    --syn-fn: #d9a9ea;
    --syn-str: #8fd3a9;
    --syn-num: #efaa72;
    --syn-com: #84908a;
    --lift: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 40px -18px rgba(0, 0, 0, .6);
    --shade: rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111613;
  --surface: #191f1b;
  --sunk: #141a16;
  --ink: #e4eae5;
  --ink-2: #b0bab2;
  --ink-3: #909b93;
  --rule: #2b332e;
  --rule-strong: #3c4741;
  --field: #6b766f;
  --track: #2f3833;
  --accent: #a7b1f5;
  --accent-hover: #c0c7f8;
  --accent-soft: #252b48;
  --accent-ink: #c6ccf8;
  --on-accent: #111613;
  --strong: #e4eae5;
  --on-strong: #111613;
  --pass: #6fcb95;
  --pass-soft: #17301f;
  --fail: #f2968d;
  --fail-soft: #3a1d1a;
  --warn: #e2b85a;
  --warn-soft: #32290f;
  --on-state: #111613;
  --syn-kw: #a7b1f5;
  --syn-fn: #d9a9ea;
  --syn-str: #8fd3a9;
  --syn-num: #efaa72;
  --syn-com: #84908a;
  --lift: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 40px -18px rgba(0, 0, 0, .6);
  --shade: rgba(0, 0, 0, .55);
}
:root[data-theme="light"] { color-scheme: light; }

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--f-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
h1, h2, h3 { text-wrap: balance; color: var(--ink); }
p, li, dd { text-wrap: pretty; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
code, kbd, pre, samp { font-family: var(--f-mono); }
code {
  font-size: .9em;
  background: var(--sunk);
  border: 1px solid var(--rule);
  padding: .05em .35em;
  border-radius: var(--r-xs);
  overflow-wrap: anywhere;
}
em { font-style: italic; }
img, svg { max-width: 100%; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
button, input, select, textarea { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.wrap {
  width: 100%;
  max-width: 1320px;
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
@media (min-width: 720px) { :root { --gutter: 28px; } }
@media (min-width: 1200px) { :root { --gutter: 40px; } }

/* ------------------------------------------------------------------ brand */
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px;
  color: var(--ink); text-decoration: none;
  font-weight: 700; font-size: 17px; letter-spacing: -.01em; line-height: 1;
}
.brand:hover { color: var(--ink); }
.brand-mark { width: 28px; height: 28px; flex: none; display: block; }
.brand-mark .bm-tile { fill: var(--accent); }
.brand-mark .bm-bar { stroke: var(--on-accent); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  font: 600 15px/1.2 var(--f-sans);
  border-radius: var(--r);
  border: 1px solid transparent;
  background: transparent; color: var(--ink);
  cursor: pointer; text-decoration: none; text-align: center;
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-accent { background: var(--strong); color: var(--on-strong); }
.btn-accent:not(:disabled):hover { background: var(--accent); color: var(--on-accent); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn-ghost:not(:disabled):hover { background: var(--sunk); border-color: var(--field); color: var(--ink); }
.btn-quiet { color: var(--ink-2); padding: 0 12px; font-weight: 500; }
.btn-quiet:not(:disabled):hover { color: var(--ink); background: var(--sunk); }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn kbd {
  font: 500 12px/1 var(--f-mono);
  padding: 3px 5px; border-radius: var(--r-xs);
  border: 1px solid currentColor; opacity: .6;
  white-space: nowrap;
}

.link-btn {
  appearance: none; background: none; border: 0;
  padding: 11px 2px; margin: -11px -2px;   /* 44px hit area without moving the text */
  font: inherit; font-weight: 600; color: var(--accent);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }

/* ------------------------------------------------------------------ top strip, header, toast */
.demo-banner {
  margin: 0; padding: 8px var(--gutter);
  background: var(--warn-soft); color: var(--ink);
  border-bottom: 1px solid var(--rule);
  font-size: 14px; line-height: 1.4; text-align: center;
}

.app-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.app-header-in { display: flex; align-items: center; gap: 12px; min-height: var(--header-h); }
.app-header .brand { margin-right: auto; }
.score { display: flex; align-items: center; gap: 10px; }
.pips { display: flex; gap: 5px; }
.pip {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--field);
}
.pip.on { background: var(--pass); box-shadow: none; }
.score-text { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.usermenu {
  display: flex; align-items: center; gap: 6px;
  padding-left: 12px; margin-left: 4px;
  border-left: 1px solid var(--rule);
}
.avatar {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent-ink);
  font: 700 14px/1 var(--f-sans);
}
.user-name {
  font-size: 14px; color: var(--ink-2);
  max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.signout { min-width: 44px; padding: 0 10px; }

@media (max-width: 639px) {
  .user-name { display: none; }
  .signout-text {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .usermenu { padding-left: 8px; gap: 2px; }
}
@media (max-width: 419px) {
  .score-text {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .app-header-in { gap: 8px; }
}

.toast {
  position: fixed; z-index: 60;
  left: var(--gutter); right: var(--gutter);
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  margin-inline: auto; max-width: 440px;
  padding: 12px 16px; border-radius: var(--r);
  background: var(--strong); color: var(--on-strong);
  box-shadow: var(--lift);
  font-size: 15px; line-height: 1.45;
}

/* ------------------------------------------------------------------ screens */
.screen { display: block; }
.screen-loading, .screen-auth, .screen-onboard { min-height: 100vh; min-height: 100dvh; }

/* loading */
.screen-loading { display: grid; place-items: center; padding: 24px var(--gutter); }
.screen-loading[hidden] { display: none !important; }
.loading { display: grid; justify-items: center; gap: 10px; text-align: center; }
.loading .brand-mark { width: 44px; height: 44px; }
.loading-name { margin: 6px 0 0; font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
.loading-line { margin: 0; color: var(--ink-2); font-size: 15px; }
.loading-bar {
  display: block; width: 140px; height: 3px; margin-top: 10px;
  border-radius: 99px; background: var(--track); overflow: hidden;
}
.loading-bar i { display: block; width: 40%; height: 100%; border-radius: inherit; background: var(--accent); }

/* ------------------------------------------------------------------ auth (also the landing page) */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "brand" "intro" "panel" "more";
  gap: 24px;
  max-width: 1180px;
  padding-top: 16px; padding-bottom: 48px;
}
.auth > .auth-brand { grid-area: brand; }
.auth > .auth-intro { grid-area: intro; }
.auth > .auth-panel { grid-area: panel; }
.auth > .auth-more { grid-area: more; }
.auth-intro { display: grid; gap: 14px; }
.auth-panel { min-width: 0; }
.auth-more { display: grid; gap: 28px; padding-top: 8px; }

.auth-title {
  margin: 0;
  font-size: clamp(30px, 7.4vw, 48px);
  line-height: 1.08; font-weight: 700; letter-spacing: -.028em;
  max-width: 22ch;
}
.auth-lede { margin: 0; font-size: 17px; line-height: 1.6; color: var(--ink-2); max-width: 56ch; }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 22px 18px 24px;
}
.auth-panel { box-shadow: var(--lift); }
.auth-form { display: grid; gap: 18px; }
.form-head { display: grid; gap: 4px; }
.form-title { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -.012em; }
.form-sub { margin: 0; font-size: 15px; color: var(--ink-2); }

.field { display: grid; gap: 6px; }
.field-label { font-weight: 600; font-size: 15px; line-height: 1.3; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field-hint { margin: 0; font-size: 14px; color: var(--ink-3); }
.input {
  display: block; width: 100%;
  height: 48px; padding: 0 14px;
  font: 400 16px/1.2 var(--f-sans); color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--field);
  border-radius: var(--r);
  transition: border-color .15s ease;
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover { border-color: var(--ink-3); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.check {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start;
  min-height: 44px; padding-top: 2px;
  font-size: 15px; line-height: 1.45; color: var(--ink-2); cursor: pointer;
}
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }

.form-error, .form-notice {
  margin: 0; padding: 10px 12px; border-radius: var(--r);
  font-size: 15px; line-height: 1.45;
}
.form-error { background: var(--fail-soft); color: var(--ink); box-shadow: inset 3px 0 0 var(--fail); }
.form-notice { background: var(--pass-soft); color: var(--ink); box-shadow: inset 3px 0 0 var(--pass); }
.small-print { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-3); }

.or {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px;
  font-size: 14px; color: var(--ink-3);
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.google-btn { width: 100%; }
.google-btn svg { width: 18px; height: 18px; }

.notice-panel { display: grid; gap: 14px; }
.notice-panel p { margin: 0; color: var(--ink-2); }

/* how it works + the grader preview + dataset line */
.how-title { margin: 0 0 12px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; counter-reset: step; max-width: 58ch; }
.steps li {
  counter-increment: step;
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px;
  font-size: 16px; color: var(--ink-2); line-height: 1.55;
}
.steps li::before {
  content: counter(step);
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--rule-strong); background: var(--surface);
  font: 600 13px/1 var(--f-mono); color: var(--ink-2);
}
.steps b { color: var(--ink); font-weight: 600; }

.peek {
  margin: 0; max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  overflow: hidden;
}
.peek-bar {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 14px; border-bottom: 1px solid var(--rule);
  font: 600 13px/1.3 var(--f-mono); color: var(--ink);
}
.peek-bar span { font-weight: 400; color: var(--ink-3); }
.peek-code {
  margin: 0; padding: 12px 14px;
  font: 14px/1.65 var(--f-mono); color: var(--ink);
  overflow-x: auto; white-space: pre;
}
.peek .verdict { margin: 0 10px 10px; }
.peek figcaption { padding: 0 14px 12px; font-size: 14px; color: var(--ink-3); }

.facts { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 14px; color: var(--ink-2); max-width: 600px; }
.facts div { display: flex; gap: 6px; align-items: baseline; }
.facts dt { order: 2; }
.facts dd { order: 1; margin: 0; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.facts-note { margin: 8px 0 0; font-size: 14px; color: var(--ink-3); max-width: 600px; }

@media (min-width: 720px) {
  .panel { padding: 28px 28px 30px; }
}
@media (min-width: 960px) {
  .auth {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
    grid-template-areas: "brand brand" "intro panel" "more panel";
    grid-template-rows: auto auto 1fr;
    column-gap: clamp(48px, 7vw, 104px);
    row-gap: 32px;
    padding-top: 28px; padding-bottom: 72px;
  }
  .auth-intro { padding-top: 28px; }
  .auth > .auth-panel { align-self: start; position: sticky; top: 24px; margin-top: 28px; }
  .auth-more { padding-top: 12px; gap: 32px; }
}

/* ------------------------------------------------------------------ onboarding */
.onboard { max-width: 760px; padding-top: 16px; padding-bottom: 64px; display: grid; gap: 24px; }
.ob-title {
  margin: 12px 0 0;
  font-size: clamp(26px, 5.6vw, 36px); line-height: 1.15; font-weight: 700; letter-spacing: -.022em;
}
.ob-lede { margin: -12px 0 0; color: var(--ink-2); font-size: 17px; max-width: 54ch; }
.ob-form { display: grid; gap: 32px; }
.ob-q { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 12px; }
.ob-q legend { padding: 0; margin: 0 0 12px; font-weight: 700; font-size: 19px; line-height: 1.3; letter-spacing: -.008em; }
.opt-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opt-grid-stack { grid-template-columns: minmax(0, 1fr); }

.opt { position: relative; display: block; cursor: pointer; min-width: 0; }
.opt input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.opt-body {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); column-gap: 12px; row-gap: 2px; align-items: start;
  min-height: 64px; height: 100%;
  padding: 16px 14px;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  transition: border-color .15s ease, background-color .15s ease;
}
.opt-body::before {
  content: ""; grid-row: 1 / span 2;
  width: 20px; height: 20px; margin-top: 1px; border-radius: 50%;
  border: 1.5px solid var(--field); background: var(--surface);
}
.opt-title { font-weight: 600; font-size: 16px; line-height: 1.35; }
.opt-sub { grid-column: 2; font-size: 15px; line-height: 1.4; color: var(--ink-2); }
.opt:hover .opt-body { border-color: var(--field); }
.opt input:checked + .opt-body { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.opt input:checked + .opt-body::before { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px var(--surface); }
.opt input:focus-visible + .opt-body { outline: 2px solid var(--accent); outline-offset: 2px; }

.ob-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
@media (max-width: 559px) {
  .ob-actions .btn-primary { width: 100%; }
  .ob-actions { justify-content: center; }
}
@media (min-width: 720px) {
  .opt-grid-stack { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .onboard { padding-top: 28px; gap: 28px; }
  .ob-title { margin-top: 28px; }
  .opt-body { padding: 18px 16px; }
}

/* ------------------------------------------------------------------ home */
.home { display: grid; gap: 32px; padding-top: 28px; padding-bottom: 40px; }
.home-top { display: grid; gap: 18px; }
.home-greeting { margin: 0; font-size: clamp(28px, 5vw, 38px); line-height: 1.12; font-weight: 700; letter-spacing: -.024em; }
.home-sub { margin: 8px 0 0; font-size: 17px; color: var(--ink-2); max-width: 60ch; }
.home-progress { display: grid; gap: 8px; align-content: end; }
.progress-text { margin: 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.progress-track { display: block; height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--pass); transition: width .4s ease; }
@media (min-width: 760px) {
  .home-top { grid-template-columns: minmax(0, 1fr) 260px; align-items: end; column-gap: 48px; }
  .home { padding-top: 44px; gap: 36px; }
}

.tip {
  display: grid; gap: 4px; max-width: 780px;
  padding: 16px 18px;
  background: var(--accent-soft); border-radius: var(--r-lg);
  color: var(--ink);
}
.tip p { margin: 0; }
.tip-title { font-weight: 700; }

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.section-head p { margin: 0; font-size: 14px; color: var(--ink-3); }

/* case index */
.case-list {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.case-list:empty { display: none; }
.case-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "id state" "title title" "meta meta" "ask ask";
  column-gap: 12px;
  padding: 18px 16px 20px;
  color: var(--ink); text-decoration: none;
  transition: background-color .15s ease;
}
.case-card + .case-card { border-top: 1px solid var(--rule); }
.case-card:hover { background: var(--sunk); color: var(--ink); text-decoration: none; }
.case-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; border-radius: var(--r-lg); }
.cc-top { display: contents; }
.cc-id {
  grid-area: id; justify-self: start; align-self: center;
  font: 600 14px/1 var(--f-mono); color: var(--ink);
  padding: 7px 8px 6px; border-radius: var(--r-sm);
  background: var(--sunk); border: 1px solid var(--rule);
}
.case-card:hover .cc-id { background: var(--surface); }
.cc-state {
  grid-area: state; align-self: center; justify-self: end;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--ink-3); white-space: nowrap;
}
.cc-state svg { width: 14px; height: 14px; flex: none; }
.cc-state::after {
  content: ""; width: 16px; height: 16px; margin-left: 4px; flex: none;
  background: var(--ink-3);
  -webkit-mask: var(--i-chev-right) center / 16px no-repeat; mask: var(--i-chev-right) center / 16px no-repeat;
}
.cc-title { grid-area: title; margin-top: 12px; font-weight: 700; font-size: 18px; line-height: 1.3; letter-spacing: -.008em; }
.cc-meta { grid-area: meta; margin-top: 2px; font-size: 14px; color: var(--ink-3); }
.cc-ask {
  grid-area: ask; margin-top: 8px;
  font-size: 15px; line-height: 1.5; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.case-card.solved .cc-id { background: var(--pass-soft); border-color: transparent; color: var(--pass); }
.case-card.solved .cc-state { color: var(--pass); font-weight: 600; }
.case-card.started .cc-state { color: var(--accent-ink); font-weight: 600; }
.case-card.started .cc-id { border-color: var(--accent); }
@media (min-width: 900px) {
  .case-card {
    grid-template-columns: 60px minmax(0, 5fr) minmax(0, 6fr) 136px;
    grid-template-areas: "id title ask state" "id meta ask state";
    grid-template-rows: auto 1fr;
    column-gap: 24px;
    padding: 22px 24px;
  }
  .cc-id { align-self: start; margin-top: 1px; }
  .cc-title { margin-top: 0; }
  .cc-meta { margin-top: 4px; }
  .cc-ask { margin-top: 0; align-self: start; padding-top: 1px; }
  .cc-state { align-self: start; margin-top: 3px; }
}

/* casebook offer */
.offer {
  display: grid; gap: 32px;
  margin-top: 16px; padding-top: 36px;
  border-top: 1px solid var(--rule);
}
.offer h2 { margin: 0 0 12px; font-size: clamp(24px, 4vw, 30px); line-height: 1.18; font-weight: 700; letter-spacing: -.02em; max-width: 24ch; }
.offer-main > p { margin: 0 0 16px; color: var(--ink-2); max-width: 62ch; }
.offer-list { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 10px; max-width: 62ch; }
.offer-list li { position: relative; padding-left: 22px; font-size: 15px; line-height: 1.5; }
.offer-list li::before {
  content: ""; position: absolute; left: 0; top: .32em;
  width: 14px; height: 14px; background: var(--pass);
  -webkit-mask: var(--i-check) center / 14px no-repeat; mask: var(--i-check) center / 14px no-repeat;
}
.price { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.price:empty { display: none; }
.fine { margin: 16px 0 0; font-size: 14px; color: var(--ink-3); max-width: 62ch; }
.offer-side-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.modules { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.modules li {
  display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--rule);
  font-size: 15px; line-height: 1.4; align-items: baseline;
}
.modules .k { font: 600 14px/1 var(--f-mono); color: var(--ink-2); }
.modules .c { grid-column: 2; font-size: 13.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.share { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 20px; }
.share:empty { display: none; }
.share .label { width: 100%; margin: 0 0 2px; }
@media (min-width: 560px) {
  .modules li { grid-template-columns: 26px minmax(0, 1fr) auto; }
  .modules .c { grid-column: auto; text-align: right; }
}
@media (min-width: 960px) {
  .offer { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: 64px; padding-top: 48px; }
}

.site-foot { padding-top: 24px; border-top: 1px solid var(--rule); font-size: 14px; color: var(--ink-3); }
.site-foot p { margin: 0 0 4px; max-width: 80ch; }

/* ------------------------------------------------------------------ case workspace */
.case-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
.case-bar .btn-quiet { padding-left: 8px; margin-left: -8px; }
.case-step { display: flex; gap: 8px; }
.case-step .btn { padding: 0 14px; }

.desk { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; padding-bottom: 64px; }

/* the brief (left) */
.brief {
  display: grid; gap: 22px; min-width: 0;
  background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 20px 16px 8px;
}
.brief:empty { display: none; }
.brief > section { display: grid; gap: 8px; min-width: 0; }
.brief-head { display: grid; gap: 10px; }
.brief-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 14px; color: var(--ink-3); }
.brief-meta .id {
  font: 600 14px/1 var(--f-mono); color: var(--ink);
  padding: 6px 7px 5px; border-radius: var(--r-sm);
  background: var(--sunk); border: 1px solid var(--rule);
}
.diff {
  padding: 2px 9px; border-radius: 99px;
  border: 1px solid var(--rule-strong); color: var(--ink-2);
  font-size: 13.5px; line-height: 1.5;
}
.brief h2 { margin: 0; font-size: 24px; line-height: 1.22; font-weight: 700; letter-spacing: -.018em; }

.label { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--ink-2); }

/* the stakeholder's message, shaped like the ping it came in */
.ask {
  margin: 0; padding: 14px 16px;
  background: var(--accent-soft); color: var(--ink);
  border-radius: 3px 16px 16px 16px;
  font-size: 16.5px; line-height: 1.55;
}
.ask code { background: var(--surface); }
.spec { display: grid; gap: 10px; font-size: 15.5px; line-height: 1.6; }
.spec p { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center;
  min-height: 38px; padding: 0 12px;
  font: 500 14px/1 var(--f-mono); color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.hintbox { display: grid; gap: 10px; justify-items: start; }
.hintbox > * { width: 100%; }
.hintbox > div { width: auto; }
.hint {
  margin: 0; padding: 12px 14px;
  background: var(--sunk); border-radius: var(--r);
  font-size: 15px; line-height: 1.55; color: var(--ink);
}
.hint b { display: block; margin-bottom: 2px; font-size: 14px; font-weight: 700; color: var(--accent-ink); }

details.fold { border-top: 1px solid var(--rule); }
.brief > details.fold:not([hidden]) + details.fold { margin-top: -22px; }
details.fold > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px;
  font-weight: 600; font-size: 15.5px; color: var(--ink);
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after {
  content: ""; width: 18px; height: 18px; flex: none;
  background: var(--ink-3);
  -webkit-mask: var(--i-chev-down) center / 18px no-repeat; mask: var(--i-chev-down) center / 18px no-repeat;
  transition: transform .15s ease;
}
details.fold[open] > summary::after { transform: rotate(180deg); }
details.fold > summary:hover { color: var(--accent); }
.fold-body { display: grid; gap: 10px; padding: 2px 0 18px; font-size: 15px; }

.traps { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; color: var(--ink-2); }
.traps li { position: relative; padding-left: 18px; }
.traps li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }

.rules { margin: 0; display: grid; gap: 2px; }
.rules dt { font-weight: 600; font-size: 15px; margin-top: 10px; }
.rules dt:first-child { margin-top: 0; }
.rules dd { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.55; }

details.tbl { border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
details.tbl > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 12px 0 10px;
}
details.tbl > summary::-webkit-details-marker { display: none; }
details.tbl > summary::before {
  content: ""; width: 14px; height: 14px; flex: none;
  background: var(--ink-3);
  -webkit-mask: var(--i-chev-right) center / 14px no-repeat; mask: var(--i-chev-right) center / 14px no-repeat;
  transition: transform .15s ease;
}
details.tbl[open] > summary::before { transform: rotate(90deg); }
details.tbl[open] > summary { border-bottom: 1px solid var(--rule); }
.tbl > summary b { font: 600 14px/1.3 var(--f-mono); color: var(--ink); overflow-wrap: anywhere; }
.tbl > summary span { margin-left: auto; font-size: 13.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl > p { margin: 10px 12px 4px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.cols { list-style: none; margin: 0; padding: 4px 12px 12px; display: grid; gap: 8px; }
.cols li { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; align-items: baseline; }
.cols button {
  justify-self: start;
  appearance: none; background: none; border: 0; padding: 4px 0; margin: 0;
  font: 500 14px/1.35 var(--f-mono); color: var(--accent);
  text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.cols button:hover { text-decoration: underline; text-underline-offset: 3px; }
.cols .ty { font: 12.5px/1.3 var(--f-mono); color: var(--ink-3); text-transform: lowercase; }
.cols .cd { grid-column: 1 / -1; font-size: 14px; line-height: 1.45; color: var(--ink-2); }

/* the bench (right) */
.bench { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; container-type: inline-size; container-name: bench; }
.bench > * { min-width: 0; }

.editor-card {
  background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  overflow: hidden;
}
.ebar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
  min-height: 46px; padding: 8px 16px;
  border-bottom: 1px solid var(--rule);
}
.fname { font: 600 14px/1.2 var(--f-mono); color: var(--ink); }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; font: 13px/1.35 var(--f-mono); color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.dot.ok { background: var(--pass); }
.dot.bad { background: var(--fail); }
.meter { height: 3px; background: var(--track); }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.editor-host { min-height: 240px; background: var(--surface); }
.editor-host textarea.plain {
  display: block; width: 100%; min-height: 280px; resize: vertical;
  padding: 14px 16px; border: 0;
  font: 14.5px/1.65 var(--f-mono);
  background: var(--surface); color: var(--ink);
}
.editor-host textarea.plain:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0; }
.actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--rule);
}
.actions .spacer { flex: 1 1 0; }

/* CodeMirror, themed from tokens (its own CSS loads first) */
.CodeMirror {
  height: auto;
  font: 14.5px/1.65 var(--f-mono);
  background: var(--surface); color: var(--ink);
}
.CodeMirror-scroll { min-height: 240px; max-height: 520px; }
.CodeMirror-lines { padding: 12px 0; }
.CodeMirror pre.CodeMirror-line, .CodeMirror pre.CodeMirror-line-like { padding: 0 14px; }
.CodeMirror-gutters { background: var(--surface); border-right: 1px solid var(--rule); }
.CodeMirror-linenumber { color: var(--ink-3); padding: 0 10px 0 6px; min-width: 22px; }
.CodeMirror-cursor { border-left: 2px solid var(--ink); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: var(--accent-soft) !important; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: var(--accent-soft); }
.CodeMirror-activeline-background { background: var(--sunk); }
.CodeMirror-matchingbracket { color: var(--accent) !important; font-weight: 700; text-decoration: underline; }
.CodeMirror-nonmatchingbracket { color: var(--fail) !important; }
.CodeMirror-focused { outline: 2px solid var(--accent); outline-offset: -2px; }
.cm-s-default .cm-keyword { color: var(--syn-kw); font-weight: 700; }
.cm-s-default .cm-builtin, .cm-s-default .cm-type { color: var(--syn-fn); }
.cm-s-default .cm-string, .cm-s-default .cm-string-2 { color: var(--syn-str); }
.cm-s-default .cm-number, .cm-s-default .cm-atom { color: var(--syn-num); }
.cm-s-default .cm-comment { color: var(--syn-com); font-style: italic; }
.cm-s-default .cm-operator, .cm-s-default .cm-punctuation, .cm-s-default .cm-bracket { color: var(--ink-2); }
.cm-s-default .cm-variable, .cm-s-default .cm-variable-2, .cm-s-default .cm-variable-3,
.cm-s-default .cm-def, .cm-s-default .cm-property, .cm-s-default .cm-qualifier { color: var(--ink); }
.cm-s-default .cm-meta { color: var(--ink-3); }
.cm-s-default .cm-error { color: var(--fail); }
.CodeMirror-hints {
  z-index: 40; padding: 4px;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  box-shadow: var(--lift);
  font: 13.5px/1.5 var(--f-mono);
}
.CodeMirror-hint { color: var(--ink); border-radius: var(--r-xs); padding: 2px 8px; }
li.CodeMirror-hint-active { background: var(--accent); color: var(--on-accent); }

/* the grader line: a test-runner verdict */
.verdict {
  display: grid; gap: 6px;
  padding: 12px 16px 13px;
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-3);
  border-radius: var(--r);
  font-family: var(--f-mono);
}
.verdict-line { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font: 600 14px/1.4 var(--f-mono); color: var(--ink); }
.badge {
  display: inline-block;
  padding: 5px 8px 4px; border-radius: var(--r-xs);
  font: 700 13px/1 var(--f-mono); letter-spacing: .06em;
  background: var(--ink-3); color: var(--surface);
}
.verdict pre {
  margin: 0; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 14px/1.55 var(--f-mono); color: var(--ink-2);
}
.v-pass { border-left-color: var(--pass); }
.v-pass .badge { background: var(--pass); color: var(--on-state); }
.v-fail, .v-error { border-left-color: var(--fail); }
.v-fail .badge, .v-error .badge { background: var(--fail); color: var(--on-state); }
.v-order { border-left-color: var(--warn); }
.v-order .badge { background: var(--warn); color: var(--on-state); }
.v-info { border-left-color: var(--ink-3); }
.v-info .badge { background: var(--ink-3); color: var(--surface); }

/* results */
.results {
  background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r-lg);
  overflow: hidden; min-width: 0;
}
.results:empty { display: none; }
.rhead {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--rule);
  font: 13px/1.4 var(--f-mono); color: var(--ink-2);
}
.rhead b { color: var(--ink); font-weight: 700; }
.table-scroll { overflow: auto; max-height: 440px; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
table.grid {
  border-collapse: separate; border-spacing: 0;
  width: max-content; min-width: 100%;
  font: 14px/1.4 var(--f-mono); font-variant-numeric: tabular-nums;
}
.grid th, .grid td { padding: 8px 16px; border-bottom: 1px solid var(--rule); white-space: nowrap; text-align: left; }
.grid th {
  position: sticky; top: 0; z-index: 1;
  background: var(--sunk); font-weight: 700; color: var(--ink);
  vertical-align: bottom;
}
.grid th small { display: block; margin-top: 1px; font-weight: 400; font-size: 12px; color: var(--ink-3); }
.grid td.n, .grid th.n { text-align: right; }
.grid td.null { color: var(--ink-3); font-style: italic; }
.grid td.idx, .grid th.idx { width: 1%; padding-right: 10px; text-align: right; color: var(--ink-3); border-right: 1px solid var(--rule); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: var(--sunk); }
.grid tr.bad td { background: var(--fail-soft); }
.grid tr.bad td.idx { color: var(--fail); font-weight: 700; box-shadow: inset 3px 0 0 var(--fail); }
.empty { display: grid; gap: 6px; padding: 26px 20px; font-size: 15px; color: var(--ink-2); }
.empty b { color: var(--ink); }

/* solved: what the number means */
.reveal {
  display: grid; gap: 24px;
  padding: 22px 18px;
  background: var(--surface);
  border: 1px solid var(--rule); border-top: 3px solid var(--pass);
  border-radius: var(--r-lg);
}
.reveal > div:first-child { display: grid; gap: 6px; }
.eyebrow { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--pass); }
.reveal .eyebrow::before {
  content: ""; width: 16px; height: 16px; flex: none; background: currentColor;
  -webkit-mask: var(--i-check) center / 16px no-repeat; mask: var(--i-check) center / 16px no-repeat;
}
.reveal h3 { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -.015em; }
.reveal > div { min-width: 0; }
.reveal > div > .label { margin-bottom: 8px; }
.wsn { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.wsn > div { display: grid; gap: 6px; align-content: start; padding-top: 12px; border-top: 1px solid var(--rule); }
.wsn p { margin: 0; font-size: 15px; line-height: 1.55; }
.wsn .label { color: var(--ink); font-weight: 700; }
.followups { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.followups li { position: relative; padding-left: 20px; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.followups li::before { content: "?"; position: absolute; left: 0; top: 0; font: 700 14px/1.55 var(--f-mono); color: var(--ink-3); }
.cta {
  display: grid; gap: 14px; align-items: center;
  padding: 18px;
  background: var(--accent-soft); border-radius: var(--r);
}
.cta p { margin: 0; }
.cta .t { font-weight: 700; font-size: 16px; line-height: 1.4; }
.cta .s { margin-top: 2px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.cta .btns { display: flex; flex-wrap: wrap; gap: 8px; }
.cta .btn-ghost { background: var(--surface); }

@container bench (min-width: 620px) {
  .wsn { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
  .cta { grid-template-columns: minmax(0, 1fr) auto; gap: 20px; padding: 18px 20px; }
  .reveal { padding: 24px 24px 26px; }
}

/* reference solution */
.solution {
  display: grid; gap: 10px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r-lg);
}
.solution > .label { color: var(--ink); }
.solution pre {
  margin: 0; padding: 14px 16px;
  background: var(--sunk); border-radius: var(--r);
  font: 13.5px/1.6 var(--f-mono); color: var(--ink);
  overflow: auto; max-height: 420px;
}
.solution .row { display: flex; flex-wrap: wrap; gap: 8px; }

/* small shared bits */
.code {
  display: inline-flex; align-items: center; min-height: 36px;
  padding: 0 10px; border-radius: var(--r-sm);
  border: 1.5px dashed var(--field);
  font: 700 14px/1 var(--f-mono); letter-spacing: .05em; color: var(--ink);
}
.tick { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 600; color: var(--pass); }
.tick svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ responsive: workspace */
@media (max-width: 559px) {
  .actions #runBtn, .actions #checkBtn { flex: 1 1 0; }
  .actions .spacer { display: none; }
  .actions .btn-quiet { min-height: 40px; }
  .btn kbd { display: none; }
  .case-step .btn { padding: 0 12px; }
}
@media (pointer: coarse) {
  .btn kbd { display: none; }
  .chip { min-height: 44px; }
  .cols button { min-height: 40px; }
}
@media (min-width: 720px) {
  .brief { padding: 24px 24px 8px; }
  .case-bar { padding-top: 14px; padding-bottom: 14px; }
}
@media (min-width: 1081px) {
  .desk { grid-template-columns: minmax(380px, 5fr) minmax(0, 7fr); gap: 24px; }
  .brief {
    position: sticky; top: calc(var(--header-h) + 16px);
    max-height: calc(100vh - var(--header-h) - 32px);
    overflow: auto; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent;
    /* scroll shadows: a soft edge appears only where there is more to read */
    background:
      linear-gradient(var(--surface) 30%, transparent) top / 100% 36px no-repeat local,
      linear-gradient(transparent, var(--surface) 70%) bottom / 100% 36px no-repeat local,
      radial-gradient(farthest-side at 50% 0, var(--shade), transparent) top / 100% 12px no-repeat scroll,
      radial-gradient(farthest-side at 50% 100%, var(--shade), transparent) bottom / 100% 12px no-repeat scroll,
      var(--surface);
  }
}

/* ------------------------------------------------------------------ motion: only in answer to an action */
@media (prefers-reduced-motion: no-preference) {
  @keyframes arena-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  @keyframes arena-slide { from { transform: translateX(-110%); } to { transform: translateX(260%); } }
  .verdict:not([hidden]), .reveal:not([hidden]), .toast:not([hidden]) { animation: arena-rise .2s ease-out; }
  .loading-bar i { animation: arena-slide 1.1s cubic-bezier(.45, 0, .25, 1) infinite; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .loading-bar i { width: 100%; opacity: .5; }
}

/* ================================================================== Arena Score, course, leaderboard */
/* header nav */
.app-nav { display: none; align-items: center; gap: 2px; margin-right: auto; margin-left: 8px; }
.app-nav a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: var(--r-sm);
  font-size: 14.5px; font-weight: 600; color: var(--ink-2); text-decoration: none;
}
.app-nav a:hover { background: var(--sunk); color: var(--ink); }
.app-nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }
@media (min-width: 900px) {
  .app-nav { display: flex; }
  .app-header .brand { margin-right: 0; }
}
body[data-screen="test"] .app-nav, body[data-screen="test"] .score { visibility: hidden; }

/* pages */
.page { display: grid; gap: 20px; padding-top: 18px; padding-bottom: 64px; align-content: start; }
.page-narrow { max-width: 880px; }
.page > .back { justify-self: start; padding-left: 8px; margin-left: -8px; }
.page-head { display: grid; gap: 10px; }
.page-title { margin: 0; font-size: clamp(26px, 5vw, 38px); line-height: 1.12; font-weight: 700; letter-spacing: -.024em; max-width: 26ch; }
.page-lede { margin: 0; font-size: 17px; line-height: 1.6; color: var(--ink-2); max-width: 62ch; }
.page-loading { padding: 40px 0; }
.panel-title { margin: 0 0 14px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.hc-eyebrow { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-ink); }
.hc-muted { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-3); }
.hc-btns { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }

/* home cards */
.home-cards { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.hcard {
  display: grid; gap: 10px; align-content: start;
  padding: 22px 18px 22px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg);
}
.hcard-score { border-top: 3px solid var(--accent); }
.hc-title { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -.015em; }
.hc-body { margin: 0; font-size: 15.5px; line-height: 1.55; color: var(--ink-2); max-width: 56ch; }
.hc-state { display: grid; gap: 12px; margin-top: 6px; }
.score-state { display: grid; gap: 12px; }
.hc-live { margin: 0; font-weight: 600; color: var(--ink); }
.hc-best { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; }
.hc-num { font-size: 44px; line-height: 1; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hc-of { font-size: 16px; color: var(--ink-3); }
.hc-progress { display: grid; gap: 6px; font-size: 14px; font-weight: 600; max-width: 320px; }
@media (min-width: 760px) {
  .home-cards { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; }
  .hcard { padding: 26px 26px 26px; }
}

.level-pill {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 99px;
  font: 700 13.5px/1 var(--f-sans); letter-spacing: .01em; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent-ink);
}
.level-pill.big { min-height: 34px; padding: 0 14px; font-size: 15px; }
.level-pill.lv-L5, .level-pill.lv-L4 { background: var(--pass-soft); color: var(--pass); }
.level-pill.lv-L1 { background: var(--sunk); color: var(--ink-2); }

/* test intro */
.intro-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .intro-grid { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 20px; } }
.part-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.part-list li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; align-items: start; }
.pl-n {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r);
  background: var(--accent-soft); color: var(--accent-ink); font: 700 18px/1 var(--f-mono);
}
.pl-body { display: grid; gap: 2px; }
.pl-body b { font-size: 16px; }
.pl-w { font-size: 13.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pl-d { font-size: 15px; line-height: 1.5; color: var(--ink-2); margin-top: 2px; }
.rule-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.rule-list li { position: relative; padding-left: 20px; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.rule-list li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.intro-go { display: grid; gap: 16px; align-items: center; border-top: 3px solid var(--accent); }
.go-t { margin: 0; font-size: 19px; font-weight: 700; }
.go-s { margin: 4px 0 0; color: var(--ink-2); font-size: 15px; }
.go-btns { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.go-note, .go-wait { margin: 0; font-size: 14.5px; color: var(--ink-3); }
.go-wait { color: var(--ink); font-weight: 600; }
@media (min-width: 760px) { .intro-go { grid-template-columns: minmax(0, 1fr) auto; } .go-btns { justify-content: flex-end; } }

/* test: bar, question nav, question */
.page-test { gap: 16px; padding-top: 0; }
.test-bar {
  position: sticky; top: var(--header-h); z-index: 20;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  padding: 10px 0;
  background: var(--bg); border-bottom: 1px solid var(--rule);
}
.tb-title { display: grid; gap: 1px; margin-right: auto; }
.tb-title b { font-size: 15.5px; }
.tb-count { font-size: 13.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.timer {
  display: inline-flex; align-items: baseline; gap: 8px; min-height: 40px; padding: 8px 12px;
  border-radius: var(--r); background: var(--surface); border: 1px solid var(--rule-strong);
  font: 700 18px/1 var(--f-mono); font-variant-numeric: tabular-nums;
}
.timer-label { font: 500 12.5px/1 var(--f-sans); color: var(--ink-3); }
.timer.low { background: var(--warn-soft); border-color: var(--warn); color: var(--ink); }
.test-desk { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.qnav { display: flex; gap: 14px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.qgroup { display: flex; align-items: center; gap: 6px; flex: none; }
.qg-label { font-size: 12.5px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-right: 2px; white-space: nowrap; }
.qchip {
  appearance: none; display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: var(--r-sm); border: 1px solid var(--rule-strong); background: var(--surface);
  font: 600 14px/1 var(--f-mono); color: var(--ink-2); cursor: pointer;
}
.qchip:hover { border-color: var(--field); color: var(--ink); }
.qchip.draft { border-style: dashed; border-color: var(--accent); }
.qchip.done { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.qchip.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); color: var(--ink); }
@media (min-width: 1081px) {
  .test-desk { grid-template-columns: 210px minmax(0, 1fr); gap: 28px; }
  .qnav { position: sticky; top: calc(var(--header-h) + 76px); flex-direction: column; overflow: visible; gap: 16px; }
  .qgroup { flex-wrap: wrap; }
  .qg-label { width: 100%; }
}

.qpane {
  display: grid; gap: 18px; min-width: 0;
  padding: 20px 16px 22px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg);
}
@media (min-width: 720px) { .qpane { padding: 26px 28px 28px; } }
.q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 14px; color: var(--ink-3); }
.q-num { font-weight: 700; color: var(--ink); }
.q-meta .diff { text-transform: capitalize; }
.q-title { margin: -6px 0 0; font-size: 24px; line-height: 1.22; font-weight: 700; letter-spacing: -.018em; }
.q-body { display: grid; gap: 16px; min-width: 0; }
.q-body > * { min-width: 0; }
.q-prompt { margin: 0; font-size: 16.5px; line-height: 1.6; max-width: 70ch; }
.q-prompt p { margin: 0 0 8px; }
.q-prompt code, .opt-title code, .explain code, .hint code, .cn-sit code { font: 0.92em var(--f-mono); padding: 1px 5px; border-radius: var(--r-xs); background: var(--sunk); }
.q-note { margin: -6px 0 0; font-size: 14px; color: var(--ink-3); }
.formula-input { font-family: var(--f-mono); font-size: 16px; }
textarea.input.area { height: auto; min-height: 168px; padding: 12px 14px; line-height: 1.55; resize: vertical; }
.input:disabled, textarea.input:disabled { background: var(--sunk); color: var(--ink-2); }
.mc { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 10px; }
.mc .opt-body, .case-node .opt-body { min-height: 0; }
.opt input:disabled + .opt-body { cursor: default; opacity: .85; }
.sqlbench { display: grid; gap: 14px; min-width: 0; }
.sqlbench > * { min-width: 0; }
.schema-fold { border-top: 0; }
.schema-fold > summary { min-height: 44px; }
.bench-out:empty { display: none; }
.more-rows { margin: 0; padding: 8px 16px; font-size: 13px; color: var(--ink-3); border-top: 1px solid var(--rule); }
.sheet-box { display: grid; gap: 6px; }
table.grid.sheet td.idx, table.grid.sheet th.idx { background: var(--sunk); }

.given { display: grid; gap: 8px; padding: 16px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sunk); }
.given .label:not(:first-child) { margin-top: 6px; }
.given-ask { margin: 0; padding: 10px 14px; border-radius: 3px 14px 14px 14px; background: var(--surface); font-size: 15.5px; line-height: 1.5; }
pre.given-sql {
  margin: 0; padding: 12px 14px; overflow: auto;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
  font: 13.5px/1.6 var(--f-mono); color: var(--ink);
}
pre.given-sql.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

.case-role { margin: 0; font: 600 13px/1.3 var(--f-mono); letter-spacing: .04em; color: var(--ink-3); }
.case-intro { margin: -8px 0 0; padding: 14px 16px; border-radius: var(--r); background: var(--accent-soft); font-size: 16px; line-height: 1.55; }
.case-nodes { display: grid; gap: 22px; }
.case-node { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 10px; }
.case-node legend { display: grid; gap: 4px; padding: 0; margin-bottom: 10px; }
.cn-step { font-size: 13px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.cn-sit { font-size: 16.5px; line-height: 1.55; font-weight: 600; color: var(--ink); }
.case-choice {
  appearance: none; display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--rule-strong); background: var(--surface);
  font: 400 15.5px/1.5 var(--f-sans); color: var(--ink);
}
.case-choice:not(:disabled):hover { border-color: var(--accent); }
.case-choice:disabled { cursor: default; color: var(--ink-3); }
.case-choice.picked { color: var(--ink); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.case-fb { display: grid; gap: 6px; padding: 14px 16px; border-radius: var(--r); background: var(--sunk); border-left: 3px solid var(--ink-3); font-size: 15px; line-height: 1.55; }
.case-fb p { margin: 0; }
.case-fb.q3 { border-left-color: var(--pass); } .case-fb.q2 { border-left-color: var(--pass); }
.case-fb.q1 { border-left-color: var(--warn); } .case-fb.q0 { border-left-color: var(--fail); }
.cf-q { font-weight: 700; font-size: 14px; }
.cf-insight { padding-top: 8px; border-top: 1px solid var(--rule); color: var(--ink-2); }

.q-foot { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--rule); }
.q-submit { display: grid; gap: 10px; justify-items: start; }
.q-confirm { display: grid; gap: 8px; width: 100%; padding: 14px 16px; border-radius: var(--r); background: var(--accent-soft); }
.q-confirm[hidden] { display: none; }
.qc-t { margin: 0; font-weight: 700; }
.qc-s { margin: 0; font-size: 14.5px; color: var(--ink-2); overflow-wrap: anywhere; font-family: var(--f-mono); }
.qc-warn { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--warn-soft); font-size: 14.5px; line-height: 1.5; }
.qc-btns { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.q-msg { margin: 0; font-size: 14.5px; }
.q-msg:empty { display: none; }
.q-msg.bad { color: var(--fail); font-weight: 600; }
.q-saved { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--pass); }
.q-saved svg, .ls-done svg { width: 14px; height: 14px; }
.q-steps { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.finish-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.finish-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 14px; }
.finish-list li + li { border-top: 1px solid var(--rule); }
.finish-list li > span:first-child { font-weight: 700; }
.fl-n { font-variant-numeric: tabular-nums; font-weight: 600; }
.fl-s { grid-column: 1 / -1; font-size: 14px; color: var(--ink-3); }
.finish-list li.short .fl-s { color: var(--warn); font-weight: 600; }

/* results */
.result-hero { display: grid; gap: 12px; border-top: 3px solid var(--accent); }
.rh-score { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 14px; }
.rh-num { font-size: clamp(56px, 13vw, 84px); line-height: .95; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.rh-of { font-size: 20px; color: var(--ink-3); }
.rh-pct { margin: 0; color: var(--ink-2); font-size: 15.5px; }
.track-bars { display: grid; gap: 16px; }
.tb-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 64px; gap: 4px 12px; align-items: center; }
.tb-name { font-weight: 700; font-size: 15px; }
.tb-track { display: block; height: 10px; border-radius: 99px; background: var(--track); overflow: hidden; }
.tb-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.tb-val { text-align: right; font: 700 15px/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.tb-sub { grid-column: 2 / -1; font-size: 13.5px; color: var(--ink-3); }
@media (max-width: 479px) { .tb-row { grid-template-columns: 80px minmax(0, 1fr) 56px; } .tb-sub { grid-column: 1 / -1; } }
.cert-box { display: grid; gap: 10px; }
.cert-box .panel-title { margin-bottom: 2px; }
.cert-box > p { margin: 0; }
.cert-code { font: 700 clamp(22px, 5vw, 28px)/1.1 var(--f-mono); letter-spacing: .04em; color: var(--ink); }
.share-box .share { margin-top: 0; }
.item-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.item-list li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; }
.item-list li + li { border-top: 1px solid var(--rule); }
.il-n { font: 600 13px/1 var(--f-mono); color: var(--ink-3); }
.il-t { display: grid; gap: 1px; min-width: 0; }
.il-t b { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.il-t span { font-size: 13px; color: var(--ink-3); }
.il-p { font: 700 14px/1 var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.il-full .il-p { color: var(--pass); }
.il-part .il-p { color: var(--warn); }
.il-zero .il-p { color: var(--fail); }
.il-skip .il-p { color: var(--ink-3); font-weight: 500; }
.next-box > p { margin: 0 0 14px; }
.panel > .check { margin-bottom: 14px; }
.panel > .field { margin-bottom: 12px; }
.panel > .field .input { max-width: 360px; }

/* leaderboard */
.board-panel { padding: 0; overflow: hidden; }
.board-panel .table-scroll { max-height: none; }
.board-panel .empty { padding: 28px 22px; }
.board-foot { padding: 12px 16px; border-top: 1px solid var(--rule); }
table.grid.board td:first-child { font-weight: 700; }

/* course */
.chapters { display: grid; gap: 16px; }
.chapter { display: grid; gap: 14px; }
.ch-head { display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr) auto; }
.ch-num { grid-column: 1 / -1; font: 600 12.5px/1.3 var(--f-mono); letter-spacing: .05em; color: var(--ink-3); }
.ch-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.012em; }
.ch-count { grid-row: 2; grid-column: 2; align-self: center; font-size: 13.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ch-blurb { grid-column: 1 / -1; margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.lessons { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.lessons li + li { border-top: 1px solid var(--rule); }
.lesson-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; grid-template-areas: "s t f" "s m f"; gap: 0 12px; align-items: center;
  min-height: 52px; padding: 9px 14px; color: var(--ink); text-decoration: none;
}
a.lesson-row:hover { background: var(--sunk); color: var(--ink); text-decoration: none; }
.lesson-row.locked { color: var(--ink-3); }
.ls-state { grid-area: s; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--field); color: var(--ink-3); }
.ls-state svg { width: 12px; height: 12px; }
.lesson-row.done .ls-state { background: var(--pass); box-shadow: none; color: var(--on-state); }
.lesson-row.locked .ls-state { box-shadow: none; }
.lesson-row.locked .ls-state svg { width: 15px; height: 15px; }
.ls-title { grid-area: t; font-weight: 600; font-size: 15px; }
.ls-meta { grid-area: m; font-size: 13px; color: var(--ink-3); text-transform: capitalize; }
.ls-free { grid-area: f; font-size: 12.5px; font-weight: 700; padding: 4px 8px; border-radius: 99px; background: var(--pass-soft); color: var(--pass); }
.ls-done { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--pass); }
.unlock { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .unlock { grid-template-columns: minmax(0, 1fr) auto; } }

/* lesson */
.page-lesson { max-width: 980px; }
.lesson-reveal { display: grid; gap: 10px; }
.lesson-reveal[hidden] { display: none; }
.explain { margin: 0; font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.rubric { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rubric li { position: relative; padding-left: 26px; font-size: 15px; }
.rubric li::before { content: ""; position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%; }
.rubric li.hit::before { background: var(--pass); -webkit-mask: var(--i-check) center / 14px no-repeat; mask: var(--i-check) center / 14px no-repeat; }
.rubric li.miss { color: var(--ink-3); }
.rubric li.miss::before { box-shadow: inset 0 0 0 1.5px var(--fail); }
.lesson-foot { border-top: 1px solid var(--rule); }

.mc .opt-title, .case-node .opt-title { font-weight: 500; line-height: 1.45; }
@media (max-width: 479px) {
  .timer-label { display: none; }
  .test-bar { gap: 8px; flex-wrap: nowrap; }
  .tb-title { min-width: 0; }
  .tb-title b { font-size: 14.5px; }
  .test-bar .btn-accent { min-height: 40px; padding: 0 12px; font-size: 14px; }
  .timer { padding: 8px 10px; font-size: 16px; }
}
#googleOnly { margin-bottom: 18px; }
#googleOnlyPrint { margin-top: 14px; }
.gis-btn { display: flex; justify-content: center; min-height: 44px; }
/* Google draws its button in an iframe; a dark page colour scheme would paint a white box behind it. */
.gis-btn iframe { color-scheme: normal; }
.pw-link { margin-top: 10px; text-align: center; }
