/* ============================================================
   Frequenzwache — dashboard styles
   Palette from the validated dataviz reference (see palette.md).
   Colour roles are theme-swapped in one place; the body is written
   against roles, never raw hex.
   ============================================================ */
.viz-root {
  color-scheme: light;
  --page:           #f9f9f7;
  --page-2:         #efeee9;
  --surface-1:      #fcfcfb;
  --surface-2:      #f2f1ec;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --muted:          #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --shadow:         rgba(11,11,11,0.10);

  --series-1:       #2a78d6; /* blue   — consumption */
  --series-violet:  #4a3aa7; /* violet — production  */

  /* synchronous-area identity — Continental Europe / Nordic / Great Britain
     as red / green / blue. Validated as a categorical triad on the light chart
     surface #fcfcfb (dataviz validator: all six checks pass; worst adjacent
     CE↔Nordic CVD ΔE 8.8 deutan, contrast all ≥3:1). */
  --area-ce:        #c62828; /* Continental Europe — red   */
  --area-nordic:    #37a548; /* Nordic (Skandinavien) — green */
  --area-gb:        #2a78d6; /* Great Britain — blue  */

  --g-renewable:    #008300;
  --g-nuclear:      #2a78d6;
  --g-fossil:       #e34948;
  --g-storage:      #898781;
  --good:           #006300;

  /* per-source hues (light) — one own colour per generation type.
     Ordered clean→dirty; adjacent pairs in that stack validated CVD-safe
     (dataviz validator, light surface #fcfcfb: all six checks pass). */
  --src-wind_onshore:       #17a398;
  --src-wind_offshore:      #2f66c8;
  --src-nuclear:            #c0569e;
  --src-hydro:              #5cc4e0;
  --src-pumped_storage_gen: #4a46a0;
  --src-other_renewable:    #3f8a2c;
  --src-solar:              #dc9e0a;
  --src-biomass:            #5c7a1a;
  --src-gas:                #ee7e33;
  --src-other_conventional: #b5403a;
  --src-hard_coal:          #c08339;
  --src-lignite:            #84400f;

  /* carbon meter gradient stops */
  --c-clean:        #008300;
  --c-lowmid:       #6faf2a;
  --c-mid:          #eda100;
  --c-high:         #eb6834;
  --c-dirty:        #d03b3b;

  /* cross-border flow direction (light) */
  --flow-out:       #17a37a; /* the centre country exports */
  --flow-in:        #e0872a; /* the centre country imports */
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .viz-root {
    color-scheme: dark;
    --page:           #0d0d0d;
    --page-2:         #17110f;
    --surface-1:      #1a1a19;
    --surface-2:      #232322;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --muted:          #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255,255,255,0.10);
    --shadow:         rgba(0,0,0,0.45);
    --series-1:       #3987e5;
    --series-violet:  #9085e9;
    /* area triad, stepped for the dark surface #1a1a19 (validator: all pass,
       CE↔Nordic CVD ΔE 8.1 deutan). */
    --area-ce:        #d4362c;
    --area-nordic:    #3cae52;
    --area-gb:        #3987e5;
    --g-renewable:    #12a012;
    --g-nuclear:      #3987e5;
    --g-fossil:       #e66767;
    --g-storage:      #a3a29a;
    --good:           #0ca30c;
    --flow-out:       #22c08f;
    --flow-in:        #f0a441;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --page:           #0d0d0d;
  --page-2:         #17110f;
  --surface-1:      #1a1a19;
  --surface-2:      #232322;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --muted:          #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255,255,255,0.10);
  --shadow:         rgba(0,0,0,0.45);
  --series-1:       #3987e5;
  --series-violet:  #9085e9;
  /* area triad, stepped for the dark surface #1a1a19 (validator: all pass,
     CE↔Nordic CVD ΔE 8.1 deutan). */
  --area-ce:        #d4362c;
  --area-nordic:    #3cae52;
  --area-gb:        #3987e5;
  --g-renewable:    #12a012;
  --g-nuclear:      #3987e5;
  --g-fossil:       #e66767;
  --g-storage:      #a3a29a;
  --good:           #0ca30c;
  /* per-source hues (dark) — same twelve entities, stepped for the dark
     surface #1a1a19; adjacent-stack pairs validated CVD-safe there. */
  --src-wind_onshore:       #1f9e93;
  --src-wind_offshore:      #4d84e0;
  --src-nuclear:            #c0568f;
  --src-hydro:              #33a2c0;
  --src-pumped_storage_gen: #6f60cc;
  --src-other_renewable:    #2f9160;
  --src-solar:              #b3841a;
  --src-biomass:            #5c7016;
  --src-gas:                #d0742f;
  --src-other_conventional: #a83a3a;
  --src-hard_coal:          #bd8236;
  --src-lignite:            #8f4e1c;
  --flow-out:       #22c08f;
  --flow-in:        #f0a441;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body.fs-open { overflow: hidden; }
body {
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

/* ---- aurora background (tinted by carbon intensity) ---- */
.aurora {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: var(--page);
  transition: background .8s ease;
}
.aurora::before, .aurora::after {
  content: ""; position: absolute; border-radius: 50%;
  filter: blur(70px); opacity: 0.55;
  background: var(--aur, #008300);
  transition: background 1.2s ease;
}
.aurora::before {
  width: 60vw; height: 60vw; max-width: 640px; max-height: 640px;
  top: -14vw; right: -12vw;
  animation: drift1 26s ease-in-out infinite alternate;
}
.aurora::after {
  width: 52vw; height: 52vw; max-width: 560px; max-height: 560px;
  bottom: -18vw; left: -14vw;
  background: var(--aur2, #2a78d6);
  animation: drift2 32s ease-in-out infinite alternate;
}
@keyframes drift1 { from { transform: translate(0,0) scale(1); } to { transform: translate(-6vw,5vw) scale(1.15); } }
@keyframes drift2 { from { transform: translate(0,0) scale(1); } to { transform: translate(7vw,-4vw) scale(1.2); } }

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(28px + env(safe-area-inset-bottom));
}
h1, h2 { margin: 0; }
a { color: var(--series-1); }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 18px 2px 10px; position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--page) 68%, transparent);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 30px; line-height: 1; filter: drop-shadow(0 2px 6px var(--shadow)); }
.brand-txt h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.015em; }
.brand-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 7px; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent);
  animation: ping 2.4s ease-out infinite;
}
@keyframes ping {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.icon-btn {
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); width: 40px; height: 40px; border-radius: 12px;
  font-size: 18px; cursor: pointer; display: grid; place-items: center;
  transition: transform .12s;
}
.icon-btn:active { transform: scale(0.92); }

/* language picker + theme toggle */
.top-actions { display: flex; align-items: center; gap: 8px; }
.lang-wrap {
  display: inline-flex; align-items: center; gap: 6px; height: 40px;
  padding: 0 10px 0 12px; border: 1px solid var(--border);
  background: var(--surface-1); border-radius: 12px; cursor: pointer;
}
.lang-ico { font-size: 15px; line-height: 1; opacity: 0.85; }
.lang-select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  color: var(--text-primary); font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 0 2px; max-width: 8.5em; line-height: 40px;
}
.lang-select:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; border-radius: 6px; }
.lang-select option { color: #111; }

/* ---- controls ---- */
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 16px; }
.segmented {
  display: inline-flex; background: var(--surface-2); border-radius: 12px;
  padding: 3px; gap: 2px; border: 1px solid var(--border);
}
.seg {
  border: 0; background: transparent; color: var(--text-secondary);
  font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 9px;
  cursor: pointer; white-space: nowrap; font-family: inherit; min-height: 36px;
  transition: color .15s;
}
.seg[aria-pressed="true"] {
  background: var(--surface-1); color: var(--text-primary);
  box-shadow: 0 1px 2px var(--shadow);
}

/* ---- status / errors ---- */
.status {
  padding: 12px 14px; border-radius: 12px; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-secondary); margin-bottom: 14px;
}
.status.error { color: var(--c-dirty); }

/* ---- layout / cards ---- */
.content { display: flex; flex-direction: column; gap: 14px; }
.content[aria-busy="true"] { opacity: 0.6; }
.card {
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 16px;
  box-shadow: 0 1px 2px var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; font-weight: 700; }
.card-hint { font-size: 11.5px; color: var(--muted); text-align: end; }
/* title + a dynamic chip (e.g. the shown time window) grouped on the left */
.card-head-left { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
.fq-window {
  font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap;
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; line-height: 1.7;
}
.fq-window:empty { display: none; }

/* staggered reveal on first paint */
.reveal { opacity: 0; transform: translateY(10px); animation: rise .6s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---- hero (radial gauge) ---- */
.hero {
  background:
    radial-gradient(130% 150% at 100% 0%, color-mix(in srgb, var(--heroAccent, var(--muted)) 20%, transparent), transparent 62%),
    color-mix(in srgb, var(--surface-1) 88%, transparent);
  overflow: hidden;
}
.hero-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hero-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; }
.hero-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hero-grid {
  display: grid; grid-template-columns: minmax(0,1fr); gap: 6px; align-items: center;
  margin-top: 6px;
}
.gauge-wrap { position: relative; width: 100%; max-width: 340px; margin: 0 auto; }
.gauge-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.gauge-center {
  position: absolute; left: 50%; top: 60%; transform: translate(-50%,-50%);
  text-align: center; width: 78%;
}
.gauge-value {
  font-size: 58px; font-weight: 800; line-height: 0.9; letter-spacing: -0.03em;
  color: var(--heroAccent, var(--text-primary)); transition: color .5s;
}
.gauge-unit { font-size: 13px; color: var(--text-secondary); font-weight: 600; margin-top: 2px; }
.gauge-unit .unit-sub { color: var(--muted); }
.gauge-badge {
  display: inline-block; margin-top: 9px; padding: 5px 13px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; color: #fff;
  background: var(--heroAccent, var(--muted)); white-space: nowrap;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--heroAccent, var(--muted)) 40%, transparent);
}
.gauge-seg { stroke-linecap: butt; transition: opacity .35s ease; }
/* value marker riding the rim — coloured + softly glowing, no centre needle */
.gauge-knob { filter: drop-shadow(0 0 5px var(--knob)); }
.gauge-tick { stroke: var(--axis); stroke-width: 1.5; }
.gauge-ticklabel { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }

.hero-foot {
  display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center;
  margin-top: 6px; font-size: 12.5px; color: var(--text-secondary);
}
.hero-foot .hf { display: inline-flex; align-items: center; gap: 6px; }
.hero-foot strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }
/* live-source health pill: green dot = primary feed, red = fallback/degraded */
.hero-foot .hf-src::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--good); flex: none;
}
.hero-foot .hf-src.warn { color: var(--c-dirty); }
.hero-foot .hf-src.warn::before { background: var(--c-dirty); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--c-dirty); }     /* more CO2 = bad */
.delta.down { color: var(--good); }        /* less CO2 = good */

/* ---- stat tiles with sparklines ---- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile {
  position: relative; overflow: hidden;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  border: 1px solid var(--border); border-radius: 16px; padding: 13px 14px;
  display: flex; flex-direction: column; gap: 3px; box-shadow: 0 1px 2px var(--shadow);
}
.tile-label { font-size: 11.5px; color: var(--text-secondary); font-weight: 600; }
.tile-value { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 11px; color: var(--muted); }
.tile-spark { width: 100%; height: 26px; margin-top: 4px; display: block; overflow: visible; }
.tile-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.tile-bar-fill { height: 100%; border-radius: 999px; width: 0; transition: width .9s cubic-bezier(.2,.7,.3,1); }
.tile-bar-fill[data-kind="renew"] { background: var(--g-renewable); }
.tile-bar-fill[data-kind="low"] { background: var(--series-1); }

/* ---- donut + legend split ---- */
.split { display: grid; grid-template-columns: minmax(0,1fr); gap: 14px; align-items: center; }
.donut-wrap { position: relative; width: 200px; max-width: 62vw; margin: 2px auto; aspect-ratio: 1; }
.donut-wrap svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); overflow: visible; }
.donut-seg { transition: stroke-dashoffset 1s cubic-bezier(.2,.7,.3,1), stroke-dasharray 1s cubic-bezier(.2,.7,.3,1); }
.donut-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.donut-center .dc-v { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.donut-center .dc-l { font-size: 11px; color: var(--text-secondary); font-weight: 600; margin-top: 1px; }
.grouplist { display: flex; flex-direction: column; gap: 8px; }
.grouprow { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 9px; }
.grouprow .gsw { width: 12px; height: 12px; border-radius: 4px; }
.grouprow .gl { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.grouprow .gv { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.grouprow .gv small { color: var(--muted); font-weight: 600; }

/* ---- stats strip (mini figures) ---- */
.stripgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.figure {
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  border: 1px solid var(--border); border-radius: 16px; padding: 13px 14px;
  box-shadow: 0 1px 2px var(--shadow); display: flex; flex-direction: column; gap: 3px;
}
.figure .fic { font-size: 17px; line-height: 1; }
.figure .flabel { font-size: 11.5px; color: var(--text-secondary); font-weight: 600; }
.figure .fvalue { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.figure .fsub { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.figure.accent-clean .fvalue { color: var(--good); }
.figure.accent-dirty .fvalue { color: var(--c-dirty); }

/* ---- ranked mix bars ---- */
.mix-bars { display: flex; flex-direction: column; gap: 8px; }
.mixrow { display: grid; grid-template-columns: 104px 1fr auto; align-items: center; gap: 10px; }
.mixrow .mlabel { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.mixrow .mdot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.mixrow .mtrack { height: 16px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.mixrow .mfill { height: 100%; border-radius: 6px; min-width: 3px; width: 0; transition: width .9s cubic-bezier(.2,.7,.3,1); }
.mixrow .mval {
  font-size: 12px; color: var(--text-primary); font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 62px; text-align: end;
}
.mixrow .mval small { color: var(--muted); font-weight: 600; }

/* ---- legend ---- */
.legend { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 8px; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; }
.legend .swatch.line { height: 3px; border-radius: 2px; width: 16px; }

/* ---- charts ---- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axisline { stroke: var(--axis); stroke-width: 1; }
.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.1s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---- equivalences ---- */
.equiv { display: grid; grid-template-columns: 1fr; gap: 11px; }
.eq {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px;
}
.eq .eqi { font-size: 24px; line-height: 1; }
.eq .eqt { font-size: 13px; color: var(--text-secondary); line-height: 1.35; }
.eq .eqt strong { color: var(--text-primary); font-variant-numeric: tabular-nums; font-size: 15px; }

/* ---- tooltip ---- */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 6px 24px var(--shadow); min-width: 140px; color: var(--text-primary);
}
.tooltip .tt-time { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tooltip .tt-row + .tt-row { margin-top: 3px; }
.tooltip .tt-k { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tooltip .tt-sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tooltip .tt-v { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- click-to-fullscreen plots ---- */
/* every plot is expandable: a corner ⤢ affordance (CSS ::after so it survives
   the chart re-renders that wipe the container's innerHTML) */
.expandable { position: relative; cursor: zoom-in; }
.expandable:focus-visible { outline: 2px solid var(--series-1); outline-offset: 3px; border-radius: 12px; }
.expandable::after {
  content: "⤢"; position: absolute; top: 6px; right: 6px; z-index: 3; pointer-events: none;
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  font-size: 14px; line-height: 1; color: var(--text-secondary);
  background: color-mix(in srgb, var(--surface-1) 80%, transparent);
  border: 1px solid var(--border); box-shadow: 0 1px 2px var(--shadow);
  opacity: 0; transform: scale(.9); transition: opacity .15s, transform .15s;
}
.expandable:hover::after,
.expandable:focus-visible::after { opacity: 1; transform: none; }
@media (hover: none) { .expandable::after { opacity: .7; transform: none; } }

.fs {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--page) 80%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: env(safe-area-inset-top) 16px calc(18px + env(safe-area-inset-bottom));
  animation: fsIn .2s ease;
}
@keyframes fsIn { from { opacity: 0; } to { opacity: 1; } }
.fs[hidden] { display: none; }
.fs-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px 8px; }
.fs-title { font-size: 16px; font-weight: 800; letter-spacing: -0.015em; }
.fs-legend { display: flex; flex-wrap: wrap; gap: 10px 12px; padding: 2px 2px 8px; }
.fs-legend:empty { display: none; }
.fs-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.fs-body .chart { width: 100%; }
.fs-body .chart svg { width: 100%; height: auto; max-height: 100%; }
/* cloned vector plots scale up via their viewBox */
.fs-scale { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.fs-scale .donut-wrap { width: min(72vh, 88vw); max-width: none; margin: 0; }
.fs-scale .donut-center .dc-v { font-size: clamp(34px, 7vh, 72px); }
.fs-scale .donut-center .dc-l { font-size: clamp(13px, 1.8vh, 20px); }
.fs-scale .gauge-wrap { width: min(84vh, 96vw); max-width: none; }
.fs-scale.fs-bars { display: block; overflow: auto; align-items: stretch; }
.fs-scale.fs-bars .mix-bars { max-width: 1000px; margin: 0 auto; gap: 12px; }
.fs-scale.fs-bars .mixrow { grid-template-columns: 150px 1fr auto; }

/* full-screen distribution histograms re-render at overlay scale. The per-area
   Δf grid can stack several plots taller than the viewport → let the body scroll
   and reflow to a single column on narrow / mobile screens. */
.fs-body.fs-scroll { display: block; overflow-y: auto; }
.fq-dist-grid-fs {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 22px 26px;
  align-content: start;
}
.fq-dist-grid-fs .fq-dist-name { font-size: 15px; }
.fq-dist-grid-fs .fq-dist-mode { font-size: 13px; }
.fq-dist-grid-fs .chart svg { max-height: none; }
/* the ⤢ expand badge sits top-right of the host; the Δf grid's first cell keeps
   its heading INSIDE the host, so reserve room there to avoid overlap (the badge
   is always visible on touch devices) */
#chartFreqDist.expandable .fq-dist-cell:first-child .fq-dist-head { padding-right: 34px; }

/* ---- info / footer ---- */
.info summary { font-size: 14px; font-weight: 700; cursor: pointer; }
.info-body { margin-top: 10px; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.info-body p { margin: 0 0 8px; }
.info-body code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.info-note { color: var(--muted); }
.foot { text-align: center; font-size: 11.5px; color: var(--muted); padding: 8px 0 2px; }

/* skeleton pulse */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
.content[aria-busy="true"] .gauge-value,
.content[aria-busy="true"] .tile-value { animation: pulse 1.2s ease-in-out infinite; }

/* ---- responsive ---- */
@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .stripgrid { grid-template-columns: repeat(4, 1fr); }
  .equiv { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 680px) {
  .split { grid-template-columns: 220px 1fr; }
  .gauge-value { font-size: 66px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .reveal { opacity: 1; transform: none; }
  .draw { stroke-dashoffset: 0; }
}

/* ============================================================
   Europe — cross-border flow hub + all-countries grid
   ============================================================ */
.eu-status { font-size: 12.5px; color: var(--muted); padding: 4px 0 10px; }
.eu-status[hidden] { display: none; }
.eu-flowhead, .eu-gridhead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 10px 0 6px; flex-wrap: wrap;
}
.eu-sub { font-size: 13px; font-weight: 800; letter-spacing: -0.01em; }
.eu-sort .seg { padding: 5px 10px; font-size: 12px; }
/* keep title + hint clustered on the left so the GW toggle hugs the right */
.eu-flowhint { margin-right: auto; }
.eu-gwtoggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  font: inherit; font-size: 12px; font-weight: 700; line-height: 1;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text-secondary);
  cursor: pointer; white-space: nowrap; transition: color .12s ease,
    border-color .12s ease, background .12s ease;
}
.eu-gwtoggle::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); transition: background .12s ease, box-shadow .12s ease;
}
.eu-gwtoggle:hover { border-color: var(--series-1); }
.eu-gwtoggle.is-on {
  color: var(--text-primary); border-color: var(--series-1);
  background: color-mix(in srgb, var(--series-1) 14%, var(--surface-2));
}
.eu-gwtoggle.is-on::before { background: var(--flow-out);
  box-shadow: 0 0 6px color-mix(in srgb, var(--flow-out) 80%, transparent); }
.eu-gwtoggle:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

/* geographic Europe choropleth map (real country borders) */
.eu-flow { width: 100%; }
.eu-flow svg { width: 100%; height: auto; display: block; overflow: visible;
  border-radius: 14px; }
.eu-sea { fill: var(--surface-1); stroke: var(--border); stroke-width: 1; opacity: 0.7; }
/* country polygons */
.eu-land-fill { fill: var(--muted); stroke: var(--surface-1);
  stroke-width: 0.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.eu-nodata .eu-land-fill { fill: color-mix(in srgb, var(--muted) 26%, transparent);
  stroke: color-mix(in srgb, var(--border) 80%, transparent); }
.eu-land.clickable { cursor: pointer; }
.eu-land.clickable:focus-visible { outline: none; }
.eu-land.clickable:hover .eu-land-fill,
.eu-land.clickable:focus-visible .eu-land-fill {
  stroke: var(--text-primary); stroke-width: 1.4; }
.eu-land.is-center .eu-land-fill { stroke: var(--text-primary); stroke-width: 2;
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--text-primary) 55%, transparent)); }
/* flow arrows */
.flow-line { fill: none; stroke-linecap: round; opacity: 0.95;
  vector-effect: non-scaling-stroke; }
.flow-line.anim { stroke-dasharray: 7 6; animation: flowmove 0.9s linear infinite; }
@keyframes flowmove { to { stroke-dashoffset: -13; } }
.flow-arrow { opacity: 1; }
/* GW value pins on the flow arrows */
.eu-flow-lbls { pointer-events: none; }
.eu-flow-lbl { filter: drop-shadow(0 1px 1.4px rgba(0,0,0,0.42)); }
.eu-flow-lbl-bg { stroke: rgba(0,0,0,0.30); stroke-width: 0.6; }
.eu-flow-lbl-tx { font-size: 9px; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; }
/* flag markers */
.eu-flags { pointer-events: none; }
.eu-flag { font-size: 9px; }
.eu-flag.is-center { font-size: 13px; }
.eu-center-ring { fill: none; stroke: var(--text-primary); stroke-width: 1.6;
  opacity: 0.9; }
/* caption + legend */
.eu-map-caption { text-align: center; font-size: 12.5px; color: var(--text-secondary);
  margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.eu-map-caption b { color: var(--text-primary); font-weight: 800; }
.eu-cap-chip { display: inline-flex; align-items: baseline; padding: 1px 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.eu-cap-chip small { font-size: 0.68em; font-weight: 700; opacity: 0.85; margin-left: 1px; }
.eu-flow-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center;
  font-size: 11.5px; color: var(--text-secondary); margin-top: 6px; }
.eu-flow-legend .swatch-co2 { border-radius: 3px; width: 34px;
  background: linear-gradient(90deg, #008300, #6faf2a, #eda100, #eb6834, #d03b3b); }
.eu-lg-pin { display: inline-flex; align-items: center; justify-content: center;
  padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 800;
  font-variant-numeric: tabular-nums; color: #fff;
  background: color-mix(in srgb, var(--flow-out) 60%, var(--flow-in));
  border: 1px solid rgba(0,0,0,0.25); }

/* country grid */
.eu-grid { display: flex; flex-direction: column; gap: 6px; }
.eu-row {
  display: grid; align-items: center; gap: 8px; width: 100%;
  grid-template-columns: 22px 24px minmax(56px, 1.1fr) 50px minmax(84px, 1.3fr) 38px 52px;
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface-2); color: var(--text-primary);
  font: inherit; text-align: left; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.eu-row:hover { border-color: var(--series-1); transform: translateX(2px); }
.eu-row.is-center { border-color: var(--series-1); box-shadow: inset 0 0 0 1px var(--series-1); }
.eu-rank { font-size: 11px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.eu-cflag { font-size: 18px; }
.eu-cname { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eu-chip { display: inline-flex; align-items: baseline; justify-content: center;
  padding: 3px 6px; border-radius: 999px; font-size: 12.5px; font-weight: 800;
  font-variant-numeric: tabular-nums; }
.eu-chip small { font-size: 0.68em; font-weight: 700; opacity: 0.85; margin-left: 1px; }
.eu-cload { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.eu-cload b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.eu-loadbar { flex: 1; min-width: 24px; height: 7px; background: var(--surface-1);
  border-radius: 4px; overflow: hidden; }
.eu-loadbar i { display: block; height: 100%; border-radius: 4px; }
.eu-cre { font-size: 12px; color: var(--text-secondary); text-align: right; font-variant-numeric: tabular-nums; }
.eu-cnet { font-size: 11.5px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.eu-cnet.imp { color: var(--flow-in); }
.eu-cnet.exp { color: var(--flow-out); }
.eu-cnet.bal { color: var(--muted); }


@media (max-width: 460px) {
  .eu-row { grid-template-columns: 18px 22px minmax(44px, 1fr) 46px minmax(60px, 1.1fr) 46px;
    gap: 6px; padding: 7px; }
  .eu-cre { display: none; }
}
.eu-src { margin: 12px 2px 0; font-size: 11px; color: var(--muted); line-height: 1.4; }

/* ============================================================
   Tabs — Deutschland | Europa | Frequenz | Netz-Physik
   ============================================================ */
.tabs {
  display: flex; gap: 6px; margin: 2px 0 12px; padding: 4px;
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  border: 1px solid var(--border); border-radius: 14px;
  overflow-x: auto; scrollbar-width: none;
  position: sticky; top: 64px; z-index: 4;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 13.5px; font-weight: 700; padding: 9px 14px;
  border-radius: 10px; cursor: pointer; white-space: nowrap;
  transition: color .15s, background .15s;
}
.tab .tab-ico { font-size: 15px; line-height: 1; }
.tab[aria-selected="true"] {
  background: var(--surface-1); color: var(--text-primary);
  box-shadow: 0 1px 3px var(--shadow);
}

/* panes: only the active tab's pane is laid out */
.pane { display: none; }
.pane { flex-direction: column; gap: 14px; }
body[data-tab="de"]   #pane-de   { display: flex; }
body[data-tab="eu"]   #pane-eu   { display: flex; }
body[data-tab="freq"] #pane-freq { display: flex; }
body[data-tab="phys"] #pane-phys { display: flex; }
body[data-tab="reserve"] #pane-reserve { display: flex; }
/* the factor/window controls only apply to the CO₂ views */
body[data-tab="freq"] .controls, body[data-tab="phys"] .controls,
body[data-tab="reserve"] .controls { display: none; }
body[data-tab="eu"] .segmented[data-role="hours"] { display: none; }

/* ============================================================
   Frequency view
   ============================================================ */
.freq-hero { text-align: center; }
.fq-big { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-top: 10px; }
.fq-value {
  font-size: 64px; font-weight: 800; line-height: 0.95; letter-spacing: -0.03em;
  color: var(--heroAccent, var(--text-primary)); transition: color .5s;
}
.fq-unit { font-size: 20px; font-weight: 700; color: var(--text-secondary); }
.fq-badges { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.fq-delta { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; transition: color .4s; }
.fq-band { max-width: 460px; margin: 12px auto 0; }
.fq-band svg { width: 100%; height: auto; display: block; overflow: visible; }
.fq-band-lbl { fill: var(--muted); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.fq-band-lbl.is-main { fill: var(--text-primary); font-weight: 700; }
/* no CSS transition on the knob: the rAF animator already eases the frequency,
   and a transition on top made the knob lag ~0.8 s behind the live number. */
@media (min-width: 680px) { .fq-value { font-size: 84px; } }

.fq-text { margin: 10px 2px 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.fq-text b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* diverging FCR meter */
.fcr-meter { max-width: 560px; margin: 2px auto; }
.fcr-track {
  position: relative; height: 16px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); overflow: hidden;
}
.fcr-center {
  position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px;
  background: var(--axis); transform: translateX(-50%); z-index: 2;
}
.fcr-fill {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 0;
  border-radius: 999px;
  transition: width .7s cubic-bezier(.2,.7,.3,1), left .7s cubic-bezier(.2,.7,.3,1), background .4s;
}
.fcr-ends {
  display: flex; justify-content: space-between; font-size: 10.5px;
  color: var(--muted); font-variant-numeric: tabular-nums; margin: 3px 2px;
}
.fcr-legends { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.fcr-mid { color: var(--text-secondary); font-weight: 700; }

/* sync-area rows under the compare chart */
.fq-areas { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.fq-area-row {
  display: grid; grid-template-columns: 14px minmax(90px,1fr) auto auto auto;
  gap: 10px; align-items: center; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
}
.fq-dot { width: 11px; height: 11px; border-radius: 4px; }
.fq-aname { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.fq-af { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fq-af small { color: var(--muted); font-weight: 600; }
.fq-adelta { font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fq-aage { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

/* adjustable history: range selector + window-statistics tiles */
.fq-range-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 2px 0 12px;
}
.fq-range-lbl {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
}
/* the range picker must read as a control, not as plain text — give it a
   bordered chip + chevron (the bare .lang-select styling looked like a label,
   so it wasn't obvious the window was adjustable). */
.fq-range-sel {
  appearance: none; -webkit-appearance: none;
  min-width: 118px; max-width: none; font-weight: 700;
  color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 11px;
  background-color: var(--surface-1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 11px 8px;
  padding: 8px 32px 8px 12px; line-height: 1.15; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.fq-range-sel:hover { border-color: color-mix(in srgb, var(--series-1) 60%, var(--border)); }
.fq-range-sel:focus-visible { outline: none; border-color: var(--series-1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--series-1) 30%, transparent); }
.fq-range-lbl > span { white-space: nowrap; }
.fq-stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.fq-stat {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px;
  padding: 10px 13px; display: flex; flex-direction: column; gap: 2px;
}
.fq-stat .flabel { font-size: 11px; color: var(--text-secondary); font-weight: 600; }
.fq-stat .fvalue { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.fq-stat .fsub { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fq-stat.is-low .fvalue { color: var(--c-dirty); }
.fq-stat.is-high .fvalue { color: var(--c-high); }
@media (min-width: 560px) { .fq-stats { grid-template-columns: repeat(4, 1fr); } }
/* per-area window-statistics — one row per synchronous area (CE/Nordic/GB),
   the colour dot carrying identity alongside the name (never colour alone). */
.fq-stat-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; grid-column: 1 / -1; }
.fq-stat-table {
  width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums;
  min-width: 380px;
}
.fq-stat-table th, .fq-stat-table td {
  padding: 8px 7px; text-align: right; white-space: nowrap;
}
.fq-stat-table thead th {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  border-bottom: 1px solid var(--border); text-transform: none;
}
.fq-stat-table thead th small { color: var(--muted); font-weight: 600; }
.fq-stat-table th.fq-st-area, .fq-stat-table td.fq-st-area { text-align: left; }
.fq-stat-table tbody td { font-size: 13.5px; font-weight: 700; color: var(--text-primary); border-bottom: 1px solid var(--border); }
.fq-stat-table tbody tr:last-child td { border-bottom: 0; }
.fq-st-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 12.5px; color: var(--text-secondary); }
.fq-st-min { color: var(--c-dirty); }
.fq-st-max { color: var(--c-high); }
.hist-axis { font-size: 10.5px; fill: var(--muted); font-weight: 600; }
.scatter-lbl { font-size: 12px; fill: var(--text-secondary); pointer-events: none; }

/* frequency distribution — one bar histogram per synchronous area (CE/Nordic/GB) */
.fq-dist-grid { display: flex; flex-direction: column; gap: 16px; }
.fq-dist-head { display: flex; align-items: center; gap: 8px; margin: 0 2px 2px; }
.fq-dist-name { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.fq-dist-mode { margin-left: auto; font-size: 12px; color: var(--text-secondary); text-align: right; }
.fq-dist-mode b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.fq-dist-plot { width: 100%; }
/* live poll retargets each bar's y/height in place — ease them so the histogram
   reads as a moving distribution, not a stutter. A fresh (re)built bar starts at
   its final size, so only subsequent live nudges animate. */
.fq-dist-bar { transition: y .35s ease, height .35s ease; }
@media (prefers-reduced-motion: reduce) { .fq-dist-bar { transition: none; } }

/* reserve (balancing power) view — per-area statistics blocks */
.rs-blocks { display: flex; flex-direction: column; gap: 16px; }
.rs-block { display: flex; flex-direction: column; gap: 10px; }
.rs-head {
  display: grid; grid-template-columns: 14px minmax(80px,1fr) auto auto;
  gap: 10px; align-items: baseline;
}
.rs-head .fq-dot { align-self: center; }
.rs-prod { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.rs-now { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.rs-now small { color: var(--muted); font-weight: 600; }
.figure .fic .fq-dot { display: inline-block; }

/* utilisation bands — one stacked bar per synchronous area. Deliberately not a
   chart: the question ("how much of the window was spent at which step") is
   answered by proportion alone, and a bar reads at a glance on a phone. */
.rs-bands { display: flex; flex-direction: column; gap: 16px; }
.rs-band-row { display: flex; flex-direction: column; gap: 7px; }
.rs-band-head {
  display: grid; grid-template-columns: 14px minmax(80px,1fr) auto;
  gap: 10px; align-items: baseline;
}
.rs-band-head .fq-dot { align-self: center; }
.rs-band-bar {
  display: flex; height: 16px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface-2);
}
.rs-band-seg { display: block; min-width: 2px; }
.rs-band-keys { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.rs-band-key {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-secondary);
}
.rs-band-key i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.rs-band-key b { font-variant-numeric: tabular-nums; color: var(--text-primary); }

/* ============================================================
   Grid-physics view
   ============================================================ */
.phys-strip .fvalue { font-variant-numeric: tabular-nums; }

/* border-flow physics table */
.phys-flows { display: flex; flex-direction: column; gap: 5px; }
.ph-row {
  display: grid; grid-template-columns: minmax(110px, 1.6fr) 1fr 1fr 0.8fr 1fr;
  gap: 8px; align-items: center; padding: 7px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  font-size: 12.5px;
}
.ph-row.ph-head {
  background: transparent; border-color: transparent; padding-top: 0; padding-bottom: 2px;
  font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.ph-route { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; }
.ph-route i { font-style: normal; color: var(--muted); font-size: 12px; }
.ph-route em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-num { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.ph-num small { color: var(--muted); font-weight: 600; }
@media (max-width: 460px) {
  .ph-row { grid-template-columns: minmax(80px, 1.4fr) 1fr 1fr 1fr; }
  .ph-row > :nth-child(4) { display: none; }
}

/* line calculator */
.calc { display: flex; flex-direction: column; gap: 14px; }
.calc-controls { display: flex; flex-direction: column; gap: 12px; }
.calc-row { display: flex; flex-direction: column; gap: 6px; }
.calc-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); display: flex; justify-content: space-between; gap: 10px; }
.calc-label b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.calc-btns { flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap; }
.calc input[type="range"] {
  width: 100%; accent-color: var(--series-1); height: 26px; margin: 0;
}
.calc-out { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.calc-tile {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px;
  padding: 11px 13px; display: flex; flex-direction: column; gap: 2px;
}
.calc-tile .flabel { font-size: 11px; color: var(--text-secondary); font-weight: 600; }
.calc-tile .fvalue { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.calc-tile .fsub { font-size: 10.5px; color: var(--muted); }
.calc-tile.is-warn .fvalue { color: var(--c-high); }
.calc-tile.is-over .fvalue { color: var(--c-dirty); }
.calc-out .fq-text { grid-column: 1 / -1; margin: 2px 2px 0; }
@media (min-width: 560px) { .calc-out { grid-template-columns: repeat(3, 1fr); } }

/* OpenInfraMap link cards */
.oim-links { display: grid; grid-template-columns: 1fr; gap: 10px; }
.oim-link {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  text-decoration: none; color: var(--text-primary);
  transition: transform .12s ease, border-color .12s ease;
}
.oim-link:hover { border-color: var(--series-1); transform: translateX(3px); }
.oim-ico { font-size: 24px; line-height: 1; }
.oim-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.oim-txt b { font-size: 13.5px; font-weight: 700; }
.oim-txt small { font-size: 11.5px; color: var(--muted); }
.oim-arrow { font-size: 16px; color: var(--series-1); font-weight: 700; }
@media (min-width: 560px) { .oim-links { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================
   Responsive layout — two separate paths off the ~900 px base
   ------------------------------------------------------------
   The stylesheet above targets the phone-to-tablet middle ground
   (single 900 px column). These two blocks take over at the
   extremes so the width of the actual screen is used:
     • ≤ 560 px  — phones: tighter chrome, more fits on screen
     • ≥ 1200 px — big monitors: wider shell + the card stacks
                   tile into 2 (then 3) newspaper columns
   ============================================================ */

/* --- compact path: phones get denser chrome --- */
@media (max-width: 560px) {
  .app { padding: env(safe-area-inset-top) 11px calc(18px + env(safe-area-inset-bottom)); }
  .content, .pane { gap: 10px; }
  .card { padding: 13px; border-radius: 16px; }
  .card-head { margin-bottom: 9px; }
  .card-head h2 { font-size: 14px; }
  .topbar { padding: 12px 2px 8px; }
  .brand { gap: 9px; }
  .brand-mark { font-size: 25px; }
  .brand-txt h1 { font-size: 17px; }
  .brand-sub { font-size: 11.5px; }
  .tabs { gap: 4px; margin-bottom: 4px; }
  .controls { gap: 8px; margin: 4px 0 12px; }
  .tiles, .stripgrid { gap: 9px; }
  .fq-value { font-size: 52px; }
  .fq-stats { gap: 8px; }
}

/* --- wide path: big monitors get a broader shell and true masonry ---
   CSS multi-column balances by height and, with unbreakable cards,
   leaves big vertical voids. Instead JS packs each card into the
   currently shortest column (see relayoutPane in app.js): columns stay
   tight, no gaps. Here we only supply the row shell the JS switches on
   via the `.masonry` class. The Europe pane is one wide card and simply
   grows with the shell. */
@media (min-width: 1200px) {
  .app { max-width: 1380px; }
  .pane.masonry { flex-direction: row; align-items: flex-start; gap: 20px; }
  .masonry-col {
    display: flex; flex-direction: column; gap: 20px;
    flex: 1 1 0; min-width: 0;
  }
  .masonry-col > * { margin: 0; }
  /* cards are re-parented between columns on every relayout — don't let
     the entrance animation replay each time */
  .pane.masonry .reveal { animation: none; opacity: 1; transform: none; }
}

/* --- ultra-wide: broader shell; JS adds a third column past 1680 px --- */
@media (min-width: 1680px) {
  .app { max-width: 1880px; }
}

/* ---- public site: footer links, legal pages ------------------------------
   The dashboard used to end in a single grey line. A public site needs a way
   to the legal pages from every view — quiet enough not to compete with the
   data, findable enough to satisfy the obligation. */
.site-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: center;
  margin-top: 6px;
}
.site-links a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.site-links a:hover, .site-links a:focus-visible { color: var(--text-secondary); border-bottom-color: currentColor; }
/* The donation link is a link, not a button: present, never shouting. */
.site-links .site-donate::before { content: "♥"; margin-right: 4px; opacity: .7; }

/* ---- server-rendered legal pages ---- */
.legal-page .legal-back {
  color: var(--text-secondary);
  font-size: 12.5px;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}
.legal-page .legal-back:hover { color: var(--text-primary); }
.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 10px 0 18px;
  font-size: 13px;
}
.legal-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.legal-nav a.is-here { color: var(--text-primary); background: var(--surface-2); }
.legal-nav .legal-lang { margin-left: auto; }
.legal-body { max-width: 68ch; margin-inline: auto; }

/* The legal pages are a narrow column inside a wider shell. Left-hugging text
   under a full-width header reads like a leftover, so the whole page is built
   around one centred axis: header, nav, column and footer share it. The running
   text stays left-aligned — centred prose over several lines is hard to read. */
.legal-page .topbar { flex-direction: column; gap: 8px; padding-bottom: 14px; }
.legal-page .brand { flex-direction: column; text-align: center; gap: 6px; }
.legal-page .brand-sub { justify-content: center; }
.legal-page .top-actions { display: flex; justify-content: center; }
.legal-page .legal-nav { justify-content: center; }
.legal-page .legal-nav .legal-lang { margin-left: 0; }
.legal-page .legal-body > h2 { text-align: center; }
.legal-page .legal-addr { text-align: center; }
.legal-page .legal-lead { text-align: center; }
.legal-body h2 {
  font-size: 15px;
  margin: 26px 0 8px;
  color: var(--text-primary);
}
.legal-body p, .legal-body li {
  font-size: 14px;
  line-height: 1.62;
  color: var(--text-secondary);
}
.legal-body ul { padding-left: 20px; margin: 8px 0; }
.legal-body li { margin-bottom: 8px; }
.legal-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: var(--surface-2);
  border-radius: 5px;
  padding: 1px 5px;
}
.legal-lead { font-size: 15px !important; color: var(--text-primary) !important; }
.legal-addr { margin: 4px 0; }
.legal-warn {
  border: 1px solid var(--area-ce);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-primary) !important;
}

/* ---- the source cards ---- */
.src-grid { display: grid; gap: 12px; margin-top: 10px; }
.src-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 15px;
  background: var(--surface-1);
}
.src-card h3 { font-size: 14.5px; margin: 0; color: var(--text-primary); }
.src-card h3 a { text-decoration: none; }
.src-op { color: var(--muted); font-weight: 400; font-size: 12.5px; }
/* The badge says in one word whether re-use is settled or a courtesy. */
.src-badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 9px;
  margin: 7px 0 2px !important;
  border: 1px solid currentColor;
}
.src-badge-open { color: var(--good); }
.src-badge-closed { color: var(--src-gas); }
.src-used { margin: 6px 0 0 !important; }
.src-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 12px;
  margin: 10px 0 0;
  font-size: 13px;
}
.src-meta dt { color: var(--muted); }
.src-meta dd { margin: 0; color: var(--text-secondary); }
.src-note { font-size: 13px !important; color: var(--muted) !important; margin-top: 10px !important; }

@media (min-width: 720px) {
  .src-grid { grid-template-columns: repeat(2, 1fr); }
}
