:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #e3e2de;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --accent: #2a78d6;       /* the single series hue (blue, light step) */
  --accent-soft: #cde2fb;
  --grid: #ebeae6;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --border: #2e2e2b;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9a998f;
    --accent: #3987e5;
    --accent-soft: #184f95;
    --grid: #2a2a27;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --border: #2e2e2b;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #9a998f;
  --accent: #3987e5;
  --accent-soft: #184f95;
  --grid: #2a2a27;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; }
.topbar nav { display: flex; gap: 16px; }
.topbar nav a { color: var(--text-secondary); }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end;
  padding: 16px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.filter-form { display: contents; }
.filters label, .field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--text-secondary);
}
.field { position: relative; }
.filters select, .filters input:not([type="checkbox"]), .filters button, .multi > summary {
  font: inherit; font-size: 14px;
  padding: 6px 8px; min-width: 160px;
  color: var(--text-primary);
  background: var(--surface-0);
  border: 1px solid var(--border); border-radius: 6px;
}

/* Multi-select dropdown (releases) and person suggestions. */
.multi > summary {
  list-style: none; cursor: pointer; min-width: 200px; max-width: 280px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-right: 28px; position: relative;
}
.multi > summary::-webkit-details-marker { display: none; }
.multi > summary::after {
  content: ""; position: absolute; right: 10px; top: 50%;
  width: 6px; height: 6px; margin-top: -5px;
  border-right: 1.5px solid var(--text-secondary); border-bottom: 1.5px solid var(--text-secondary);
  transform: rotate(45deg);
}
.menu {
  position: absolute; top: 100%; left: 0; z-index: 10; margin-top: 4px;
  min-width: 100%; max-height: 360px; overflow: auto;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12); padding: 4px;
}
.filters .menu label.check {
  flex-direction: row; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-primary);
  padding: 5px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.menu label.check:hover, .people a:hover, .people a:focus { background: var(--surface-0); }
.filters .menu-action {
  display: block; width: 100%; min-width: 0; text-align: left; cursor: pointer;
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  background: none; color: var(--accent); margin-bottom: 4px;
}
.results { min-width: 320px; }
.results:empty { display: none; }
.people { list-style: none; margin: 0; padding: 0; }
.people a {
  display: flex; flex-direction: column; padding: 6px 8px; border-radius: 6px;
  color: var(--text-primary); text-decoration: none; outline: none;
}
.pname { font-size: 14px; }
.pmeta { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.results .none { margin: 0; padding: 6px 8px; font-size: 13px; color: var(--text-muted); }

main { padding: 24px; max-width: 1400px; margin: 0 auto; transition: opacity .15s; }
main.htmx-request { opacity: .5; }
.heading h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.sub { margin: 4px 0 0; color: var(--text-secondary); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  font-size: 13px; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text-primary);
}

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 20px 0; }
.tile, .card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tile { padding: 16px 18px; }
.tile-value { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--text-secondary); font-size: 13px; }

.grid2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; margin-bottom: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.card { margin: 0; padding: 16px 18px; min-width: 0; }
.card h2, figcaption { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.chart { width: 100%; height: 340px; }

.rank { width: 100%; border-collapse: collapse; font-size: 14px; }
.rank th {
  text-align: left; font-weight: 500; font-size: 12px;
  color: var(--text-muted); border-bottom: 1px solid var(--border); padding: 6px 4px;
}
.rank td { padding: 5px 4px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.rank .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank .pos { color: var(--text-muted); width: 2.5em; }
.rank .name a { color: var(--text-primary); overflow-wrap: anywhere; }
.meter { display: block; height: 3px; margin-top: 3px; background: var(--grid); border-radius: 2px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.card:has(.rank) { max-height: 640px; overflow: auto; }
.muted { color: var(--text-muted); }
.empty { color: var(--text-secondary); padding: 24px 0; }

.foot { padding: 24px; color: var(--text-muted); font-size: 13px; text-align: center; }

@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .topbar, .filters, main { padding-left: 16px; padding-right: 16px; }
  .filters label, .field, .filters select, .filters input:not([type="checkbox"]), .multi > summary { width: 100%; max-width: none; }
  .results { min-width: 0; }
  .tile-value { font-size: 22px; }
}
