:root {
  --bg: #0a0a0f;
  --bg-raised: #101018;
  --surface: #16161f;
  --border: #1e1e2a;
  --border-light: #2a2a38;

  --fg: #e8e8ed;
  --fg-strong: #fafafb;
  --fg-body: #b0b0bc;
  --muted: #6e6e7a;

  --accent: #62d84e;
  --accent-soft: rgba(98, 216, 78, 0.08);

  --helps: #34d399;
  --neutral: #8b92a8;
  --hurts: #f87171;
  --link: #7be06a;

  --clr-chronos: #94a3b8;
  --clr-dc-noctx: #60a5fa;
  --clr-dc-ctx: #34d399;
  --clr-dc-shuffled: #f87171;

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --base-font: 15px;
}

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

html {
  font-size: var(--base-font);
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--fg);
  background: var(--bg);
  font-size: var(--base-font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--link); text-decoration: none; transition: color 0.2s; }
a:hover { color: #a8f09e; }


/* ── Sticky Top Nav ───────────────────────────────────── */

#topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 56px;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: background 0.3s;
}

.nav-logo {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--fg-strong);
  letter-spacing: -0.03em;
}
.nav-logo:hover { color: var(--fg-strong); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links a {
  font-size: 0.867rem;
  color: var(--muted);
  font-weight: 400;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--fg); }

.nav-cta {
  padding: 6px 16px;
  border: 1px solid var(--accent);
  border-radius: 100px;
  font-weight: 500;
  color: var(--accent) !important;
  transition: all 0.2s;
}
.nav-cta:hover {
  background: rgba(98, 216, 78, 0.1);
  border-color: var(--accent);
}


/* ── Hero ─────────────────────────────────────────────── */

#hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 90vh;
  padding: 160px 32px 120px;
  animation: fadeUp 0.8s ease both;
}

#hero h1 {
  font-family: var(--font-body);
  font-size: 5.5rem;
  font-weight: 700;
  color: var(--fg-strong);
  letter-spacing: -0.04em;
  line-height: 1;
}

.hero-tagline {
  margin-top: 20px;
  font-size: 1.33rem;
  color: var(--fg-body);
  font-weight: 300;
  letter-spacing: -0.01em;
}

.hero-authors {
  margin-top: 28px;
}

.author-list {
  font-size: 1rem;
  color: var(--fg-body);
  font-weight: 400;
  line-height: 1.6;
}

.author-affil {
  margin-top: 4px;
  font-size: 0.933rem;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.hero-links {
  display: flex;
  gap: 12px;
  margin-top: 36px;
  animation: fadeUp 0.6s ease 0.3s both;
}

.hero-links a {
  display: inline-flex;
  align-items: center;
  padding: 10px 24px;
  border-radius: 100px;
  font-size: 0.933rem;
  font-weight: 500;
  border: 1px solid var(--border-light);
  color: var(--fg-body);
  transition: all 0.25s;
}

.hero-links a:hover {
  border-color: rgba(255,255,255,0.15);
  color: var(--fg);
  background: rgba(255,255,255,0.03);
}

.hero-cta {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: var(--bg) !important;
  font-weight: 600;
}
.hero-cta:hover {
  background: #78e066 !important;
  border-color: #78e066 !important;
}


/* ── Content Sections ─────────────────────────────────── */

.content-section {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 100px 32px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.content-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.content-section h2 {
  font-family: var(--font-body);
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--fg-strong);
  letter-spacing: -0.03em;
  margin-bottom: 20px;
  line-height: 1.2;
}

.content-section p {
  font-size: 1.067rem;
  line-height: 1.8;
  color: var(--fg-body);
  max-width: 680px;
}

.results-subhead {
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.01em;
  margin: 48px 0 12px;
}

.results-subhead:first-of-type {
  margin-top: 0;
}

.references {
  margin-top: 32px;
  font-size: 0.786rem;
  line-height: 1.6;
  color: var(--muted);
  max-width: none;
}

.content-section p strong {
  color: var(--fg);
  font-weight: 600;
}

.content-section p a {
  color: var(--fg);
  border-bottom: 1px solid var(--border-light);
  transition: border-color 0.2s;
}
.content-section p a:hover {
  border-bottom-color: var(--fg);
}


/* ── Figures ──────────────────────────────────────────── */

.content-section figure {
  margin: 48px 0 0;
}

.fig-img {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2), 0 8px 32px rgba(0,0,0,0.2);
}

.fig-img img {
  display: block;
  width: 100%;
  height: auto;
  padding: 20px;
}

.content-section figcaption {
  margin-top: 14px;
  font-size: 0.867rem;
  line-height: 1.55;
  color: var(--muted);
}


/* ── Benchmark Table ─────────────────────────────────── */

.bench-table-wrap {
  margin: 48px 0 0;
  overflow-x: auto;
}

.bench-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.857rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.bench-table thead th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.786rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg);
  padding: 8px 10px;
  border-bottom: 2px solid var(--border-light);
  text-align: center;
}

.bench-table thead th:first-child {
  text-align: left;
}

.bench-table .sub-header th {
  font-weight: 500;
  font-size: 0.714rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 4px 10px;
}

.bench-table td {
  padding: 6px 10px;
  text-align: center;
  color: var(--fg-body);
  border-bottom: 1px solid var(--border);
}

.bench-table td:first-child {
  text-align: left;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--fg);
}

.bench-table td.na { color: var(--muted); }

.bench-table td.best {
  color: var(--accent);
  font-weight: 600;
}

.bench-table td.second {
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--fg);
}

.bench-table .sep-label td {
  font-family: var(--font-body);
  font-size: 0.714rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: left;
  padding: 16px 10px 6px;
  border-bottom: 1px solid var(--border);
}

.bench-table .highlight td {
  color: var(--fg-strong);
  font-weight: 600;
}

.bench-table .highlight td:first-child {
  color: var(--accent);
}

.bench-table .highlight td.best {
  color: var(--accent);
}

.bench-table .highlight td.second {
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--fg-strong);
}

.bench-table .ablation td {
  font-size: 0.786rem;
  color: var(--muted);
  border-bottom: none;
}

.bench-table .ablation td:first-child {
  font-weight: 400;
  color: var(--muted);
}

.fig-wide {
  max-width: none;
}

.figure-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 48px;
}

.figure-row figure {
  margin-top: 0;
}


/* ── Demo Section ─────────────────────────────────────── */

#demo-section {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: 100px 32px 80px;
}

.demo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
}

.demo-header h2 {
  font-family: var(--font-body);
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--fg-strong);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.demo-sub {
  margin-top: 6px;
  font-size: 1rem;
  color: var(--fg-body);
}

.demo-sub strong {
  color: var(--fg);
  font-weight: 600;
}

.font-size-ctl {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.font-size-ctl button {
  font-family: var(--font-body);
  font-size: 0.857rem;
  font-weight: 500;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.4;
}
.font-size-ctl button:hover {
  border-color: var(--border-light);
  color: var(--fg);
}
.font-size-ctl button.active {
  border-color: var(--fg);
  color: var(--fg);
}

#demo-app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 80vh;
  min-height: 500px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-raised);
}


/* ── Sidebar ──────────────────────────────────────────── */

#sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-raised);
  overflow-y: auto;
  padding: 16px;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.filters label {
  display: flex;
  flex-direction: column;
  font-size: 0.714rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  flex: 1;
  gap: 4px;
}

.filters select {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.929rem;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%236e6e7a' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.filters select:hover { border-color: var(--border-light); }
.filters select:focus { outline: none; border-color: var(--muted); }


/* ── Example List ─────────────────────────────────────── */

#example-list { list-style: none; }

#example-list li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  cursor: pointer;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  animation: slideIn 0.35s ease both;
}

#example-list li:hover {
  background: var(--surface);
  border-color: var(--border);
  border-left-color: var(--border-light);
}

#example-list li.active {
  background: var(--surface);
  border-color: var(--border-light);
  border-left-color: var(--accent);
}

.row-title {
  font-size: 0.929rem;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.3;
}

.row-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
  font-size: 0.786rem;
  color: var(--muted);
}

.ratio {
  font-family: var(--font-mono);
  font-size: 0.714rem;
  opacity: 0.7;
}

.tag {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.643rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.tag-context-helps { background: rgba(52, 211, 153, 0.1); color: var(--helps); }
.tag-neutral       { background: rgba(139, 146, 168, 0.1); color: var(--neutral); }
.tag-context-hurts { background: rgba(248, 113, 113, 0.1); color: var(--hurts); }


/* ── Detail Panel ─────────────────────────────────────── */

#detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 24px;
  overflow-y: auto;
  min-height: 0;
}


/* ── Context Card ─────────────────────────────────────── */

#context-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  max-height: 30vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.context-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.context-label {
  font-size: 0.714rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.context-title {
  font-family: var(--font-mono);
  font-size: 0.786rem;
  color: var(--muted);
}

#context-text {
  white-space: pre-wrap;
  font-size: 0.929rem;
  line-height: 1.65;
  color: var(--fg);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  transition: opacity 0.3s ease;
}

/* Context card states */
#context-card.ctx-none {
  border-left-color: var(--border-light);
  opacity: 0.5;
}
#context-card.ctx-none .context-label { color: var(--muted); }
#context-card.ctx-none #context-text { color: var(--muted); }

#context-card.ctx-irrelevant {
  border-left-color: var(--hurts);
}
.ctx-label-irrelevant { color: var(--hurts) !important; }
#context-card.ctx-irrelevant #context-text { color: var(--muted); }

#context-text::-webkit-scrollbar { width: 4px; }
#context-text::-webkit-scrollbar-track { background: transparent; }
#context-text::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }


/* ── Controls ─────────────────────────────────────────── */

#controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

#controls > label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.929rem;
  cursor: pointer;
  color: var(--fg);
  transition: opacity 0.2s;
  user-select: none;
}
#controls > label:hover { opacity: 0.7; }

#controls > label > input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-light);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

#controls > label > input[type="checkbox"]:checked {
  background: var(--fg);
  border-color: var(--fg);
}

#controls > label > input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4.5px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

#controls > label > input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

#controls .hint { color: var(--muted); font-size: 0.786rem; font-weight: 400; }

/* ── Context toggle switch ── */
.ctx-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
  transition: opacity 0.2s;
}
.ctx-switch.disabled { opacity: 0.3; pointer-events: none; }

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--border-light);
  border-radius: 10px;
  position: relative;
  transition: background 0.3s ease;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--fg);
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.toggle-state {
  font-size: 0.857rem;
  color: var(--fg);
  user-select: none;
  transition: color 0.2s;
}
.toggle-state.off { color: var(--muted); }

/* ── Shuffled option ── */
.shuffled-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.786rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s;
}
.shuffled-opt:hover { color: var(--fg); }
.shuffled-opt.disabled { opacity: 0.3; pointer-events: none; }

.shuffled-opt input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-light);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

.shuffled-opt input[type="checkbox"]:checked {
  background: var(--muted);
  border-color: var(--muted);
}

.shuffled-opt input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3.5px;
  top: 0.5px;
  width: 4px;
  height: 7px;
  border: solid var(--bg);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}


/* ── Plot ─────────────────────────────────────────────── */

#plot {
  min-height: 350px;
  flex-shrink: 0;
}


/* ── Metrics ──────────────────────────────────────────── */

#metrics {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  max-height: 220px;
  overflow-y: auto;
}

#metrics h3 {
  margin: 0 0 8px;
  font-size: 0.714rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
#metrics .hint { text-transform: none; letter-spacing: 0; font-weight: 400; }

#metrics table {
  width: 100%;
  max-width: 380px;
  border-collapse: collapse;
  font-size: 0.929rem;
}

#metrics td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
}

#metrics td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.857rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-strong);
}

#metrics .empty { color: var(--muted); font-size: 0.857rem; padding: 4px 0; }

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: -1px;
}

.ratio-note {
  margin-top: 10px;
  font-size: 0.857rem;
  color: var(--muted);
}
.ratio-note b {
  color: var(--fg-strong);
  font-family: var(--font-mono);
}


/* ── Animations ───────────────────────────────────────── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}


/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 900px) {
  #topnav { padding: 0 20px; }
  .nav-links { gap: 16px; }
  .nav-links a:not(.nav-cta) { display: none; }
  #hero { min-height: 70vh; padding: 120px 24px 80px; }
  #hero h1 { font-size: 3rem; }
  .hero-tagline { font-size: 1.1rem; }
  .content-section { padding: 60px 24px; }
  .content-section h2 { font-size: 1.6rem; }
  .figure-row { grid-template-columns: 1fr; }
  .fig-wide { margin-left: 0; margin-right: 0; }
  #demo-section { padding: 60px 16px 40px; }
  #demo-app {
    grid-template-columns: 1fr;
    height: auto;
  }
  #sidebar {
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  #context-card { max-height: none; }
  #detail { overflow: visible; }
}
