:root {
  --bg: #f1e9d8;
  --surface: #fdf9f0;
  --surface-2: #f7f0e2;
  --border: #ddd0b8;
  --text: #2a1e16;
  --text-muted: #6b5c4c;
  --text-faint: #9a8a72;
  --gold: #fb4b1e;
  --gold-dim: rgba(251, 75, 30, 0.14);
  --positive: #4f7942;
  --negative: #af4a2a;
  --radius: 3px;
  --font-display: "Source Serif 4", Georgia, serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { padding: 0; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.mono { font-family: var(--font-mono); }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.neutral { color: var(--text-faint); }

.eyebrow {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}

.topbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
}
.topbar-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
}
.topbar-link:hover {
  color: var(--gold);
  background: var(--surface-2);
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 0 64px;
}

/* ---------- hero ---------- */

.hero { padding: 56px 24px 28px; }
.hero-inner { max-width: 720px; }

.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.55;
  margin: 0;
  max-width: 560px;
}

/* ---------- ticker ---------- */

.ticker-wrap {
  overflow: hidden;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}

.ticker-track {
  display: inline-flex;
  align-items: center;
  padding: 10px 0;
  animation: ticker-scroll 60s linear infinite;
}

.ticker-wrap:hover .ticker-track { animation-play-state: paused; }

.ticker-item {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 14px;
}

.ticker-label {
  color: var(--gold);
  font-weight: 600;
}

.ticker-sep { color: var(--text-faint); margin-left: 14px; }

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
}

/* ---------- ledger (stat cards) ---------- */

.ledger {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  margin: 32px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat-card { background: var(--surface); padding: 18px 20px; }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 8px; }

@media (max-width: 900px) {
  .ledger { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- index section ---------- */

.index-section { margin: 48px 24px 0; }
.section-heading { margin-bottom: 14px; }

.note-box {
  margin: 0 0 20px;
  padding: 16px 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.7;
}

.note-box code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.board {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.board-controls {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

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

.board-controls select,
.board-controls input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: var(--radius);
  min-width: 200px;
}

.board-controls input { min-width: 260px; }

.count-note {
  color: var(--text-faint);
  font-size: 12px;
  margin-left: auto;
  padding-bottom: 9px;
  white-space: nowrap;
}

.table-wrap { overflow-x: auto; }

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

thead th {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th.sortable { cursor: pointer; user-select: none; }
thead th:first-child { text-align: left; }
thead th.sortable:hover { color: var(--gold); }

.sort-arrow { color: var(--gold); }

tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr.lang-row { cursor: pointer; }
tbody tr.lang-row:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

.num-col { text-align: right; }

.lang-name { font-weight: 500; }
.lang-code { font-size: 11px; margin-top: 2px; }

.detail-empty { color: var(--text-faint); font-size: 13px; }

.variant-list {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 28px;
}

.category-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px 16px;
}

.category-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}

.category-name { color: var(--text); }
.category-native { color: var(--text-faint); font-weight: 400; font-size: 12px; margin-left: 4px; }
.category-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 2px;
  margin-left: 6px;
}
.category-tag.repertoire { background: rgba(138, 106, 74, 0.18); color: #6a4a2f; }
.category-tag.blocked { background: rgba(175, 74, 42, 0.16); color: var(--negative); }
.category-tag.allocatable { background: rgba(79, 121, 66, 0.16); color: var(--positive); }

.category-count { font-family: var(--font-mono); color: var(--text-muted); white-space: nowrap; }

.empty-row {
  text-align: center;
  color: var(--text-faint);
  padding: 32px 16px;
}

/* ---------- composition bar (repertoire / blocked / allocatable split) ---------- */

.composition-bar {
  display: flex;
  height: 28px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.composition-seg { height: 100%; }
.composition-seg.repertoire { background: #8a6a4a; }
.composition-seg.blocked { background: var(--negative); }
.composition-seg.allocatable { background: var(--positive); }

.composition-legend {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}
.composition-legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}
.composition-legend .swatch.repertoire { background: #8a6a4a; }
.composition-legend .swatch.blocked { background: var(--negative); }
.composition-legend .swatch.allocatable { background: var(--positive); }

/* ---------- registry list (per-TLD table breakdown on language page) ---------- */

.registry-list { font-size: 13px; }
.registry-list table { width: 100%; border-collapse: collapse; }
.registry-list thead th {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.registry-list thead th:first-child { text-align: left; }
.registry-list tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-family: var(--font-mono);
}
.registry-list tbody td:first-child { text-align: left; font-family: var(--font-body); }
.registry-list tbody tr:last-child td { border-bottom: none; }
.registry-list .registry-tld { font-weight: 500; }
.registry-list .registry-version { color: var(--text-faint); margin-left: 4px; font-size: 11px; }

.more-note {
  margin-top: 12px;
  color: var(--text-faint);
  font-size: 12px;
}

/* ---------- footer ---------- */

.site-footer {
  margin: 56px 24px 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12px;
  font-family: var(--font-mono);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--gold); }

/* ---------- language detail page ---------- */

.lang-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.back-links {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.nav-link:hover { color: var(--gold); }

.lang-page h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 34px;
  line-height: 1.15;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 28px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 40px;
}

.stat-grid.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }

.trend-section { margin-bottom: 40px; }
.trend-section h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 14px;
}

.trend-chart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.trend-chart svg { width: 100%; height: auto; display: block; }

.chart-axis {
  display: flex;
  justify-content: space-between;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 8px;
}

.empty-state {
  margin: 12px 0;
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.external-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}
.external-link:hover { text-decoration: underline; }

.methodology-note {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.7;
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
