/* Plain Economy keeps its forest-green, cream and gold identity in both themes. */
:root {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f0eee5;
  --muted: #c0c1b7;
  --paper: #171d19;
  --line: #475249;
  --green: #a7c6a8;
  --brand: #b2d0a3;
  --accent-red: #ffb4a6;
  --surface-green: #213b2c;
  --surface-red: #3b2726;
  --on-accent-red: #251714;
  --gold: #e6c878;
  --focus: var(--gold);
  --grid-minor: rgb(178 208 163 / 3.5%);
  --grid-major: rgb(178 208 163 / 7.5%);
}

html[data-theme="dark"] {
  background-color: var(--paper);
}

html[data-theme="dark"] body {
  background: transparent;
  color: var(--ink);
}

/* These controls use --ink as a light-theme background with white text. Keep
   their dark-theme foreground/background pair intentional and high contrast. */
html[data-theme="dark"] .skip-link {
  background-color: #222c25;
  color: var(--ink);
}

html[data-theme="dark"] .button {
  background-color: var(--brand);
  color: #171d19;
}

html[data-theme="dark"] .platform-rank {
  color: #171d19;
}

html[data-theme="dark"] .button:hover {
  background-color: var(--gold);
  color: #171d19;
}

html[data-theme="dark"] .hero-example,
html[data-theme="dark"] .topic-list > a:hover,
html[data-theme="dark"] .approach,
html[data-theme="dark"] th,
html[data-theme="dark"] .investment-notice,
html[data-theme="dark"] .market-load-prompt,
html[data-theme="dark"] .market-chart-links,
html[data-theme="dark"] .country-picker summary,
html[data-theme="dark"] .country-picker nav,
html[data-theme="dark"] .country-picker a:hover,
html[data-theme="dark"] .country-picker a[aria-current="page"],
html[data-theme="dark"] .platform-countries a,
html[data-theme="dark"] .platform-facts div,
html[data-theme="dark"] .platform-table th[scope="row"],
html[data-theme="dark"] .consent-banner,
html[data-theme="dark"] .consent-panel,
html[data-theme="dark"] .math-formula,
html[data-theme="dark"] .draft-banner {
  background-color: #222c25;
  color: var(--ink);
}

html[data-theme="dark"] .country-picker a:hover,
html[data-theme="dark"] .country-picker a[aria-current="page"] {
  background-color: #3b5543;
}

html[data-theme="dark"] .data-chart,
html[data-theme="dark"] .market-widget-panel,
html[data-theme="dark"] .scene-stats p,
html[data-theme="dark"] .bar-track,
html[data-theme="dark"] .budget-left,
html[data-theme="dark"] .key-figures p,
html[data-theme="dark"] .hero-news,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .site-theme-select {
  background-color: #222c25;
  color: var(--ink);
  border-color: var(--line);
}

/* A fallback for unstyled buttons only. Zero specificity lets component
   rules (pressed calendar chips, the footer's link-style button) win. */
:where(html[data-theme="dark"]) :where(button:not(.button)) {
  background-color: #222c25;
  color: var(--ink);
  border-color: var(--line);
}

html[data-theme="dark"] .quick-chart,
html[data-theme="dark"] .hero .quick-chart,
html[data-theme="dark"] .chart-income,
html[data-theme="dark"] .chart-indicators {
  --chart-ink: #f0eee5;
  background-color: #25312a;
  color: var(--chart-ink);
}

html[data-theme="dark"] .quick-chart figcaption,
html[data-theme="dark"] .guide-card.data-card .key-figures p,
html[data-theme="dark"] .key-figures p,
html[data-theme="dark"] .data-chart-subtitle {
  color: #c0c1b7;
}

html[data-theme="dark"] .budget-left strong,
html[data-theme="dark"] .article-body a,
html[data-theme="dark"] .wordmark,
html[data-theme="dark"] .footer-brand,
html[data-theme="dark"] .platform-total strong {
  color: #c3d9b7;
}

html[data-theme="dark"] .draft-banner {
  color: #f0d59b;
}

html[data-theme="dark"] .remember-box,
html[data-theme="dark"] .remember-box > strong {
  background-color: #26313a;
  color: #d4e1f0;
}

html[data-theme="dark"] .short-answer {
  background-color: #24352a;
}

html[data-theme="dark"] .short-answer strong {
  color: #b8d7b4;
}

html[data-theme="dark"] .scenario-table tbody th {
  background-color: #222c25;
}

html[data-theme="dark"] .data-chart .chart-svg text {
  fill: #f0eee5;
}

/* Precedents charts: the year at the end of each line keeps its green or red,
   lightened to read on the dark panel. */
html[data-theme="dark"] .precedent-chart .chart-svg text[fill="#2f7d4a"] {
  fill: #86c99a;
}
html[data-theme="dark"] .precedent-chart .chart-svg text[fill="#b5452b"] {
  fill: #ec9a80;
}

html[data-theme="dark"] .data-chart .chart-svg line,
html[data-theme="dark"] .data-chart .chart-svg path:not([stroke]),
html[data-theme="dark"] .data-chart .chart-svg rect[fill="#fff"],
html[data-theme="dark"] .data-chart .chart-svg rect[fill="#ffffff"] {
  stroke: #aeb8ad;
}

html[data-theme="dark"] .site-footer {
  background: #101512;
}

html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] select:focus-visible,
html[data-theme="dark"] input:focus-visible,
html[data-theme="dark"] textarea:focus-visible,
html[data-theme="dark"] summary:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.site-theme-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.site-theme-select {
  min-height: 40px;
  padding: 6px 30px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.site-theme-select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (max-width: 700px) {
  .site-theme-control {
    margin-left: auto;
  }
}

html[data-theme="dark"] .bar-track {
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0 calc(25% - 1px),
    rgb(240 238 229 / 16%) calc(25% - 1px) 25%
  );
}
html[data-theme="dark"] .budget-row + .budget-row .bar-track {
  background-image: repeating-linear-gradient(
    135deg,
    rgb(95 211 141 / 34%) 0 4px,
    transparent 4px 8px
  );
}
html[data-theme="dark"] .chart-legend .legend-toggle {
  background: none;
}
