:root {
  --paper: #f2eee6;
  --paper-2: #e8e2d6;
  --surface: #fbf8f1;
  --ink: #1b1916;
  --ink-soft: #4a453e;
  --muted: #6f685f;
  --rule: #d8d0c3;
  --rule-strong: #c3b9a8;
  --forest: #16382f;
  --forest-mid: #2a5c4e;
  --clay: #8f4a2c;
  --clay-soft: #c9a28d;
  --amber: #8a5a12;
  --amber-bg: #f3e4c4;
  --ok-bg: #dce8e2;
  --danger-bg: #ead9d0;
  --shadow: 0 1px 0 rgba(27, 25, 22, 0.04), 0 18px 40px rgba(27, 25, 22, 0.06);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
}
.skip:focus {
  left: 12px;
  top: 12px;
  background: var(--ink);
  color: var(--surface);
  padding: 8px 12px;
  z-index: 20;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: 28px 32px 16px;
  border-bottom: 1px solid var(--rule);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.wordmark {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  gap: 6px;
}

.nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: var(--forest);
  color: var(--surface);
}

.thesis {
  margin: 0;
  padding: 18px 32px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  line-height: 1.35;
  color: var(--forest);
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}

#main {
  padding: 28px 32px 64px;
  min-height: 60vh;
}

.site-footer {
  padding: 20px 32px 32px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 13px;
}
.site-footer p { margin: 0 0 4px; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 550;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}
h1 { font-size: 32px; }
h2 { font-size: 24px; margin-top: 36px; }
h3 { font-size: 18px; }

.lede, .note, .caption {
  color: var(--ink-soft);
  max-width: 68ch;
}
.caption { font-size: 13px; margin-top: 8px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 20px 0 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}
.field.grow { flex: 1; min-width: 220px; }

.field span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type="search"],
select,
button,
.chip {
  appearance: none;
  font: inherit;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
}

input[type="search"]:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--forest-mid);
  outline-offset: 2px;
}

.sorts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.chip[aria-pressed="true"] {
  background: var(--forest);
  color: var(--surface);
  border-color: var(--forest);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  position: sticky;
  top: 0;
  background: #efe9dd;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

th[aria-sort="descending"]::after { content: " ↓"; }
th[aria-sort="ascending"]::after { content: " ↑"; }

tbody tr { cursor: pointer; }
tbody tr:hover { background: #f3eee4; }

a { color: var(--forest); }
table a { font-weight: 500; text-decoration: none; }
table a:hover { text-decoration: underline; }

tr.no-ref td { color: var(--muted); }
tr.no-ref td:first-child { box-shadow: inset 3px 0 0 var(--rule-strong); }

.num { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.ci { display: block; color: var(--muted); font-size: 12px; }

.badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-weight: 500;
}
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.ok { background: var(--ok-bg); color: var(--forest); }

.group-rule td {
  background: #efe9dd;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: default;
}

.grid-2, .grid-3, .grid-4, .stats {
  display: grid;
  gap: 14px;
}
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 20px 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.stat-value {
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: -0.03em;
}
.stat-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.back {
  color: var(--forest);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.chart {
  width: 100%;
  min-height: 360px;
}
.chart svg { max-width: 100%; height: auto; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin: 8px 0 12px;
}
.toggle input { accent-color: var(--forest); width: 16px; height: 16px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}
.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.feature-table th { cursor: default; }
.feature-table th::after { content: none; }
.feature-table tbody tr { cursor: default; }

.flag {
  margin-left: 8px;
}

.panel-note {
  background: var(--surface);
  border-left: 3px solid var(--forest);
  padding: 12px 16px;
  margin: 16px 0 24px;
  color: var(--ink-soft);
}

.muted-row { color: var(--muted); }

.banner {
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
}
.banner.hold {
  background: var(--ok-bg);
  border-color: var(--forest-mid);
}
.banner.fail {
  background: var(--danger-bg);
  border-color: var(--clay);
}
.banner-flag {
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 10px;
  font-size: 13px;
}
.banner.hold .banner-flag { color: var(--forest); }
.banner.fail .banner-flag { color: var(--clay); }

.provenance {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}
.provenance ul {
  padding-left: 1.2em;
  color: var(--ink-soft);
  font-size: 13px;
}
.provenance li { margin: 4px 0; }

@media (max-width: 900px) {
  .site-header, #main, .thesis, .site-footer { padding-left: 16px; padding-right: 16px; }
  .stats, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .thesis { font-size: 18px; }
  h1 { font-size: 26px; }
}
