:root { color-scheme: light; }
.topbar .header-actions { gap: 16px; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 2px;
  padding: 3px;
  border: 1px solid #dcdcdc;
  border-radius: 18px;
  background: #ededed;
  color:var(--ink);
}
.theme-toggle > span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; }
.theme-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .theme-light { color:var(--ink); background: #ffffff; box-shadow: 0 1px 3px #2b2b2b1a; }
.theme-toggle:hover { border-color: #9e9e9e; }

:root[data-theme="dark"] {
  color-scheme: dark;
  color:var(--ink);
  background: #151515;
  --ink:#f5f5f5;
  --muted:#f5f5f5;
  --line: #3a3a3a;
  --accent:#f5f5f5;
  --accent-light: #353535;
  --purple: #bfbfbf;
  --purple-light: #373737;
  --surface: #202020;
  --surface-raised: #282828;
  --subtle-line: #303030;
}
[data-theme="dark"] .topbar,
[data-theme="dark"] .sidebar { background: #1c1c1c; }
[data-theme="dark"] .brand img.logo-light { display: none; }
[data-theme="dark"] .brand img.logo-dark { display: block; }
[data-theme="dark"] .brand > span,
[data-theme="dark"] .external-arrow { color:var(--ink); }
[data-theme="dark"] .theme-toggle { background: #151515; border-color: #464646; color:var(--ink); }
[data-theme="dark"] .theme-toggle .theme-light { background: transparent; color:var(--ink); box-shadow: none; }
[data-theme="dark"] .theme-toggle .theme-dark { background: #3a3a3a; color:var(--ink); }
[data-theme="dark"] .theme-toggle:hover { border-color: #9c9c9c; }
[data-theme="dark"] .view-nav button,
[data-theme="dark"] .header-actions .methodology,
[data-theme="dark"] .text-button { color:var(--ink); }
[data-theme="dark"] .view-nav button.active,
[data-theme="dark"] .view-nav button:hover,
[data-theme="dark"] .header-actions .methodology:hover,
[data-theme="dark"] .text-button:hover { color:var(--ink); }
[data-theme="dark"] .view-nav button.active:after { background: #b5b5b5; }
[data-theme="dark"] .result-link { color:var(--ink); border-bottom-color: #686868; }
[data-theme="dark"] .result-link:hover { color:var(--ink); border-bottom-color: currentColor; }
[data-theme="dark"] select {
  color:var(--ink);
  background-color: var(--surface-raised);
  border-color: #474747;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%23f5f5f5' stroke-width='1.2'/%3E%3C/svg%3E");
}
[data-theme="dark"] .results-controls select { background-color: transparent; border-color: transparent; }
[data-theme="dark"] .title-quant-control select { background-color: transparent; border-color: transparent; }
[data-theme="dark"] .path-select { background: #303030; border-color: #555555; }
[data-theme="dark"] .path-select:hover { border-color: #999999; }
[data-theme="dark"] .quant-chip { color:var(--ink); border-color: #454545; }
[data-theme="dark"] .quant-chip.selected { color:var(--ink); background: #353535; border-color: #6c6c6c; }
[data-theme="dark"] .quant-chip:hover { border-color: #a5a5a5; }
[data-theme="dark"] .button,
[data-theme="dark"] .skip-link { color:var(--ink); background: var(--surface-raised); border-color: #474747; }
[data-theme="dark"] .button:hover,
[data-theme="dark"] .icon-button:hover { background: #333333; border-color: #6a6a6a; }
[data-theme="dark"] .chart-card { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .chart-card-head,
[data-theme="dark"] .chart-row { border-color: var(--subtle-line); }
[data-theme="dark"] .chart-title h3 { color:var(--ink); }
[data-theme="dark"] .chart-description,
[data-theme="dark"] .chart-legend,
[data-theme="dark"] .chart-legend .unit,
[data-theme="dark"] .results-controls label { color:var(--ink); }
[data-theme="dark"] .bar-line:hover .bar-fill { filter: brightness(1.2); }
[data-theme="dark"] .quant-label { color:var(--ink); }
[data-theme="dark"] .quant-label:hover b { color:var(--ink); }
[data-theme="dark"] .quant-label small,
[data-theme="dark"] .axis,
[data-theme="dark"] .missing-value,
[data-theme="dark"] footer,
[data-theme="dark"] footer a { color:var(--ink); }
[data-theme="dark"] .axis { border-color: var(--line); }
[data-theme="dark"] .sweep-empty,
[data-theme="dark"] .history-empty { color:var(--ink); }
[data-theme="dark"] .sweep-grid,
[data-theme="dark"] .history-grid { stroke: #3b3b3b; }
[data-theme="dark"] .sweep-axis,
[data-theme="dark"] .sweep-axis-title,
[data-theme="dark"] .history-axis,
[data-theme="dark"] .history-axis-title { fill:var(--ink); }
[data-theme="dark"] .sweep-point circle { stroke: var(--surface); }
[data-theme="dark"] .sweep-point .hit { stroke: none; }
[data-theme="dark"] .sweep-point:hover circle:not(.hit),
[data-theme="dark"] .sweep-point:focus-visible circle:not(.hit) { stroke: var(--plot-value); }
[data-theme="dark"] .history-legend-label { fill:var(--ink); }
[data-theme="dark"] .history-dot { stroke: var(--surface); }
[data-theme="dark"] .fa-off .history-dot { fill: var(--surface); stroke: var(--plot-off); }
[data-theme="dark"] .history-point.active .history-dot,
[data-theme="dark"] .history-point:focus-visible .history-dot { stroke: var(--plot-value); }
[data-theme="dark"] .empty-state { color:var(--ink); background: var(--surface); border-color: #555555; }
[data-theme="dark"] .empty-state h3,
[data-theme="dark"] .loading { color:var(--ink); }
[data-theme="dark"] .loading.error { color:var(--ink); }
[data-theme="dark"] dialog { color:var(--ink); background: var(--surface); border-color: #555555; box-shadow: 0 30px 100px #00000099; }
[data-theme="dark"] dialog::backdrop { background: #070707b3; }
[data-theme="dark"] .icon-button,
[data-theme="dark"] #dialog-body { color:var(--ink); }
[data-theme="dark"] #dialog-body h3,
[data-theme="dark"] #dialog-body dd { color:var(--ink); }
[data-theme="dark"] #dialog-body dt { color:var(--ink); }
[data-theme="dark"] #dialog-body a { color:var(--ink); }
[data-theme="dark"] #dialog-body dl { background: #1c1c1c; border-color: #404040; }
[data-theme="dark"] #dialog-body code { color:var(--ink); background: #2f2f2f; }
[data-theme="dark"] #dialog-body .record-group { border-color: #404040; }
@media (max-width: 580px) { .topbar .header-actions { gap: 8px; } }

:root[data-theme="dark"]{--plot-off:#f3b78f;--plot-value:#ffb27d;--plot-off-value:#d4b39c;--plot-track:#303030;--plot-tag-bg:#303030;--plot-tag-text:#f5f5f5}
