/* CART project page. Palette taken from the paper's figures:
   E1-E4 capacity ramp, mint/green spatial mixer ("where"),
   peach/rust channel mixer ("what"). */

:root {
  color-scheme: light;

  --ink: #151a2d;
  --text: #2b3245;
  --muted: #5d6679;
  --line: #e2e5ee;
  --line-strong: #cfd4e0;
  --bg: #ffffff;
  --bg-alt: #f6f7fa;
  --navy: #1f2640;
  --navy-hover: #323c63;
  --link: #2c6689;

  --e1: #d8eacc;
  --e2: #92c6b8;
  --e3: #5c97b4;
  --e4: #53608a;

  --where: #0c6c54;
  --where-soft: #e3f4ec;
  --where-hl: #bfe5d2;
  --what: #9b3d1f;
  --what-soft: #fbeee6;
  --what-hl: #f7d3c1;

  --good: #17774f;

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

  --radius: 14px;
  --nav-h: 56px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 12px);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

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

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

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--e3);
  outline-offset: 3px;
  border-radius: 6px;
}

p { margin: 0 0 1em; }
h1, h2, h3 { color: var(--ink); margin: 0; }
h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.6rem, 3.2vw, 2.15rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 0.6em;
}
h3 {
  font-family: var(--sans);
  font-weight: 650;
  font-size: 1.12rem;
  line-height: 1.35;
  margin-bottom: 0.55em;
}
var { font-style: italic; font-family: var(--serif); }
sub, sup { line-height: 0; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}
.prose { max-width: 820px; }

/* ---------- Top navigation ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topnav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 9px);
  gap: 2px;
}
.brand-mark i { width: 9px; height: 9px; border-radius: 2px; background: var(--e1); }
.brand-mark i:nth-child(2) { background: var(--e2); }
.brand-mark i:nth-child(3) { background: var(--e3); }
.brand-mark i:nth-child(4) { background: var(--e4); }

.topnav-links {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
  mask-image: linear-gradient(90deg, #000 88%, transparent);
}
.topnav-links::-webkit-scrollbar { display: none; }
.topnav-links a {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}
.topnav-links a:hover { color: var(--ink); background: var(--bg-alt); text-decoration: none; }
.topnav-links a.active { color: var(--ink); background: var(--bg-alt); }

@media (min-width: 900px) {
  .topnav-links { -webkit-mask-image: none; mask-image: none; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 64px 0 40px;
  text-align: center;
  background:
    radial-gradient(1100px 380px at 50% -120px, rgba(146, 198, 184, 0.18), transparent 70%),
    var(--bg);
}
.venue {
  display: inline-block;
  margin: 0 0 22px;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2rem, 4.8vw, 3.35rem);
  line-height: 1.14;
  letter-spacing: -0.015em;
  margin: 0 auto 18px;
  max-width: 22ch;
  text-wrap: balance;
}
@media (min-width: 900px) {
  .hero h1 { max-width: none; }
}
@media (max-width: 899px) {
  .br-wide { display: none; }
}

.hl-where,
.hl-what {
  padding: 0 0.06em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.hl-where { background: linear-gradient(transparent 60%, var(--where-hl) 60%, var(--where-hl) 90%, transparent 90%); }
.hl-what { background: linear-gradient(transparent 60%, var(--what-hl) 60%, var(--what-hl) 90%, transparent 90%); }

.method-name {
  color: var(--muted);
  font-size: 1.08rem;
  margin-bottom: 28px;
}
.method-name strong { color: var(--ink); letter-spacing: 0.04em; }

.authors,
.affils {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}
.authors { gap: 6px 22px; max-width: 880px; font-size: 1.05rem; }
.authors a { color: var(--ink); font-weight: 500; border-bottom: 1px solid var(--line-strong); }
.authors a:hover { text-decoration: none; border-bottom-color: var(--ink); }
.authors sup, .affils sup, .author-notes sup { color: var(--muted); font-size: 0.72em; margin-left: 1px; }
.affils { gap: 4px 22px; margin-top: 12px; color: var(--muted); font-size: 0.95rem; }
.author-notes { margin: 6px 0 28px; color: var(--muted); font-size: 0.85rem; }

.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--navy);
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.btn:hover { background: var(--navy-hover); text-decoration: none; transform: translateY(-1px); }
.btn svg,
.copy-btn svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--bg-alt); }

.formerly {
  margin: 22px auto 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section-tight { padding: 36px 0 64px; }
.section.alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section.alt + .section.alt { border-top: 0; }

.section-head { max-width: 820px; margin-bottom: 32px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--where);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.lead { font-size: 1.06rem; color: var(--text); margin: 0; }
.h-small { font-size: 1.35rem; }

/* ---------- Figures ---------- */
.figure { margin: 0; }
.figure-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 2px rgba(21, 26, 45, 0.04), 0 8px 24px -12px rgba(21, 26, 45, 0.12);
}
.figure-card img { width: 100%; border-radius: 6px; }
.figure figcaption {
  margin: 14px auto 0;
  max-width: 920px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}
.figure figcaption strong { color: var(--ink); }
.zoomable { display: block; cursor: zoom-in; }

/* ---------- Stat tiles ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 36px;
}
@media (min-width: 900px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
}
.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  background: #fff;
}
.stat p { margin: 0; }
.stat-label { color: var(--muted); font-size: 0.85rem; line-height: 1.35; }
.stat-value {
  color: var(--ink);
  font-weight: 600;
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 6px 0 4px !important;
}
.stat-value .unit {
  color: var(--muted);
  font-size: 0.6em;
  font-weight: 500;
  letter-spacing: 0;
}
.stat-delta { color: var(--muted); font-size: 0.84rem; line-height: 1.35; }
.stat-delta.good { color: var(--good); font-weight: 600; }

/* ---------- Abstract ---------- */
.abstract { font-size: 1.08rem; line-height: 1.75; color: var(--text); margin: 0; }

/* ---------- Two-column splits ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: center; }
.split-text > :last-child { margin-bottom: 0; }
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
  .split-reverse .split-media { order: 2; }
  .analysis-row { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .pca { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
  .efficiency { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
}
.analysis-wide { margin-top: 64px; }
.analysis-wide-text { max-width: 820px; margin-bottom: 22px; }
.analysis-wide-text p { margin: 0; }
.efficiency .table-key { margin-bottom: 18px; }

.ticks { list-style: none; padding: 0; margin: 0; }
.ticks li { position: relative; padding-left: 26px; margin-bottom: 14px; }
.ticks li::before {
  content: "";
  position: absolute;
  left: 2px; top: 0.62em;
  width: 12px; height: 12px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--e2), var(--e4));
}

/* ---------- Method ---------- */
.mixers {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin: 36px 0 56px;
}
@media (min-width: 900px) {
  .mixers { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
}
.mixer {
  position: relative;
  border-radius: var(--radius);
  padding: 26px 26px 22px;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}
.mixer::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
}
.mixer-where::before { background: var(--where); }
.mixer-what::before { background: var(--what); }
.mixer-kicker {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.mixer-where .mixer-kicker { color: var(--where); }
.mixer-what .mixer-kicker { color: var(--what); }
.mixer h3 { font-family: var(--serif); font-size: 1.45rem; font-weight: 700; }
.mixer-foot {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line-strong);
  color: var(--muted);
  font-size: 0.92rem;
}

.ladder {
  margin-top: 18px;
  padding: 16px 18px 12px;
  border-radius: 10px;
  background: var(--where-soft);
}
.rung {
  display: grid;
  grid-template-columns: 30px 1fr 28px;
  align-items: center;
  gap: 10px;
  height: 22px;
}
.rung + .rung { margin-top: 4px; }
.rung-name { font-family: var(--serif); font-style: italic; color: var(--ink); font-size: 0.95rem; }
.rung-track { display: block; }
.rung-bar {
  display: block;
  width: var(--w);
  height: 10px;
  background: var(--c);
  border-radius: 0 4px 4px 0;
  box-shadow: inset 0 0 0 1px rgba(21, 26, 45, 0.08);
}
.rung-val { color: var(--text); font-size: 0.85rem; font-variant-numeric: tabular-nums; text-align: right; }
.ladder-note { margin: 10px 0 0; color: var(--muted); font-size: 0.8rem; }

.multihot {
  margin-top: 18px;
  padding: 16px 18px 12px;
  border-radius: 10px;
  background: var(--what-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.multihot .ladder-note { flex-basis: 100%; margin-top: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}
.chip b { font-variant-numeric: tabular-nums; }
.chip.on { border-color: #e6b8a3; color: var(--what); background: #fff; }
.chip.on b { color: var(--what); }

/* ---------- Tabs & tables ---------- */
.tablist {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  margin-bottom: 20px;
  max-width: 100%;
}
.tablist [role="tab"] {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 0.92rem/1.2 var(--sans);
  padding: 9px 14px;
  border-radius: 9px;
  cursor: pointer;
}
.tablist [role="tab"]:hover { color: var(--ink); }
.tablist [role="tab"][aria-selected="true"] {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(21, 26, 45, 0.08), 0 0 0 1px var(--line);
}
[role="tabpanel"]:focus-visible { outline-offset: 6px; }

.table-caption { max-width: 860px; color: var(--text); }
.table-key { margin: 10px 0 0; color: var(--muted); font-size: 0.85rem; }

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
table.results {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.results th,
.results td {
  padding: 10px 12px;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.results tbody tr:last-child > * { border-bottom: 0; }
.results thead th {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.84rem;
  background: #fbfbfd;
}
.results thead tr.group th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-top: 12px;
  padding-bottom: 6px;
  border-bottom: 0;
}
.results thead tr.group th[colspan]:not(:empty) { box-shadow: inset 0 -2px 0 var(--line); }
.results th[scope="row"],
.results thead tr > th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  box-shadow: inset -1px 0 0 var(--line);
}
.results thead tr > th:first-child { background: #fbfbfd; }
.results .p { display: block; color: var(--text); }
.results .s { display: block; margin-top: 3px; color: var(--muted); font-size: 0.78rem; }
.results .best,
.results td.best { font-weight: 700; color: var(--ink); }
.results .avg { box-shadow: inset 1px 0 0 var(--line); background: #fbfbfd; }
.results thead tr.group th.avg { box-shadow: none; }
.results tr.ours > * { background: var(--where-soft); }
.results tr.ours th[scope="row"] { font-weight: 700; }
.results tr.ours .avg { background: #d5eee2; }
.ours-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--where);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}
.results tr.section th {
  position: static;
  text-align: left;
  background: var(--bg-alt);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-top: 8px;
  padding-bottom: 8px;
  box-shadow: none;
}
.results .delta { color: var(--muted); }
.results.compact td { color: var(--text); }
.results sub { font-size: 0.75em; }

/* ---------- Comparison slider ---------- */
.compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  margin-bottom: 48px;
  align-items: start;
}
@media (min-width: 900px) {
  .compare { grid-template-columns: minmax(0, 620px) minmax(0, 1fr); gap: 36px; }
}
.compare-stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #11131a;
  cursor: ew-resize;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 1px 2px rgba(21, 26, 45, 0.06), 0 16px 40px -20px rgba(21, 26, 45, 0.35);
}
.compare-stage img { width: 100%; -webkit-user-drag: none; pointer-events: none; }
.compare-ref {
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: cover;
  clip-path: inset(0 calc(100% - var(--pos)) 0 0);
}
.compare-divider {
  position: absolute;
  top: 0; bottom: 0;
  left: var(--pos);
  width: 44px;
  margin-left: -22px;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}
.compare-divider::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.compare-knob {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.compare-knob::before,
.compare-knob::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0; height: 0;
  border: 6px solid transparent;
  margin-top: -6px;
}
.compare-knob::before { left: 5px; border-right-color: var(--navy); }
.compare-knob::after { right: 5px; border-left-color: var(--navy); }
.compare-divider:focus-visible { outline: none; }
.compare-divider:focus-visible .compare-knob { box-shadow: 0 0 0 3px var(--e3), 0 2px 10px rgba(0, 0, 0, 0.35); }
.compare-tag {
  position: absolute;
  top: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(17, 19, 26, 0.68);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  pointer-events: none;
}
.compare-tag-left { left: 12px; }
.compare-tag-right { right: 12px; background: var(--where); }

.control-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.segmented { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.segmented button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  font: 500 0.9rem/1.2 var(--sans);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.segmented button:hover { border-color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.compare-note {
  margin: 0;
  padding: 14px 16px;
  border-left: 3px solid var(--where);
  background: #fff;
  border-radius: 0 10px 10px 0;
  color: var(--text);
  font-size: 0.95rem;
}

/* ---------- Analysis ---------- */
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: 1px;
}
.dot-where { background: var(--where); }
.dot-what { background: var(--what); }

/* ---------- BibTeX ---------- */
.bibtex { position: relative; }
.bibtex pre {
  margin: 0;
  padding: 22px 24px;
  border-radius: 12px;
  background: #151a2d;
  color: #e7eaf3;
  font: 0.86rem/1.7 var(--mono);
  overflow-x: auto;
}
.copy-btn {
  position: absolute;
  top: 12px; right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #e7eaf3;
  font: 500 0.82rem/1.2 var(--sans);
  cursor: pointer;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.16); }
.copy-btn svg { width: 15px; height: 15px; }

/* ---------- Earlier version & footer ---------- */
.resource-list { margin: 0; padding-left: 1.2em; }
.resource-list li { margin-bottom: 4px; }

.footer {
  padding: 28px 0 40px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}
.footer p { margin: 0; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .hero { padding: 40px 0 32px; }
  .section { padding: 52px 0; }
  .section-tight { padding: 28px 0 48px; }
  .figure-card { padding: 8px; border-radius: 12px; }
  .mixer { padding: 22px 18px 18px; }
  .authors { gap: 4px 16px; font-size: 1rem; }
  .affils { gap: 2px 14px; font-size: 0.9rem; }
  .tablist { display: flex; }
  .tablist [role="tab"] { flex: 1 1 auto; padding: 8px 10px; font-size: 0.86rem; }
  .results th,
  .results td { padding: 8px 9px; }
  .bibtex pre { padding: 52px 16px 18px; font-size: 0.78rem; }
}
