:root {
  --ink: #1c1915;
  --muted: #5c564e;
  --line: #e4ddd3;
  --paper: #f7f4ef;
  --card: #fffdf9;
  --hot: #c2410c;
  --hot-soft: #fff1e8;
  --blue: #1d4e89;
  --shadow: 0 18px 50px rgba(40, 28, 16, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 80% -10%, #ffe8d6 0%, transparent 55%),
    var(--paper);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.55;
}

a { color: var(--hot); }
img, video { max-width: 100%; display: block; }
button, select { font: inherit; }

.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }

header {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
  background: rgba(247, 244, 239, 0.9);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}
.brand { font-weight: 700; letter-spacing: 0.08em; text-decoration: none; color: var(--ink); }
.nav-links { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-links a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 15px;
}
.nav-links a.primary { background: var(--ink); color: white; border-color: var(--ink); }

.hero { padding: 48px 0 12px; }
h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 560;
  font-size: clamp(40px, 6vw, 68px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}
.lede { max-width: 740px; color: var(--muted); font-size: 20px; margin: 0 0 8px; }
.authors { color: var(--muted); font-size: 15px; }

h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 560;
  font-size: 34px;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
h3 { margin: 0 0 8px; font-size: 20px; }
.section { padding: 36px 0; }
.sub { color: var(--muted); margin: 0 0 18px; max-width: 760px; }

.stage {
  background: #16130f;
  color: #f6f1ea;
  border-radius: 22px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.stage-top, .controls, .readout, .stats {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.stage-top { justify-content: space-between; margin-bottom: 12px; }
.stage h2 { color: white; font-size: 28px; }
.controls button, .controls select, .task-tabs button {
  border: 1px solid #3a342c;
  background: #241f1a;
  color: #f6f1ea;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}
.controls button.active, .task-tabs button.active { background: var(--hot); border-color: var(--hot); color: white; }
.controls button:hover, .task-tabs button:hover { border-color: #8a8176; }

.failure-note { margin: 0 0 14px; color: #e7dfd6; font-size: 16px; max-width: 860px; }
.failure-note strong { color: white; }
.demo-layout { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 16px; align-items: start; }
#curves, #tsne { width: 100%; height: auto; background: transparent; display: block; }
#curves { aspect-ratio: 16 / 11; }
#tsne { aspect-ratio: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; list-style: none; margin: 8px 0 0; padding: 0; color: #e7dfd6; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 4px; border-radius: 99px; display: inline-block; }
.swatch.ours { background: #e4572e; }
.swatch.proxy { background: #4c9be8; }
.swatch.real { background: #6fbf73; }
.swatch.mi { background: #e3b341; }
.swatch.random { background: #b7aea4; }
.clip-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.clip-row figure { margin: 0; }
.clip-row img { width: 100%; border-radius: 10px; background: #111; aspect-ratio: 1242 / 375; object-fit: cover; }
.clip-row figcaption, .clip-row p { color: #d9cfc3; font-size: 14px; }
.clip-row p { margin: 0 0 6px; letter-spacing: 0.04em; text-transform: uppercase; color: #c8bfb4; }
.panel { min-width: 0; }
.panel p { margin: 0 0 6px; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; color: #c8bfb4; }
canvas { width: 100%; height: auto; border-radius: 12px; background: #111; }

.budget { margin-top: 14px; }
.budget-track { height: 10px; background: #3a342c; border-radius: 999px; overflow: hidden; }
.budget-fill { height: 100%; width: 0; background: #3b82c4; }
.budget span { display: block; margin-top: 6px; color: #c8bfb4; font-size: 14px; }

.readout { margin-top: 12px; color: #e7dfd6; font-size: 16px; }
.stats { margin-top: 8px; }
.stats div {
  background: #241f1a;
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 120px;
}
.stats b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stats span { color: #c8bfb4; font-size: 13px; }

.inspect {
  margin-top: 10px;
  min-height: 1.4em;
  color: #d9cfc3;
  font-size: 15px;
}

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.card, .figure, .table-wrap, .video-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card strong { color: var(--hot); }

.task-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.task-tabs button { background: var(--card); color: var(--ink); border-color: var(--line); }
.figure img { border-radius: 12px; background: white; }
.figure figcaption, .video-card figcaption { color: var(--muted); font-size: 15px; margin-top: 8px; }
.hidden { display: none; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; }
td.best { background: var(--hot-soft); font-weight: 700; }

.video-hero video { width: 100%; border-radius: 16px; background: #111; max-height: 640px; }
.video-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.video-card video, .video-card img { border-radius: 12px; background: #111; width: 100%; }
.missing {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--hot-soft);
  color: var(--ink);
}

footer { padding: 10px 0 40px; color: var(--muted); font-size: 14px; }

@media (max-width: 800px) {
  .demo-layout, .cards, .video-grid, .clip-row { grid-template-columns: 1fr; }
  .hero { padding-top: 28px; }
}
