:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --link: #1c5cab;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  /* Energy sources: fixed meaning across charts (checked for colour-blind separation) */
  --energy-wind: #2a78d6;
  --energy-solar: #eda100;
  --energy-hydro: #1fa5c4;
  --energy-bio: #3f8f2a;
  --energy-nuclear: #7a4fd0;
  --energy-other: #8c8c8c;
  --energy-gas: #eb6834;
  --energy-coal: #8e4a22;
  /* Parties: their own conventional colours (CDU/CSU black, SPD red, ...) */
  --party-union: #1f1f1f;
  --party-spd: #e3000f;
  --party-afd: #009ee0;
  --party-greens: #3f9a2a;
  --party-left: #be3075;
  --party-fdp: #d9ad00;
  --party-bsw: #6b2346;
  --party-other: #9a9a97;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --link: #86b6ef;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  --energy-wind: #3987e5;
  --energy-solar: #c98500;
  --energy-hydro: #1d93ad;
  --energy-bio: #4e9a35;
  --energy-nuclear: #a477e8;
  --energy-other: #757575;
  --energy-gas: #e0703c;
  --energy-coal: #93491f;
  --party-union: #e2e1dc;
  --party-spd: #f0444c;
  --party-afd: #2fb3ee;
  --party-greens: #5bb043;
  --party-left: #e0569a;
  --party-fdp: #f2c400;
  --party-bsw: #b05a86;
  --party-other: #6e6e6b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --link: #86b6ef;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --energy-wind: #3987e5;
  --energy-solar: #c98500;
  --energy-hydro: #1d93ad;
  --energy-bio: #4e9a35;
  --energy-nuclear: #a477e8;
  --energy-other: #757575;
  --energy-gas: #e0703c;
  --energy-coal: #93491f;
  --party-union: #e2e1dc;
  --party-spd: #f0444c;
  --party-afd: #2fb3ee;
  --party-greens: #5bb043;
  --party-left: #e0569a;
  --party-fdp: #f2c400;
  --party-bsw: #b05a86;
  --party-other: #6e6e6b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 16px/1.55 var(--font);
}
a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.4em; text-wrap: balance; }
p { margin: 0 0 0.8em; }
.muted { color: var(--text-muted); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* header / footer */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface-1); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text-primary); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; font-size: 17px; }
.brand-mark { width: 18px; height: 18px; border-radius: 4px; background: linear-gradient(to top, var(--series-1) 0 33%, var(--series-3) 33% 66%, var(--series-4) 66%); }
.nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: 15px; }
.nav a { color: var(--text-secondary); text-decoration: none; }
.nav a:hover { color: var(--text-primary); text-decoration: underline; }
.nav .lang { border: 1px solid var(--border); border-radius: 999px; padding: 1px 10px; }
.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 24px 0 40px; color: var(--text-secondary); font-size: 14px; }

/* hero & headings */
.hero { padding: 48px 0 24px; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); letter-spacing: -0.02em; }
.lede { font-size: clamp(17px, 2.2vw, 20px); color: var(--text-secondary); max-width: 46em; }
.hero-meta { color: var(--text-muted); font-size: 14px; }
.page-head { padding: 36px 0 12px; }
.page-head h1 { font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.01em; }
.crumb { margin: 24px 0 0; font-size: 15px; }
.prose { max-width: 44em; }
.prose h2 { font-size: 20px; margin-top: 1.4em; }

/* cards */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 8px 0 32px; }
.topic-card { padding: 20px; text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: border-color 0.15s; }
.topic-card:hover { border-color: var(--accent); }
.topic-card h2 { font-size: 19px; }
.topic-card p { color: var(--text-secondary); font-size: 15px; flex: 1; }
.topic-card .count { color: var(--link); font-size: 14px; font-weight: 600; }

.toc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.toc a { font-size: 13px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--text-secondary); background: var(--surface-1); }
.toc a:hover { color: var(--text-primary); border-color: var(--accent); }

.featured { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr)); gap: 16px; }
.chart-list { display: grid; gap: 20px; margin-top: 16px; }

.chart-card { margin: 0; padding: 20px 20px 14px; min-width: 0; scroll-margin-top: 72px; }
.chart-card h3 { font-size: 20px; }
.chart-card.compact h3 { font-size: 17px; }
.chart-card h3 a { color: var(--text-primary); text-decoration: none; }
.chart-card h3 a:hover { text-decoration: underline; }
.subtitle { color: var(--text-secondary); font-size: 14px; max-width: 52em; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--text-secondary); margin: 4px 0 6px; min-height: 4px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.year-chip { font-size: 12px; font-weight: 600; color: var(--text-secondary); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.plot { position: relative; min-height: 120px; }
.plot svg { display: block; max-width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.notes { margin-top: 10px; font-size: 13px; color: var(--text-secondary); }
.notes h4 { font-size: 13px; font-weight: 600; margin: 0 0 4px; color: var(--text-primary); }
.notes ol { margin: 0; padding-left: 1.6em; }
.notes li { margin: 2px 0; }
.note-when { font-weight: 600; color: var(--text-primary); }
.note-kind { color: var(--text-muted); }
.card-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px 16px; flex-wrap: wrap; border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.source { font-size: 12px; color: var(--text-muted); margin: 0; flex: 1 1 260px; }
.source a { color: var(--text-secondary); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button, .actions a {
  font: inherit; font-size: 12px; line-height: 1; padding: 7px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  cursor: pointer; text-decoration: none;
}
.actions button:hover, .actions a:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* tooltip */
.tooltip {
  position: absolute; top: 8px; pointer-events: none; z-index: 5;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); padding: 8px 10px; font-size: 12px; min-width: 150px;
}
.tooltip strong { display: block; margin-bottom: 4px; font-size: 13px; }
.tip-row { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tip-val { margin-left: auto; padding-left: 12px; color: var(--text-primary); font-variant-numeric: tabular-nums; font-weight: 600; }
.tip-note { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--grid); color: var(--text-secondary); max-width: 240px; white-space: normal; }
.crosshair { position: absolute; top: 18px; bottom: 28px; width: 1px; background: var(--text-muted); pointer-events: none; }

/* tables */
.table-scroll { overflow-x: auto; max-height: 420px; container-type: inline-size; }
.data-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.data-table th { position: sticky; top: 0; background: var(--surface-1); color: var(--text-secondary); font-weight: 600; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.page-head + .table-scroll { max-height: none; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
.data-table tr.noted td:first-child { font-weight: 600; }
.data-table tr.noted td:first-child, .data-table tr.note-row td { box-shadow: inset 3px 0 0 var(--text-muted); }
.data-table tr.note-row td { white-space: normal; color: var(--text-secondary); }
/* A note row spans every column, so in a table wider than the screen its text would
   wrap at the table's width and run off screen. Instead the row is a zero-width block
   (so it doesn't widen the first column) whose cell is as wide as the visible scroll
   area (100cqi of .table-scroll). */
.data-table tr.note-row { display: block; width: 0; }
.data-table tr.note-row td { display: block; width: 100cqi; box-sizing: border-box; }
.note-ref { display: inline-block; min-width: 1.4em; padding: 0 4px; border-radius: 4px; background: var(--grid); color: var(--text-primary); font-weight: 600; text-align: center; }

@media (max-width: 560px) {
  .chart-card { padding: 16px 12px 12px; }
  .header-inner { padding: 8px 0; }
  .nav { gap: 12px; font-size: 14px; }
}
