:root {
  --ink: #16191d;
  --muted: #5b6470;
  --line: #d9dee4;
  --bg: #fbfcfd;
  --panel: #ffffff;
  --accent: #1d4e89;
  --warn: #8a5a00;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8ebee;
    --muted: #9aa4b1;
    --line: #2b3239;
    --bg: #14171a;
    --panel: #1b1f23;
    --accent: #7fb0e5;
    --warn: #e0b060;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand { font-weight: 650; text-decoration: none; color: var(--ink); }
nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; font-size: 0.94rem; }
nav a:hover { color: var(--ink); }
nav a.active { color: var(--accent); font-weight: 600; }

main { max-width: 1060px; margin: 0 auto; padding: 1.5rem; }
h1 { font-size: 1.6rem; margin: 0 0 0.4rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.4rem; }
.lede { color: var(--muted); max-width: 62ch; margin: 0 0 1.2rem; }
.note, .caveat { font-size: 0.86rem; color: var(--muted); max-width: 70ch; }
.caveat { border-left: 2px solid var(--line); padding-left: 0.7rem; margin: 0.7rem 0; }

.controls { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.8rem; }
.controls label { font-size: 0.85rem; color: var(--muted); display: grid; gap: 0.25rem; }
select, input[type="search"] {
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
}
input[type="search"] { width: 100%; max-width: 30rem; font-size: 1rem; }

#deck-wrap {
  position: relative;
  height: 62vh;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}
#deck { width: 100%; height: 100%; display: block; }

.legend {
  position: absolute; right: 0.6rem; top: 0.6rem;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.5rem 0.6rem; font-size: 0.78rem; max-height: 85%; overflow: auto;
}
.legend div { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

.cards { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  display: flex; gap: 0.7rem; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 0.6rem; cursor: pointer; text-align: left;
  font: inherit; color: inherit;
}
.card:hover { border-color: var(--accent); }
.card img { width: 44px; height: 56px; object-fit: cover; border-radius: 3px; background: var(--line); flex: none; }
.card .who { font-weight: 600; font-size: 0.95rem; }
.card .meta { font-size: 0.8rem; color: var(--muted); }

.detail {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 1rem; margin-top: 1rem;
}
.detail h3 { margin: 0 0 0.2rem; font-size: 1.2rem; }
.detail .meta { color: var(--muted); font-size: 0.88rem; }
.stats { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0.9rem 0; }
.stat { border-top: 2px solid var(--line); padding-top: 0.4rem; }
.stat b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.78rem; color: var(--muted); }

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

.axis-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.axis-grid section { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 0.8rem; }
.axis-grid h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.axis-grid ol { margin: 0; padding-left: 1.1rem; font-size: 0.85rem; }
.axis-grid li { margin-bottom: 0.45rem; }
.axis-grid a { color: var(--accent); }

.bar { height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--accent); }

.badge {
  display: inline-block; font-size: 0.72rem; padding: 0.05rem 0.4rem;
  border-radius: 10px; border: 1px solid var(--line); color: var(--muted);
}
.badge.unverified { color: var(--warn); border-color: var(--warn); }

footer { border-top: 1px solid var(--line); margin-top: 2.5rem; padding: 1rem 1.5rem; }
footer p { max-width: 80ch; margin: 0 auto; font-size: 0.8rem; color: var(--muted); }
a { color: var(--accent); }

/* Authored content is deliberately set apart from computed output: a reader should
   never have to work out whether they are looking at a measurement or an argument. */
.story {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); background: var(--panel);
  padding: 1.2rem 1.4rem; margin-top: 1rem; max-width: 70ch;
}
.story h2 { font-size: 1.05rem; margin: 1.4rem 0 0.3rem; }
.story p { margin: 0 0 0.9rem; }
.story .byline {
  font-size: 0.82rem; color: var(--muted);
  border-bottom: 1px solid var(--line); padding-bottom: 0.6rem; margin-bottom: 1rem;
}
.story .byline b { color: var(--ink); }
.figure {
  font-variant-numeric: tabular-nums; font-weight: 650;
  border-bottom: 1px dotted var(--accent); cursor: help; white-space: nowrap;
}
.story-card { display: block; }
.story-card .who { font-size: 1rem; }

.axis-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 1rem 1.2rem; margin-bottom: 1.4rem;
}
.axis-card > h2 { margin: 0 0 0.15rem; font-size: 1.15rem; }
.axis-card .variance { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.9rem; }
.ridge { width: 100%; height: auto; display: block; margin: 0.4rem 0 0.2rem; }
.ridge .label { font-size: 9px; fill: var(--muted); }
.ridge .axis-line { stroke: var(--line); stroke-width: 1; }
.ridge .tick { font-size: 9px; fill: var(--muted); }
.ends { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: 0.9rem; }
.end { border-top: 2px solid var(--line); padding-top: 0.6rem; }
.end h3 { margin: 0 0 0.3rem; font-size: 0.9rem; }
.end .keywords { font-size: 0.85rem; margin: 0 0 0.5rem; }
.end .keywords b { font-weight: 650; }
.end ol { margin: 0; padding-left: 1.1rem; font-size: 0.84rem; }
.end li { margin-bottom: 0.4rem; }
.end .subject { color: var(--muted); font-size: 0.78rem; }

.end .themes { margin: 0 0 0.5rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.end .theme {
  font-size: 0.78rem; padding: 0.12rem 0.5rem; border-radius: 11px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.decomposition { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.decomposition h3 { margin: 0 0 0.3rem; font-size: 0.9rem; }
.decomposition table { font-size: 0.85rem; }
.decomposition tr.spacer td {
  font-size: 0.72rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em; border-bottom: none; padding-top: 0.6rem;
}
.badge.second { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.chip-axis {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; padding: 0.15rem 0.3rem 0.15rem 0.5rem;
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 4px;
  background: var(--panel);
}
.chip-axis .dash { width: 12px; height: 2px; flex: none; }
.chip-axis .name { white-space: nowrap; }
.chip-axis .poles { color: var(--muted); font-size: 0.74rem; white-space: nowrap; }
.chip-axis button {
  font: inherit; line-height: 1; cursor: pointer; color: var(--muted);
  background: none; border: none; padding: 0 0.2rem;
}
.chip-axis button:hover { color: var(--ink); }

.standouts { margin-top: 1rem; }
.standouts > h3 { font-size: 0.9rem; margin: 0 0 0.3rem; }
.standouts > .note { margin: 0 0 0.8rem; }
.standout { margin-bottom: 0.7rem; max-width: 560px; }
.standout .head { margin: 0; font-size: 0.88rem; display: flex; flex-wrap: wrap; gap: 0.1rem 0.5rem; align-items: baseline; }
.standout .lean { font-size: 0.78rem; color: var(--muted); }
.standout-bar { display: block; width: 100%; height: auto; }
.standout-bar .axis-line { stroke: var(--line); stroke-width: 1.5; }
.standout-bar .tick { font-size: 8.5px; fill: var(--muted); }

.group-head { display: flex; gap: 0.9rem; align-items: center; margin-bottom: 1.2rem; }
.group-head h1 { margin: 0 0 0.1rem; }
.group-head .chip { width: 30px; height: 30px; border-radius: 6px; flex: none; }
.legend a { text-decoration: none; color: inherit; }
.legend a:hover { text-decoration: underline; }

#tl-wrap {
  position: relative; height: 62vh; min-height: 380px;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--panel);
}
#tl-deck { width: 100%; height: 100%; display: block; }
#tl-list tr[data-code] { cursor: pointer; }
#tl-list tr[data-code]:hover td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
#tl-list tr.chosen td { background: color-mix(in srgb, var(--accent) 13%, transparent); }
#tl-list tr.chosen td:first-child { font-weight: 600; }
#tl-topic { margin-top: 1.2rem; }

#topic-cloud-wrap {
  position: relative; height: 52vh; min-height: 340px;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--panel);
}
#topic-cloud { width: 100%; height: 100%; display: block; }
.theme-link { cursor: pointer; text-decoration: none; }
a.theme { text-decoration: none; }
a.theme:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.support-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.35rem; font-size: 0.87rem; }
.support-row .name { width: 10rem; flex: none; }
.support-row .bar { flex: 1; }
.support-row .value { width: 3.4rem; text-align: right; font-variant-numeric: tabular-nums; }

.member-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.member-head img { width: 96px; height: 122px; object-fit: cover; border-radius: 4px; background: var(--line); flex: none; }
.member-head h1 { margin: 0 0 0.2rem; }
.term-block {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.term-block h2 { margin: 0 0 0.6rem; font-size: 1.05rem; }
.divergence { margin-top: 0.8rem; }
.divergence h3 { font-size: 0.9rem; margin: 0 0 0.4rem; }
.divergence li { margin-bottom: 0.45rem; font-size: 0.88rem; }
.divergence .compare { color: var(--muted); font-size: 0.82rem; }
