:root {
  --ink: #1a1a1a;
  --text: #333;
  --muted: #666;
  --rule: #e2e2e2;
  --bg: #fff;
  --surface: #fff;
  --code-bg: #fff;
  --tint: 6%;

  --adapt: #007D34;
  --evolved: #C10020;
  --measure: #1F4E99;
  --best-bg: #A3D9A5;
  --second-bg: #EBF5EA;
  --check: #1B7837;
  --cross: #B2182B;

  /* Pathway accents: colour-blind-safe set; Workflow and Memory darkened for AA on the 6% tint */
  --pw-model: #4C6A92;
  --pw-tool: #8A5A9E;
  --pw-workflow: #98641A;
  --pw-memory: #2E7B76;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: 16px;
}

/* Dark theme: data-theme is set on <html> by the inline script in <head> (system default or saved choice) */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f1f3f5;
  --text: #d9dde2;
  --muted: #9aa1a9;
  --rule: #2c3036;
  --bg: #121417;
  --surface: #1a1d21;
  --code-bg: #0e1013;
  --tint: 10%;

  --adapt: #4CC27A;
  --evolved: #FF6B6B;
  --measure: #7FA7E6;
  --best-bg: #1F4D2B;
  --second-bg: #183222;

  --pw-model: #8FAAD3;
  --pw-tool: #C39BD6;
  --pw-workflow: #D9A55A;
  --pw-memory: #5FBDB4;
}

@media (min-width: 768px) {
  :root { --gutter: 24px; }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.55;
}

.hero, main, .site-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--measure); }

:focus-visible {
  outline: 2px solid var(--measure);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -3rem;
  background: var(--bg);
  color: var(--ink);
  padding: .5rem .75rem;
  border: 1px solid var(--ink);
}
.skip-link:focus { top: .5rem; }

/* Hero */
.hero {
  text-align: center;
  padding-top: 4rem;
  padding-bottom: 2.5rem;
}

h1, h2 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  margin: 0 0 1.5rem;
  text-wrap: balance;
}

.authors, .affiliations {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .25rem 1.25rem;
}

.authors { color: var(--ink); font-size: 1.0625rem; }
.affiliations { color: var(--text); font-size: .95rem; margin-top: .5rem; }
.notes { color: var(--muted); font-size: .875rem; margin: .5rem 0 0; }

sup { font-size: .7em; line-height: 0; }

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  margin-top: 1.75rem;
}

.btn {
  display: inline-block;
  padding: .45rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-size: .9375rem;
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn[aria-disabled="true"] {
  border-color: var(--rule);
  color: var(--muted);
  cursor: not-allowed;
}
.btn[aria-disabled="true"]:hover { background: none; color: var(--muted); }

/* Sections */
main > section { margin-top: 4.5rem; }

h2 { font-size: 1.6rem; margin: 0 0 1rem; }
#abstract-title { text-align: center; }

h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 .5rem;
}

.prose {
  font-family: var(--serif);
  line-height: 1.6;
}

.tldr {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--ink);
  margin: 0 0 2.5rem;
}

.adapt {
  font-variant: small-caps;
  font-weight: 700;
  color: var(--adapt);
}

/* Teaser */
.teaser { margin: 1rem 0 0; }
.teaser figcaption {
  color: var(--muted);
  font-size: .875rem;
  margin-top: .75rem;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 1rem;
}
.card {
  --accent: var(--ink);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--accent);
  border-radius: 4px;
  padding-bottom: 1rem;
  font-size: .9375rem;
  overflow: hidden;
  background: var(--surface);
}
.card-model { --accent: var(--pw-model); }
.card-tool { --accent: var(--pw-tool); }
.card-workflow { --accent: var(--pw-workflow); }
.card-memory { --accent: var(--pw-memory); }
.card h3 {
  margin: 0 0 .75rem;
  padding: .6rem 1.1rem;
  color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) var(--tint), var(--surface));
}
.card p, .card dl { margin-inline: 1.1rem; }
.card p { margin-block: 0; }
@media (max-width: 639px) {
  .cards { grid-template-columns: 1fr; grid-auto-rows: auto; }
}

/* BibTeX */
.bibtex-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.copy-btn {
  font: 600 .875rem var(--sans);
  padding: .35rem .9rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.copy-btn:hover { background: var(--ink); color: var(--bg); }

pre {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow-x: auto;
  font-size: .8125rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--code-bg);
}

/* Footer */
.site-footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: .875rem;
}

/* Placeholder marker: grep for class="todo" */
.todo {
  outline: 1px dashed var(--evolved);
  color: var(--evolved);
  padding: 0 .2em;
}

/* Card details: B / E / Agent / Data */
.card dl {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: .25rem .5rem;
  margin-top: .75rem;
  margin-bottom: 0;
  align-items: baseline;
}
.card dt { color: var(--muted); }
.card dd { margin: 0; }
.model {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .9em;
}

.bullets { padding-left: 1.25rem; }
.bullets li + li { margin-top: .5rem; }

/* Results table: fits the 960px column; scrolls inside its wrapper on narrow screens */
.table-wrap { overflow-x: auto; }
.results {
  border-collapse: separate; /* collapsed borders stay put and leak under sticky cells */
  border-spacing: 0;
  width: 100%;
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.results caption {
  caption-side: bottom;
  text-align: left;
  position: sticky;
  left: 0;
  max-width: calc(100vw - 2 * var(--gutter));
  color: var(--muted);
  font-size: .875rem;
  padding: .75rem 0 0;
}
/* Pathway group lines, drawn on cells (colgroup borders need border-collapse) */
.results thead tr:first-child th:nth-child(n+3),
.results thead tr:last-child th:nth-child(4n+5),
.results tbody td:nth-child(4n+6) { border-left: 1px solid var(--rule); }
.results th, .results td {
  padding: .3rem .45rem;
  text-align: center;
  white-space: nowrap;
}
.results thead th {
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
}
.results thead tr:last-child th { border-bottom-color: var(--ink); }
.results .h-e { color: var(--evolved); }
.results .h-ea { color: var(--adapt); }
.results tbody th {
  text-align: left;
  font-weight: 400;
  white-space: normal;
}
/* Only the metric column is sticky (a :first-child rule caught Model's B, since Metric has rowspan=2) */
.results .col-metric {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg);
  border-right: 1px solid var(--rule);
}
.results thead .col-metric { z-index: 3; border-bottom-color: var(--ink); }
.results tr.mod th {
  white-space: normal;
  font-weight: 600;
  padding-top: 1rem;
  border-bottom: 1px solid var(--ink);
}
.results tr.mod td { border-bottom: 1px solid var(--ink); }
.results tr.sub th {
  color: var(--muted);
  font-size: .8125rem;
  font-style: italic;
  padding-top: .6rem;
}
.results td.best { background: var(--best-bg); }
.results td.second { background: var(--second-bg); }
.results td.second span, .key.second span { text-decoration: underline; }
.key { padding: 0 .25em; color: var(--ink); }
.key.best { background: var(--best-bg); }
.key.second { background: var(--second-bg); }

.legend {
  color: var(--muted);
  font-size: .875rem;
  margin: .75rem 0 0;
}

.figure { max-width: 640px; margin: 2.5rem auto 0; }
.figure img { width: 100%; }
.figure figcaption {
  color: var(--muted);
  font-size: .875rem;
  margin-top: .75rem;
}
.takeaways { margin-top: 2rem; }

.text-btn {
  font: inherit;
  font-size: .875rem;
  color: var(--measure);
  background: none;
  border: 0;
  padding: 0;
  margin-top: .75rem;
  text-decoration: underline;
  cursor: pointer;
}

/* Justified body text (hero, captions, tables, buttons and BibTeX stay ragged) */
.prose, .tldr, .card p {
  text-align: justify;
  hyphens: auto;
  text-wrap: pretty;
}

/* Theme toggle: top-left icon button that scrolls away with the hero, one icon at a time */
.theme-toggle {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle:hover { background: color-mix(in srgb, var(--ink) 8%, var(--surface)); }
.theme-toggle:focus-visible { outline: 2px solid var(--measure); outline-offset: 2px; }
[data-theme="light"] .icon-sun,
[data-theme="dark"] .icon-moon { display: none; }

/* Figures are never inverted. Same white panel in both themes (invisible on the light background), so the image box is identical */
.teaser img,
.figure img {
  box-sizing: border-box;
  background: #fff;
  padding: 12px;
  border-radius: 6px;
}
