/* ---------- design tokens (light), dark below ---------- */
:root {
  color-scheme: light;
  --page: #f6f7f5;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;      /* lake level, bottom temperature */
  --series-2: #eb6834;      /* surface temperature, lake samples */
  --series-1-soft: rgba(42, 120, 214, 0.10);
  --band: rgba(137, 135, 129, 0.16);
  --track: #b7d3f6;         /* lighter step of the blue ramp */
  --good: #006300;
  --warn-bg: #fff3d6;
  --warn-ink: #6b4b00;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px -16px rgba(11, 11, 11, 0.18);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-1-soft: rgba(57, 135, 229, 0.14);
    --band: rgba(195, 194, 183, 0.14);
    --track: #184f95;
    --good: #0ca30c;
    --warn-bg: #3a2d08;
    --warn-ink: #fbd77a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-1-soft: rgba(57, 135, 229, 0.14);
  --band: rgba(195, 194, 183, 0.14);
  --track: #184f95;
  --good: #0ca30c;
  --warn-bg: #3a2d08;
  --warn-ink: #fbd77a;
  --shadow: none;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--page);
}
a { color: inherit; text-decoration-color: var(--axis); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--ink); }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
button { font: inherit; color: inherit; }
svg { display: block; }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px 40px;
  display: grid;
  gap: 16px;
}
/* grid/flex children may shrink below their content width (keeps canvases and long text from forcing a horizontal scroll) */
main > *, .hero-main, .hero-side, .spark-block, .tile, .chart-wrap, .table-wrap { min-width: 0; }
body { overflow-x: clip; }

/* ---------- header ---------- */
.site-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 77px; height: 44px; flex-shrink: 0; border-radius: 10px; }
.brand-mark .sky { fill: var(--series-1); }
.brand .brand-name { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; }
.tagline { color: var(--ink-2); font-size: 14px; }
.header-actions { display: flex; align-items: center; gap: 10px; }

.icon-button {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
}
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-button:hover { border-color: var(--axis); }

/* ---------- segmented controls ---------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
}
.segmented button {
  border: 0; background: transparent; border-radius: 7px;
  padding: 6px 11px; font-size: 14px; color: var(--ink-2); cursor: pointer;
  white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--surface); font-weight: 600; }
.segmented button:focus-visible, .icon-button:focus-visible, .ghost:focus-visible, .check input:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 2px;
}

/* ---------- status ---------- */
.status { font-size: 14px; color: var(--ink-2); min-height: 1.4em; }
.status.warn {
  background: var(--warn-bg); color: var(--warn-ink);
  padding: 8px 12px; border-radius: 10px;
}
.status:empty { display: none; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.label, h1.label { font-size: 13px; font-weight: 400; color: var(--ink-2); letter-spacing: 0.01em; margin: 0; }
.meta { font-size: 12.5px; color: var(--muted); }
.value { font-size: 30px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; margin: 4px 0 6px; }
.value small { font-size: 0.55em; font-weight: 500; color: var(--ink-2); margin-left: 2px; }

/* ---------- hero ---------- */
.hero { display: grid; gap: 24px; grid-template-columns: 1fr; padding: 24px 20px; }
.hero-figure {
  font-size: clamp(56px, 11vw, 92px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 6px 0 4px;
  display: flex; align-items: baseline; gap: 8px;
}
.hero-unit { font-size: 0.32em; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.hero-sub { font-size: 17px; color: var(--ink-2); }
.deltas {
  display: flex; flex-wrap: wrap; gap: 10px 28px;
  margin: 18px 0 14px;
}
.deltas dd small { display: block; font-weight: 400; }
.deltas dt { font-size: 12.5px; color: var(--muted); }
.deltas dd { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.deltas dd .dir { font-size: 0.75em; margin-right: 2px; color: var(--ink-2); }
.hero-side { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: stretch; }
.meter { width: 176px; min-height: 200px; }
.meter svg { width: 100%; height: 100%; overflow: visible; }
.meter .track { fill: var(--track); }
.meter .fill { fill: var(--series-1); }
.meter .tick { stroke: var(--axis); stroke-width: 1; }
.meter .tick-label { font-size: 11px; fill: var(--ink-2); }
.meter .tick-value { font-size: 11px; fill: var(--muted); }
.meter .now { fill: var(--surface); stroke: var(--series-1); stroke-width: 2; }
.meter .target { stroke: var(--ink-2); stroke-dasharray: 2 3; }
.spark-block { display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; min-width: 0; }
.spark { width: 100%; height: 64px; overflow: visible; }
.spark-sm { height: 36px; margin: 2px 0 8px; }
.spark .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--series-1-soft); }
.spark .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark.temp .line { stroke: var(--series-2); }
.spark.temp .dot { fill: var(--series-2); }
.spark.temp .area { fill: rgba(235, 104, 52, 0.10); }
.spark.muted .line { stroke: var(--axis); }
.spark.muted .dot { fill: var(--ink-2); }
.spark.muted .area { fill: var(--band); }

@media (min-width: 760px) {
  .hero { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; }
  .hero-side { grid-template-columns: auto 1fr; }
}

/* ---------- KPI tiles ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.tile .meta { margin-top: auto; }

/* ---------- controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; padding-top: 6px; }
.ranges { max-width: 100%; overflow-x: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--series-1); margin: 0; }

/* ---------- charts ---------- */
.chart-card { padding-bottom: 16px; }
.chart-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.chart-head h2 { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.chart-sub { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
.ghost {
  border: 1px solid var(--border); background: transparent; border-radius: 8px;
  padding: 6px 12px; font-size: 13px; color: var(--ink-2); cursor: pointer; flex-shrink: 0;
}
.ghost:hover { color: var(--ink); border-color: var(--axis); }
.ghost[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chart-wrap { position: relative; height: 340px; }
.chart-wrap.dim { opacity: 0.5; transition: opacity 0.2s; }
.chart-wrap[hidden] { display: none; }
@media (max-width: 600px) { .chart-wrap { height: 280px; } }
.note { font-size: 13px; color: var(--ink-2); margin-top: 10px; }
.note:empty { display: none; }

.table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.table-wrap th, .table-wrap td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.table-wrap th:first-child, .table-wrap td:first-child { text-align: left; }
.table-wrap th { position: sticky; top: 0; background: var(--surface); color: var(--ink-2); font-weight: 600; z-index: 1; }
.table-wrap td { font-variant-numeric: tabular-nums; }
.table-wrap caption { text-align: left; padding: 8px 12px; color: var(--muted); font-size: 12.5px; caption-side: bottom; }

/* ---------- tooltip ---------- */
.tooltip {
  position: absolute; z-index: 10; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px -12px rgba(0, 0, 0, 0.35);
  padding: 8px 10px; font-size: 13px; min-width: 150px;
  transition: opacity 0.08s;
}
.tooltip[hidden] { display: none; }
.tooltip .tt-title { color: var(--ink-2); font-size: 12px; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.tooltip .tt-key { width: 14px; height: 0; border-top: 2px solid; border-radius: 2px; flex-shrink: 0; }
.tooltip .tt-key.dot { width: 8px; height: 8px; border: 0; border-radius: 50%; margin: 0 3px; }
.tooltip .tt-key.band { height: 8px; border: 0; border-radius: 2px; }
.tooltip .tt-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.tooltip .tt-name { color: var(--ink-2); }

/* ---------- facts & about ---------- */
.facts h2, .about h2, .faq h2 { font-size: 18px; font-weight: 650; margin-bottom: 12px; letter-spacing: -0.01em; }
.faq-grid { display: grid; gap: 18px 28px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.faq h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.faq p { font-size: 14.5px; color: var(--ink-2); }
.fact-grid { display: grid; gap: 14px 24px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.fact-grid dt { font-size: 13px; color: var(--ink-2); }
.fact-grid dd { font-size: 20px; font-weight: 600; margin-top: 2px; }
.fact-grid dd small { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); margin-top: 1px; }
.sources { padding-left: 18px; display: grid; gap: 8px; font-size: 14.5px; color: var(--ink-2); }
.sources strong { color: var(--ink); }
.about .meta { margin-top: 14px; }
.site-footer { max-width: 1120px; margin: 0 auto; padding: 0 16px 32px; font-size: 12.5px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
