/* =========================================================================
   Spectral GS-SLAM — academic project page.
   Standard scroll layout: centered hero, anchored sections, no chrome.
   Reuses the visual vocabulary (palette, typography, grain, cards, eqns,
   tables) of the personal site but drops its app-shell entirely.
   ========================================================================= */

:root {
  --bg-color: #0a0a0a;
  --bg-elev: #111111;
  --surface-color: #161616;
  --surface-hi: #1c1c1c;
  --accent-color: #ffffff;
  --accent-glow: oklch(0.78 0.12 230);
  --accent-soft: oklch(0.78 0.08 230 / 0.18);
  --text-main: #e6e6e6;
  --text-dim: #888888;
  --text-faint: #555;
  --border: rgba(255, 255, 255, 0.06);
  --border-hi: rgba(255, 255, 255, 0.12);
  --max-w: 960px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

::selection { background: var(--accent-soft); color: #fff; }

img, video, canvas, svg { max-width: 100%; height: auto; display: block; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-feature-settings: "ss01", "cv11";
  line-height: 1.5;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background ambient gradient orb (mouse reactive) */
#bg-orb {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, oklch(0.6 0.18 230 / 0.18), transparent 60%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
  transform: translate(-50%, -50%);
  will-change: transform;
}

/* Subtle grain overlay */
#grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Reading progress bar */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, transparent, var(--accent-glow), var(--accent-color));
  z-index: 5000;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Top fade veil: a soft gradient backdrop behind the floating nav so they
   stay legible over scrolling content without slapping a hard chrome bar on. */
#top-veil {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 110px;
  z-index: 40;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    oklch(0.16 0 0 / 0.78) 0%,
    oklch(0.13 0 0 / 0.55) 40%,
    oklch(0.10 0 0 / 0.25) 70%,
    transparent 100%
  );
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  /* Feather the blur edge so it doesn't make a hard horizontal seam. */
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 60%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 60%, transparent 100%);
}

/* ---------- Top corner watermark (replaces sidebar identity) ---------- */
.top-mark {
  position: fixed;
  top: 24px;
  left: 28px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.3s var(--ease);
}
.top-mark:hover { color: var(--accent-glow); }
.top-mark .glyph {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}
.top-mark .glyph svg { width: 22px; height: 22px; }
.top-mark .label .v { color: var(--text-main); }
.top-mark .label .slash { opacity: 0.4; margin: 0 2px; }
@media (max-width: 680px) {
  .top-mark { top: 18px; left: 18px; font-size: 0.66rem; }
  .top-mark .glyph { width: 18px; height: 18px; }
  .top-mark .glyph svg { width: 18px; height: 18px; }
}

/* Top-right meta corner */
.top-meta {
  position: fixed;
  top: 24px;
  right: 28px;
  z-index: 50;
  display: flex;
  gap: 18px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.top-meta a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.25s var(--ease);
  position: relative;
  padding: 4px 2px;
}
.top-meta a:hover { color: var(--accent-glow); }
.top-meta a.is-active {
  color: var(--accent-glow);
}
.top-meta a.is-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -4px;
  height: 1px;
  background: var(--accent-glow);
  box-shadow: 0 0 8px var(--accent-glow);
  border-radius: 1px;
  animation: nav-underline-in 0.35s var(--ease) backwards;
}
@keyframes nav-underline-in {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}
.top-meta .sep { color: var(--text-faint); opacity: 0.4; }
@media (max-width: 680px) { .top-meta { display: none; } }

/* ---------- Container ---------- */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
  position: relative;
  z-index: 1;
}
@media (max-width: 680px) {
  .container { padding: 0 20px; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: clamp(110px, 14vh, 160px) 0 56px;
  overflow: hidden;
}
.hero canvas#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 0;
  opacity: 0.85;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 100%);
}
.hero .container { position: relative; z-index: 2; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 22px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-hi);
  background: rgba(255, 255, 255, 0.02);
}
.eyebrow .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: oklch(0.75 0.18 145);
  box-shadow: 0 0 0 0 oklch(0.75 0.18 145 / 0.6);
  animation: pulse 2s var(--ease) infinite;
}
.eyebrow .accent { color: var(--accent-glow); }
.eyebrow .sep { opacity: 0.4; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 oklch(0.75 0.18 145 / 0.5); }
  70% { box-shadow: 0 0 0 8px oklch(0.75 0.18 145 / 0); }
  100% { box-shadow: 0 0 0 0 oklch(0.75 0.18 145 / 0); }
}

h1.paper-title {
  font-size: clamp(2.4rem, 6vw, 4rem);
  letter-spacing: -0.03em;
  line-height: 1.04;
  font-weight: 700;
  margin-bottom: 16px;
  max-width: 18ch;
}
h1.paper-title .accent {
  background: linear-gradient(90deg, var(--accent-glow), oklch(0.85 0.16 200));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.paper-subtitle {
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  color: var(--text-dim);
  font-weight: 400;
  letter-spacing: -0.005em;
  line-height: 1.5;
  margin-bottom: 30px;
  max-width: 56ch;
}

/* Author/affiliation lines */
.authors {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 8px;
  line-height: 1.6;
}
.authors .author { display: inline-flex; align-items: baseline; gap: 4px; }
.authors .author a {
  color: var(--text-main);
}
.authors .author sup {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--accent-glow);
  font-size: 0.7rem;
}
.affiliations {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-bottom: 30px;
}
.affiliations sup { color: var(--accent-glow); margin-right: 2px; }
.venue {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.25rem;
  color: var(--accent-glow);
  letter-spacing: 0.06em;
  margin-bottom: 28px;
}
.venue .accent { color: var(--accent-glow); }

/* Action button row */
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-hi);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: all 0.3s var(--ease);
}
.action-btn svg { width: 14px; height: 14px; stroke: currentColor; }
.action-btn:hover {
  border-color: oklch(0.78 0.12 230 / 0.55);
  background: oklch(0.78 0.12 230 / 0.10);
  color: var(--accent-glow);
  transform: translateY(-1px);
}
.action-btn.is-primary {
  background: oklch(0.78 0.14 230 / 0.18);
  border-color: oklch(0.78 0.14 230 / 0.55);
  color: var(--accent-glow);
}
.action-btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------- Section frame ---------- */
section.scroll-section {
  padding: 60px 0;
  position: relative;
  z-index: 1;
}
section.scroll-section + section.scroll-section {
  border-top: 1px solid var(--border);
}

.section-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-glow);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--accent-glow);
}
.section-eyebrow .num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text-faint);
  margin-left: auto;
  letter-spacing: 0.12em;
}

h2.section-title {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 14px;
  text-wrap: pretty;
  max-width: 22ch;
}
.section-lede {
  font-size: 1.02rem;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 62ch;
  margin-bottom: 28px;
}
.section-lede strong { color: var(--text-main); font-weight: 500; }

h3.sub-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 36px 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
h3.sub-title .step {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--accent-glow);
  background: oklch(0.78 0.14 230 / 0.16);
  border: 1px solid oklch(0.78 0.14 230 / 0.35);
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

p.body {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--text-dim);
  margin: 0 0 14px;
  max-width: 62ch;
}
p.body strong, p.body .em { color: var(--text-main); font-weight: 500; }
p.body .term {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86em;
  color: var(--accent-glow);
  padding: 1px 5px;
  border-radius: 3px;
  background: oklch(0.78 0.12 230 / 0.08);
  border: 1px solid oklch(0.78 0.12 230 / 0.18);
  letter-spacing: 0;
}

.k-callout {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86em;
  color: var(--accent-glow);
  background: oklch(0.78 0.12 230 / 0.08);
  border: 1px solid oklch(0.78 0.12 230 / 0.18);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ---------- TL;DR card ---------- */
.tldr {
  border: 1px solid oklch(0.78 0.12 230 / 0.25);
  background:
    linear-gradient(180deg, oklch(0.78 0.12 230 / 0.04), transparent),
    var(--surface-color);
  border-radius: 14px;
  padding: 24px 26px;
  margin: 36px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: start;
}
.tldr-mark {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-glow);
  padding: 6px 10px;
  border-radius: 6px;
  background: oklch(0.78 0.14 230 / 0.16);
  border: 1px solid oklch(0.78 0.14 230 / 0.35);
  white-space: nowrap;
}
.tldr p { font-size: 1rem; line-height: 1.65; color: var(--text-main); margin: 0; }
.tldr p + p { margin-top: 8px; color: var(--text-dim); font-size: 0.92rem; }
@media (max-width: 640px) {
  .tldr { grid-template-columns: 1fr; gap: 14px; padding: 18px; }
  .tldr-mark { justify-self: start; }
}

/* ---------- Teaser video ---------- */
.teaser-video {
  margin: 36px 0 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #050505;
  aspect-ratio: 16 / 9;
  position: relative;
}
.teaser-video video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.teaser-video .teaser-cap {
  position: absolute;
  bottom: 14px;
  left: 16px;
  right: 16px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.teaser-video .teaser-cap .teaser-view {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: oklch(0.78 0.14 230 / 0.18);
  color: var(--accent-glow);
  border: 1px solid oklch(0.78 0.14 230 / 0.35);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.teaser-video .teaser-cap .right { color: var(--accent-glow); }

/* ---------- Failure (problem) grid ---------- */
.failure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 8px 0 0;
}
.failure-card {
  background: var(--surface-color);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 22px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s, transform 0.3s var(--ease);
}
.failure-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%),
    oklch(0.78 0.12 230 / 0.06), transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}
.failure-card:hover { border-color: var(--border-hi); transform: translateY(-2px); }
.failure-card:hover::after { opacity: 1; }
.failure-card .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: oklch(0.72 0.18 30);
  margin-bottom: 12px;
}
.failure-card .tag::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: oklch(0.72 0.18 30);
  box-shadow: 0 0 8px oklch(0.72 0.18 30 / 0.6);
}
.failure-card h3 {
  font-size: 1.06rem;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.failure-card p {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-dim);
}
.failure-card .baseline {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.74rem;
  color: var(--text-faint);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.failure-card .baseline strong { color: oklch(0.72 0.18 30); font-weight: 500; }
@media (max-width: 640px) {
  .failure-grid { grid-template-columns: 1fr; }
}

/* ---------- Contributions ---------- */
.contrib-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.contrib-list li {
  background: var(--surface-color);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.contrib-list .num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.66rem;
  color: var(--accent-glow);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.contrib-list .body strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.contrib-list .body .note {
  font-size: 0.86rem;
  color: var(--text-dim);
  line-height: 1.55;
}
@media (max-width: 880px) { .contrib-list { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .contrib-list { grid-template-columns: 1fr; } }

/* ---------- Metric strip ---------- */
.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin: 0;
}
.stat-card {
  padding: 22px 20px 20px;
  background: var(--surface-color);
  position: relative;
  overflow: hidden;
  cursor: default;
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%),
    oklch(0.78 0.12 230 / 0.10), transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}
.stat-card:hover::after { opacity: 1; }
.stat-card .stat-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.stat-card .stat-value {
  font-size: clamp(1.5rem, 2.6vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1;
}
.stat-card .stat-value .unit {
  font-size: 0.72em;
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 4px;
  letter-spacing: -0.01em;
}
.stat-card .stat-sub {
  font-size: 0.74rem;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.4;
}
.stat-card.is-highlight .stat-value { color: var(--accent-glow); }
@media (max-width: 768px) { .metric-strip { grid-template-columns: repeat(2, 1fr); } }

/* ---------- System diagram ---------- */
.diagram {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent),
    var(--surface-color);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin: 8px 0 28px;
  position: relative;
  overflow: hidden;
}
.diagram::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000, transparent 90%);
}
.diagram-cap {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.68rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.diagram-cap .right { color: var(--accent-glow); }
.diagram-flow {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}
.flow-node {
  background: var(--bg-color);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  padding: 14px 14px 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.flow-node .label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.flow-node .title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}
.flow-node .desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.45;
}
.flow-node.is-input { border-style: dashed; }
.flow-node.is-accent {
  border-color: oklch(0.78 0.14 230 / 0.55);
  background:
    linear-gradient(180deg, oklch(0.78 0.12 230 / 0.06), transparent),
    var(--bg-color);
}
.flow-node.is-accent .title { color: var(--accent-glow); }
.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--accent-glow);
  font-size: 1.4rem;
  position: relative;
}
.flow-arrow::before {
  content: "";
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  opacity: 0.45;
}
.flow-arrow span {
  background: var(--surface-color);
  padding: 0 8px;
  position: relative;
}
.diagram-detail {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  position: relative;
}
.diagram-detail .sub-node {
  font-size: 0.78rem;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  color: var(--text-dim);
  line-height: 1.45;
}
.diagram-detail .sub-node strong {
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.66rem;
  color: var(--accent-glow);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: 500;
}
@media (max-width: 820px) {
  .diagram-flow { grid-template-columns: 1fr; gap: 8px; }
  .flow-arrow { transform: rotate(90deg); height: 20px; }
  .diagram-detail { grid-template-columns: 1fr; }
}

/* ---------- Equations ---------- */
.method-block { margin: 20px 0 32px; }
.eqn {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 14px 0;
  padding: 14px 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent),
    var(--surface-color);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.94rem;
  color: var(--text-main);
  overflow-x: auto;
  position: relative;
}
.eqn .formula { flex: 1; white-space: nowrap; font-feature-settings: "ss01"; }
.eqn .formula i { color: var(--accent-glow); font-style: normal; }
.eqn .formula .op { color: var(--text-dim); margin: 0 4px; }
.eqn .formula .sub { font-size: 0.7em; vertical-align: sub; color: var(--text-dim); }
.eqn .formula .sup { font-size: 0.7em; vertical-align: super; color: var(--text-dim); }
.eqn .num {
  color: var(--text-faint);
  font-size: 0.8rem;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}
.eqn::before {
  content: "";
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 2px;
  background: linear-gradient(180deg, var(--accent-glow), transparent);
  opacity: 0.5;
  border-radius: 1px;
}

/* ---------- Note callout ---------- */
.note-callout {
  border-left: 2px solid oklch(0.78 0.14 230 / 0.5);
  padding: 12px 18px;
  margin: 16px 0;
  background: linear-gradient(90deg, oklch(0.78 0.12 230 / 0.05), transparent);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 70ch;
}
.note-callout strong { color: var(--accent-glow); font-weight: 500; margin-right: 6px; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 14px 0 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-color);
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 560px;
}
.table-wrap th, .table-wrap td {
  padding: 11px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.table-wrap th {
  font-weight: 500;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.02);
}
.table-wrap th.group {
  border-bottom: 1px solid var(--border-hi);
  border-left: 1px solid var(--border);
  text-align: center;
  color: var(--accent-glow);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
}
.table-wrap th:first-child, .table-wrap td:first-child { text-align: left; }
/* The :first-child rule above also catches the first <th> in the SUB-HEADER row
   (the "near" cell under NO TEXTURE), which should stay right-aligned with the
   rest of the numeric headers. Higher-specificity override forces it back. */
.table-wrap thead tr + tr th:first-child { text-align: right; }
/* Second column carries a text label (Tracker / Metric) — keep it left-aligned
   in both the header (rowspan=2) and the data cell that follows .method. */
.table-wrap thead tr:first-child th:nth-child(2) { text-align: left; }
.table-wrap td.method + td { text-align: left; }
/* The stacked "%/tracked" header should center over its column. */
.table-wrap th.th-stack { text-align: center; }
.table-wrap td.method { color: var(--text-main); font-weight: 500; }
.table-wrap td.method .tag-rt,
.table-wrap td.method .tag-nrt {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
}
.table-wrap td.method .tag-rt {
  color: oklch(0.75 0.18 145);
  border: 1px solid oklch(0.75 0.18 145 / 0.35);
  background: oklch(0.75 0.18 145 / 0.08);
}
.table-wrap td.method .tag-nrt {
  color: var(--text-faint);
  border: 1px solid var(--border-hi);
}
.table-wrap tr.is-ours {
  background: linear-gradient(90deg, oklch(0.78 0.12 230 / 0.10), oklch(0.78 0.12 230 / 0.03));
}
.table-wrap tr.is-ours td {
  color: var(--text-main);
  border-bottom-color: oklch(0.78 0.14 230 / 0.25);
}
.table-wrap tr.is-ours td:first-child {
  color: var(--accent-glow);
  font-weight: 600;
}
.table-wrap td .best { color: var(--accent-glow); font-weight: 600; }
.table-wrap td .second { color: var(--text-main); border-bottom: 1px solid var(--border-hi); }
.table-wrap td .fail { color: oklch(0.72 0.18 30); font-family: 'JetBrains Mono', ui-monospace, monospace; }
.table-wrap caption {
  text-align: left;
  caption-side: top;
  padding: 12px 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.table-wrap caption .cap-title { color: var(--text-dim); }
.table-wrap caption .cap-tag { color: var(--accent-glow); font-size: 0.66rem; letter-spacing: 0.16em; }
.table-legend {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 14px 4px 24px;
}
.table-legend .swatch { display: inline-flex; align-items: center; gap: 6px; }
.table-legend .dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.table-legend .dot.best { background: var(--accent-glow); }
.table-legend .dot.second { background: var(--text-dim); }
.table-legend .dot.fail { background: oklch(0.72 0.18 30); }
.table-block { margin: 24px 0 8px; }
.table-block + .table-block { margin-top: 36px; }
/* Wide-block: lets a single table-block escape the 960px container and use the
   full viewport so a dense column layout doesn't horizontally scroll. The
   negative-margin trick keeps the rest of the section centered. */
.table-block.is-wide {
  width: min(1280px, calc(100vw - 48px));
  margin-left: calc(50% - min(640px, 50vw - 24px));
  position: relative;
}
.table-block.is-wide .table-wrap { overflow-x: visible; }
.table-block.is-wide .table-wrap table { min-width: 0; }
.table-block.is-wide .table-wrap th,
.table-block.is-wide .table-wrap td { padding: 9px 6px; }
.table-block.is-wide .table-wrap th.th-stack {
  line-height: 1.15;
  white-space: normal;
  min-width: 48px;
}
/* Drop a touch of letter-spacing on the group headers so "NO STRUCTURE" doesn't
   bully the columns under it into being wider than the ones under "NO TEXTURE". */
.table-block.is-wide .table-wrap th.group {
  letter-spacing: 0.08em;
  padding-left: 6px;
  padding-right: 6px;
}
/* Stop the Method column from claiming extra slack. width:1% + nowrap is the
   classic trick to make a column shrink to its content under auto layout. */
.table-block.is-wide .table-wrap th:first-child,
.table-block.is-wide .table-wrap td:first-child {
  width: 1%;
  white-space: nowrap;
  padding-left: 14px;
  padding-right: 14px;
}
.table-block.is-wide .table-wrap th:nth-child(2),
.table-block.is-wide .table-wrap td:nth-child(2) {
  width: 1%;
  white-space: nowrap;
  padding-right: 12px;
}
/* Constrain % tracked and FPS columns too so the freed slack doesn't pool there. */
.table-block.is-wide .table-wrap th:nth-child(3),
.table-block.is-wide .table-wrap td:nth-child(3) { width: 72px; min-width: 56px; }
.table-block.is-wide .table-wrap th:last-child,
.table-block.is-wide .table-wrap td:last-child { width: 56px; min-width: 48px; padding-right: 8px; }
/* Force the 8 numeric data columns (cols 4–11) to share equal widths so the
   No Texture and No Structure groups look symmetric. */
.table-block.is-wide .table-wrap tbody td:nth-child(n+4):nth-child(-n+11),
.table-block.is-wide .table-wrap thead tr:nth-child(2) th {
  width: 72px;
  min-width: 56px;
}
@media (max-width: 1000px) {
  /* On narrower screens, fall back to the normal scroll behaviour so the cells
     don't crush below readability. */
  .table-block.is-wide { width: 100%; margin-left: 0; }
  .table-block.is-wide .table-wrap { overflow-x: auto; }
  .table-block.is-wide .table-wrap table { min-width: 720px; }
}
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  flex-wrap: wrap;
}
.table-head .cap-title { color: var(--text-dim); }
.table-head .cap-tag {
  color: var(--accent-glow);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
}

/* ---------- Gallery ---------- */
.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin: 8px 0 0;
}
.video-card {
  background: var(--surface-color);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  transition: border-color 0.3s, transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.video-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%),
    oklch(0.78 0.12 230 / 0.08), transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  border-radius: inherit;
}
.video-card:hover { border-color: var(--border-hi); }
.video-card:hover::after { opacity: 1; }
.video-card .video-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  flex-wrap: wrap;
}
.video-card .video-head-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.video-card h3 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.video-card .scene-tag {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.video-card .scene-tag.is-degen {
  color: oklch(0.78 0.14 50);
  border-color: oklch(0.78 0.14 50 / 0.4);
  background: oklch(0.78 0.14 50 / 0.06);
}
.video-card .scene-desc {
  font-size: 0.86rem;
  color: var(--text-dim);
  padding: 0 20px 14px;
  line-height: 1.55;
  max-width: 76ch;
}
.video-stage {
  position: relative;
  background: #050505;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
/* Quad-panel captures are 4:3 — show them whole rather than cropping. */
.video-stage.is-quad { aspect-ratio: 4 / 3; }
.video-stage video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.video-stage.is-quad video { object-fit: contain; }
.video-stage video.is-active { opacity: 1; }

/* ---------- BibTeX ---------- */
.bibtex-block {
  position: relative;
  background: var(--surface-color);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--text-main);
  margin: 14px 0 24px;
  overflow-x: auto;
}
.bibtex-block pre { margin: 0; white-space: pre; color: var(--text-main); }
.bibtex-block .k { color: var(--accent-glow); }
.bibtex-block .v { color: var(--text-main); }
.bibtex-block .dim { color: var(--text-dim); }
.bibtex-block .tt { color: oklch(0.78 0.14 70); }
.copy-btn {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--bg-color);
  color: var(--text-dim);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s var(--ease);
}
.copy-btn:hover {
  color: var(--accent-glow);
  border-color: oklch(0.78 0.12 230 / 0.5);
  background: oklch(0.78 0.12 230 / 0.08);
}
.copy-btn.is-copied {
  color: oklch(0.78 0.16 145);
  border-color: oklch(0.78 0.16 145 / 0.5);
  background: oklch(0.78 0.16 145 / 0.08);
}

/* ---------- Acknowledgements + footer ---------- */
.ack-text {
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 70ch;
}
.ack-text a {
  color: var(--accent-glow);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  transition: border-color 0.2s;
}
.ack-text a:hover { border-color: var(--accent-glow); }

footer.site-footer {
  margin-top: 24px;
  padding: 36px 0 48px;
  border-top: 1px solid var(--border);
  text-align: center;
  position: relative;
  z-index: 1;
}
footer.site-footer p {
  color: var(--text-dim);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
footer.site-footer .divider {
  width: 40px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  margin: 14px auto 0;
}

/* ---------- Reveal-on-scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.reveal.in { opacity: 1; transform: translateY(0); }

/* ---------- prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  #bg-orb, #grain { display: none; }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .hero { padding-top: clamp(90px, 12vh, 130px); padding-bottom: 40px; }
  section.scroll-section { padding: 44px 0; }
  .tldr { padding: 18px; }
  .table-wrap caption { font-size: 0.62rem; padding: 10px 12px; }
  .eqn { font-size: 0.82rem; padding: 12px 14px; }
  .failure-grid { gap: 12px; }
  .video-card .scene-desc { padding: 0 16px 12px; }
  .video-card .video-head { padding: 14px 16px 10px; }
}
