/* Shared semantic palette. Page styles retain their original light base colors. */
:root {
  color-scheme: light;
  --brand-fill: #29483d;
  --brand-hover: #48685b;
  --copper-fill: #b95f38;
  --header-bg: rgba(244,240,230,.96);
  --focus: #9a4828;
  --surface-soft: #f3f0e7;
  --input: #f8f6ef;
  --card-soft: #faf8f2;
  --selected: #f0f5f0;
  --surface-raised: #fffdf8;
  --track: #e3e5df;
  --field: #faf9f4;
  --error-bg: #f5dfda;
  --error-text: #78372d;
  --tint: #ebe6da;
  --neutral-bg: #eee8df;
  --positive-bg: #dfe9df;
  --positive-text: #29483d;
  --negative-bg: #f1e3dc;
  --negative-text: #6d3e2e;
  --tip-bg: #e8e2d3;
  --tip-text: #484535;
  --resolved-bg: #dce9df;
  --resolved-text: #29553b;
  --improved-bg: #e3ead8;
  --improved-text: #536427;
  --warning-bg: #f2ddd5;
  --warning-text: #8b4326;
  --problem-text: #7b3b25;
  --info-bg: #dbe7ec;
  --info-text: #244f61;
  --notice-bg: #f5e3da;
  --notice-text: #673b2b;
  --notice-border: #ddb59f;
  --trust-bg: #ece8df;
  --trust-text: #625f57;
  --pending-bg: #e9e4cb;
  --pending-text: #655d28;
  --note-text: #85503a;
  --subtle-text: #8a918c;
  --gradient-green: #d9e4dc;
  --gradient-paper: #f2eee3;
  --experience-gradient: #e3eadf;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #161e19;
  --paper-strong: #293229;
  --cream: #202b24;
  --ink: #f0f1e9;
  --muted: #b6c0b6;
  --sage: #a1c3ad;
  --sage-dark: #b8dbc6;
  --sage-light: #304638;
  --copper: #eeac89;
  --brand-fill: #29483d;
  --brand-hover: #365b48;
  --copper-fill: #874224;
  --line: rgba(193,213,195,.24);
  --shadow: 0 20px 50px rgba(0,0,0,.25);
  --header-bg: rgba(22,30,25,.96);
  --section-header-bg: rgba(22,30,25,.95);
  --surface-translucent: rgba(32,43,36,.8);
  --focus: #f2b48f;
  --surface-soft: #252e28;
  --input: #18221d;
  --card-soft: #222d26;
  --selected: #304438;
  --surface-raised: #202b24;
  --track: #435247;
  --field: #18221d;
  --error-bg: #492b29;
  --error-text: #ffc6b9;
  --tint: #2b342b;
  --neutral-bg: #343a30;
  --positive-bg: #293e30;
  --positive-text: #b8dbc6;
  --negative-bg: #422f29;
  --negative-text: #f2c2ac;
  --tip-bg: #38372a;
  --tip-text: #e5dfb9;
  --resolved-bg: #293e30;
  --resolved-text: #b8dbc6;
  --improved-bg: #343e29;
  --improved-text: #d4dfae;
  --warning-bg: #422e26;
  --warning-text: #f6c4ab;
  --problem-text: #f6c4ab;
  --info-bg: #263d46;
  --info-text: #b8dcea;
  --notice-bg: #422e26;
  --notice-text: #f6c4ab;
  --notice-border: #926d59;
  --trust-bg: #35372f;
  --trust-text: #d2d1c6;
  --pending-bg: #3c3927;
  --pending-text: #e4dca3;
  --note-text: #edb99f;
  --subtle-text: #abb9ae;
  --gradient-green: #2c4336;
  --gradient-paper: #253027;
  --experience-gradient: #293a2e;
}
/* These controls intentionally keep a light fill in both themes. */
.light-link, .latest-analysis a, .detail-link, .editorial-card > a { color: #29483d; }
.light-link:hover { background: #d9e4dc; }
.problem-link { color: #4c2d21; }
.brand-mark { color: #fffdf7; }
:root[data-theme="dark"] .method-grid article { background: var(--cream); }
:root[data-theme="dark"] .sp-data-table tbody tr:nth-child(even) { background: var(--paper-strong); }
:root[data-theme="dark"] .home-hero::before,
:root[data-theme="dark"] .search-stage::before { background: var(--sage-light); }
:root[data-theme="dark"] .workflow-card { border-color: var(--line); }
html body :is(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}
input, select, textarea { accent-color: var(--sage-dark); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Theme switch: native button keyboard behavior, stable accessible name. */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 12px; margin-left: 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--cream); color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { background: var(--sage-light); }
.theme-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: block; }
.theme-label { min-width: 46px; text-align: left; }
.theme-track { width: 30px; height: 18px; padding: 3px; border-radius: 999px; background: var(--muted); }
.theme-track::before { content: ""; display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--cream); }
[aria-checked="true"] .theme-track { background: var(--sage-dark); }
[aria-checked="true"] .theme-track::before { transform: translateX(12px); }
