/* ============================================================
   OR-Bench dashboard styles
   ============================================================ */

:root {
  --bg: #f7f7f5;
  --bg-elev: #ffffff;
  --bg-soft: #f1f1ee;
  --bg-side: #fbfaf7;
  --ink: #1a1a1a;
  --ink-soft: #4d4d4d;
  --ink-mute: #8a8a85;
  --line: #e3e3dc;
  --line-soft: #ececdf;
  --accent: #8a2030;
  --accent-soft: #c44f5d;
  --accent-tint: #f4e3e6;
  --good: #1f8a4d;
  --warn: #b6772a;
  --bad: #c63b3b;
  --info: #2a5fb3;
  --code-bg: #fdfaf3;
  --shadow-1: 0 1px 2px rgba(20,20,20,0.04), 0 1px 3px rgba(20,20,20,0.06);
  --shadow-2: 0 8px 32px rgba(20,20,20,0.08);
  --r-1: 6px;
  --r-2: 10px;
  --r-3: 14px;
  --font-serif: "Source Serif Pro", "Georgia", "Cambria", "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Menlo", "Consolas", monospace;
}

[data-theme="dark"] {
  --bg: #15161a;
  --bg-elev: #1d1f24;
  --bg-soft: #23252b;
  --bg-side: #1a1c20;
  --ink: #ececec;
  --ink-soft: #c8c8c8;
  --ink-mute: #898a90;
  --line: #2f3239;
  --line-soft: #2a2c33;
  --accent: #e07b89;
  --accent-soft: #e8a3ad;
  --accent-tint: #382227;
  --good: #4ec77d;
  --warn: #e7b15e;
  --bad: #ec6f6f;
  --info: #6e9eff;
  --code-bg: #1b1d22;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.35);
  --shadow-2: 0 8px 32px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { line-height: 1.55; font-size: 15px; }

h1, h2, h3, h4 { font-family: var(--font-serif); color: var(--ink); margin: 0; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 18px; font-weight: 600; }
h4 { font-size: 16px; font-weight: 600; }

p { margin: 0 0 12px; color: var(--ink-soft); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================== TOP BAR ============================== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  height: 60px;
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-soft) 100%);
  color: white;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-weight: 700;
  border-radius: 8px;
  font-size: 14px;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-1);
}

.brand-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.1;
}
.brand-sub {
  color: var(--ink-mute);
  font-size: 12px;
}

.topnav { display: flex; align-items: center; gap: 18px; }
.topnav-meta { color: var(--ink-mute); font-size: 13px; }

.theme-btn {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 8px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.theme-btn:hover { background: var(--accent-tint); color: var(--accent); }

/* ============================== LAYOUT ============================== */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 60px);
}

/* ============================== SIDEBAR ============================== */
.sidebar {
  background:
    linear-gradient(180deg, var(--bg-side) 0%, var(--bg-side) 80%, transparent 100%),
    radial-gradient(ellipse at top right, var(--accent-tint) 0%, transparent 30%),
    var(--bg-side);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
[data-theme="dark"] .sidebar {
  background:
    linear-gradient(180deg, var(--bg-side) 0%, var(--bg-side) 80%, transparent 100%),
    radial-gradient(ellipse at top right, rgba(224, 123, 137, 0.06) 0%, transparent 30%),
    var(--bg-side);
}

.side-nav { padding: 4px 0; }

.side-list { list-style: none; padding: 0; margin: 0; }

/* Group label — non-interactive section divider */
.side-group {
  display: block;
  padding: 18px 12px 6px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-mute);
  cursor: default;
  pointer-events: none;
  position: relative;
  white-space: nowrap;
}
.side-group::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 6px;
  border-top: 1px solid var(--line-soft);
}
.side-list > li.side-group:first-child::before { display: none; }
.side-list > li.side-group:first-child { padding-top: 4px; }

/* Item row */
.side-list > li {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-1);
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13.5px;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    padding-left 0.18s ease;
  margin-bottom: 1px;
  position: relative;
  user-select: none;
}
.side-list > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
  transition: background 0.18s ease, top 0.18s ease, bottom 0.18s ease;
}
.side-list > li:hover {
  background: var(--bg-soft);
  color: var(--ink);
  padding-left: 14px;
}
.side-list > li:hover .side-icon { color: var(--accent); }

.side-list > li.active {
  background: linear-gradient(90deg, var(--accent-tint) 0%, transparent 100%);
  color: var(--accent);
  font-weight: 600;
}
.side-list > li.active::before {
  background: var(--accent);
  top: 10%;
  bottom: 10%;
}
.side-list > li.active .side-icon { color: var(--accent); }

.side-icon {
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease;
}
.side-icon svg { display: block; }

.side-label {
  line-height: 1.25;
  letter-spacing: -0.003em;
}

.side-filter { margin-bottom: 14px; }
.filter-label {
  display: block;
  font-size: 12px;
  color: var(--ink-mute);
  margin-bottom: 6px;
  font-weight: 500;
}
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); color: white; border-color: var(--accent); }

.meta-list { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
.meta-list li {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line-soft);
}
.meta-list li:last-child { border-bottom: none; }
.meta-k { color: var(--ink-mute); }
.meta-v { color: var(--ink); font-family: var(--font-mono); font-size: 11.5px; text-align: right; }

.side-foot { padding-bottom: 24px; }

/* ============================== MAIN CONTENT ============================== */
.content {
  padding: 28px 36px 48px;
  max-width: 1400px;
}

.panel { display: none; animation: fadeIn 0.25s ease; }
.panel.active { display: block; }

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

.panel-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 30px;
  margin-bottom: 24px;
}
.kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.lead {
  font-size: 16px;
  color: var(--ink-soft);
  max-width: 850px;
  line-height: 1.6;
  margin-top: 10px;
}

.hero-badges { display: flex; gap: 12px; flex-shrink: 0; }
.badge {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 12px 16px;
  text-align: center;
  min-width: 80px;
  box-shadow: var(--shadow-1);
}
.badge-n {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
}
.badge-l {
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ============================== CARDS / GRIDS ============================== */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-1);
}

.card-head { margin-bottom: 16px; }
.card-head h3 { margin-bottom: 4px; }
.card-sub { color: var(--ink-mute); font-size: 13.5px; margin: 0; }

.grid { display: grid; gap: 22px; margin-bottom: 22px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.two-7-5 { grid-template-columns: 7fr 5fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 1100px) {
  .grid.two, .grid.two-7-5, .grid.three { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 230px 1fr; }
  .content { padding: 22px 24px 40px; }
}

/* ============================== OVERVIEW BLOCKS ============================== */
.bullet { list-style: none; padding: 0; margin: 0; }
.bullet li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 14px;
}
.bullet li::before {
  content: "▸";
  position: absolute;
  left: 4px; top: 0;
  color: var(--accent);
}

.model-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .model-cards { grid-template-columns: 1fr; } }
.model-card {
  display: grid; grid-template-columns: 130px 1fr;
  gap: 14px; align-items: center;
  padding: 12px;
  background: var(--bg-soft);
  border-radius: var(--r-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all 0.15s ease;
}
.model-card:hover { border-color: var(--accent); background: var(--accent-tint); }
.model-svg svg { width: 100%; height: 100px; color: var(--ink-soft); }
.model-svg .schema-q { fill: var(--bg-elev); stroke: var(--ink-soft); }
.model-svg .schema-s { fill: var(--accent-tint); stroke: var(--accent); }
.model-svg .schema-t { fill: var(--ink); font-size: 10px; font-family: var(--font-sans); }
.model-svg .schema-l { fill: var(--accent); font-size: 11px; font-family: var(--font-serif); font-style: italic; }
.model-meta h4 { margin-bottom: 4px; }
.model-meta p { font-size: 13px; margin: 0; }

.exp-grid { gap: 14px; }
.exp-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 18px;
  cursor: pointer;
  transition: all 0.18s ease;
  color: inherit;
  display: block;
  text-decoration: none;
  position: relative;
}
.exp-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  text-decoration: none;
}
.exp-card.hidden { display: none; }
.exp-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 3px 7px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 10px;
}
.exp-card h4 { margin-bottom: 6px; }
.exp-card p { font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.exp-foot { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-mute); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-good { background: var(--good); }
.dot-warn { background: var(--warn); }
.dot-bad  { background: var(--bad); }

/* ============================== SEGMENTED CONTROLS ============================== */
.seg {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 4px;
  gap: 3px;
  flex-wrap: wrap;
}
.seg-btn {
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}
.seg-btn:hover { background: var(--bg-elev); color: var(--ink); }
.seg-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 6px rgba(138, 32, 48, 0.25);
  font-weight: 600;
}
[data-theme="dark"] .seg-btn.active { box-shadow: 0 2px 8px rgba(224, 123, 137, 0.3); color: #1d1f24; }

/* Larger / louder segmented control, used on the regime picker */
.seg-lg {
  display: flex;
  width: 100%;
  padding: 6px;
  gap: 4px;
  margin-top: 8px;
}
.seg-lg .seg-btn {
  font-size: 15px;
  font-weight: 600;
  padding: 14px 22px;
  letter-spacing: -0.005em;
  flex: 1;
  text-align: center;
}
.seg-lg .seg-btn.active { transform: translateY(-1px); }

.seg-mini { margin-bottom: 12px; }
.seg-mini .seg-btn { font-size: 12px; padding: 5px 10px; }

/* Inline seg control sitting inside a diagram-head */
.diagram-head-seg {
  margin: 0;
  flex-shrink: 0;
  padding: 3px;
  gap: 2px;
}
.diagram-head-seg .seg-btn {
  font-size: 11px;
  padding: 4px 9px;
}

/* ============================== REGIME PANELS ============================== */
.regime-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
  margin-top: 16px;
}
@media (max-width: 1100px) {
  .regime-grid { grid-template-columns: 1fr; }
}
.regime-lead {
  font-size: 14.5px;
  color: var(--ink);
  margin-bottom: 14px;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

/* Per-regime section heading shown inside each panel */
.regime-h {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.regime-h-sub {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Polished regime-panel layout (matches the Setup card) */
.regime-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 4px 0 14px;
  line-height: 1.2;
  color: var(--ink);
}
.regime-prose {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 0 0 16px;
}
.regime-prose strong, .regime-prose em { color: var(--ink); }

.regime-result {
  margin-top: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  box-shadow: 0 4px 16px rgba(138, 32, 48, 0.08);
  padding: 12px 16px;
  border-radius: var(--r-2);
}
[data-theme="dark"] .regime-result { background: rgba(56, 34, 39, 0.5); }
.regime-result-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.regime-result p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-style: italic;
  color: var(--ink);
  line-height: 1.45;
}
.regime-result strong { color: var(--accent); font-style: normal; }

/* "Good" variant for the classical sanity-check */
.regime-result-good { border-color: var(--good); box-shadow: 0 4px 16px rgba(31, 138, 77, 0.10); }
.regime-result-good .regime-result-label { color: var(--good); }
.regime-result-good strong { color: var(--good); }
.eyebrow-good { color: var(--good); }
.eyebrow-good .eyebrow-dot { background: var(--good); box-shadow: 0 0 0 4px rgba(31, 138, 77, 0.18); }

/* Optional parameter pill placed inside the eyebrow line */
.eyebrow-param {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  background: var(--accent-tint);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

/* ----- Right column variants ----- */

/* Hero stat block for the classical sanity-check */
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.stat-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(31, 138, 77, 0.12) 0%, transparent 70%);
  border-bottom: 1px solid var(--line-soft);
}
.stat-tick {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--good);
  color: white;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(31, 138, 77, 0.3);
}
.stat-card-body {
  padding: 22px 18px 18px;
  text-align: center;
}
.stat-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 14px;
}
.stat-cell {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.stat-value {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 600;
  color: var(--good);
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-value.stat-mute { color: var(--ink); }
.stat-sep {
  font-family: var(--font-serif);
  font-size: 28px;
  color: var(--ink-mute);
  font-weight: 400;
}
.stat-foot {
  font-size: 11.5px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
}

/* Polished policy-heatmap card (slowdown regimes) */
.pol-card { background: var(--bg-elev); }
.pol-card .diagram-body-img {
  display: flex;
  justify-content: center;
  background: var(--bg-elev);
}
.pol-card .diagram-body-img img {
  max-width: 360px;
  width: 100%;
  height: auto;
}
.pol-card .diagram-head {
  background: linear-gradient(90deg, var(--accent-tint) 0%, transparent 70%);
}
.pol-card-alt .diagram-head {
  background: linear-gradient(90deg, rgba(42, 95, 179, 0.10) 0%, transparent 70%);
}
[data-theme="dark"] .pol-card-alt .diagram-head {
  background: linear-gradient(90deg, rgba(110, 158, 255, 0.16) 0%, transparent 70%);
}
.pol-card-good .diagram-head {
  background: linear-gradient(90deg, rgba(31, 138, 77, 0.12) 0%, transparent 70%);
}
[data-theme="dark"] .pol-card-good .diagram-head {
  background: linear-gradient(90deg, rgba(78, 199, 125, 0.16) 0%, transparent 70%);
}

.diagram-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--accent);
  color: white;
  padding: 3px 9px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(138, 32, 48, 0.25);
}
.pol-card-alt .diagram-pill { background: var(--info); box-shadow: 0 2px 6px rgba(42, 95, 179, 0.25); }
.diagram-pill-good { background: var(--good) !important; box-shadow: 0 2px 6px rgba(31, 138, 77, 0.25) !important; }

.diagram-body-img { padding: 0; background: var(--bg-elev); }
.diagram-body-img img {
  width: 100%;
  display: block;
  background: white;
  padding: 8px;
}
[data-theme="dark"] .diagram-body-img img { background: #f5f5f5; }

.diagram-cap {
  padding: 10px 14px 12px;
  font-size: 12.5px;
  color: var(--ink-mute);
  background: var(--bg-elev);
  border-top: 1px solid var(--line-soft);
  line-height: 1.45;
}

/* When the diagram-card is also .zoom-fig, push the ⤢ icon below the head bar */
.diagram-card.zoom-fig::after { top: 14px; }
.diagram-card.zoom-fig { background: var(--bg-elev); }
.diagram-card.zoom-fig:hover { transform: translateY(-2px); }

/* "Question." pull-quote inside a regime panel */
.regime-q {
  font-size: 14.5px;
  color: var(--ink);
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 var(--r-1) var(--r-1) 0;
  margin: 14px 0;
}
.regime-q strong { color: var(--accent); }

/* Inline learned-policy figure inside a regime's text column */
.regime-pol {
  margin-top: 18px;
  max-width: 100%;
}
.regime-pol img { max-height: 280px; object-fit: contain; }

/* In-schematic caption strip */
.schema-cap {
  fill: var(--ink-mute);
  font-size: 11px;
  font-family: var(--font-sans);
  font-style: italic;
}

/* "Hot" queue box (highlighted when its threshold is in play) */
.schema-q-hot {
  fill: var(--accent-tint) !important;
  stroke: var(--accent) !important;
}

/* ============================== TABLES ============================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  font-size: 13.5px;
  margin-top: 12px;
}
.data-table caption {
  text-align: left;
  font-size: 12px;
  color: var(--ink-mute);
  margin-bottom: 6px;
  caption-side: top;
}
.data-table thead { background: var(--bg-soft); }
.data-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
.data-table th[data-sort]:hover { color: var(--accent); }
.data-table th[data-sort]::after {
  content: " ⇅";
  opacity: 0.4;
  font-size: 10px;
}
.data-table th.sort-asc::after { content: " ↑"; opacity: 1; color: var(--accent); }
.data-table th.sort-desc::after { content: " ↓"; opacity: 1; color: var(--accent); }
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-sans);
}
.data-table td:nth-child(2) { font-family: var(--font-mono); font-size: 12.5px; }
.data-table tr:last-child td { border-bottom: none; }
.row-highlight { background: var(--accent-tint); }
[data-theme="dark"] .row-highlight { background: #2a1d20; }
.row-highlight td { color: var(--ink); }

/* ============================== PILLS ============================== */
.pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  display: inline-block;
}
.pill-good { background: rgba(31, 138, 77, 0.12); color: var(--good); }
.pill-warn { background: rgba(182, 119, 42, 0.12); color: var(--warn); }
.pill-bad  { background: rgba(198, 59, 59, 0.12); color: var(--bad); }
.pill-info { background: rgba(42, 95, 179, 0.12); color: var(--info); }

/* ============================== CALLOUTS ============================== */
.callout {
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-1);
  padding: 12px 16px;
  margin-top: 16px;
}
.callout-soft { border-left-color: var(--info); }
.callout-info { border-left-color: var(--good); }
.callout-h {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 4px;
}
.callout-soft .callout-h { color: var(--info); }
.callout-info .callout-h { color: var(--good); }
.callout p { font-size: 13.5px; margin: 0; color: var(--ink); }

/* ============================== FIGURES ============================== */
.zoom-fig {
  margin: 0;
  cursor: zoom-in;
  position: relative;
  border-radius: var(--r-2);
  overflow: hidden;
  background: var(--bg-soft);
  transition: transform 0.18s ease;
}
.zoom-fig img {
  width: 100%;
  display: block;
  transition: transform 0.25s ease;
  background: white;
  padding: 8px;
}
[data-theme="dark"] .zoom-fig img { background: #f5f5f5; }
.zoom-fig:hover img { transform: scale(1.01); }
.zoom-fig::after {
  content: "⤢";
  position: absolute;
  top: 10px; right: 12px;
  width: 28px; height: 28px;
  background: rgba(0,0,0,0.55);
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  font-size: 14px;
  pointer-events: none;
}
.zoom-fig:hover::after { opacity: 1; }
.zoom-fig figcaption {
  font-size: 12.5px;
  color: var(--ink-mute);
  padding: 10px 14px 12px;
  line-height: 1.45;
  background: var(--bg-elev);
}
.zoom-fig.wide { grid-column: 1 / -1; }
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 12px;
}
@media (max-width: 1100px) { .compare-grid { grid-template-columns: 1fr; } }
.pol-fig img { max-height: 320px; object-fit: contain; }

/* ============================== KV GRID ============================== */
.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.kv {
  background: var(--bg-soft);
  padding: 10px 12px;
  border-radius: var(--r-1);
  border: 1px solid var(--line-soft);
}
.kv-k {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--ink-mute);
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.kv-v { font-size: 13px; color: var(--ink); font-family: var(--font-mono); }

/* ============================== CROSS-INSTANCE MATRIX ============================== */
.cim-wrap {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  margin-top: 12px;
}
@media (max-width: 1100px) { .cim-wrap { grid-template-columns: 1fr; } }
.cim-grid {
  display: grid;
  grid-template-columns: 110px repeat(5, 1fr);
  gap: 4px;
  background: var(--bg-soft);
  padding: 10px;
  border-radius: var(--r-2);
}
.cim-cell {
  padding: 14px 6px;
  text-align: center;
  font-size: 13.5px;
  border-radius: 4px;
  display: grid; place-items: center;
  min-height: 56px;
  font-weight: 600;
  cursor: default;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.cim-corner { background: transparent; }
.cim-colhead, .cim-rowhead {
  background: transparent;
  font-size: 12.5px;
  color: var(--ink);
  font-weight: 600;
  font-family: var(--font-mono);
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.cim-rowhead { text-align: right; padding-right: 14px; justify-content: end; }
.cim-data {
  font-family: var(--font-mono);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.cim-data:hover { transform: scale(1.04); box-shadow: var(--shadow-2); z-index: 2; }
.cim-data.active { outline: 2px solid var(--ink); outline-offset: -2px; }

.cim-axes { display: contents; }
.cim-yaxis, .cim-xaxis {
  display: none;
}

.cim-detail {
  background: var(--bg-soft);
  border-radius: var(--r-2);
  padding: 16px 18px;
  border: 1px solid var(--line);
  align-self: start;
  position: sticky;
  top: 80px;
}
.cim-detail-h {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 8px;
}
.cim-detail-body { font-size: 13px; color: var(--ink); line-height: 1.55; }
.cim-detail-body .cim-train, .cim-detail-body .cim-eval { font-family: var(--font-mono); font-size: 12px; }
.cim-detail-row { display: grid; grid-template-columns: 90px 1fr; gap: 6px; padding: 4px 0; }
.cim-detail-row .cim-k { color: var(--ink-mute); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.cim-detail-cost { font-size: 24px; font-family: var(--font-serif); font-weight: 600; color: var(--accent); margin-top: 6px; }

.legend-strip { margin-left: 12px; font-size: 12px; color: var(--ink-mute); }
.legend-box {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 6px;
  margin-right: 2px;
}

/* ============================== LIGHTBOX ============================== */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(10,10,10,0.85);
  z-index: 100;
  display: grid; place-items: center;
  padding: 40px;
  animation: fadeIn 0.18s ease;
}
.lightbox[hidden] { display: none; }
.lb-stage { max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; }
.lb-stage img {
  max-width: 100%;
  max-height: 80vh;
  background: white;
  padding: 14px;
  border-radius: var(--r-2);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.lb-cap {
  color: #e5e5e5;
  font-size: 13.5px;
  padding: 14px 6px 0;
  max-width: 800px;
  text-align: center;
  line-height: 1.5;
}
.lb-close, .lb-prev, .lb-next {
  position: absolute;
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 24px;
  cursor: pointer;
  border-radius: 50%;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  transition: background 0.15s ease;
}
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,0.2); }
.lb-close { top: 24px; right: 24px; }
.lb-prev { left: 24px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 24px; top: 50%; transform: translateY(-50%); }

/* ============================== FOOTER ============================== */
.footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 18px;
  font-size: 12.5px;
  color: var(--ink-mute);
}

/* ============================== SCROLLBAR ============================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-mute); }

/* ============================== ANCHOR FLASH ============================== */
@keyframes anchorFlash {
  0%   { box-shadow: 0 0 0 0 rgba(138, 32, 48, 0.45); }
  60%  { box-shadow: 0 0 0 10px rgba(138, 32, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(138, 32, 48, 0); }
}
.anchor-flash { animation: anchorFlash 1.4s ease-out; }

/* ============================== INFO LINK (inline "View setup") ============================== */
.info-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-mute);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px 5px 10px;
  margin-left: 12px;
  vertical-align: middle;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  top: -3px;
}
.info-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(138, 32, 48, 0.25);
}
.info-link::after {
  content: " (click to read the setup)";
  font-style: italic;
  font-size: 11.5px;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.25s ease, opacity 0.15s ease 0.05s;
}
.info-link:hover::after { opacity: 0.9; max-width: 220px; }

/* ============================== SETUP CARD (top of two-class page) ============================== */
.setup-card {
  padding: 32px 36px;
  background:
    radial-gradient(circle at 0% 0%, var(--accent-tint) 0%, transparent 38%),
    radial-gradient(circle at 100% 100%, rgba(42, 95, 179, 0.06) 0%, transparent 40%),
    var(--bg-elev);
  border-color: var(--line);
  position: relative;
  overflow: hidden;
}
[data-theme="dark"] .setup-card {
  background:
    radial-gradient(circle at 0% 0%, rgba(224, 123, 137, 0.10) 0%, transparent 38%),
    radial-gradient(circle at 100% 100%, rgba(110, 158, 255, 0.07) 0%, transparent 40%),
    var(--bg-elev);
}
.setup-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; height: 100%;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), transparent 80%);
  opacity: 0.7;
}

.setup-grid {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 36px;
  align-items: center;
}
@media (max-width: 1100px) { .setup-grid { grid-template-columns: 1fr; gap: 24px; } }

/* Eyebrow tag above the heading */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-tint);
}

.setup-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
  line-height: 1.2;
  color: var(--ink);
}

.setup-text p { font-size: 14.5px; line-height: 1.65; margin-bottom: 14px; }
.setup-text strong { color: var(--ink); }

/* "The question" pull-quote, more polished */
.setup-q {
  margin-top: 22px;
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  box-shadow: 0 4px 16px rgba(138, 32, 48, 0.08);
  padding: 14px 18px;
  border-radius: var(--r-2);
  position: relative;
}
[data-theme="dark"] .setup-q { background: rgba(56, 34, 39, 0.5); }
.setup-q-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.setup-q p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16px;
  font-style: italic;
  color: var(--ink);
  line-height: 1.45;
}

.info-link-inline {
  margin-left: 0;
  margin-top: 18px;
  top: 0;
}

.setup-diagrams {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

/* Each diagram framed as a labelled mini-card */
.diagram-card {
  margin: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.diagram-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

.diagram-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, var(--accent-tint) 0%, transparent 70%);
  border-bottom: 1px solid var(--line-soft);
}
.diagram-card-alt .diagram-head {
  background: linear-gradient(90deg, rgba(42, 95, 179, 0.10) 0%, transparent 70%);
}
[data-theme="dark"] .diagram-card-alt .diagram-head {
  background: linear-gradient(90deg, rgba(110, 158, 255, 0.16) 0%, transparent 70%);
}

.diagram-num {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--accent);
  color: white;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 13px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(138, 32, 48, 0.3);
}
.diagram-card-alt .diagram-num { background: var(--info); box-shadow: 0 2px 6px rgba(42, 95, 179, 0.3); }

.diagram-titles { flex: 1; line-height: 1.2; }
.diagram-title {
  font-family: var(--font-serif);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}
.diagram-sub {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 1px;
  font-family: var(--font-mono);
}

.diagram-body {
  padding: 8px 14px 12px;
  background: var(--bg-elev);
}
.diagram-body svg {
  width: 100%;
  max-height: 175px;
  color: var(--ink-soft);
  display: block;
}

/* Decorative connector between the two diagrams */
.diagram-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 2px 0;
  color: var(--ink-mute);
}
.diagram-arrow-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line) 30%, var(--line) 70%, transparent);
  max-width: 40px;
}
.diagram-arrow-text {
  font-family: var(--font-sans);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}
.diagram-arrow svg { color: var(--accent); }

/* legacy alias so any remaining .schematic-grid references still flow */
.schematic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
}
@media (max-width: 1100px) { .schematic-grid { grid-template-columns: 1fr; } }
.schematic { margin: 0; text-align: center; }
.schematic svg {
  width: 100%;
  max-height: 200px;
  color: var(--ink-soft);
}

/* Network-diagram SVG class colours, unscoped so they apply inside
   .schematic, .diagram-card, or anywhere else. The .model-svg block
   below intentionally overrides a few of these with higher specificity. */
.schema-q { fill: var(--bg-soft); stroke: var(--ink-soft); stroke-width: 1.4; }
.schema-s { fill: var(--accent-tint); stroke: var(--accent); stroke-width: 1.4; }
.schema-t { fill: var(--ink); font-size: 13px; font-family: var(--font-sans); }
.schema-l { fill: var(--accent); font-size: 15px; font-family: var(--font-serif); font-style: italic; }
.schema-l-sm { fill: var(--ink-soft); font-size: 11px; font-family: var(--font-serif); font-style: italic; }
.schema-l-sm.slow { fill: var(--bad); font-weight: 600; }
.schema-arrow-slow {
  stroke: var(--bad);
  color: var(--bad);  /* feeds currentColor into the arrowhead marker */
  fill: none;
  stroke-width: 1.6;
}
.schematic figcaption {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-soft);
  font-family: var(--font-sans);
}

/* ============================== SETUP MODAL ============================== */
.setup-modal {
  position: fixed; inset: 0;
  background: rgba(10,10,10,0.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: grid; place-items: center;
  padding: 40px 20px;
  animation: fadeIn 0.18s ease;
  overflow-y: auto;
}
.setup-modal[hidden] { display: none; }
.setup-modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  max-width: 720px;
  width: 100%;
  padding: 32px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  position: relative;
  animation: popIn 0.22s ease;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.setup-modal-card h3 {
  font-size: 22px;
  margin-bottom: 16px;
  padding-right: 32px;
}
.setup-modal-card h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-top: 22px;
  margin-bottom: 10px;
}
.setup-modal-card p { font-size: 14.5px; color: var(--ink); line-height: 1.6; }
.setup-modal-card code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--line-soft);
}
.setup-close {
  position: absolute;
  top: 16px; right: 18px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.15s ease;
}
.setup-close:hover { background: var(--accent); border-color: var(--accent); color: white; }
.param-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 8px 0 4px;
}
@media (max-width: 600px) { .param-grid { grid-template-columns: repeat(2, 1fr); } }
.param {
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-1);
  padding: 8px 10px;
  text-align: center;
}
.param-k {
  font-size: 12.5px;
  color: var(--ink-mute);
  font-family: var(--font-serif);
  font-style: italic;
}
.param-v {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  margin-top: 2px;
  font-weight: 600;
}

/* ============================== OVERVIEW: AUTHORS / HERO ACTIONS / BIBTEX ============================== */
.authors {
  margin-top: 14px;
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}
.authors .author { color: var(--ink); }
.authors .author-sep { color: var(--ink-mute); opacity: 0.6; }

/* Wider-left setup variant — prose dominates, thesis/actions/algo-cards on the right */
.setup-grid-wide {
  grid-template-columns: 2fr 1fr;
  gap: 40px;
  align-items: center;
}
/* Overview's sticky aside stays anchored at the top of the row */
.setup-grid-wide .setup-aside { align-self: start; }
@media (max-width: 1100px) { .setup-grid-wide { grid-template-columns: 1fr; } }
.setup-grid-wide .setup-text .setup-title { margin-bottom: 16px; }
.setup-grid-wide .setup-lead {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin-bottom: 14px;
}
.setup-grid-wide .setup-lead:last-child { margin-bottom: 0; }
.setup-grid-wide .setup-lead strong { color: var(--ink); }
/* Algo-cards inside a narrow right column stack instead of going 2x2 */
.setup-grid-wide .algo-grid { grid-template-columns: 1fr; }

.setup-aside {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.setup-q-hero {
  margin-top: 0;
  padding: 18px 20px;
}
.setup-q-hero p {
  font-size: 15.5px;
  line-height: 1.5;
}
.hero-actions-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 0;
}
.hero-actions-stack .hero-btn { justify-content: center; padding: 11px 18px; }

.setup-text .setup-lead {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin-bottom: 0;
}

/* Mini-TOC inside the overview's Setup card */
.toc-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.toc-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--accent-tint) 0%, transparent 70%);
  border-bottom: 1px solid var(--line-soft);
}
.toc-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--accent);
  color: white;
  padding: 3px 9px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(138, 32, 48, 0.25);
}
.toc-titles { line-height: 1.25; }
.toc-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.toc-sub {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 1px;
  font-family: var(--font-mono);
}
.toc-list { padding: 6px 12px 14px; }
.toc-group { margin-top: 10px; }
.toc-group:first-child { margin-top: 4px; }
.toc-group-h {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 6px 4px 4px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--line-soft);
}
.toc-group-h-alt { color: var(--info); }
.toc-roman {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  color: inherit;
  font-style: italic;
  letter-spacing: 0;
  text-transform: none;
}
.toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--r-1);
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, padding-left 0.15s ease, color 0.15s ease;
}
.toc-item:hover {
  background: var(--bg-soft);
  padding-left: 12px;
  color: var(--accent);
  text-decoration: none;
}
.toc-item-name { line-height: 1.2; }
.toc-item-arr {
  color: var(--ink-mute);
  font-family: var(--font-mono);
  font-size: 14px;
  transition: transform 0.15s ease, color 0.15s ease;
}
.toc-item:hover .toc-item-arr {
  color: var(--accent);
  transform: translateX(3px);
}

/* Two-part grouping inside the case-studies card */
.part-block { margin-bottom: 22px; }
.part-block:last-child { margin-bottom: 0; }
.part-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 6px 0 10px;
  border-bottom: 1px solid var(--line-soft);
}
.part-num {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(138, 32, 48, 0.25);
}
.part-block:nth-child(odd) .part-num { background: var(--accent); }
.part-block:nth-child(even) .part-num { background: var(--info); box-shadow: 0 2px 6px rgba(42, 95, 179, 0.3); }
.part-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.part-sub {
  font-size: 12.5px;
  color: var(--ink-mute);
  margin-top: 2px;
  line-height: 1.35;
}

/* Case-study card thumbnail slot */
.exp-thumb {
  width: 100%;
  height: 92px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-1);
  margin-bottom: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  padding: 8px 10px;
  transition: background 0.18s ease, color 0.18s ease;
}
/* Brittleness cards: taller thumbnail to fit the full canonical schematic */
.exp-thumb-tall {
  height: 150px;
  padding: 10px 14px;
}
.exp-card:hover .exp-thumb {
  background: var(--accent-tint);
  color: var(--accent);
}
.exp-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}
.exp-thumb-cs1 { background: linear-gradient(135deg, rgba(138, 32, 48, 0.06), transparent 70%), var(--bg-soft); }
.exp-thumb-cs2 { background: linear-gradient(135deg, rgba(42, 95, 179, 0.07), transparent 70%), var(--bg-soft); }
.exp-thumb-algo { background: linear-gradient(135deg, rgba(31, 138, 77, 0.07), transparent 70%), var(--bg-soft); }
.exp-thumb-hp { background: var(--bg-soft); }
.exp-thumb-mask { background: linear-gradient(135deg, rgba(182, 119, 42, 0.06), transparent 70%), var(--bg-soft); }
[data-theme="dark"] .exp-thumb-hp { background: #1d1f24; }
[data-theme="dark"] .exp-thumb-hp svg rect { stroke: rgba(0,0,0,0.15); stroke-width: 0.5; }

/* ============================== OVERVIEW HERO ACTIONS / PAPER STATS / BIBTEX ============================== */
.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}
.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--line);
  text-decoration: none;
  transition: all 0.18s ease;
}
.hero-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}
.hero-btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(138, 32, 48, 0.25);
}
.hero-btn-primary:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: white;
}
[data-theme="dark"] .hero-btn-primary { color: #1d1f24; }
[data-theme="dark"] .hero-btn-primary:hover { color: #1d1f24; }

/* BibTeX block */
.bibtex-card { padding-bottom: 28px; }
.bibtex-block {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  overflow: hidden;
}
.bibtex-pre {
  margin: 0;
  padding: 18px 22px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
  overflow-x: auto;
  white-space: pre;
}
[data-theme="dark"] .bibtex-pre { color: var(--ink); }
.bibtex-pre code {
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  padding: 0;
}
.bibtex-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-elev);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.bibtex-copy:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.bibtex-copy.copied {
  background: var(--good);
  color: white;
  border-color: var(--good);
}

/* ============================== ALGORITHM CARDS (algo-grid, hover-reveal) ============================== */
.algo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px) { .algo-grid { grid-template-columns: 1fr; } }

.algo-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  overflow: hidden;
  cursor: default;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  outline: none;
}
.algo-card:hover, .algo-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

.algo-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(90deg, var(--bg-soft) 0%, transparent 80%);
}
.algo-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 999px;
  color: white;
  flex-shrink: 0;
  background: var(--accent);
  box-shadow: 0 2px 5px rgba(138, 32, 48, 0.18);
}
.algo-badge-ppo      { background: #8a2030; }     /* accent red */
.algo-badge-pathwise { background: #2a5fb3; }     /* info blue */
.algo-badge-rb       { background: #1f8a4d; }     /* good green */
.algo-badge-rn       { background: #b6772a; }     /* warn amber */

.algo-titles { flex: 1; line-height: 1.25; min-width: 0; }
.algo-name {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}
.algo-sub {
  font-size: 11.5px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  margin-top: 1px;
}

/* Hover-revealed detail block */
.algo-card-detail {
  max-height: 0;
  opacity: 0;
  padding: 0 12px;
  transition: max-height 0.28s ease, opacity 0.18s ease, padding 0.2s ease;
  overflow: hidden;
  background: var(--bg-elev);
}
.algo-card:hover .algo-card-detail,
.algo-card:focus-visible .algo-card-detail,
.algo-card:focus-within .algo-card-detail {
  max-height: 320px;
  opacity: 1;
  padding: 10px 12px 12px;
}
.algo-detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line-soft);
}
.algo-detail-row:last-child { border-bottom: none; }
.algo-detail-row span { color: var(--ink-mute); }
.algo-detail-row strong { color: var(--ink); font-family: var(--font-sans); font-weight: 600; }

.algo-hint {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--ink-mute);
  text-align: center;
  font-style: italic;
}

/* Constrain the algorithms training-curves figure so it doesn't dominate the card */
.algo-fig {
  max-width: 620px;
  margin: 0 auto;
}

/* The masking 2-panel figure is wider (left = slowdown, right = N-model) */
.mask-fig {
  max-width: 820px;
  margin: 0 auto;
}
.mask-fig img { max-height: 360px; width: 100%; object-fit: contain; }

/* ============================== HYPERPARAMETER SECTION ============================== */

/* Setup card right column: base PPO config */
.base-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.base-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--accent-tint) 0%, transparent 70%);
  border-bottom: 1px solid var(--line-soft);
}
.base-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  background: var(--accent);
  color: white;
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(138, 32, 48, 0.25);
}
.base-titles { line-height: 1.25; }
.base-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.base-sub {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 1px;
  font-family: var(--font-mono);
}
.base-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px 16px 10px;
}
.base-kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-soft);
  border-radius: var(--r-1);
  align-items: baseline;
  font-size: 12.5px;
}
.base-k {
  color: var(--ink-mute);
  font-family: var(--font-sans);
}
.base-v {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
}
.base-foot {
  padding: 8px 16px 14px;
  font-size: 11.5px;
  color: var(--ink-mute);
  font-style: italic;
}

/* Hyperparam figure + legend grid */
.hp-grid {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 24px;
  align-items: start;
}
.hp-grid-wide {
  grid-template-columns: 6fr 6fr;
}
@media (max-width: 1100px) { .hp-grid, .hp-grid-wide { grid-template-columns: 1fr; } }

.hp-fig {
  max-width: 100%;
  margin: 0 auto;
}
.hp-fig img { max-height: 360px; width: 100%; object-fit: contain; background: white; padding: 8px; }
[data-theme="dark"] .hp-fig img { background: #f5f5f5; }

.hp-fig-wide {
  max-width: 760px;
  margin: 0 auto;
}
.hp-fig-wide img { max-height: 320px; width: 100%; object-fit: contain; background: white; padding: 8px; }
[data-theme="dark"] .hp-fig-wide img { background: #f5f5f5; }

/* Config legend (rows hoverable to reveal details) */
.config-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.config-legend-12 {
  /* The 12-row legend wraps into two columns to stay readable */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-content: start;
}
.config-legend-h {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
  font-weight: 600;
}

.config-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--r-1);
  transition: background 0.15s ease, border-color 0.15s ease;
  cursor: default;
  outline: none;
}
.config-row:hover, .config-row:focus-visible, .config-row:focus-within {
  background: var(--bg-elev);
  border-color: var(--accent);
}

.config-badge {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 12.5px;
  color: white;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
/* Distinct badge colours for A-E (matches a 5-line palette) */
.config-A { background: #4a7faa; }
.config-B { background: #c44545; }
.config-C { background: #2e8e63; }
.config-D { background: #d28a3b; }
.config-E { background: #7c6dad; }
/* Numbered configs use a uniform muted accent */
.config-N { background: #8a2030; font-size: 11.5px; }

.config-titles { line-height: 1.25; min-width: 0; }
.config-name {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.config-sub {
  font-size: 11px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  margin-top: 1px;
}

.config-detail {
  grid-column: 1 / -1;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.15s ease;
  padding: 0 4px;
}
.config-row:hover .config-detail,
.config-row:focus-visible .config-detail,
.config-row:focus-within .config-detail {
  max-height: 220px;
  opacity: 1;
  padding: 8px 4px 2px;
}
.config-detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 3px 0;
  font-size: 11.5px;
  border-top: 1px dashed var(--line-soft);
}
.config-detail-row:first-child { border-top: none; }
.config-detail-row span { color: var(--ink-mute); }
.config-detail-row strong { color: var(--ink); font-family: var(--font-mono); font-weight: 600; font-size: 11px; }
.config-detail-row strong em { color: var(--ink-mute); font-style: normal; font-weight: 400; }

/* ----- Live 12×5 hyperparameter matrix ----- */
.hpmat-wrap {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) { .hpmat-wrap { grid-template-columns: 1fr; } }

.hpmat-grid {
  display: grid;
  grid-template-columns: 150px repeat(5, 1fr);
  gap: 4px;
  background: var(--bg-soft);
  padding: 10px;
  border-radius: var(--r-2);
}
.hpmat-cell {
  padding: 10px 6px;
  text-align: center;
  font-size: 12.5px;
  border-radius: 4px;
  display: grid; place-items: center;
  min-height: 40px;
  font-weight: 600;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.hpmat-corner { background: transparent; }
.hpmat-colhead {
  background: transparent;
  font-size: 11.5px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
  line-height: 1.2;
}
.hpmat-rowhead {
  background: transparent;
  font-size: 11.5px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: left;
  justify-content: start;
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.15;
}
.hpmat-rowname { color: var(--ink); }
.hpmat-rowtag { color: var(--ink-mute); font-size: 10px; font-weight: 500; }
.hpmat-data {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12.5px;
  position: relative;
}
.hpmat-data:hover { transform: scale(1.04); box-shadow: var(--shadow-2); z-index: 2; }
.hpmat-data.active { outline: 2px solid var(--ink); outline-offset: -2px; }
.hpmat-data-best::after {
  content: "★";
  position: absolute;
  top: 2px; right: 4px;
  font-size: 10px;
  color: rgba(255,255,255,0.9);
}

.hpmat-detail {
  background: var(--bg-soft);
  border-radius: var(--r-2);
  padding: 16px 18px;
  border: 1px solid var(--line);
  align-self: start;
  position: sticky;
  top: 80px;
}
.hpmat-detail-h {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}
.hpmat-detail-sub {
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--ink-soft);
  font-size: 13px;
  margin-left: 4px;
}
.hpmat-detail-meta {
  font-size: 12px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  padding: 4px 0;
  border-bottom: 1px dashed var(--line-soft);
  margin-bottom: 6px;
}
.hpmat-detail-meta strong { color: var(--ink); font-weight: 600; }
.hpmat-detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px dashed var(--line-soft);
}
.hpmat-detail-row span { color: var(--ink-mute); }
.hpmat-detail-row strong { color: var(--ink); font-family: var(--font-mono); font-weight: 600; font-size: 11.5px; }
.hpmat-detail-cost {
  font-size: 26px;
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--accent);
  margin: 10px 0 6px;
}
.hpmat-detail-body {
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.5;
}

/* ============================== TAKEAWAYS ============================== */
.takeaways-card { padding: 22px 26px; }
.takeaways {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 820px) { .takeaways { grid-template-columns: 1fr; } }
.takeaway {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-2);
  padding: 14px 16px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.takeaway:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.takeaway-num {
  width: 30px; height: 30px;
  background: var(--accent);
  color: white;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  display: grid; place-items: center;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(138, 32, 48, 0.25);
}
.takeaway-h {
  font-family: var(--font-serif);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.takeaway-body p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* ============================== MOBILE ============================== */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    top: 0;
    height: auto;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 18px;
  }
  .content { padding: 20px; }
  .panel-header { flex-direction: column; gap: 14px; }
  .hero-badges { width: 100%; }
}
