:root,
[data-theme="light"] {
  --bg: #fbfaf7;
  --bg-2: #f2f0ea;
  --fg: #1d1f23;
  --muted: #6a6d73;
  --line: #e3e0d8;
  --grid: #ebe8e1;
  --zero: #b9b5ab;
  --accent: #1d4f9c;
  --badge-bg: #fff1c2;
  --badge-fg: #6b4c00;
  --seg-a: #4a5568;
  --seg-b: #a9b3c1;
  --seg-r: repeating-linear-gradient(45deg, #d8d4cb 0 3px, transparent 3px 6px);
  --ok: #8a96a8;
  --bad: #c63d2f;
  --shadow: 0 6px 24px rgb(0 0 0 / 0.12);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #15171b;
  --bg-2: #1d2026;
  --fg: #e8e6e1;
  --muted: #9a9ca2;
  --line: #2c3038;
  --grid: #262a31;
  --zero: #4b505a;
  --accent: #8cb8ff;
  --badge-bg: #4a3a00;
  --badge-fg: #ffe089;
  --seg-a: #c2cad6;
  --seg-b: #5c6676;
  --seg-r: repeating-linear-gradient(45deg, #3a3f48 0 3px, transparent 3px 6px);
  --ok: #6f7b8e;
  --bad: #e5604f;
  --shadow: 0 6px 24px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 104px; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 1180px; margin: 0 auto; padding: 0 20px 80px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.5rem; margin-bottom: 6px; }
h3 { font-size: 1.05rem; margin: 18px 0 8px; }
h4 { font-size: 0.95rem; margin: 16px 0 6px; }
a { color: var(--accent); }
code { font: 0.88em ui-monospace, SFMono-Regular, Menlo, monospace; }
figure { margin: 0 0 18px; }
figcaption { font-weight: 600; margin-bottom: 8px; font-size: 0.92rem; }
section { padding: 36px 0 8px; border-top: 1px solid var(--line); }
section.intro { border-top: 0; padding-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.dek, .note, .question { color: var(--muted); margin: 4px 0 14px; max-width: 72ch; }
.question { color: var(--fg); font-size: 1.02rem; }
.lede { font-size: 1.08rem; max-width: 75ch; margin: 0 0 12px; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-inner { max-width: 1180px; margin: 0 auto; padding: 8px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand h1 { font-size: 1.15rem; letter-spacing: 0.01em; }
.badge { background: var(--badge-bg); color: var(--badge-fg); font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em; }
.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.seg-ctl { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg-ctl button { background: none; border: 0; padding: 4px 10px; border-right: 1px solid var(--line); }
.seg-ctl button:last-child { border-right: 0; }
.seg-ctl button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.mk { flex: none; vertical-align: -2px; }
.brand h1 a { color: inherit; text-decoration: none; }
.seg-label { font-size: 0.78rem; color: var(--muted); padding: 4px 4px 4px 9px; border-right: 1px solid var(--line); }
.seg-ctl button:disabled { opacity: 0.4; cursor: not-allowed; }
.legend { display: inline-flex; font-size: 0.88rem; flex-wrap: wrap; gap: 4px 14px; margin-left: 6px; padding: 0; color: var(--fg); }

/* section ribbon */
.ribbon { border-top: 1px solid var(--line); }
.ribbon-inner { max-width: 1180px; margin: 0 auto; padding: 0 20px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.ribbon-inner::-webkit-scrollbar { display: none; }
.ribbon a { flex: none; padding: 8px 10px 7px; font-size: 0.86rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.ribbon a:hover { color: var(--fg); }
.ribbon a[aria-current] { color: var(--fg); border-bottom-color: var(--fg); font-weight: 600; }

/* pills */
.pills { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 10px 0 6px; }
.pill-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pill-group-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-right: 2px; }
.pill { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-size: 0.88rem; }
.pill[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* charts */
.chart { width: 100%; }
svg { display: block; overflow: visible; }
svg text { fill: var(--fg); font-size: 11.5px; }
.axis text { fill: var(--muted); }
.axis line, .axis path { stroke: var(--zero); }
.axis-y text { font-size: 11px; }
.grid line { stroke: var(--grid); }
.zero { stroke: var(--zero); stroke-width: 1.2; }
.end-labels text { fill: var(--muted); font-weight: 600; font-size: 11.5px; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ci { stroke-width: 1.4; }
.mark { cursor: pointer; }
.mark:hover, .mark:focus { stroke: var(--fg); stroke-width: 1.5; }
.direct-labels text { font-weight: 700; font-size: 12px; fill: var(--fg); }
.series-line.dashed { stroke-dasharray: 5 4; stroke-width: 1.6; }
.connector { stroke-width: 1.5; opacity: 0.5; }
.sample-dot { opacity: 0.22; pointer-events: none; }

.band { fill: var(--bg-2); opacity: 0.55; }
.row-labels text { font-size: 11.5px; }
.row-labels text.muted { fill: var(--muted); }
.panel-title { font-weight: 600; font-size: 12px; }
.dumbbell { stroke: var(--zero); stroke-width: 2; }
.pred-tick { stroke: var(--fg); stroke-width: 2; cursor: pointer; }
.diag { stroke: var(--zero); stroke-dasharray: 3 3; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.small-multiple figcaption { font-weight: 600; }

/* heatmaps */
.table-wrap { overflow-x: auto; }
.heatmap { border-collapse: separate; border-spacing: 2px; font-size: 0.85rem; }
.heatmap th { font-weight: 600; text-align: left; white-space: nowrap; padding: 4px 8px 4px 0; }
.heatmap th .mk { margin-right: 5px; }
.heatmap thead th { vertical-align: bottom; text-align: center; padding: 0 2px 4px; white-space: normal; }
.heatmap td { min-width: 56px; height: 34px; text-align: center; font-variant-numeric: tabular-nums; border-radius: 4px; cursor: default; }
.heatmap td.empty { color: var(--muted); background: var(--bg-2); }
.heatmap td.self { outline: 2px solid var(--fg); outline-offset: -2px; }
.col-btn { background: none; border: 0; border-bottom: 2px solid transparent; padding: 2px 2px 3px; font-size: 0.8rem; font-weight: 600; color: var(--muted); max-width: 88px; line-height: 1.15; }
.col-btn[aria-pressed="true"] { color: var(--fg); border-bottom-color: var(--fg); }
.col-btn:hover { color: var(--fg); }
.matrix th small { display: block; font-weight: 400; margin-left: 19px; }
.matrix thead th span { display: block; font-size: 0.78rem; }
.key { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--muted); margin-top: 8px; }
.key-bar { width: 180px; height: 10px; border-radius: 3px; }

/* family rows: chips & swatches */
.fam-row { display: grid; grid-template-columns: 96px 1fr; gap: 8px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.fam-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.88rem; padding-top: 4px; }
.fam-cells { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid var(--line); border-left: 3px solid var(--fam); border-radius: 5px; padding: 2px 7px 3px; background: var(--bg-2); line-height: 1.2; }
.chip b { display: block; font-size: 0.86rem; font-weight: 600; }
.chip span { font-size: 0.7rem; color: var(--muted); }
.swatches { gap: 8px; }
.swatch { display: flex; flex-direction: column; align-items: center; width: 54px; gap: 2px; }
.swatch > span { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line); }
.swatch small { font-size: 0.66rem; color: var(--muted); text-align: center; line-height: 1.1; }
.sw-inline { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* split bars */
.bar-group { padding: 4px 0; border-bottom: 1px solid var(--line); }
.bar-row { display: grid; grid-template-columns: 150px 1fr; gap: 8px; align-items: center; margin: 2px 0; }
.bar-label { display: flex; align-items: center; gap: 5px; font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { display: flex; height: 16px; border-radius: 3px; overflow: hidden; background: var(--bg-2); }
.seg { display: flex; align-items: center; padding-left: 4px; font-size: 0.68rem; color: #fff; white-space: nowrap; overflow: hidden; }
.seg-a { background: var(--seg-a); color: var(--bg); }
.seg-b { background: var(--seg-b); color: var(--fg); }
.seg-r { background: var(--seg-r); color: var(--fg); }
.seg-ok { background: var(--ok); color: #fff; }
.seg-bad { background: var(--bad); color: #fff; }
.seg-key { display: inline-block; width: 11px; height: 11px; border-radius: 2px; vertical-align: -1px; margin: 0 3px 0 6px; }
.vibe .bar-row { grid-template-columns: 118px 1fr; }

/* feud */
.slider-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.slider-row input { width: min(420px, 60vw); }
.slider-row output { font-weight: 700; min-width: 7ch; }
.sp-row { display: grid; grid-template-columns: 110px 1fr 46px; gap: 8px; align-items: center; margin: 4px 0; }
.sp-track { position: relative; height: 16px; background: var(--bg-2); border-radius: 3px; }
.sp-zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--zero); }
.sp-bar { position: absolute; top: 3px; height: 10px; border-radius: 2px; }
.sp-val { font-size: 0.82rem; font-variant-numeric: tabular-nums; text-align: right; }
.feud-grid .bar-row { grid-template-columns: 110px 1fr; }

/* identity */
.quote { border-left: 3px solid var(--bad); padding: 4px 0 4px 12px; margin: 0 0 12px; }
.quote blockquote { margin: 0 0 4px; font-style: italic; }
.quote figcaption { font-weight: 400; font-size: 0.82rem; display: flex; gap: 5px; align-items: center; }

/* self-knowledge */
.rel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.rel figcaption { display: flex; gap: 5px; align-items: center; font-size: 0.82rem; margin-bottom: 2px; }
.jokes { list-style: none; padding: 0; margin: 0; }
.jokes li { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.jokes blockquote { margin: 0; }
.jokes .topic { font-size: 0.78rem; color: var(--muted); }
.jokes .score { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
#joke-model { margin-left: 8px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg-2); font-weight: 400; }

/* methods */
.caveat { background: var(--bg-2); border-left: 4px solid var(--badge-fg); padding: 10px 14px; border-radius: 4px; max-width: 80ch; }
table.data { border-collapse: collapse; font-size: 0.84rem; width: 100%; }
table.data th, table.data td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data td:first-child { white-space: nowrap; }
table.data tr.muted td { color: var(--muted); }
.unverified { color: var(--badge-fg); font-size: 0.8em; }
.stat-grid { display: grid; gap: 2px 18px; margin: 6px 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 18px 0; }
.tile { background: var(--bg-2); border-radius: 8px; padding: 12px 14px; }
.tile-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tile-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.tile-note { font-size: 0.8rem; color: var(--muted); }
.facts { display: grid; grid-template-columns: 150px minmax(0, 72ch); gap: 8px 18px; margin: 0 0 18px; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; }
@media (max-width: 640px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd { margin-bottom: 8px; } }
details.prompts { margin: 8px 0 18px; }
details.prompts summary { cursor: pointer; font-weight: 600; }
.glance td { min-width: 44px; height: 30px; font-size: 0.8rem; }
.glance th[scope="row"] { display: flex; align-items: center; gap: 5px; font-size: 0.82rem; }
.glance .col-btn { max-width: 74px; font-size: 0.72rem; }
.stat-grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
table.mini { border-collapse: collapse; font-size: 0.82rem; margin: 6px 0; }
table.mini th, table.mini td { padding: 3px 10px 3px 0; text-align: left; border-bottom: 1px solid var(--line); }

/* tooltip */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 300px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 7px;
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 0.8rem;
}
.tip-title { display: flex; align-items: center; gap: 5px; font-weight: 700; margin-bottom: 2px; }
.tip-sub { color: var(--muted); margin-bottom: 4px; font-size: 0.76rem; }
.tip-row { display: flex; justify-content: space-between; gap: 14px; }
.tip-row span { color: var(--muted); }
.tip-row b { font-variant-numeric: tabular-nums; }

/* side panel */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(440px, 100vw);
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  overflow-y: auto; padding: 18px 20px 40px;
}
.panel-close { position: sticky; top: 0; float: right; background: var(--bg); }
.panel h3 { display: flex; align-items: center; gap: 6px; font-size: 1.15rem; margin: 0 0 4px; }
.panel .prompt { font-style: italic; margin: 0 0 6px; }
.answers { padding-left: 18px; }
.answers li { margin-bottom: 10px; }
.answers blockquote { margin: 0 0 2px; padding: 6px 10px; background: var(--bg-2); border-radius: 5px; white-space: pre-wrap; }
.answers .muted { font-size: 0.75rem; }

body.is-mock main::before {
  content: "Mock data: every number on this page is a seeded random draw, not a finding.";
  display: block; margin: 14px 0 0; padding: 6px 12px; font-size: 0.85rem; border-radius: 5px;
  background: var(--badge-bg); color: var(--badge-fg);
}

.empty-note {
  padding: 3rem 1rem;
  text-align: center;
}

/* narrow screens: keep the sticky header short */
@media (max-width: 640px) {
  html { scroll-padding-top: 128px; }
  .top-inner { gap: 6px 10px; padding: 6px 14px; }
  .brand h1 { font-size: 1.05rem; }
  .controls { gap: 6px; }
  .seg-label { display: none; }
  .seg-ctl button, #theme-btn { padding: 3px 7px; font-size: 0.8rem; }
  .ribbon-inner { padding: 0 8px; }
  .ribbon a { padding: 6px 8px; font-size: 0.82rem; }
  main { padding: 0 14px 60px; }
}
