:root {
  color-scheme: light;
  --bg: #e9eef1;            /* pilvinen taivas / pelti */
  --surface: #ffffff;
  --ink: #1a2026;
  --ink-2: #4b5660;
  --ink-3: #6b7680;
  --rule: #d2d9de;
  --post: #2b2f33;          /* toteemin runko */
  --tab: #f5c400;           /* keltainen tunnistetasku */
  --tab-ink: #3b2f00;
  --led-red: #ff4a3d;
  --panel-red: #3a0e0c;
  --led-white: #ddf7ff;
  --panel-white: #0f1b20;
  --warn-ink: #8a5000;
  --warn-bg: #fff0cf;
  --new-ink: #0a6b3d;
  --new-bg: #dcf5e7;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --grid: #e3e8ec;
  --focus: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #14181b;
    --surface: #1c2125;
    --ink: #e7ecef;
    --ink-2: #b4bec6;
    --ink-3: #8c979f;
    --rule: #2f363c;
    --post: #0b0d0f;
    --warn-ink: #ffc96b;
    --warn-bg: #3a2a0c;
    --new-ink: #7fe0ad;
    --new-bg: #10301f;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --grid: #262c31;
    --focus: #6da7ec;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
main { max-width: 1080px; margin: 0 auto; padding: 28px 16px 40px; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.25rem); line-height: 1.15; margin: 0 0 .35rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 0; }
.where { margin: 0; color: var(--ink-2); }
.updated { margin: .5rem 0 0; color: var(--ink-3); font-size: .9rem; }
.updated.stale { color: var(--warn-ink); background: var(--warn-bg); padding: .4rem .6rem; border-radius: 6px; display: inline-block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
section { margin-top: 36px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; }
button, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 6px; padding: .3rem .7rem; cursor: pointer;
}
button:hover, select:hover { border-color: var(--ink-3); }

/* ---------- toteemi ---------- */
.now { margin-top: 24px; }
.totem {
  background: var(--post);
  border-radius: 10px;
  padding: 14px;
  display: grid;
  gap: 10px;
  max-width: 760px;
}
.row {
  display: grid;
  grid-template-columns: 64px minmax(0, 260px) 1fr;
  align-items: center;
  gap: 0 16px;
}
.tab {
  background: var(--tab); color: var(--tab-ink);
  border-radius: 6px; height: 100%; min-height: 72px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.05rem;
}
.led { border-radius: 6px; padding: 12px 14px; line-height: 0; }
.led.red { background: var(--panel-red); color: var(--led-red); }
.led.white { background: var(--panel-white); color: var(--led-white); }
.led svg { width: 100%; height: auto; display: block; }
.led .on { fill: currentColor; }
.led .off { fill: currentColor; opacity: .045; }
.led.unsure .on { opacity: .38; }
.led.unsure { outline: 2px dashed var(--tab); outline-offset: -5px; }
.note { color: #e9eef1; font-size: .92rem; line-height: 1.4; }
.note .name { font-weight: 650; color: #fff; }
.note .line { color: #b9c3ca; }
.flag { display: inline-block; margin-top: .3rem; padding: .1rem .45rem; border-radius: 4px; font-size: .85rem; font-weight: 600; }
.flag.warn { background: #f5c400; color: #2a2000; }
.flag.new { background: #7fe0ad; color: #06301c; }
.flag.wait { background: #b9d7ff; color: #0d2a52; }

@media (max-width: 620px) {
  .row { grid-template-columns: 52px 1fr; gap: 8px 10px; }
  .note { grid-column: 1 / -1; }
  .tab { min-height: 56px; font-size: .95rem; }
}

/* ---------- graafi ---------- */
.range { display: flex; gap: 6px; flex-wrap: wrap; }
.range button[aria-checked="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; font-size: .9rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 18px; height: 0; border-top: 2px solid; display: inline-block; }
.chart-wrap { position: relative; background: var(--surface); border-radius: 8px; padding: 8px 4px 4px; }
.chart { min-height: 240px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; }
.chart text { fill: var(--ink-3); font-size: 12px; }
.chart .lbl { fill: var(--ink); font-size: 12.5px; font-weight: 600; }
.chart .gridline { stroke: var(--grid); }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .xhair { stroke: var(--ink-3); stroke-width: 1; }
.chart .empty { fill: var(--ink-3); font-size: 14px; }
.tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 6px;
  box-shadow: 0 4px 14px rgb(0 0 0 / .12);
  padding: 8px 10px; font-size: .85rem; min-width: 150px;
}
.tip .when { color: var(--ink-3); margin-bottom: 4px; }
.tip .r { display: grid; grid-template-columns: 16px auto 1fr; gap: 8px; align-items: center; }
.tip .r b { font-variant-numeric: tabular-nums; }
.tip .r span:last-child { color: var(--ink-2); }
.table-view { margin-top: 10px; }
.table-view summary { cursor: pointer; color: var(--ink-2); }
.table-view table { border-collapse: collapse; margin-top: 8px; font-size: .9rem; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { text-align: left; padding: 4px 14px 4px 0; border-bottom: 1px solid var(--rule); }
.table-view td.num { text-align: right; }

/* ---------- kamerakuvat ---------- */
.snap-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#snap-slider { width: 100%; margin: 0 0 12px; accent-color: var(--ink); }
.snap-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  grid-template-areas: "full crop" "info crop";
  gap: 12px 16px;
}
.snap-view figure { margin: 0; }
.snap-full { grid-area: full; }
.snap-crop { grid-area: crop; }
.snap-info { grid-area: info; }
.snap-full img, .snap-crop img { width: 100%; display: block; border-radius: 6px; background: #000; }
.snap-time { margin: 0 0 6px; font-weight: 650; }
.snap-read { border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.snap-read caption { text-align: left; color: var(--ink-3); font-size: .85rem; padding-bottom: 2px; }
.snap-read th { text-align: left; font-weight: 500; color: var(--ink-2); padding: 2px 14px 2px 0; }
.snap-read td { padding: 2px 14px 2px 0; }
.snap-read .st { color: var(--ink-3); }
.snap-read .st.bad { color: var(--warn-ink); font-weight: 600; }
@media (max-width: 620px) {
  .snap-view { grid-template-columns: 1fr 96px; grid-template-areas: "full full" "info crop"; }
}

.disclaimer {
  margin-top: 44px; padding-top: 16px; border-top: 1px solid var(--rule);
  color: var(--ink-2); font-size: .9rem; max-width: 70ch;
}
@media (prefers-reduced-motion: no-preference) {
  .tab, .led { transition: opacity .2s; }
}
.defs { position: absolute; }
