/* ==========================================================================
   GRASP project page
   Vanilla CSS, no build step. Light by default; dark only via explicit
   [data-theme="dark"] (toggle in nav, persisted in localStorage).
   ========================================================================== */

/* ---------- tokens ---------- */
:root {
  --bg:            #ffffff;
  --bg-alt:        #f6f7f9;
  --surface:       #ffffff;
  --surface-2:     #f2f4f7;
  --ink:           #14161a;
  --ink-2:         #3d434e;
  --muted:         #6b7280;
  --border:        #e2e5ea;
  --border-strong: #cbd1da;

  --brand:         #881C1C;
  --brand-fill:    #881C1C;
  --brand-2:       #b03a2e;
  --brand-soft:    #fbeded;
  --brand-ink:     #6b1414;

  --semantic:      #1b4fa8;
  --semantic-soft: #e9eff9;
  --keyword:       #b45309;
  --keyword-soft:  #fdf2e0;
  --read:          #0f766e;
  --read-soft:     #e2f5f2;
  --plain:         #64748b;
  --plain-soft:    #eef1f5;

  --good:          #15803d;
  --good-soft:     #e6f4ec;
  --good-line:     #86c8a2;
  --bad:           #d92d20;
  --bad-soft:      #fdecec;
  --bad-line:      #f0a3a3;
  --warn:          #a16207;
  --warn-soft:     #fdf6e3;

  --radius:   14px;
  --radius-s: 9px;
  --shadow:   0 1px 2px rgba(16,20,28,.05), 0 8px 24px -14px rgba(16,20,28,.22);
  --shadow-s: 0 1px 2px rgba(16,20,28,.06);

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  --nav-h: 56px;
  --maxw: 1120px;
}

/* Light is the default regardless of the visitor's OS theme: there is no
   `prefers-color-scheme: dark` block. Dark only applies when the visitor
   explicitly toggles it (stamps [data-theme="dark"], persisted below). */
:root[data-theme="dark"] {
  --bg:            #0e1117;
  --bg-alt:        #131820;
  --surface:       #161b23;
  --surface-2:     #1c222c;
  --ink:           #e8edf4;
  --ink-2:         #c2cad6;
  --muted:         #8b95a5;
  --border:        #262d38;
  --border-strong: #38414f;

  --brand:         #e79289;
  --brand-fill:    #a8322c;
  --brand-2:       #efa898;
  --brand-soft:    #2a1a17;
  --brand-ink:     #f0b6b6;

  --semantic:      #7fb2f2;
  --semantic-soft: #12233f;
  --keyword:       #e2a03f;
  --keyword-soft:  #2e2413;
  --read:          #4fd1c5;
  --read-soft:     #10312f;
  --plain:         #94a3b8;
  --plain-soft:    #1d232d;

  --good:          #57cc8a;
  --good-soft:     #12291d;
  --good-line:     #2f6b47;
  --bad:           #ff7a72;
  --bad-soft:      #38151a;
  --bad-line:      #8c3a3c;
  --warn:          #e0b341;
  --warn-soft:     #2b2413;

  --shadow:   0 1px 2px rgba(0,0,0,.4), 0 10px 30px -18px rgba(0,0,0,.8);
  --shadow-s: 0 1px 2px rgba(0,0,0,.35);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0; font-weight: 680; letter-spacing: -0.02em; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, pre { font-family: var(--mono); }
sub, sup { line-height: 0; vertical-align: baseline; position: relative; }
sub { font-size: .62em; top: .3em; }
sup { font-size: .68em; top: -.45em; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.wrap-wide { max-width: 1500px; margin: 0 auto; padding: 0 22px; }
.prose { max-width: 760px; margin-inline: auto; }
.prose p { color: var(--ink-2); }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1500px; margin: 0 auto; padding: 0 22px;
  height: 100%; display: flex; align-items: center; gap: 18px;
}
.nav-brand {
  font-weight: 800; letter-spacing: -.03em; font-size: 17px;
  color: var(--ink); text-decoration: none; flex: none;
}
.nav-brand:hover { text-decoration: none; }
.nav-links {
  display: flex; gap: 2px; margin-left: auto; overflow-x: auto;
  scrollbar-width: none;
  /* without this the flex item's content-based minimum widens the whole
     page on narrow screens instead of scrolling inside the strip */
  min-width: 0;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  padding: 6px 11px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  color: var(--muted); white-space: nowrap;
}
.nav-links a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-links a.active { color: var(--brand); background: var(--brand-soft); }
.theme-btn {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  border-radius: 9px; cursor: pointer; font-size: 15px; line-height: 1;
}
.theme-btn:hover { border-color: var(--border-strong); color: var(--ink); }

/* ---------- hero ---------- */
.hero { padding: 62px 0 30px; text-align: center; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -180px 0 auto 0; height: 420px;
  background: radial-gradient(ellipse 60% 100% at 50% 0%,
              color-mix(in srgb, var(--brand) 13%, transparent), transparent 70%);
  pointer-events: none;
}
.hero > * { position: relative; }
.venue {
  display: inline-block; font-size: 12.5px; font-weight: 650; letter-spacing: .07em;
  text-transform: uppercase; color: var(--brand-ink);
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent);
  padding: 5px 13px; border-radius: 999px; margin-bottom: 22px;
}
.hero h1 {
  font-size: clamp(2.6rem, 7.5vw, 4.4rem); font-weight: 820; letter-spacing: -.045em;
  background: linear-gradient(100deg, var(--brand) 0%, var(--brand-2) 55%, var(--brand) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--brand);
  margin-bottom: 8px;
}
.hero .expand {
  font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: .02em;
  margin-bottom: 16px;
}
.hero .expand b { color: var(--brand); font-weight: 700; }
.hero h2 {
  font-size: clamp(1.15rem, 3vw, 1.72rem); font-weight: 600; color: var(--ink);
  letter-spacing: -.025em; max-width: 800px; margin: 0 auto 26px;
}
.authors { font-size: 16px; color: var(--ink-2); max-width: 760px; margin: 0 auto 6px; }
.authors a { color: var(--ink-2); text-decoration: none; font-weight: 550; }
.authors a:hover { color: var(--brand); }
.authors sup { font-size: 11px; color: var(--muted); }
.affil { font-size: 14.5px; color: var(--muted); margin-bottom: 4px; }
.affil sup { color: var(--muted); }
.footnote-eq { font-size: 13px; color: var(--muted); margin-bottom: 26px; }

/* link buttons */
.links { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  border: 1px solid var(--ink);
  font-size: 14.5px; font-weight: 570; letter-spacing: -.01em;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.btn-emoji { font-size: 16px; line-height: 1; flex: none; }
/* arXiv logomark: white keyed out, so it sits on either theme's button */
.btn-logo { height: 17px; width: auto; flex: none; display: block; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-brand { background: var(--brand-fill); border-color: var(--brand-fill); color: #fff; }

/* ---------- section scaffolding ---------- */
section { padding: 58px 0; }
.band { background: var(--bg-alt); border-block: 1px solid var(--border); }
.sec-head { text-align: center; max-width: 780px; margin: 0 auto 38px; }
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 10px;
}
.sec-head h2 { font-size: clamp(1.7rem, 4vw, 2.3rem); letter-spacing: -.035em; margin-bottom: 12px; }
.sec-head p { color: var(--muted); font-size: 17px; margin: 0; }

/* ---------- figures ---------- */
figure { margin: 0; }
.fig {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-s);
}
.fig img { width: 100%; height: auto; display: block; border-radius: 6px; }
.fig figcaption {
  font-size: 14.2px; color: var(--muted); line-height: 1.6; margin-top: 14px;
  padding-top: 13px; border-top: 1px solid var(--border);
}
.fig figcaption b, .fig figcaption strong { color: var(--ink-2); }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; }
/* min(..., 100%) keeps the track from exceeding the viewport on narrow screens */
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(272px, 100%), 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(226px, 100%), 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-s);
}
.card h3 { font-size: 16.5px; margin-bottom: 8px; letter-spacing: -.02em; }
.card p { font-size: 14.6px; color: var(--muted); margin: 0; line-height: 1.62; }
.card .num {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand-ink);
  font-size: 12.5px; font-weight: 750; margin-bottom: 12px;
}

/* tool cards */
.tool-card { border-top: 3px solid var(--c); }
.tool-card .tool-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tool-sym {
  font-family: var(--serif); font-size: 19px;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--cs); color: var(--c); flex: none; font-weight: 600;
  display: block; text-align: center; line-height: 34px; white-space: nowrap;
}
.tool-card h3 { margin: 0; }
.tool-card .mono-tag {
  font-family: var(--mono); font-size: 12px; color: var(--c);
  background: var(--cs); padding: 2px 8px; border-radius: 5px; display: inline-block;
  margin-bottom: 10px;
}
.tool-card.semantic { --c: var(--semantic); --cs: var(--semantic-soft); }
.tool-card.keyword  { --c: var(--keyword);  --cs: var(--keyword-soft); }
.tool-card.read     { --c: var(--read);     --cs: var(--read-soft); }

/* reward cards */
.rw .rw-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
/* min-width:0 lets the title shrink so the weight chip cannot push the card wide */
.rw .rw-head h3 { margin: 0; min-width: 0; overflow-wrap: break-word; }
.rw .rw-sym {
  font-family: var(--serif); font-size: 15.5px;
  color: var(--brand); font-weight: 600; margin-right: 7px;
}
.rw .rw-w {
  flex: none; white-space: nowrap; margin-top: 2px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  color: var(--muted); background: var(--surface-2);
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border);
}
.formula {
  font-family: var(--serif); font-size: 15px; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 9px 12px; border-radius: var(--radius-s); margin: 11px 0 0;
  overflow-x: auto; white-space: normal; word-break: break-word;
}
.formula.big { text-align: center; font-size: 18px; padding: 15px; white-space: normal; }

/* weight bar */
.wbar { display: flex; height: 36px; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); margin-top: 6px; }
.wbar > div {
  font-size: 11.5px; font-weight: 700; color: #fff;
  font-family: var(--mono); letter-spacing: -.02em;
  display: block; text-align: center; line-height: 34px;
  white-space: nowrap; overflow: hidden; padding: 0 4px; min-width: 0;
}
.wbar-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.wbar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.wbar-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* The reward bar is a graphic, so its swatches keep fixed colors in both
   themes: the dark-theme tints are too light to carry white label text. */
.sw-a { background: #881C1C; }
.sw-r { background: #0f766e; }
.sw-s { background: #b45309; }
.sw-e { background: #55607a; }

/* ---------- outcome strip (teaser) ---------- */
.outcomes { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); margin-top: 22px; }
.oc {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--l);
  border-radius: var(--radius-s); padding: 16px 18px;
}
.oc.wrong { --l: var(--bad-line); }
.oc.right { --l: var(--good-line); }
.oc .oc-m { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.oc .oc-a { font-size: 19px; font-weight: 700; letter-spacing: -.025em; margin: 5px 0 6px; }
.oc.wrong .oc-a { color: var(--bad); }
.oc.right .oc-a { color: var(--good); }
.oc .oc-d { font-size: 13.6px; color: var(--muted); line-height: 1.55; }

/* ==========================================================================
   CASE STUDY EXPLORER
   ========================================================================== */
.explorer { --col-min: 330px; }

.case-tabs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 24px; }
.case-tab {
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
  font-size: 14px; font-weight: 570; font-family: inherit;
  transition: all .14s ease;
}
.case-tab:hover { border-color: var(--border-strong); }
.case-tab[aria-selected="true"] {
  background: var(--brand-fill); border-color: var(--brand-fill); color: #fff;
  box-shadow: 0 4px 14px -6px var(--brand-fill);
}
.case-tab small { display: block; font-size: 11.5px; opacity: .72; font-weight: 500; }

/* question panel */
.qpanel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow-s);
}
.qpanel .qtop { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: baseline; margin-bottom: 12px; }
.qpanel .qlabel {
  font-size: 11.5px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase;
  color: var(--brand); background: var(--brand-soft); padding: 3px 9px; border-radius: 6px;
}
.qpanel .qds { font-size: 13px; color: var(--muted); font-family: var(--mono); }
.qpanel .qtext {
  font-size: clamp(1.05rem, 2.4vw, 1.35rem); font-weight: 600; letter-spacing: -.02em;
  color: var(--ink); line-height: 1.42; margin-bottom: 16px;
}
.qmeta { display: grid; gap: 14px; grid-template-columns: minmax(240px, 1fr) minmax(280px, 1.35fr); }
@media (max-width: 720px) { .qmeta { grid-template-columns: 1fr; } }
.qbox {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 14px 16px;
}
.qbox h4 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 700; margin-bottom: 9px;
}
.gold-answer { font-size: 17px; font-weight: 700; color: var(--good); letter-spacing: -.02em; }
.hop { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.hop:last-child { margin-bottom: 0; }
.hop .hn {
  flex: none; font-size: 10.5px; font-weight: 750; font-family: var(--mono);
  background: var(--brand-soft); color: var(--brand-ink);
  padding: 2px 6px; border-radius: 5px; margin-top: 2px;
}
.qbox .trap { font-size: 13.8px; color: var(--muted); line-height: 1.6; margin: 0; }
.qbox .trap em { color: var(--ink-2); }

/* controls */
.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px;
  position: sticky; top: calc(var(--nav-h) + 8px); z-index: 30;
  box-shadow: var(--shadow-s);
}
.ctl-group { display: flex; align-items: center; gap: 7px; }
.ctl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; min-width: 34px; padding: 0 12px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 550;
  transition: all .13s ease;
}
.ctl-btn:hover:not(:disabled) { border-color: var(--border-strong); color: var(--ink); background: var(--surface-2); }
.ctl-btn:disabled { opacity: .4; cursor: default; }
.ctl-btn.primary { background: var(--brand-fill); border-color: var(--brand-fill); color: #fff; }
.ctl-btn.primary:hover { filter: brightness(1.07); }
.ctl-sep { width: 1px; height: 24px; background: var(--border); }
.step-readout {
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  min-width: 74px; text-align: center;
}
.ctl-slider { flex: 1 1 180px; min-width: 140px; display: flex; align-items: center; }
.ctl-slider input { width: 100%; accent-color: var(--brand); cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 13.2px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 34px; height: 19px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background .15s ease; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; transition: transform .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .track { background: var(--brand-fill); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* columns */
.cols {
  display: grid; gap: 14px; align-items: start;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
}
@media (max-width: 1180px) { .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .cols { grid-template-columns: 1fr; }
  .cols .col { display: none; }
  .cols .col.mobile-active { display: flex; }
  .mobile-picker { display: flex !important; }
}
.mobile-picker { display: none; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.mobile-picker button {
  flex: 1 1 auto; padding: 8px 10px; font-size: 13px; font-weight: 600; font-family: inherit;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); cursor: pointer;
}
.mobile-picker button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

.col {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-s);
}
.col.is-correct { border-color: var(--good-line); box-shadow: 0 0 0 1px var(--good-line), var(--shadow); }

.col-head { padding: 14px 16px 13px; border-bottom: 1px solid var(--border); background: var(--surface); }
.col.is-correct .col-head { background: var(--good-soft); border-bottom-color: var(--good-line); }
.col-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.col-title h3 { font-size: 16.5px; letter-spacing: -.025em; }
.chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 2.5px 7px; border-radius: 5px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.chip.ours { background: var(--brand-fill); color: #fff; border-color: var(--brand-fill); }
.col-spec { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.8px; color: var(--muted); font-family: var(--mono); }
.col-spec b { color: var(--ink-2); font-weight: 600; }

.col-answer {
  display: flex; align-items: baseline; gap: 9px; padding: 11px 16px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.col-answer .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; }
.col-answer .val { font-size: 15.5px; font-weight: 700; letter-spacing: -.02em; }
.col-answer .mark { font-size: 14px; font-weight: 800; }
.col.wrong .col-answer { background: var(--bad-soft); border-bottom-color: var(--bad-line); }
.col.wrong .col-answer .val, .col.wrong .col-answer .mark { color: var(--bad); }
.col.is-correct .col-answer { background: var(--good-soft); border-bottom-color: var(--good-line); }
.col.is-correct .col-answer .val, .col.is-correct .col-answer .mark { color: var(--good); }

.col-verdict {
  padding: 11px 16px; font-size: 13.4px; line-height: 1.55; color: var(--ink-2);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.col-verdict strong { color: var(--ink); }
.col-verdict code {
  font-size: 12px; background: var(--surface); padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--border);
}

.col-body { padding: 12px; display: flex; flex-direction: column; gap: 9px; }
.col-count {
  font-size: 11.5px; color: var(--muted); font-family: var(--mono);
  padding: 0 16px 11px; border-bottom: 1px solid var(--border); margin-bottom: 0;
}

/* steps */
.step {
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); overflow: hidden;
  animation: pop .22s ease both;
}
@keyframes pop { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .step { animation: none; } }

.step.dim { opacity: .32; filter: saturate(.5); }
.step-lab {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase;
  padding: 7px 11px; border-bottom: 1px solid var(--border);
  color: var(--sc, var(--muted)); background: var(--scs, var(--surface-2));
}
.step-lab .idx {
  margin-left: auto; font-family: var(--mono); font-size: 10px; opacity: .7;
  letter-spacing: 0; text-transform: none;
}
.step-body { padding: 11px 13px; font-size: 13.9px; line-height: 1.62; color: var(--ink-2); }

.step.think { --sc: var(--plain); --scs: var(--plain-soft); }
.step.refine { --sc: var(--brand); --scs: var(--brand-soft); }
.step.procstep { --sc: var(--plain); --scs: var(--plain-soft); }
.step.tool-semantic_search { --sc: var(--semantic); --scs: var(--semantic-soft); border-color: color-mix(in srgb, var(--semantic) 32%, var(--border)); }
.step.tool-keyword_search  { --sc: var(--keyword);  --scs: var(--keyword-soft);  border-color: color-mix(in srgb, var(--keyword) 32%, var(--border)); }
.step.tool-read_chunk      { --sc: var(--read);     --scs: var(--read-soft);     border-color: color-mix(in srgb, var(--read) 32%, var(--border)); }
.step.tool-search          { --sc: var(--plain);    --scs: var(--plain-soft); }
.step.obs { --sc: var(--muted); --scs: var(--surface-2); }
.step.context { --sc: var(--warn); --scs: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.step.answer.good { --sc: var(--good); --scs: var(--good-soft); border-color: var(--good-line); }
.step.answer.bad  { --sc: var(--bad);  --scs: var(--bad-soft);  border-color: var(--bad-line); }

.query {
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px;
  word-break: break-word;
}
.answer-val { font-size: 16px; font-weight: 750; letter-spacing: -.02em; }
.step.answer.good .answer-val { color: var(--good); }
.step.answer.bad .answer-val { color: var(--bad); }

/* retrieved docs */
.docs { display: flex; flex-direction: column; gap: 7px; }
.doc {
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2);
  overflow: hidden;
}
.doc.gold { border-color: var(--good-line); background: var(--good-soft); }
.doc.bridge { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: var(--warn-soft); }
.doc-head {
  display: flex; align-items: center; gap: 7px; padding: 7px 9px;
  cursor: pointer; user-select: none; font-size: 12.4px;
}
.doc-head:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.doc-n {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px; flex: none;
}
.doc-title { font-weight: 620; color: var(--ink-2); flex: 1; min-width: 0; overflow-wrap: anywhere; }
.doc.gold .doc-title { color: var(--good); }
.doc-badge {
  font-size: 9.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 5px; border-radius: 4px; flex: none;
}
.doc-badge.gold { background: var(--good); color: #fff; }
.doc-badge.bridge { background: var(--warn); color: #fff; }
.doc-sim { font-family: var(--mono); font-size: 10.5px; color: var(--muted); flex: none; }
.doc-caret { flex: none; color: var(--muted); font-size: 10px; transition: transform .15s ease; }
.doc[open] .doc-caret { transform: rotate(90deg); }
.doc-text {
  padding: 0 10px 9px; font-size: 12.7px; line-height: 1.58; color: var(--muted);
  border-top: 1px dashed var(--border); padding-top: 8px; margin: 0 0 0;
}

.obs-meta { font-size: 11.5px; color: var(--muted); font-family: var(--mono); margin-bottom: 7px; }

/* highlights */
mark {
  background: none; padding: 0 1px; border-radius: 3px; font-weight: 620;
}
.hl-on mark.bad  { background: var(--bad-soft);  color: var(--bad);  box-shadow: inset 0 -2px 0 var(--bad-line); }
.hl-on mark.good { background: var(--good-soft); color: var(--good); box-shadow: inset 0 -2px 0 var(--good-line); }
mark.bad, mark.good { color: inherit; }

/* takeaway */
.takeaway {
  margin-top: 20px; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--brand); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow-s);
}
.takeaway h3 { font-size: 15.5px; margin-bottom: 9px; }
.takeaway p { font-size: 14.6px; color: var(--ink-2); margin: 0 0 .7em; line-height: 1.65; }
.takeaway p:last-child { margin-bottom: 0; }
.takeaway .src { font-size: 12.5px; color: var(--muted); font-family: var(--mono); margin-top: 12px; }

/* ---------- results tables ---------- */
.tabs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 22px; }
.tab {
  padding: 8px 16px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
  font-family: inherit; font-size: 13.6px; font-weight: 560; transition: all .13s ease;
}
.tab:hover { border-color: var(--border-strong); }
.tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.tbl-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-s);
}
.tbl-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
thead th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  color: var(--muted); text-align: center; padding: 11px 10px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
thead th.grp { border-left: 1px solid var(--border); }
thead tr.sub th { font-size: 11px; padding: 7px 10px; letter-spacing: .04em; }
tbody td { padding: 9px 10px; text-align: center; border-bottom: 1px solid var(--border); color: var(--ink-2); }
tbody td.l { text-align: left; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.ours { background: var(--brand-soft); }
tbody tr.ours td { color: var(--ink); font-weight: 620; }
tbody tr.ours td.l { color: var(--brand-ink); font-weight: 750; }
tbody tr.sec-start td { border-top: 1px solid var(--border-strong); }
tbody tr:hover:not(.ours) { background: var(--surface-2); }
td.best { font-weight: 750; color: var(--ink); }
td.second { text-decoration: underline; text-underline-offset: 3px; }
.tbl-cap {
  font-size: 13.4px; color: var(--muted); padding: 13px 18px;
  border-top: 1px solid var(--border); background: var(--surface-2); line-height: 1.6;
}
.tbl-cap b { color: var(--ink-2); }

/* bar cell */
.bar-cell { position: relative; }
.bar-cell .bar {
  position: absolute; left: 6px; right: 6px; bottom: 3px; height: 3px;
  background: var(--border); border-radius: 2px; overflow: hidden;
}
.bar-cell .bar i {
  display: block; height: 100%; background: var(--brand-2); border-radius: 2px;
  width: var(--w, 0%); transition: width .6s cubic-bezier(.22,.9,.3,1);
}
tbody tr.ours .bar-cell .bar i { background: var(--brand); }

/* delta */
.delta { font-family: var(--mono); font-size: 12px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* ---------- emergent behaviour ---------- */
.cycle {
  display: flex; align-items: stretch; justify-content: center; gap: 0; flex-wrap: wrap;
}
.cyc-node {
  flex: 1 1 210px; min-width: 0; max-width: 300px; text-align: center; padding: 20px 18px;
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--c);
  border-radius: var(--radius);
}
.cyc-node .sym {
  font-family: var(--serif); font-size: 24px; color: var(--c);
  width: 46px; height: 46px; border-radius: 12px; background: var(--cs);
  margin: 0 auto 11px; font-weight: 600;
  display: block; text-align: center; line-height: 46px; white-space: nowrap;
}
.cyc-node h4 { font-size: 15.5px; margin-bottom: 5px; }
.cyc-node .role { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--c); margin-bottom: 8px; }
.cyc-node p { font-size: 13.6px; color: var(--muted); margin: 0; line-height: 1.58; }
.cyc-arrow { display: grid; place-items: center; padding: 0 6px; color: var(--border-strong); font-size: 22px; flex: none; }
@media (max-width: 700px) {
  /* stack the cycle vertically: side-by-side nodes cannot shrink below their
     min-content width and would widen the whole page */
  .cycle { flex-direction: column; align-items: stretch; }
  .cyc-node { max-width: none; }
  .cyc-arrow { transform: rotate(90deg); padding: 8px 0; }
}

/* ---------- bibtex ---------- */
.bib {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.bib pre {
  margin: 0; padding: 20px; overflow-x: auto; font-size: 13px; line-height: 1.66;
  color: var(--ink-2); background: var(--surface-2);
}
.copy-btn {
  position: absolute; top: 11px; right: 11px;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
}
.copy-btn:hover { background: var(--bg); color: var(--ink); }
.copy-btn.done { color: var(--good); border-color: var(--good-line); }

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--border); background: var(--bg-alt);
  padding: 40px 0 48px; text-align: center;
}
/* Hero affiliation logos. The plate stays light in both themes: the CICS mark
   is a dark maroon and the Adobe wordmark is near-black, so neither survives on
   a dark ground, and the Adobe asset carries its own white background anyway. */
.affiliations { display: flex; justify-content: center; margin-top: 30px; }
.logo-plate {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(20px, 4vw, 38px); flex-wrap: wrap;
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 14px clamp(18px, 3vw, 28px);
}
.logo-plate .logo { display: block; width: auto; }
.logo-cics { height: 36px; }
.logo-adobe { height: 44px; }
.logo-rule { width: 1px; align-self: stretch; background: #e2e5ea; }
@media (max-width: 460px) {
  .logo-rule { display: none; }
  .logo-cics { height: 32px; }
  .logo-adobe { height: 40px; }
}

footer p { font-size: 13.6px; color: var(--muted); max-width: 660px; margin: 0 auto .8em; line-height: 1.65; }
footer .foot-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; font-size: 14px; }

/* ---------- misc ---------- */
.center { text-align: center; }
.mt-l { margin-top: 34px; }
.mt-m { margin-top: 22px; }
.note {
  font-size: 13.4px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 12px 15px; margin-top: 16px;
}
.stat-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; text-align: center;
}
.stat .v {
  font-size: 30px; font-weight: 780; letter-spacing: -.04em; color: var(--brand);
  line-height: 1.1; font-variant-numeric: tabular-nums;
}
.stat .v small { font-size: 15px; font-weight: 650; color: var(--muted); }
.stat .k { font-size: 12.6px; color: var(--muted); margin-top: 5px; line-height: 1.4; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  section { padding: 44px 0; }
  .hero { padding: 40px 0 22px; }
  .controls { position: static; }
}

@media print {
  .nav, .controls, .theme-btn, .mobile-picker { display: none !important; }
  .step.dim { opacity: 1; filter: none; }
  .cols { grid-template-columns: 1fr; }
}

/* ---------- details/summary reset (retrieved-document disclosures) ---------- */
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary::marker { content: ""; }
