:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --text: #1d1f23;
  --muted: #6b7079;
  --line: #e6e3de;
  --accent: #2f6fd6;
  --accent-soft: #e7effc;
  --warn: #b56a00;
  --bad: #c2362f;

  --canon: #8fb996;
  --anime_canon: #5f95d8;
  --mixed: #e2b04a;
  --filler: #e0665c;
  --recap: #a07bd6;
  --unknown: #c9c6c0;

  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417;
    --panel: #1b1d21;
    --text: #e8e6e3;
    --muted: #9298a2;
    --line: #2c2f35;
    --accent: #7aa8f5;
    --accent-soft: #1e2a3d;
    --warn: #e2a33b;
    --bad: #f07a72;
    --canon: #5e8f66;
    --anime_canon: #4a7fc4;
    --mixed: #c99a37;
    --filler: #d0574d;
    --recap: #8a66c2;
    --unknown: #4a4c51;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.88em; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 2rem;
  padding: 0.8rem max(1.25rem, calc((100vw - 1180px) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.mark {
  display: inline-grid; place-items: center;
  width: 1.7rem; height: 1.7rem; margin-right: 0.35rem;
  border-radius: 7px; background: var(--accent); color: #fff; font-size: 0.95rem;
}
.top nav { display: flex; gap: 1.25rem; }
.top nav a { color: var(--muted); font-weight: 500; }
.top nav a[aria-current="page"], .top nav a:hover { color: var(--text); text-decoration: none; }

main { max-width: 1180px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
footer { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 0.4rem; letter-spacing: -0.015em; }
h2 { font-size: 1.2rem; margin: 2.5rem 0 1rem; display: flex; align-items: baseline; gap: 0.6rem; }
h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }
.more { margin-left: auto; font-size: 0.85rem; font-weight: 500; }
.lede { color: var(--muted); margin: 0 0 1.5rem; max-width: 70ch; }
.muted { color: var(--muted); font-weight: normal; }
.empty { color: var(--muted); padding: 2rem 0; }
.crumbs { margin: 0 0 0.25rem; font-size: 0.9rem; }
.meta { color: var(--muted); margin: 0 0 1.25rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; margin: 0 0 1.25rem; }
.stats > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; }
.stats dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stats dd { margin: 0.1rem 0 0; font-size: 1.75rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stats small { color: var(--muted); font-size: 0.8rem; }
.stats.small dd { font-size: 1.35rem; }

.bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--unknown); gap: 1px; }
.bar span { display: block; min-width: 2px; }
.hero .bar, main > .bar { height: 14px; }
.bar-cell { width: 26%; min-width: 120px; }
.bar-cell .bar { height: 8px; }

.legend { list-style: none; padding: 0; margin: 0.6rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; font-size: 0.85rem; color: var(--muted); }
.legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 3px; margin-right: 0.35rem; vertical-align: -1px; }

.t-canon { background: var(--canon); }
.t-anime_canon { background: var(--anime_canon); }
.t-mixed { background: var(--mixed); }
.t-filler { background: var(--filler); }
.t-recap { background: var(--recap); }
.t-unknown { background: var(--unknown); }

.tag { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--line); color: var(--muted); }
.tag.airing { background: var(--accent-soft); color: var(--accent); }
.tag.hiatus { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.tag.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tag.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.pill { display: inline-block; min-width: 1.3rem; padding: 0 0.4rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.72rem; font-weight: 700; text-align: center; }
.src { display: inline-block; margin-right: 0.3rem; padding: 0 0.4rem; border: 1px solid var(--line); border-radius: 5px; font-size: 0.75rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 0.9rem; }
th, td { padding: 0.55rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; background: color-mix(in srgb, var(--line) 35%, var(--panel)); }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text); }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.api td:first-child { white-space: nowrap; width: 1%; }
.shows td:nth-child(6), .shows td:nth-child(8) { white-space: nowrap; }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-bottom: 0.75rem; }
.tools input[type="search"] { flex: 1 1 280px; padding: 0.55rem 0.8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
.tools input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.tools label { color: var(--muted); font-size: 0.9rem; }

.run { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; margin-bottom: 0.75rem; }
.run.has-fail { border-left: 3px solid var(--bad); }
.run header { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.run time { font-weight: 600; }
.run .nums { margin: 0.4rem 0 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; color: var(--muted); font-size: 0.9rem; }
.run .nums b { color: var(--text); font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; margin-top: 0.5rem; }
.log { list-style: none; margin: 0.5rem 0 0; padding: 0.6rem 0.8rem; max-height: 22rem; overflow: auto; background: var(--bg); border-radius: 8px; font: 0.8rem/1.6 var(--mono); }
.log .fail { color: var(--bad); }

.toc { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.toc a { padding: 0.3rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font-size: 0.85rem; color: var(--text); }
.toc a:hover { border-color: var(--accent); text-decoration: none; }
.review td:nth-child(3) { white-space: nowrap; }

.season h3 { display: flex; gap: 0.4rem; }
.grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr)); gap: 3px; }
.grid li {
  display: grid; place-items: center; height: 1.9rem; border-radius: 5px;
  font: 600 0.72rem/1 var(--mono); color: rgba(0,0,0,0.62); cursor: default;
  font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) { .grid li { color: rgba(255,255,255,0.82); } }
.grid li.c-provisional { opacity: 0.55; outline: 1px dashed var(--muted); outline-offset: -2px; }
.grid li.c-conflict { box-shadow: inset 0 0 0 2px var(--bad); }
.grid li.c-overridden { box-shadow: inset 0 0 0 2px var(--text); }
.grid li:hover { transform: scale(1.12); position: relative; z-index: 1; }

.changes td { font-size: 0.85rem; }
.unlisted { columns: 3 16rem; padding-left: 1.1rem; margin: 0.75rem 0 0; font-size: 0.9rem; }
.unlisted li { break-inside: avoid; margin-bottom: 0.2rem; }
#unlisted details > summary { font-size: 1rem; color: var(--text); font-weight: 600; }

@media (max-width: 720px) {
  .top { gap: 1rem; }
  .top nav { gap: 0.8rem; font-size: 0.9rem; }
  .shows th:nth-child(4), .shows td:nth-child(4), .shows th:nth-child(6), .shows td:nth-child(6), .shows th:nth-child(8), .shows td:nth-child(8) { display: none; }
  h1 { font-size: 1.5rem; }
}
