/* Theme tokens keep controls and reading surfaces coherent while graph data colors stay categorical. */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111719;
  --panel: #191f22;
  --text: #e7ecec;
  --muted: #adb8ba;
  --faint: #839195;
  --line: #333d40;
  --mint: #9cccb5;
  --gold: #dfbf79;
  --blue: #86b9d1;
  --violet: #b3a4d1;

  --accent: #9bb9b7;
  --accent-strong: #bfd2cf;
  --on-accent: #152225;
  --surface: #191f22;
  --surface-raised: #20282b;
  --surface-inset: #141a1d;
  --surface-hover: #263033;
  --map-surface: #141b1e;
  --map-land: #263236;
  --map-border: #46565a;
  --map-grid: #29373a;
  --map-label-halo: #141b1e;
  --selection: #345052;
  --edge-stroke: #5c6568;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6f5;
  --panel: #fbfcfb;
  --text: #1d2a2f;
  --muted: #53646a;
  --faint: #738389;
  --line: #d7dfe0;

  /* Keep the map legend's category keys consistent across themes. */
  --mint: #9cccb5;
  --gold: #dfbf79;
  --blue: #86b9d1;
  --violet: #b3a4d1;

  --accent: #326d73;
  --accent-strong: #24585f;
  --on-accent: #ffffff;
  --surface: #fbfcfb;
  --surface-raised: #f1f5f4;
  --surface-inset: #f5f8f7;
  --surface-hover: #e9efee;
  --map-surface: #e9efef;
  --map-land: #d5dfe0;
  --map-border: #a7b5b7;
  --map-grid: #d1dcdd;
  --map-label-halo: #f7f9f8;
  --selection: #dce9e7;
  --edge-stroke: #b7c6ca;
}

html,
body {
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  color: var(--text);
}

button {
  background: var(--surface-raised);
  border-color: var(--line);
}

button:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline-color: var(--accent);
}

button[aria-pressed="true"],
.view-switch button[aria-pressed="true"],
.lenses button[aria-pressed="true"] {
  background: var(--selection);
  border-color: var(--accent);
  color: var(--text);
}

a,
.brand-mark,
.eyebrow,
.kind,
.group-context,
.bill strong,
.legislation-reader summary,
.more-evidence summary {
  color: var(--accent-strong);
}

a:hover {
  color: var(--text);
}

.topbar,
.inspector,
.search-area {
  background: var(--panel);
  border-color: var(--line);
}

.view-switch {
  border-color: var(--line);
}

.view-switch button {
  color: var(--muted);
}

.local-badge,
.local-badge i {
  color: var(--muted);
}

.local-badge i {
  background: var(--accent);
}

.map-shell {
  background: var(--map-surface);
}

.map-footer,
.muted,
.search-label,
.stat-grid span,
.source-list li,
.connection span,
.bill small,
.lawmaker-list small {
  color: var(--muted);
}

.search-input,
.map-controls button,
.lenses button,
.bill-filter select {
  background: var(--surface-inset);
  border-color: var(--line);
}

.search-input > span {
  color: var(--muted);
}

input {
  color: var(--text);
}

input::placeholder {
  color: var(--faint);
}

#search-results button,
.connection,
.actor-card,
.bill,
.lawmaker-list button {
  color: var(--text);
  border-color: var(--line);
}

#search-results button:hover,
.connection:hover,
.actor-card:hover,
.bill:hover,
.lawmaker-list button:hover {
  background: var(--surface-hover);
}

h2,
h3,
.relationship-heading,
.overview-title {
  color: var(--text);
}

h3,
#detail > p,
.bill .bill-title,
.fact,
.fact-list li,
.connection span,
.bill p,
.power-list p,
.relationship-reason,
.provision-list,
.legislative-timeline span {
  color: var(--muted);
}

.stat-grid div,
.section-rule,
.connection,
.actor-card,
.bill,
.lawmaker-list button,
.outcome-pill,
.legislation-reader,
.paper-card,
.jurisdiction-table,
.authority-table {
  border-color: var(--line);
}

.chip,
.outcome-badge,
.outcome-pill {
  color: var(--muted);
  background: var(--surface-inset);
}

.connection-type,
.connection-meta,
.source-number,
.connection em,
.disclosure-amount,
.candidate-amount,
.outcome-date {
  color: var(--accent);
}

.relationship-reason {
  color: var(--text) !important;
}

.tooltip-meta {
  color: var(--muted) !important;
}

.uncertainty {
  color: var(--muted);
  border-left-color: var(--accent);
}

.group-card,
.candidate-card,
.evidence-source,
.outcome-pill,
.legislation-reader,
.paper-card {
  background: var(--surface-raised);
  border-color: var(--line);
  box-shadow: none;
}

.group-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.group-dot {
  box-shadow: none;
}

.primary-action {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.primary-action:hover {
  color: var(--on-accent);
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.partner-pill {
  color: var(--text);
  background: var(--surface-raised);
  border-color: var(--line);
}

.partner-pill:hover {
  border-color: var(--accent);
}

.opposition .candidate-card {
  background: var(--surface-raised);
}

.opposition h3 {
  color: var(--muted);
}

.candidate-activity li {
  color: var(--muted);
  border-top-color: var(--line);
}

.power-list li {
  border-left-color: var(--line);
}

.law-text {
  color: var(--text);
  background: var(--surface-inset);
}

.review-stamp {
  color: var(--muted) !important;
}

.outcome-date {
  color: var(--accent) !important;
}

.legislative-timeline {
  border-left-color: var(--line);
}

.legislative-timeline li::before {
  background: var(--accent);
}

#tooltip {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 12px 30px rgb(0 0 0 / 18%);
  backdrop-filter: none;
}

.tooltip-kind,
.tooltip-title,
.tooltip-reason,
.tooltip-meta,
.tooltip-source,
.tooltip-instruction {
  color: var(--text);
}

.tooltip-instruction {
  border-top-color: var(--line);
}

#error {
  color: #fff;
  background: #783f38;
}

.geo-land {
  fill: var(--map-land);
  stroke: var(--map-border);
}

.geo-grid {
  stroke: var(--map-grid);
}

.geo-leader {
  stroke: var(--faint);
}

.cluster-circle {
  fill-opacity: 0.025;
  stroke-opacity: 0.28;
}

.country-circle {
  fill-opacity: 0.035;
  stroke-opacity: 0.48;
}

.cluster-label,
.country-label {
  fill: var(--muted);
}

.container-label {
  stroke: var(--map-label-halo);
}

.node-label {
  fill: var(--text);
  stroke: var(--map-label-halo);
  stroke-width: 3px;
  stroke-opacity: 0.92;
}

.node-metric {
  fill: var(--muted);
}

.node .bubble {
  filter: none;
}

.connection-flow {
  filter: none;
}

/* New reading views use the same calm surfaces as the map inspector. */
.assignment-content,
.lab-content {
  color: var(--text);
}

.paper-card {
  border: 1px solid var(--line);
  border-radius: 10px;
}

.layers-grid {
  color: var(--text);
}

.jurisdiction-table,
.authority-table {
  color: var(--text);
  border-color: var(--line);
}

.jurisdiction-table th,
.jurisdiction-table td,
.authority-table th,
.authority-table td {
  border-color: var(--line);
}

:root[data-theme="light"] .node-label {
  fill: #1e3034;
  stroke: var(--map-label-halo);
}

:root[data-theme="light"] .node:hover .bubble,
:root[data-theme="light"] .node:focus-visible .bubble,
:root[data-theme="light"] .node.selected .bubble {
  stroke: #26383d !important;
}

:root[data-theme="light"] .container-label {
  stroke: #f7f9f8;
}

:root[data-theme="light"] .cluster-label,
:root[data-theme="light"] .country-label {
  fill: #43575d;
}

:root[data-theme="light"] .cluster-circle {
  fill-opacity: 0.018;
  stroke-opacity: 0.34;
}

:root[data-theme="light"] .country-circle {
  fill-opacity: 0.025;
  stroke-opacity: 0.42;
}

:root[data-theme="light"] .outcome-badge.enacted {
  color: #365d40;
  background: #e7f0e8;
  border-color: #a9c0ad;
}

:root[data-theme="light"] .outcome-badge.vetoed,
:root[data-theme="light"] .outcome-badge.failed {
  color: #824b3e;
  background: #f6eae7;
  border-color: #d8b7ad;
}

:root[data-theme="light"] .outcome-badge.governor {
  color: #53646a;
}
