:root {
  color-scheme: light;
  --bg: #f3f2f2;
  --surface: #fbfafa;
  --text: #201e1d;
  --muted: #6d6a69;
  --line: #d7d3d3;
  --accent: #d72a10;
  --bar: #2a78d6;
  --ok: #1d6b35;
  --warn-bg: #fff2d6;
  --warn: #8a4b00;
  --race-row: 46px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #161514;
    --surface: #201f1e;
    --text: #f0efec;
    --muted: #a8a5a1;
    --line: #3a3837;
    --accent: #ff6a4d;
    --bar: #3987e5;
    --ok: #5fc27a;
    --warn-bg: #3b2a0c;
    --warn: #ffc56b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 Archivo, system-ui, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { font-weight: 800; line-height: 1.15; margin: 0; }

.site-header, main, .site-footer { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.site-header { padding-top: 32px; padding-bottom: 8px; display: grid; gap: 12px; }
.site-header h1 { font-size: clamp(28px, 6vw, 44px); letter-spacing: -0.02em; }
.lede { margin: 8px 0 0; max-width: 68ch; }

.freshness {
  margin: 0; padding: 8px 12px; border-radius: 6px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--line);
}
.freshness strong { color: var(--ok); }
.freshness.stale { background: var(--warn-bg); border-color: var(--warn); }
.freshness.stale strong { color: var(--warn); }

.source { padding: 28px 0 8px; border-top: 2px solid var(--text); margin-top: 24px; }
.source-head h2 { font-size: 26px; }
.source-about { margin: 6px 0 0; max-width: 72ch; }
.source-range { margin: 4px 0 16px; color: var(--muted); font-size: 13px; }

.lists { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.list h3 { font-size: 15px; margin-bottom: 8px; }
.list-note { margin: -4px 0 8px; font-size: 12px; color: var(--muted); line-height: 1.35; }
.list ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { display: grid; grid-template-columns: 1.6em 36px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.list-rank { font-weight: 800; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.list-poster { width: 36px; height: 54px; object-fit: cover; border-radius: 3px; background: var(--line); display: block; }
.list-body { min-width: 0; display: grid; }
.list-title {
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.list-title:hover { text-decoration: underline; }
.list-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
/* A Wikipedia article's short description, under a one-line title. */
.list-body.has-description .list-title { -webkit-line-clamp: 1; }
.list-description {
  color: var(--muted); font-size: 12px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.image-credit { display: block; }

.race { margin: 20px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.race-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 8px; }
.race-toolbar h3 { font-size: 17px; margin-right: auto; }
.race-toolbar select, .race-toolbar button { font: inherit; font-weight: 600; }
.race-toolbar button {
  padding: 4px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text); cursor: pointer;
}
.race-date { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; min-width: 8.5em; text-align: right; }
.race input[type="range"] { width: 100%; accent-color: var(--accent); margin: 4px 0 12px; }
.race-bars { position: relative; height: calc(10 * var(--race-row)); overflow: hidden; }
.race-bar {
  position: absolute; left: 0; right: 0; top: 0; height: calc(var(--race-row) - 6px);
  display: grid; grid-template-columns: 27px minmax(0, 220px) 1fr; gap: 8px; align-items: center;
  font-size: 13px; transition: opacity 0.3s; will-change: transform;
}
.race-bar.hidden { opacity: 0; }
.race-poster { width: 27px; height: 40px; object-fit: cover; border-radius: 2px; background: var(--line); display: block; }
.race-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.race-track { display: flex; align-items: center; height: 70%; min-width: 0; }
.race-fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.race-value { padding-left: 6px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.site-footer { padding-top: 24px; padding-bottom: 40px; margin-top: 32px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.site-footer p { margin: 0 0 6px; }
.tmdb-credit img { display: inline-block; vertical-align: middle; margin-right: 6px; }

@media (max-width: 900px) {
  .lists { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .lists { grid-template-columns: 1fr; }
  :root { --race-row: 42px; }
  .race-bar { grid-template-columns: 27px minmax(0, 120px) 1fr; font-size: 12px; }
}

/* The update log page (status.html). */
.crumb { margin: 0 0 6px; font-size: 14px; }
.status-totals {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px;
  margin-top: 24px;
}
.total { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.total h3 { font-size: 14px; color: var(--muted); font-weight: 600; }
.total-value { margin: 4px 0 2px; font-size: 26px; font-weight: 800; }
.total-detail { margin: 0; font-size: 13px; color: var(--muted); }
.status-log { margin-top: 28px; padding-top: 20px; border-top: 2px solid var(--text); }
.status-log h2 { font-size: 24px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.status-log table { width: 100%; border-collapse: collapse; font-size: 14px; }
.status-log th, .status-log td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.status-log th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.status-log td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.status-log tbody tr:last-child td { border-bottom: 0; }
.status-log tr.nothing-new td { color: var(--muted); }
.note { margin: 10px 0 0; font-size: 13px; color: var(--muted); max-width: 80ch; }

/* Health banner, coverage and growth charts (status.html). */
:root {
  --series-imdb: #2a78d6;
  --series-tmdb: #eb6834;
  --series-wikipedia: #1baf7a;
  --series-polymarket: #eda100;
  --series-runs: #6d6a69;
  --critical: #c62828;
  --critical-bg: #fde8e6;
  --ok-bg: #e6f4ea;
}
@media (prefers-color-scheme: dark) {
  :root {
    --series-imdb: #3987e5;
    --series-tmdb: #d95926;
    --series-wikipedia: #199e70;
    --series-polymarket: #c98500;
    --series-runs: #a8a5a1;
    --critical: #ff7a70;
    --critical-bg: #3a1714;
    --ok-bg: #12301c;
  }
}
.health {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px;
  margin-top: 20px; padding: 14px 16px; border-radius: 8px; border: 2px solid var(--line);
}
.health:empty { display: none; }
.health-badge {
  display: inline-block; padding: 3px 12px; border-radius: 999px;
  font-size: 15px; font-weight: 800; color: #fff; white-space: nowrap;
}
.health-detail p { margin: 0; }
.health-ok { background: var(--ok-bg); border-color: var(--ok); }
.health-ok .health-badge { background: var(--ok); }
.health-error { background: var(--critical-bg); border-color: var(--critical); }
.health-error .health-badge { background: var(--critical); }
@media (prefers-color-scheme: dark) {
  .health-badge { color: #161514; }
}

.status-charts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.coverage { width: 100%; height: auto; min-width: 720px; }
.chart { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.chart figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; margin-bottom: 10px; }
.chart h2 { font-size: 17px; }
.chart-scroll { overflow-x: auto; }
.chart-scroll svg { display: block; }
.growth { width: 100%; height: auto; min-width: 560px; }
.legend { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-label { font-size: 12px; font-weight: 600; fill: var(--text); }
.chart-tick { font-size: 11px; fill: var(--muted); }
.chart-today { fill: var(--text); font-weight: 600; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.cell-runs { fill: var(--series-runs); background: var(--series-runs); }
.cell-imdb { fill: var(--series-imdb); background: var(--series-imdb); }
.cell-tmdb { fill: var(--series-tmdb); background: var(--series-tmdb); }
.cell-wikipedia { fill: var(--series-wikipedia); background: var(--series-wikipedia); }
.cell-polymarket { fill: var(--series-polymarket); background: var(--series-polymarket); }
.cell-none { fill: transparent; }
.cell-pending { fill: transparent; stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 3 2; }
span.cell-pending { border: 1.5px dashed var(--line); }
.cell-missing rect { fill: var(--critical-bg); stroke: var(--critical); stroke-width: 1.5; }
.cell-missing path { stroke: var(--critical); stroke-width: 2; stroke-linecap: round; }
span.cell-missing { background: var(--critical-bg); border: 1.5px solid var(--critical); }
.growth-line { fill: none; stroke: var(--series-imdb); stroke-width: 2; }
.growth-point { fill: var(--series-imdb); stroke: var(--surface); stroke-width: 2; }

/* The top movies at a chosen half-life (app.js renderRanking): each movie
   slides to its new rank when the half-life changes. */
.ranking h3 { margin-bottom: 8px; }
.half-lives { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 6px; }
.half-lives button {
  font: inherit; font-size: 14px; font-weight: 600; padding: 6px 16px;
  border: 0; border-right: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer;
}
.half-lives button:last-child { border-right: 0; }
.half-lives button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.ranking-board {
  --row: 62px; position: relative; overflow: hidden;
  /* The top list, plus a zone below it where #21 to #23 fade out, so movies
     can be seen sliding out of the list and up into it. */
  height: calc((var(--rows) + 2.6) * var(--row));
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(var(--rows) * var(--row) - 6px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 calc(var(--rows) * var(--row) - 6px), transparent 100%);
}
.ranking-board::after {
  content: ""; position: absolute; left: 0; right: 0; top: calc(var(--rows) * var(--row) - 4px);
  border-top: 1px dashed var(--line);
}
.ranking-board .list-rank {
  position: absolute; left: 0; top: calc(var(--rank) * var(--row)); width: 1.6em; height: 54px;
  display: flex; align-items: center; justify-content: flex-end;
}
.ranking-card {
  position: absolute; left: 2.4em; right: 0; top: 0; height: 54px;
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  transform: translateY(calc(var(--rank) * var(--row)));
  background: var(--surface); border-radius: 4px; pointer-events: none;
}
.ranking-card.shown { pointer-events: auto; }
.ranking-board.moving .ranking-card { transition: transform 1s cubic-bezier(0.45, 0, 0.55, 1); }
.ranking-board.moving .ranking-card { box-shadow: 0 2px 8px rgb(0 0 0 / 0.12); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The version under each page's title. */
.site-header .version { margin: 4px 0 0; font-size: 12px; font-variant-numeric: tabular-nums; }
.site-header .version a { color: var(--muted); text-decoration: none; }
.site-header .version a:hover { text-decoration: underline; }

/* A tab for each source (app.js showSources). */
.source-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.source-tabs button {
  display: grid; text-align: left; gap: 1px; cursor: pointer;
  padding: 8px 16px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
.source-tabs button:hover { border-color: var(--muted); }
.source-tabs button[aria-selected="true"] { border-color: var(--text); background: var(--text); color: var(--bg); }
.tab-name { font-weight: 800; font-size: 16px; }
.tab-days { font-size: 13px; opacity: 0.8; font-variant-numeric: tabular-nums; }
.source[hidden] { display: none; }

/* Wikipedia's topics (app.js renderRanking): All, People, Politics… */
.topics { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.topics button {
  font: inherit; font-size: 13px; font-weight: 600; padding: 4px 11px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--text);
}
.topics button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* The history chart (app.js renderHistory): the palette's eight series
   colors, in their fixed order, stepped for each mode. */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}
.history-toggle {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px; border-radius: 6px;
  cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--muted); background: var(--surface); color: var(--text);
}
.history-toggle svg { width: 15px; height: 15px; flex: none; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 560px) {
  .history-toggle { padding: 0 7px; }
  .history-toggle-label { display: none; }
}
.history-toggle:hover { border-color: var(--text); }
/* Chosen: filled with its line's color (--pick), so the button, legend and line match. */
.history-toggle[aria-pressed="true"] { background: var(--pick); border-color: var(--pick); color: #fff; }
.history-toggle[aria-pressed="true"][data-slot="4"] { color: #0b0b0b; }   /* dark ink on yellow */
.history-toggle:disabled { opacity: 0.35; cursor: not-allowed; }
.visually-hidden .history-toggle { width: auto; height: auto; }
.history { margin: 20px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.history[hidden] { display: none; }
.history-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 8px; }
.history-head h3 { font-size: 17px; margin: 0; }
.history-head .list-note { margin: 0; }
.history-clear {
  margin-left: auto; font: inherit; font-size: 13px; padding: 3px 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text);
}
.history-legend { margin-bottom: 6px; }
.history-legend .legend-item { color: var(--text); }
.legend-remove {
  font: inherit; font-size: 15px; line-height: 1; padding: 0 4px; cursor: pointer;
  border: 0; background: none; color: var(--muted);
}
.legend-remove:hover { color: var(--text); }
.history-plot { position: relative; }
.history-chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.history-grid { stroke: var(--line); stroke-width: 1; }
.history-axis { stroke: var(--muted); stroke-width: 1; }
.history-tick { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.history-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.history-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.history-dot { stroke: var(--surface); stroke-width: 2; }
.history-hit { fill: transparent; cursor: crosshair; }
.history-tip {
  position: absolute; top: 8px; z-index: 2; min-width: 160px; max-width: 280px; pointer-events: none;
  display: grid; gap: 3px; padding: 8px 10px; font-size: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.14);
}
.history-tip[hidden] { display: none; }
.history-tip-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.history-tip-row > :nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-tip-value { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Search: chart any Wikipedia article (app.js renderSearch). */
.search { margin: 0 0 16px; max-width: 520px; }
.search-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.search-field { position: relative; }
.search input {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 15px; padding: 9px 12px;
  border: 1px solid var(--muted); border-radius: 8px; background: var(--surface); color: var(--text);
}
.search input:focus { outline: 2px solid var(--text); outline-offset: 1px; }
.search-list {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px 0;
  list-style: none; max-height: 340px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.16);
}
.search-list[hidden] { display: none; }
.search-list li { display: grid; padding: 7px 12px; cursor: pointer; }
.search-list li[aria-selected="true"], .search-list li:hover { background: var(--line); }
.search-title { font-weight: 600; font-size: 14px; }
.search-description { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-status { margin: 6px 0 0; font-size: 12px; color: var(--muted); min-height: 1em; }
.legend-state { color: var(--muted); font-size: 12px; }

/* A source without images (Polymarket): no poster column. */
.no-images .list-poster, .no-images .race-poster { display: none; }
.no-images .list li { grid-template-columns: 1.6em minmax(0, 1fr) auto; }
.no-images .ranking-card { grid-template-columns: minmax(0, 1fr) auto; }
.no-images .race-bar { grid-template-columns: minmax(0, 240px) 1fr; }
@media (max-width: 640px) {
  .no-images .race-bar { grid-template-columns: minmax(0, 140px) 1fr; }
}
