:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6e69;
  --line: #e3e2dc;
  --line-2: #d3d2cb;
  --accent: #2a78d6;
  --link: #1f63b8;
  --track: #ecebe6;
  --focus: #2a78d6;
  --l-paid_first: #1baf7a;
  --l-independent: #2a78d6;
  --l-via_service: #8a8983;
  --l-linked: #eda100;
  --l-sweeper: #4a3aa7;
  --l-owner_linked: #e34948;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --raised: #20201f;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9c9b92;
    --line: #2d2d2a;
    --line-2: #3a3a36;
    --accent: #3987e5;
    --link: #74aef0;
    --track: #262624;
    --focus: #74aef0;
    --l-paid_first: #199e70;
    --l-independent: #3987e5;
    --l-via_service: #6e6d68;
    --l-linked: #c98500;
    --l-sweeper: #9085e9;
    --l-owner_linked: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --raised: #20201f;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #9c9b92;
  --line: #2d2d2a;
  --line-2: #3a3a36;
  --accent: #3987e5;
  --link: #74aef0;
  --track: #262624;
  --focus: #74aef0;
  --l-paid_first: #199e70;
  --l-independent: #3987e5;
  --l-via_service: #6e6d68;
  --l-linked: #c98500;
  --l-sweeper: #9085e9;
  --l-owner_linked: #e66767;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

code, .mono { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--track); padding: 0.1em 0.35em; border-radius: 4px; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
h2 { font-size: 1.3rem; font-weight: 650; margin-bottom: 14px; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 1rem; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; }
.brand { color: var(--ink); font-weight: 650; text-decoration: none; display: flex; align-items: center; gap: 8px; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chain {
  font-size: 0.75rem; font-weight: 600; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px; padding: 1px 8px;
}
.topnav { display: flex; align-items: center; gap: 20px; font-size: 0.925rem; }
.theme-toggle {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  color: var(--ink-2); background: transparent; border: 1px solid var(--line-2); border-radius: 9px; cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-2); }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }
.theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.topnav a { color: var(--ink-2); text-decoration: none; }
.topnav a:hover { color: var(--ink); }

.hero {
  min-height: calc(82vh - 56px); min-height: calc(82svh - 56px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 56px 0 64px;
}
.hero h1 { font-size: clamp(2.1rem, 5.6vw, 3.4rem); font-weight: 700; letter-spacing: -0.03em; }
.lede { color: var(--ink-2); font-size: 1.15rem; margin: 14px 0 36px; }
.has-agent .hero { min-height: 0; padding: 40px 0 8px; }
.has-agent .hero h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); }
.has-agent .lede { margin-bottom: 24px; }

.search { position: relative; width: 100%; max-width: 580px; margin: 0 auto; text-align: left; scroll-margin-top: 72px; }
.search input {
  width: 100%; height: 52px; padding: 0 16px; scroll-margin-top: 72px;
  font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--raised); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.results {
  position: absolute; left: 0; right: 0; top: 58px; z-index: 10;
  list-style: none; margin: 0; padding: 6px;
  background: var(--raised); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.14);
  max-height: 360px; overflow-y: auto;
}
.results li { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.results li[aria-selected="true"], .results li:hover { background: var(--track); }
.results .rid { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); flex: none; }
.results .rname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .rnote { font-size: 0.85rem; color: var(--muted); flex: none; }
.search-status { min-height: 1.4em; margin: 8px 0 0; font-size: 0.875rem; color: var(--muted); text-align: center; }

.chips { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 0; font-size: 0.9rem; color: var(--muted); }
.chips button {
  font: inherit; font-size: 0.875rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chips button:hover { border-color: var(--accent); }
.chips button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.agent {
  scroll-margin-top: 72px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; margin: 24px 0 8px;
}
.agent:empty { display: none; }
.agent-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.eyebrow { font-size: 0.85rem; color: var(--muted); margin: 0 0 4px; overflow-wrap: anywhere; }
.agent h2 { font-size: 1.6rem; margin: 0; overflow-wrap: anywhere; }
.agent-actions { display: flex; gap: 8px; flex: none; }
.btn {
  font: inherit; font-size: 0.85rem; color: var(--ink-2);
  background: transparent; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { color: var(--ink); border-color: var(--ink-2); }

.contrast { display: flex; align-items: flex-start; gap: 20px; margin: 22px 0 18px; }
.contrast > div { display: grid; }
.contrast strong { font-size: 2.4rem; font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; }
.contrast span { font-size: 0.95rem; color: var(--ink-2); }
.contrast small { font-size: 0.8rem; color: var(--muted); }
.contrast .backed strong { color: var(--accent); }
.contrast .arrow { font-size: 1.6rem; line-height: 1; color: var(--muted); margin-top: 0.4rem; }

.breakdown { margin: 0 0 16px; }
.breakdown .stack { margin-bottom: 10px; }
.verdict { margin: 0 0 22px; padding-left: 1.1em; max-width: 70ch; color: var(--ink-2); }
.verdict li + li { margin-top: 2px; }

.group-title { font-size: 1rem; margin: 0 0 10px; }
.sources { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.sources + .sources-more { margin-top: 10px; }
.source + .source { border-top: 1px solid var(--line); }
.source summary {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; align-items: center;
  padding: 11px 16px; cursor: pointer; list-style: none;
}
.source summary::-webkit-details-marker { display: none; }
.source summary:hover { background: color-mix(in srgb, var(--track) 55%, transparent); }
.src-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.src-name::before { content: "+"; width: 0.8em; color: var(--muted); font-family: var(--mono); }
.source details[open] .src-name::before { content: "−"; }
.src-size { font-size: 0.9rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.src-count { font-size: 0.875rem; color: var(--muted); text-align: right; white-space: nowrap; }
.src-link { grid-column: 1 / -1; font-size: 0.825rem; color: var(--muted); padding-left: calc(0.8em + 10px); overflow-wrap: anywhere; }
.src-body { padding: 0 16px 16px; }
.src-body h4 { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin: 14px 0 6px; }
.src-body .btn { margin-top: 10px; }
.also { font-size: 0.875rem; color: var(--ink-2); margin: 6px 0 0; }
.table-wrap { overflow-x: auto; }
.note { color: var(--muted); font-weight: 400; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tags-cell { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }

.empty { border: 1px dashed var(--line-2); border-radius: 12px; padding: 18px; color: var(--ink-2); margin: 0; }

.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.l-paid_first { --c: var(--l-paid_first); }
.l-independent { --c: var(--l-independent); }
.l-via_service { --c: var(--l-via_service); }
.l-linked { --c: var(--l-linked); }
.l-sweeper { --c: var(--l-sweeper); }
.l-owner_linked { --c: var(--l-owner_linked); }
.label-chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 0.8rem; font-weight: 500; color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 1px 9px;
}

.stack { display: flex; gap: 2px; width: 100%; min-width: 0; }
.stack .seg { flex-basis: 0; min-width: 3px; background: var(--c); }
.stack .seg:first-child { border-radius: 4px 0 0 4px; }
.stack .seg:last-child { border-radius: 0 4px 4px 0; }
.stack .seg:only-child { border-radius: 4px; }
.stack-sm .seg { height: 10px; }
.stack-lg .seg { height: 18px; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; font-size: 0.85rem; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .count { color: var(--muted); font-variant-numeric: tabular-nums; }

.section { padding: 56px 0 0; }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0 0; }
.facts div { display: flex; flex-direction: column-reverse; justify-content: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.facts dd { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.facts dt { font-size: 0.85rem; color: var(--ink-2); }

.chart { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px 18px; }
.chart figcaption { font-weight: 600; margin-bottom: 12px; }
.chart .stack { margin-bottom: 12px; }

.top-head, .top-list a {
  display: grid; grid-template-columns: 2rem minmax(0, 1fr) minmax(0, 1.3fr) 9rem; gap: 4px 16px; align-items: center;
}
.top-head { padding: 0 16px 6px; font-size: 0.8rem; color: var(--muted); }
.top-head span:last-child { text-align: right; white-space: nowrap; }
.top-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.top-list li + li { border-top: 1px solid var(--line); }
.top-list a { padding: 10px 16px; color: inherit; text-decoration: none; }
.top-list a:hover { background: color-mix(in srgb, var(--track) 55%, transparent); }
.top-rank { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.top-name { min-width: 0; display: grid; }
.top-name strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-name small { font-size: 0.8rem; color: var(--muted); }
.top-share { text-align: right; font-weight: 650; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.key { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 24px; }
.key li { display: flex; align-items: baseline; gap: 8px; font-size: 0.925rem; }
.key .swatch { transform: translateY(1px); }
.key strong { font-weight: 600; white-space: nowrap; }
.key span:last-child { color: var(--ink-2); }
.fine { font-size: 0.875rem; color: var(--muted); max-width: 70ch; }

.tip {
  position: fixed; z-index: 30; pointer-events: none; display: grid; gap: 1px;
  background: var(--raised); color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 10px; font-size: 0.825rem; box-shadow: 0 8px 24px rgb(0 0 0 / 0.14); white-space: nowrap;
}
.tip strong { font-weight: 600; }
.tip span { color: var(--ink-2); }

.footer { border-top: 1px solid var(--line); margin-top: 56px; padding: 24px 0 40px; font-size: 0.85rem; color: var(--muted); }
.footer p { margin: 0 0 6px; }
.footer a { color: var(--ink-2); }
.footer p a + a { margin-left: 6px; }

@media (max-width: 760px) {
  .topnav a:not([data-repo-link]) { display: none; }
  .topnav { gap: 14px; }
  .hero { min-height: calc(74svh - 56px); padding: 40px 0 48px; }
  .agent { padding: 18px; border-radius: 14px; }
  .contrast strong { font-size: 2rem; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-head { display: none; }
  .top-list a { grid-template-columns: 1.6rem minmax(0, 1fr) auto; }
  .top-list .stack { grid-column: 2 / -1; grid-row: 2; }
  .top-share::after { content: " independent"; font-size: 0.8rem; font-weight: 400; color: var(--muted); }
  .results .rnote { display: none; }
}

@media (max-width: 420px) {
  .brand { font-size: 0.875rem; }
  .chain { display: none; }
  .topbar-inner, .topnav { gap: 10px; }
  .theme-toggle { width: 30px; height: 30px; }
  .agent-head { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
