:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --border: #e3e0d8;
  --text: #1c1b19;
  --text-2: #5f5c55;
  --text-3: #8a867d;
  --accent: #1b64be;
  --girl: #f47230;
  --boy: #257de0;
  --up: #0a7d24;
  --down: #c23b3c;
  --grid: #ebe8e1;
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141413; --surface: #1d1d1b; --surface-2: #262624; --border: #33322f;
    --text: #efeee9; --text-2: #aaa79f; --text-3: #7d7a73; --accent: #6aabf1;
    --girl: #e76624; --boy: #338ced; --up: #3fbf5a; --down: #eb6263; --grid: #2c2b28;
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
    --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141413; --surface: #1d1d1b; --surface-2: #262624; --border: #33322f;
  --text: #efeee9; --text-2: #aaa79f; --text-3: #7d7a73; --accent: #6aabf1;
  --girl: #e76624; --boy: #338ced; --up: #3fbf5a; --down: #eb6263; --grid: #2c2b28;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
  --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
.brand span { color: var(--text-3); font-weight: 500; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  padding: 7px 14px; border-radius: 999px; color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--text); color: var(--surface); }

main { padding: 32px 0 48px; }
.page-title { margin-bottom: 6px; font-size: 28px; }
.lede { color: var(--text-2); margin: 0 0 24px; max-width: 680px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sub { color: var(--text-3); font-size: 13px; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* Controls */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font: inherit; cursor: pointer; line-height: 1.2;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .4; cursor: default; }
select.btn { padding-right: 28px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button {
  appearance: none; border: 0; background: none; color: var(--text-2); font: inherit;
  padding: 7px 14px; cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--surface); }
input[type="range"] { accent-color: var(--accent); flex: 1; min-width: 140px; max-width: 360px; }
.year-big { font-size: 22px; font-weight: 700; min-width: 3ch; }

/* Top 20 */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; }
.rank-cell { width: 2.5em; color: var(--text-3); font-weight: 600; }
.name-cell a { color: var(--text); font-weight: 600; }
.name-cell a:hover { color: var(--accent); }
.change { font-size: 13px; white-space: nowrap; width: 4.5em; }
.change.up { color: var(--up); }
.change.down { color: var(--down); }
.change.same { color: var(--text-3); }
.change.new { color: var(--accent); font-weight: 600; font-size: 11px; letter-spacing: .04em; }
.spark-cell { width: 110px; padding-top: 2px; padding-bottom: 2px; }
.spark { display: block; width: 100px; height: 26px; }
@media (max-width: 480px) { .spark-cell, .spark-head { display: none; } }
tbody tr:hover { background: var(--surface-2); }

.ones-table td, .ones-table th { padding: 5px 8px; }
.ones-wrap { max-height: 460px; overflow: auto; }

/* Search */
.search { position: relative; flex: 1; min-width: 240px; max-width: 520px; }
.search input {
  width: 100%; font: inherit; font-size: 17px; padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10; margin: 0; padding: 4px;
  list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 360px; overflow: auto;
}
.suggest li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--surface-2); }
.suggest .s-name { font-weight: 600; }
.suggest .s-meta { margin-left: auto; color: var(--text-3); font-size: 13px; }
.suggest .empty { color: var(--text-3); cursor: default; }

.tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.tag.g { color: var(--girl); background: color-mix(in srgb, var(--girl) 14%, transparent); }
.tag.b { color: var(--boy); background: color-mix(in srgb, var(--boy) 14%, transparent); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 600;
}
.chip button {
  appearance: none; border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 16px;
  width: 24px; height: 24px; border-radius: 50%; line-height: 1;
}
.chip button:hover { background: var(--surface-2); color: var(--text); }

.empty-state { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty-state .examples { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

.chart-box { position: relative; height: 380px; }
@media (max-width: 600px) { .chart-box { height: 300px; } }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-top: 20px; }
.stat-card h3 { font-size: 20px; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.stat-grid .k { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.stat-grid .v { font-size: 20px; font-weight: 700; }
.stat-grid .v small { font-size: 13px; font-weight: 500; color: var(--text-3); }

details.table-view { margin-top: 20px; }
details.table-view summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.table-scroll { overflow-x: auto; margin-top: 12px; }
.table-scroll td, .table-scroll th { white-space: nowrap; }
.muted { color: var(--text-3); }

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

.loading { color: var(--text-3); padding: 24px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top names page additions */
.note {
  margin: -8px 0 20px; padding: 10px 14px; border-radius: 8px; font-size: 14px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
}
.ones-table tbody tr { cursor: pointer; }
.ones-table tr.is-current { background: var(--surface-2); font-weight: 600; }
.name-cell span { font-weight: 600; }
