:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --ink: #1c1a17;
  --ink-2: #57534e;
  --muted: #78716c;
  --line: #e7e4df;
  --accent: #c2410c;

  /* Series colors (bars, swatches). Validated as a set for CVD separation. */
  --ai: #f05a12;
  --assisted: #d9a400;
  --human: #16a34a;

  /* Highlight tints: one per label x confidence, like Pangram's share page. */
  --ai-low: rgba(255, 84, 0, 0.10);
  --ai-medium: rgba(255, 84, 0, 0.19);
  --ai-high: rgba(255, 84, 0, 0.30);
  --assisted-low: rgba(234, 179, 8, 0.14);
  --assisted-medium: rgba(234, 179, 8, 0.24);
  --assisted-high: rgba(234, 179, 8, 0.36);
  --human-low: rgba(34, 197, 94, 0.10);
  --human-medium: rgba(34, 197, 94, 0.18);
  --human-high: rgba(34, 197, 94, 0.28);

  --chip-ai-bg: #fde7db;
  --chip-ai-ink: #9a3412;
  --chip-mixed-bg: #fdf0c8;
  --chip-mixed-ink: #854d0e;
  --chip-human-bg: #dcf3e3;
  --chip-human-ink: #166534;

  --radius: 14px;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151412;
    --surface: #1e1c1a;
    --ink: #f1efeb;
    --ink-2: #c4bfb8;
    --muted: #9a948c;
    --line: #34312d;
    --accent: #fb923c;
    --ai: #ff6a26;
    --assisted: #e5b400;
    --human: #22b858;
    --ai-low: rgba(255, 106, 38, 0.16);
    --ai-medium: rgba(255, 106, 38, 0.27);
    --ai-high: rgba(255, 106, 38, 0.40);
    --assisted-low: rgba(229, 180, 0, 0.16);
    --assisted-medium: rgba(229, 180, 0, 0.27);
    --assisted-high: rgba(229, 180, 0, 0.40);
    --human-low: rgba(34, 184, 88, 0.15);
    --human-medium: rgba(34, 184, 88, 0.25);
    --human-high: rgba(34, 184, 88, 0.37);
    --chip-ai-bg: #4a2412;
    --chip-ai-ink: #fdba8c;
    --chip-mixed-bg: #43360c;
    --chip-mixed-ink: #fcd965;
    --chip-human-bg: #143a22;
    --chip-human-ink: #86efac;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151412;
  --surface: #1e1c1a;
  --ink: #f1efeb;
  --ink-2: #c4bfb8;
  --muted: #9a948c;
  --line: #34312d;
  --accent: #fb923c;
  --ai: #ff6a26;
  --assisted: #e5b400;
  --human: #22b858;
  --ai-low: rgba(255, 106, 38, 0.16);
  --ai-medium: rgba(255, 106, 38, 0.27);
  --ai-high: rgba(255, 106, 38, 0.40);
  --assisted-low: rgba(229, 180, 0, 0.16);
  --assisted-medium: rgba(229, 180, 0, 0.27);
  --assisted-high: rgba(229, 180, 0, 0.40);
  --human-low: rgba(34, 184, 88, 0.15);
  --human-medium: rgba(34, 184, 88, 0.25);
  --human-high: rgba(34, 184, 88, 0.37);
  --chip-ai-bg: #4a2412;
  --chip-ai-ink: #fdba8c;
  --chip-mixed-bg: #43360c;
  --chip-mixed-ink: #fcd965;
  --chip-human-bg: #143a22;
  --chip-human-ink: #86efac;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
}
a { color: inherit; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

/* Masthead */
.masthead { border-bottom: 1px solid var(--line); background: var(--surface); }
.masthead-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; text-decoration: none; }
.brand span { color: var(--accent); }

/* Index */
.intro { padding: 40px 0 8px; max-width: 760px; }
.intro h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 12px; }
.intro p { color: var(--ink-2); margin: 0 0 10px; font-size: 16px; }

/* Name search */
.search-wrap { position: sticky; top: 0; z-index: 5; padding: 14px 0 6px; margin-top: 18px; background: var(--bg); }
.search {
  width: 100%; max-width: 480px; font: 16px/1.4 var(--sans); color: var(--ink);
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.search::placeholder { color: var(--muted); }
.modes { border: 0; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; }
.modes label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; color: var(--ink-2); }
.modes input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.modes label:has(input:checked) { color: var(--ink); font-weight: 600; }
.modes .n { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
mark { background: color-mix(in srgb, var(--assisted) 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
[hidden] { display: none !important; }

/* AI-use claims quoted under a text */
.claim { margin: -4px 18px 12px; padding: 8px 12px; border-left: 3px solid var(--line); font-size: 13.5px; }
.claim-q { margin: 0 0 3px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.claim-q b { font-weight: 600; }
.claim-a { margin: 0; font: italic 15px/1.5 var(--serif); color: var(--ink); }

.section-title { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 36px 0 10px; }
.race { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
/* Three shades step down the hierarchy: race, then candidate, then the plain text rows. Mixing in
   --line gives more contrast with the card in both color modes. */
.race-head { margin: 0; padding: 12px 18px; font-size: 13px; font-weight: 600; color: var(--ink-2); background: color-mix(in srgb, var(--line) 70%, var(--surface)); border-bottom: 1px solid var(--line); }
.cand + .cand { border-top: 1px solid var(--line); }
.cand-head { margin: 0; padding: 11px 18px; font-size: 17px; letter-spacing: -0.01em; background: color-mix(in srgb, var(--line) 35%, var(--surface)); }
.cand-note { margin-left: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.list > .race:first-child { margin-top: 18px; }
.doc-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 180px 72px 150px; align-items: center; gap: 16px;
  padding: 11px 18px; border-top: 1px solid var(--line); text-decoration: none;
}
.doc-row:hover, .doc-row:focus-visible { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); outline: none; }
.doc-row .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .w { color: var(--muted); font-size: 12px; margin-left: 6px; }
.doc-row .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
@media (max-width: 700px) {
  .doc-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .doc-row .t { grid-column: 1 / -1; white-space: normal; }
  .doc-row .bar { grid-column: 1 / -1; }
  .doc-row .pct { text-align: left; }
  .doc-row .chip { justify-self: end; }
}

/* Split bar */
.bar { display: flex; gap: 2px; height: 10px; border-radius: 4px; overflow: hidden; background: var(--line); }
.bar i { display: block; height: 100%; min-width: 2px; }
.bar .ai { background: var(--ai); }
.bar .assisted { background: var(--assisted); }
.bar .human { background: var(--human); }

.chip { display: inline-block; justify-self: start; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.ai { background: var(--chip-ai-bg); color: var(--chip-ai-ink); }
.chip.mixed { background: var(--chip-mixed-bg); color: var(--chip-mixed-ink); }
.chip.human { background: var(--chip-human-bg); color: var(--chip-human-ink); }

/* Document view */
.crumbs { padding: 22px 0 0; font-size: 13px; color: var(--muted); }
.crumbs { display: flex; flex-wrap: wrap; gap: 2px 6px; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs .crumb:last-child a { color: var(--muted); }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--muted); margin-left: 6px; }

/* Breadcrumb targets on the index */
.section-title, .race, .cand { scroll-margin-top: 16px; }
/* An inset outline: a race card clips anything outside a candidate block, and an
   outline paints over the rows' hover backgrounds where a box-shadow would not. */
.race.flash, .cand.flash { outline: 3px solid transparent; outline-offset: -3px; animation: flash 1.6s ease-out; }
.race.flash { border-radius: var(--radius); }
.section-title.flash { animation: flash-text 1.6s ease-out; }
@keyframes flash {
  0%, 30% { outline-color: color-mix(in srgb, var(--accent) 55%, transparent); }
  100% { outline-color: transparent; }
}
@keyframes flash-text {
  0%, 30% { color: var(--accent); }
  100% { color: var(--muted); }
}
.doc-head { padding: 10px 0 18px; }
.doc-head h1 { margin: 0 0 4px; font-size: clamp(22px, 3vw, 28px); letter-spacing: -0.02em; line-height: 1.2; }
.doc-head .sub { color: var(--ink-2); margin: 0; }
.origin { margin: 8px 0 0; font-size: 13px; }
.origin a { display: flex; align-items: baseline; gap: 6px; min-width: 0; max-width: 100%; width: fit-content; text-decoration: none; color: var(--accent); }
.origin b { flex: none; font-weight: 600; }
.origin span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.origin i { flex: none; font-style: normal; font-weight: 600; }
.origin a:hover b, .origin a:hover span { text-decoration: underline; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 16px; }
.tabs a { font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink-2); }
.tabs a[aria-current="page"] { border-color: var(--ink); color: var(--ink); font-weight: 600; }

.doc { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 28px; align-items: start; padding-bottom: 48px; }
@media (max-width: 900px) { .doc { grid-template-columns: minmax(0, 1fr); } .panel { order: -1; position: static !important; } }

.reader { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.reader-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink-2); user-select: none; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.text { padding: 22px 20px 30px; font: 17px/1.95 var(--serif); max-width: 74ch; overflow-wrap: anywhere; }
@media (min-width: 720px) { .text { padding: 30px 40px 40px; } }
.text .p { display: block; height: 0.7em; }

.seg { border-radius: 3px; padding: 3px 0; -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background-color .12s, box-shadow .12s; cursor: default; }
.seg:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.seg.ai.low { background: var(--ai-low); }
.seg.ai.medium { background: var(--ai-medium); }
.seg.ai.high { background: var(--ai-high); }
.seg.assisted.low { background: var(--assisted-low); }
.seg.assisted.medium { background: var(--assisted-medium); }
.seg.assisted.high { background: var(--assisted-high); }
.seg.human.low { background: var(--human-low); }
.seg.human.medium { background: var(--human-medium); }
.seg.human.high { background: var(--human-high); }
.seg.hot.ai { box-shadow: inset 0 -2px 0 var(--ai); }
.seg.hot.assisted { box-shadow: inset 0 -2px 0 var(--assisted); }
.seg.hot.human { box-shadow: inset 0 -2px 0 var(--human); }
.plain .seg { background: none !important; box-shadow: none !important; }

.panel { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.card .pred { color: var(--ink-2); margin: 6px 0 16px; font-size: 14px; }
.hero { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.hero b { font-size: 46px; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hero span { color: var(--ink-2); }
.card .bar { height: 12px; }
.legend { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; font-size: 13px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; }
.legend .n { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.meta { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.shade { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 6px; font-size: 12px; color: var(--ink-2); align-items: center; }
.shade .cell { height: 22px; border-radius: 4px; }
.shade .hd { text-align: center; color: var(--muted); }
.note { font-size: 13px; color: var(--ink-2); margin: 10px 0 0; }
.warn { border-left: 3px solid var(--assisted); padding-left: 10px; }

/* Tooltip */
.tip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 260px;
  background: var(--ink); color: var(--bg); border-radius: 8px; padding: 8px 10px; font: 12.5px/1.45 var(--sans);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
.tip b { font-weight: 600; }
.tip .k { opacity: 0.75; }
.tip-key { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tip-key li { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; }
.tip-key i { width: 14px; height: 10px; border-radius: 3px; }
.tip-key b { font-variant-numeric: tabular-nums; padding-left: 10px; }

.empty { padding: 60px 0; color: var(--ink-2); }
.footer { color: var(--muted); font-size: 13px; padding-top: 18px; padding-bottom: 36px; border-top: 1px solid var(--line); }
