:root {
  --bg: #f3efe6;
  --bg-deep: #ebe4d6;
  --paper: #fffcf6;
  --ink: #1c1915;
  --ink-soft: #3f3a33;
  --muted: #6f675c;
  --line: #ddd4c4;
  --line-strong: #cfc4b0;
  --accent: #1e3d59;
  --accent-soft: #e7eef4;
  --gold: #8a6a2f;
  --gt: #1b7a4a;
  --gt-bg: rgba(27, 122, 74, 0.14);
  --playhead: #c23b2e;
  --ok: #1b7a4a;
  --ok-bg: #e8f5ee;
  --warn: #9a6b12;
  --warn-bg: #f7efd8;
  --fail: #b42318;
  --fail-bg: #f8e8e6;
  --halluc: #6b4ea0;
  --halluc-bg: #efe8f7;
  --fam-physical: #1e3d59;
  --fam-func: #6d4c2b;
  --fam-assoc: #3d5a45;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 420px at 50% -80px, rgba(30, 61, 89, 0.06), transparent 70%),
    var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  z-index: 100;
}
.skip-link:focus { left: 12px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 28px; }

/* ── Top bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 252, 246, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--accent);
  padding: 3px 6px 2px;
  border-radius: 3px;
}

.brand-name {
  font-family: var(--serif);
  font-weight: 650;
  font-size: 15px;
}

.brand-sep, .brand-sub {
  color: var(--muted);
  font-size: 13px;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  justify-content: flex-end;
}

.top-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px;
  font-weight: 550;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}

.top-nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.top-nav .nav-code {
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
}
.top-nav .nav-code:hover { color: #fff; opacity: 0.92; border-bottom: none; }

/* ── Title block ── */
.site-header {
  padding: 40px 0 8px;
}

.kicker {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
  margin-bottom: 12px;
}

.site-header h1 {
  font-family: var(--serif);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 650;
  line-height: 1.32;
  text-align: center;
  letter-spacing: -0.015em;
  color: var(--ink);
  max-width: 920px;
  margin: 0 auto 22px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 760px;
  margin: 0 auto 26px;
}

.metric {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 8px 10px;
  text-align: center;
}

.metric-val {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 650;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.metric-lab {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.abstract-wrapper { max-width: 860px; margin: 0 auto; }

.abstract-details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(28, 25, 21, 0.03);
}

.abstract-toggle {
  cursor: pointer;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
  list-style: none;
}

.abstract-toggle::-webkit-details-marker { display: none; }
.abstract-toggle::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 8px;
  border-left: 5px solid var(--gold);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: translateY(-1px);
}
.abstract-details[open] .abstract-toggle::before {
  transform: rotate(90deg) translateY(-1px);
}

.abstract {
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.78;
  color: var(--ink-soft);
  padding: 0 22px 20px;
  text-align: justify;
}

/* ── Figure / taxonomy ── */
.model-section, .taxonomy-section { padding: 28px 0 0; }

.model-fig, .taxonomy-fig {
  max-width: 920px;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 22px 18px;
}

.fig-caption {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 16px;
  line-height: 1.45;
}

.fig-id {
  display: inline-block;
  margin-right: 8px;
  color: var(--gold);
  font-weight: 700;
}

.model-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 6px;
  background: #fff;
}

.taxonomy-scroll { overflow-x: auto; }

.taxonomy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.taxonomy-table th,
.taxonomy-table td {
  padding: 8px 10px;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.taxonomy-table thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line-strong);
}

.taxonomy-table .col-family { width: 18%; }
.taxonomy-table .col-canonical {
  width: 22%;
  white-space: nowrap;
  font-weight: 650;
  color: var(--ink);
}
.taxonomy-table .col-source { width: 60%; color: var(--ink-soft); }

.taxonomy-table td.family-cell {
  font-weight: 700;
  font-size: 12.5px;
  line-height: 1.35;
  vertical-align: middle;
  border-right: 1px solid var(--line);
  background: #f7f3ea;
}

.fam-physical td.family-cell { color: var(--fam-physical); box-shadow: inset 3px 0 0 var(--fam-physical); }
.fam-func td.family-cell { color: var(--fam-func); box-shadow: inset 3px 0 0 var(--fam-func); }
.fam-assoc td.family-cell { color: var(--fam-assoc); box-shadow: inset 3px 0 0 var(--fam-assoc); }

.taxonomy-table tr.family-sep td { border-top: 1px solid var(--line-strong); }
.taxonomy-table tbody tr:last-child td { border-bottom: none; }

.ds {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 2px;
}

.orig {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
}

.added {
  font-style: italic;
  color: var(--gold);
}

.code-bar {
  text-align: center;
  padding: 28px 0 8px;
}

.code-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--accent);
  background: var(--paper);
  border: 1px solid var(--accent);
  border-radius: 999px;
  text-decoration: none;
}
.code-btn:hover { background: var(--accent); color: #fff; }

/* ── Demo heading ── */
.demo-heading {
  max-width: 1180px;
  margin: 28px auto 16px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.demo-heading .kicker { text-align: left; margin-bottom: 6px; }

.demo-heading h2 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 8px;
}

.demo-heading .demo-sub {
  max-width: 760px;
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: 228px 1fr;
  gap: 22px;
  align-items: start;
  padding-bottom: 56px;
}

.sidebar {
  position: sticky;
  top: 68px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.sidebar-head {
  padding: 10px 14px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid rgba(221, 212, 196, 0.7);
  color: var(--ink-soft);
}

.nav-num {
  flex: 0 0 1.6em;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.nav-item:hover { background: #f7f3ea; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-item.active .nav-num { color: var(--accent); }

.main { min-width: 0; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 14px;
}

.card h2 {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 650;
  margin-bottom: 12px;
}

.case-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.case-index {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.case-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 650;
  margin-bottom: 12px;
}

.asr {
  font-size: 15px;
  line-height: 1.75;
  padding: 14px 16px;
  background: #f7f3ea;
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  color: var(--ink-soft);
}

.asr .hl {
  color: var(--gt);
  font-weight: 700;
  background: var(--gt-bg);
  padding: 0 4px;
  border-radius: 3px;
}

.wave-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}

.gt-lane {
  position: relative;
  min-height: 38px;
  padding: 6px 0;
  border-radius: 8px 8px 0 0;
  background: #f4faf6;
  border: 1px solid var(--line);
  border-bottom: none;
  overflow: hidden;
}

.gt-band {
  position: absolute;
  top: 7px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  padding: 0 10px;
  pointer-events: none;
  background: var(--gt-bg);
  border: 1.5px solid var(--gt);
  color: var(--gt);
  transform: translateX(-50%);
}

.wave-stack { position: relative; }

.wave-wrap .gt-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.gt-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--gt);
  opacity: 0.9;
}
.gt-marker.end { opacity: 0.65; }

.wave-wrap {
  position: relative;
  border: 1px solid #1c1915;
  border-radius: 0 0 8px 8px;
  background: #161310;
  overflow: hidden;
  cursor: pointer;
}

.wave-canvas { display: block; width: 100%; height: 110px; }

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--playhead);
  pointer-events: none;
  z-index: 5;
  left: 0;
}
.playhead::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -4px;
  border: 5px solid transparent;
  border-top-color: var(--playhead);
}

.time-ruler {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}

.time-now {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

audio {
  width: 100%;
  margin-top: 12px;
  height: 36px;
}

.cmp-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.cmp-table th,
.cmp-table td {
  padding: 10px 12px;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.cmp-table th {
  background: var(--bg-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.cmp-table tbody tr:last-child td { border-bottom: none; }
.cmp-table tr.gt-row { background: #f7f3ea; }
.cmp-table tr.nv-row { background: var(--accent-soft); }
.cmp-table tr.nv-row td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.ev-pair { min-height: 22px; margin: 4px 0; }
.ev, .reason {
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.reason.ok, .reason.warn, .reason.bad, .reason.na, .reason.halluc, .reason.gt-dash {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.ev.gt-black { color: var(--ink); }
.reason.gt-dash { color: var(--muted); background: #efe9dc; }
.ev.ok, .reason.ok { color: var(--ok); }
.reason.ok { background: var(--ok-bg); }
.ev.warn, .reason.warn { color: var(--warn); }
.reason.warn { background: var(--warn-bg); }
.ev.bad, .reason.bad { color: var(--fail); }
.reason.bad { background: var(--fail-bg); }
.ev.na, .reason.na { color: var(--muted); font-style: italic; background: #f0ece3; }
.ev.halluc, .reason.halluc { color: var(--halluc); font-style: italic; }
.reason.halluc { background: var(--halluc-bg); }

.col-target, .col-pred { min-width: 180px; }
.loading { color: var(--muted); padding: 48px; text-align: center; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 32px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .topbar-inner { flex-direction: column; align-items: flex-start; padding: 10px 28px; }
  .site-header h1 { font-size: 20px; }
  .brand-sub, .brand-sep { display: none; }
}
