/* ==========================================================================
   Meteo Sněžka
   Barvy z vrcholu: mlha, jinovatka, žula, lišejník a červená turistické značky.
   Červená patří jen nárazům a maximům.
   ========================================================================== */

@font-face {
  font-family: "Signika";
  src: url("fonts/signika-latin-ext.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Signika";
  src: url("fonts/signika-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Negative: řez pro světlé písmo na tmavém, kompenzuje přezáření. */
@font-face {
  font-family: "Signika Negative";
  src: url("fonts/signika-negative-latin-ext.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Signika Negative";
  src: url("fonts/signika-negative-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokeny ---------- */

:root {
  color-scheme: light;
  --bg: #E6ECEE;          /* mlha */
  --surface: #F4F7F8;     /* jinovatka */
  --surface-2: #D8E0E3;
  --ink: #1B2830;         /* žula */
  --ink-2: #47565F;       /* lišejník */
  --ink-3: #5C6B73;
  --hair: #C3CDD2;
  --red: #B8262F;         /* turistická značka */
  --good: #1C6F46;
  --warn: #8A5300;

  /* Řady grafů (ověřeno validátorem palety) */
  --c-wind: #2a78d6;
  --c-gust: #e34948;
  --c-temp: #eb6834;
  --c-chill: #6250d6;
  --c-dew: #1baf7a;
  --c-hum: #2a78d6;
  /* Pozadí grafu teploty nad a pod nulou */
  --tint-warm: rgba(227, 73, 72, 0.10);
  --tint-cold: rgba(42, 120, 214, 0.09);

  /* Přístroj */
  --dial-face: #F4F7F8;
  --dial-ring: #1B2830;
  --dial-arrow: #1B2830;
  --dial-halo: #F4F7F8;
  --dial-rose: #2a78d6;
  --dial-flow: 27, 40, 48;

  --font: "Signika", system-ui, sans-serif;
  --radius-pill: 999px;
  --radius-panel: 14px;
  --gutter: 16px;
  --measure: 34rem;
  /* Horní okraj, pod který nesmí obsah: stavový řádek a pod ním rozmazaný přechod, který iOS 26
     kreslí přes horní okraj webové aplikace. Rezerva 16 px jen tam, kde nějaký okraj je (PWA
     na iPhonu), v prohlížeči zůstává 0. */
  --safe-top: calc(env(safe-area-inset-top, 0px) + min(16px, env(safe-area-inset-top, 0px)));
  /* Boční odsazení obsahu: na šířku na iPhonu je na boku výřez displeje (bezpečný okraj), jinak --gutter. */
  --gutter-l: max(var(--gutter), env(safe-area-inset-left, 0px));
  --gutter-r: max(var(--gutter), env(safe-area-inset-right, 0px));
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121B21;
    --surface: #1A262D;
    --surface-2: #24323A;
    --ink: #E4ECEF;
    --ink-2: #A9B8BF;
    --ink-3: #81919A;
    --hair: #2E3D45;
    --red: #F2777C;
    --good: #5CC08E;
    --warn: #E0A24A;
    --c-wind: #3987e5;
    --c-gust: #e66767;
    --c-temp: #d95926;
    --c-chill: #9085e9;
    --c-dew: #199e70;
    --c-hum: #3987e5;
    --tint-warm: rgba(230, 103, 103, 0.10);
    --tint-cold: rgba(57, 135, 229, 0.13);
    --dial-face: #1A262D;
    --dial-ring: #E4ECEF;
    --dial-arrow: #E4ECEF;
    --dial-halo: #121B21;
    --dial-rose: #3987e5;
    --dial-flow: 228, 236, 239;
    --font: "Signika Negative", "Signika", system-ui, sans-serif;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121B21;
  --surface: #1A262D;
  --surface-2: #24323A;
  --ink: #E4ECEF;
  --ink-2: #A9B8BF;
  --ink-3: #81919A;
  --hair: #2E3D45;
  --red: #F2777C;
  --good: #5CC08E;
  --warn: #E0A24A;
  --c-wind: #3987e5;
  --c-gust: #e66767;
  --c-temp: #d95926;
  --c-chill: #9085e9;
  --c-dew: #199e70;
  --c-hum: #3987e5;
  --tint-warm: rgba(230, 103, 103, 0.10);
  --tint-cold: rgba(57, 135, 229, 0.13);
  --dial-face: #1A262D;
  --dial-ring: #E4ECEF;
  --dial-arrow: #E4ECEF;
  --dial-halo: #121B21;
  --dial-rose: #3987e5;
  --dial-flow: 228, 236, 239;
  --font: "Signika Negative", "Signika", system-ui, sans-serif;
}

/* ---------- Základ ---------- */

/* Než modul dosadí jiný jazyk než češtinu, obsah se neukazuje (pojistka 2,5 s v index.html). */
html[data-pending] .bar, html[data-pending] main { visibility: hidden; }

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, figure { margin: 0; }

h2 {
  font-size: 1.3125rem;
  line-height: 1.25;
  font-weight: 600;
}

h3 {
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 600;
}

a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.u { color: var(--ink-2); font-weight: 400; }

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--gutter-r) 64px var(--gutter-l);
}

/* ---------- Horní lišta ---------- */

.bar {
  max-width: 1240px;
  margin: 0 auto;
  /* V PWA na iPhonu je stránka pod stavovým řádkem (black-translucent): mezera se k němu přičítá,
     jinak lišta sedí přímo na jeho hraně a iOS ji překryje rozmazaným přechodem. */
  padding: calc(var(--safe-top) + 12px) var(--gutter-r) 12px var(--gutter-l);
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 1.125rem;
  white-space: nowrap;
}
.brand img { border-radius: 8px; }
.brand b { font-weight: 600; }

.status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.status-dot {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
}
.status[data-state="live"] .status-dot { background: var(--good); }
.status[data-state="polling"] .status-dot { background: var(--good); opacity: 0.6; }
.status[data-state="stale"] .status-dot,
.status[data-state="offline"] .status-dot { background: var(--warn); }
.status[data-state="stale"], .status[data-state="offline"] { color: var(--warn); }
#status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Stav spojení otevírá diagnostiku */
button.status {
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
}
button.status:hover { background: var(--surface-2); color: var(--ink); }

.settings-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
}
.settings-btn svg, .close svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; }
.settings-btn:hover { border-color: var(--ink-3); }

/* Stav čidla: v liště, aby jeho objevení neposouvalo obsah stránky */
.sensor-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 10px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--warn) 9%, var(--surface));
  color: var(--warn);
  font-size: 0.875rem;
  cursor: pointer;
}
.sensor-chip[hidden] { display: none; }
.sensor-chip svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.sensor-chip:hover { border-color: var(--warn); }

.sensor-pop {
  position: fixed;
  inset: auto;
  top: calc(var(--safe-top) + 64px);
  right: max(var(--gutter-r), calc((100vw - 1240px) / 2 + var(--gutter)));
  margin: 0;
  width: min(22rem, calc(100vw - var(--gutter-l) - var(--gutter-r)));
  padding: 14px 16px;
  border: 1px solid var(--hair);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(10, 18, 22, 0.16);
  font-size: 0.9375rem;
}

@media (max-width: 560px) {
  .settings-btn span, .sensor-chip span { display: none; }
  .settings-btn, .sensor-chip { padding: 8px; }
  .bar { gap: 10px; }
  .brand span { font-size: 1rem; }
}
/* Na nejužších displejích ustoupí nadmořská výška, aby byl čas posledních dat vidět celý. */
@media (max-width: 420px) {
  .brand-alt { display: none; }
  button.status { padding-inline: 4px; }
}

/* ---------- Teď: čtení + přístroj ---------- */

.now {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "readout" "air" "instrument";
  gap: 28px;
  padding: 12px 0 48px;
}

@media (min-width: 960px) {
  .now {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-template-areas: "readout instrument" "air instrument";
    grid-template-rows: auto 1fr;
    column-gap: 56px;
    row-gap: 40px;
    padding-top: 24px;
    align-items: start;
  }
}

.readout { grid-area: readout; }

.speed {
  display: flex;
  align-items: baseline;
  gap: 0.25em;
  line-height: 0.9;
}
.speed-value {
  font-size: clamp(5.5rem, 22vw, 9.5rem);
  font-weight: 500;
  letter-spacing: -0.035em;
}
.speed-unit {
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  color: var(--ink-2);
}
.speed-alt {
  margin-top: 8px;
  font-size: 1.3125rem;
  color: var(--ink-2);
}

.bft { margin-top: 24px; }
.bft-name { font-size: 1.5rem; line-height: 1.25; }
.bft-name strong { font-weight: 600; }
.bft-name span { color: var(--ink-2); }

.bft-scale {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 2px;
  align-items: center;
  height: 14px;
  max-width: 26rem;
}
.bft-scale li {
  height: 8px;
  background: var(--surface-2);
}
.bft-scale li:first-child { border-radius: 4px 0 0 4px; }
.bft-scale li:last-child { border-radius: 0 4px 4px 0; }
.bft-scale li.on { background: var(--ink-3); }
.bft-scale li.cur { background: var(--ink); height: 14px; border-radius: 3px; }

.bft-note {
  margin-top: 10px;
  color: var(--ink-2);
  max-width: var(--measure);
}

.dir {
  margin-top: 24px;
  font-size: 1.3125rem;
  line-height: 1.35;
}
.dir b { font-weight: 600; }
.dir-deg { color: var(--ink-2); font-variant-numeric: tabular-nums; }

.gusts { margin-top: 28px; }
.gusts h2 { font-size: 1rem; font-weight: 600; }
.gusts dl {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, auto));
  justify-content: start;
  column-gap: 32px;
  row-gap: 8px;
}
.gusts dt { font-size: 0.875rem; color: var(--ink-2); white-space: nowrap; }
.gusts dd { font-size: 1.5rem; font-weight: 500; line-height: 1.2; }


/* Na mobilu musí být teploty vidět bez posouvání: popis stupně se rozbalí klepnutím,
   nárazy v jednom řádku, menší mezery a číslo. */
.bft-toggle {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.bft-toggle .chev { display: none; align-self: center; fill: none; stroke: var(--ink-2); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s; }
@media (max-width: 560px) {
  .speed-value { font-size: clamp(4.5rem, 19vw, 6rem); }
  .speed-alt { margin-top: 4px; font-size: 1.125rem; }
  .bft { margin-top: 14px; }
  .bft-name { font-size: 1.25rem; }
  .bft-toggle { cursor: pointer; }
  .bft-toggle .chev { display: inline-block; }
  .bft-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
  .bft-note { display: none; font-size: 0.9375rem; }
  .bft[data-open] .bft-note { display: block; }
  .dir { margin-top: 14px; font-size: 1.125rem; }
  .dir-deg { font-size: 0.875rem; }
  .gusts { margin-top: 16px; }
  .gusts h2 { font-size: 0.9375rem; }
  .gusts dl { margin-top: 4px; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 12px; }
  .gusts dt { font-size: 0.8125rem; white-space: normal; line-height: 1.25; }
  .gusts div { display: flex; flex-direction: column; justify-content: flex-end; }
  .gusts dd { font-size: 1.375rem; }
  .now { gap: 20px; }
  .air { gap: 14px 16px; padding-top: 16px; }
  .air .fig { font-size: 1.875rem; }
}

/* Teploty */
.air {
  grid-area: air;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 24px;
  padding-top: 24px;
  border-top: 1px solid var(--hair);
}
@media (min-width: 640px) and (max-width: 959px) {
  .air { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.air dt { font-size: 0.875rem; color: var(--ink-2); }
.air .fig { font-size: 2.25rem; font-weight: 500; line-height: 1.1; letter-spacing: -0.01em; }
.air .sub { margin-top: 2px; font-size: 0.875rem; color: var(--ink-2); }

/* ---------- Přístroj ---------- */

.instrument {
  grid-area: instrument;
  width: 100%;
  max-width: 640px;
  justify-self: center;
}

.dial {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
}
.dial > * {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Kotouč má poloměr 380 z 1000 jednotek SVG. */
.dial .ortho,
.dial .flow {
  clip-path: circle(38% at 50% 50%);
}
.dial .ortho {
  object-fit: cover;
  filter: saturate(0.82) contrast(1.04);
}
.instrument[data-dial="compass"] .ortho { visibility: hidden; }

.overlay { overflow: visible; }
.overlay text { font-family: var(--font); }

.dial-face { fill: var(--dial-face); }
.instrument[data-dial="map"] .dial-face { fill: rgba(12, 22, 28, 0.22); }

.ring { fill: none; stroke: var(--dial-ring); stroke-width: 2; }
.ticks line { stroke: var(--dial-ring); stroke-width: 2; }
.ticks line.minor { stroke-width: 1.25; opacity: 0.55; }

.places text {
  fill: var(--ink-2);
  font-size: 25px;
  letter-spacing: 0.01em;
}
.places text.here { fill: var(--ink); font-weight: 600; }
@media (max-width: 560px) {
  .places text { font-size: 34px; }
  .cardinals text { font-size: 38px; }
}

.cardinals text {
  font-size: 30px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  fill: var(--dial-ring);
  paint-order: stroke;
  stroke: var(--dial-face);
  stroke-width: 6px;
}
.instrument[data-dial="map"] .cardinals text { fill: #fff; stroke: rgba(10, 18, 22, 0.55); }

.rose path {
  fill: var(--dial-rose);
  fill-opacity: 0.2;
  stroke: var(--dial-rose);
  stroke-width: 2;
  stroke-linejoin: round;
}
.instrument[data-dial="map"] .rose path { fill: #fff; fill-opacity: 0.22; stroke: #fff; stroke-opacity: 0.85; }


.gust-mark { fill: var(--red); stroke: var(--dial-face); stroke-width: 3; }
.instrument[data-dial="map"] .gust-mark { stroke: var(--bg); }

.arrow { transition: transform 0.9s cubic-bezier(0.25, 0.8, 0.3, 1); }
.arrow .halo { stroke: var(--dial-halo); stroke-width: 14; stroke-linecap: round; fill: none; }
.arrow .shaft { stroke: var(--dial-arrow); stroke-width: 6; stroke-linecap: round; fill: none; }
.arrow .head { fill: var(--dial-arrow); stroke: var(--dial-halo); stroke-width: 4; stroke-linejoin: round; paint-order: stroke; }
.instrument[data-dial="map"] .arrow .shaft { stroke: #fff; }
.instrument[data-dial="map"] .arrow .head { fill: #fff; stroke: rgba(10, 18, 22, 0.6); }
.instrument[data-dial="map"] .arrow .halo { stroke: rgba(10, 18, 22, 0.45); }
.instrument[data-smooth] .arrow { transition: transform 80ms linear; }
.arrow[hidden], .gust-mark[hidden], .avg-mark[hidden], .spread[hidden], .spread-range[hidden] { display: none; }

/* Průměrný směr za minutu: barvou patří k šipce, tvarem ke značce nárazu */
.avg-mark {
  fill: var(--dial-arrow);
  stroke: var(--dial-halo);
  stroke-width: 3;
  stroke-linejoin: round;
  paint-order: stroke;
  transition: transform 0.9s cubic-bezier(0.25, 0.8, 0.3, 1);
}
.instrument[data-dial="map"] .avg-mark { fill: #fff; stroke: rgba(10, 18, 22, 0.6); }

/* Rozptyl směru za 10 min na vnitřní hraně kotouče: výrazně 80 % času, slabě celé rozpětí */
.spread { fill: var(--dial-ring); fill-opacity: 0.4; }
.spread-range { fill: var(--dial-ring); fill-opacity: 0.14; }
.instrument[data-dial="map"] .spread { fill: #fff; fill-opacity: 0.72; }
.instrument[data-dial="map"] .spread-range { fill: #fff; fill-opacity: 0.3; }

.hub { fill: var(--dial-arrow); stroke: var(--dial-halo); stroke-width: 4; }
.instrument[data-dial="map"] .hub { fill: #fff; stroke: rgba(10, 18, 22, 0.6); }

.instrument figcaption {
  margin-top: 8px;
  display: grid;
  gap: 12px;
  justify-items: start;
}
.key {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.875rem;
  color: var(--ink-2);
}
.key-item { display: inline-flex; align-items: center; gap: 6px; }
/* Vzorek je výřez podkladu kotouče (kompas, nebo ortofoto) se značkou ve stejném stylu jako na něm. */
.key-item svg {
  width: 34px;
  height: 20px;
  padding: 4px 5px;
  box-sizing: border-box;
  overflow: visible;
  flex: none;
  border-radius: 5px;
  background: var(--dial-face);
  box-shadow: inset 0 0 0 1px var(--hair);
}
.instrument[data-dial="map"] .key-item svg { background: url("img/ortofoto-800.webp") -60px -250px / 400px; box-shadow: none; }
.k-halo { stroke: var(--dial-halo); stroke-width: 5; stroke-linecap: round; }
.k-arrow { stroke: var(--dial-arrow); stroke-width: 2.5; stroke-linecap: round; }
.k-avg { fill: var(--dial-arrow); stroke: var(--dial-halo); stroke-width: 1.5; stroke-linejoin: round; paint-order: stroke; }
.k-spread { fill: var(--dial-ring); fill-opacity: 0.4; }
.k-spread-range { fill: var(--dial-ring); fill-opacity: 0.14; }
.k-rose { fill: var(--dial-rose); fill-opacity: 0.2; stroke: var(--dial-rose); stroke-width: 1.5; stroke-linejoin: round; }
.k-gust { fill: var(--red); stroke: var(--dial-face); stroke-width: 1.5; stroke-linejoin: round; paint-order: stroke; }
.instrument[data-dial="map"] .k-halo { stroke: rgba(10, 18, 22, 0.45); }
.instrument[data-dial="map"] .k-arrow { stroke: #fff; }
.instrument[data-dial="map"] .k-avg { fill: #fff; stroke: rgba(10, 18, 22, 0.6); }
.instrument[data-dial="map"] .k-spread { fill: #fff; fill-opacity: 0.72; }
.instrument[data-dial="map"] .k-spread-range { fill: #fff; fill-opacity: 0.3; }
.instrument[data-dial="map"] .k-rose { fill: #fff; fill-opacity: 0.22; stroke: #fff; stroke-opacity: 0.85; }
.instrument[data-dial="map"] .k-gust { stroke: var(--bg); }
.rose-summary { color: var(--ink-2); max-width: var(--measure); }

/* ---------- Přepínače ---------- */

.segmented {
  position: relative;
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  background: var(--surface);
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--ink-2);
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-checked="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* Na úzkém displeji jeden řádek, který se posouvá do strany; okraj mizí tam, kde něco pokračuje. */
@media (max-width: 560px) {
  .section-head .segmented {
    flex-wrap: nowrap;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .section-head .segmented::-webkit-scrollbar { display: none; }
  .section-head .segmented button { flex: none; white-space: nowrap; }
  .segmented[data-more="end"] { mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
  .segmented[data-more="start"] { mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); }
  .segmented[data-more="both"] { mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); }
}

/* ---------- Sekce ---------- */

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 20px;
}

.history, .stats, .about {
  padding-top: 40px;
  border-top: 1px solid var(--hair);
  margin-top: 8px;
}
.stats, .about { margin-top: 56px; }

.history-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 24px;
  min-height: 1.75rem;
  margin: -8px 0 16px;
  color: var(--ink-2);
  font-size: 0.9375rem;
}
.history-note:empty { display: none; }
.zoom-slot {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font-variant-numeric: tabular-nums;
}
.zoom-slot[data-zoomed] { color: var(--ink); }
.zoom-reset {
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  background: var(--surface);
  padding: 3px 12px;
  font-size: 0.875rem;
  cursor: pointer;
}
.zoom-reset:hover { border-color: var(--ink-3); }
.zoom-reset[hidden] { display: none; }
/* Na dotykových displejích se tahem posouvá stránka, nápověda k myši tam nepatří. */
@media (hover: none) {
  .zoom-slot:not([data-zoomed]) { display: none; }
}

/* Sloupec má šířku stránky, ne obsahu: jinak by ho široký graf (třeba po otočení z šířky na výšku)
   držel roztažený, graf by si změřil zase velkou šířku a stránka by šla posouvat do stran. */
.panels { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.panel { min-width: 0; }
.panels.loading { opacity: 0.5; transition: opacity 0.2s; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.png-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  margin: -6px -6px -6px 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}
.png-btn:hover { border-color: var(--hair); background: var(--surface); color: var(--ink); }
.png-btn svg, .png-all svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.png-all {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  background: var(--surface);
  padding: 4px 12px;
  color: var(--ink-2);
  font-size: 0.875rem;
  cursor: pointer;
}
.png-all:hover { border-color: var(--ink-3); color: var(--ink); }
.plot { min-height: 80px; }

/* uPlot: legenda nad grafem slouží jako odečet hodnot pod kurzorem */
.uplot { font-family: var(--font); display: flex; flex-direction: column; }
.u-legend {
  order: -1;
  font-size: 0.875rem;
  color: var(--ink-2);
  text-align: left;
  margin: 0 0 4px;
}
.u-legend tr { display: inline-flex; align-items: baseline; margin-right: 18px; }
.u-legend th, .u-legend td { padding: 0; border: 0; text-align: left; }
.u-legend .u-series > * { padding: 0; }
.u-legend .u-series:first-child .u-label { display: none; }
.u-legend .u-series:first-child th::after { content: none; }
.u-legend .u-series:first-child .u-value { color: var(--ink-2); font-weight: 400; padding-left: 0; }
.u-legend .u-label { font-weight: 400; display: inline-flex; align-items: center; }
.u-legend .u-label::after { content: ""; }
.u-legend .u-value { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; padding-left: 6px; }
.u-legend .u-marker { width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; }
.u-legend .u-off > * { opacity: 0.4; }
.u-cursor-x { border-right: 1px solid var(--ink-3) !important; }
.u-cursor-y { display: none; }
.u-select { background: rgba(127, 127, 127, 0.12); }

.table-view { margin-top: 28px; }
.table-view summary {
  cursor: pointer;
  color: var(--ink-2);
  width: fit-content;
}
.table-view summary:hover { color: var(--ink); }
.table-view .table-wrap { margin-top: 12px; max-height: 32rem; overflow: auto; }
.table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 16px;
}
.table-tools-label { color: var(--ink-2); font-size: 0.875rem; }
.table-note { flex-basis: 100%; color: var(--ink-2); font-size: 0.875rem; }
.table-note:empty { display: none; }

/* ---------- Tabulky ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
}
th, td {
  padding: 8px 12px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--hair);
}
th:first-child, td:first-child { text-align: left; padding-left: 0; }
thead th {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ink-2);
  position: sticky;
  top: 0;
  background: var(--bg);
}
tbody th { font-weight: 400; color: var(--ink-2); }
/* Čas za hodnotou má pevnou šířku (8 znaků, „12:44:11"), aby hodnoty nad sebou lícovaly. */
td .t {
  display: inline-block;
  min-width: 8ch;
  margin-left: 8px;
  color: var(--ink-3);
  font-size: 0.8125rem;
  text-align: right;
}
/* Světová strana za stupni, také pevná šířka („WSW") */
td .pt { display: inline-block; min-width: 2.4em; margin-left: 0.3em; text-align: left; }

/* Hodnota jako barevný štítek (barvy nastavuje colors.js); záporný okraj drží zarovnání */
.v[style] {
  margin: -2px -6px;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 500;
}

.stats-table { table-layout: fixed; min-width: 34rem; }
.stats-table th:first-child { width: 16%; }
.stats-table[data-tab="wind"] { min-width: 46rem; }
.stats-table[data-tab="wind"] th:first-child { width: 12%; }

/* Na mobilu čas pod hodnotou a zalomené záhlaví, aby se tabulka vešla bez posouvání */
@media (max-width: 560px) {
  /* šířky sloupců podle obsahu: nejdelší slovo záhlaví určí minimum */
  .stats-table, .stats-table[data-tab="wind"] { min-width: 0; table-layout: auto; }
  .stats-table th, .stats-table td { padding: 8px 3px; white-space: normal; vertical-align: top; }
  .stats-table thead th { vertical-align: bottom; font-size: 0.75rem; }
  .stats-table th:first-child, .stats-table[data-tab="wind"] th:first-child { width: auto; padding-left: 0; white-space: nowrap; }
  /* barevný štítek přesahuje o 6 px (záporný okraj), poslední sloupec mu musí nechat místo */
  .stats-table td:last-child, .stats-table th:last-child { padding-right: 6px; }
  .stats-table td .t, .stats-table td .pt { display: block; min-width: 0; margin: 4px 0 0; text-align: right; }
  .stats-table td .t { font-size: 0.75rem; }
  .stats-table td .pt { color: var(--ink-2); font-size: 0.8125rem; }
}

/* ---------- O měření ---------- */

.about {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
}
@media (min-width: 960px) {
  /* Stejné sloupce jako horní část stránky: text pod čtením, údaje pod přístrojem */
  .about { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); column-gap: 56px; }
  .specs { padding-top: calc(1.3125rem * 1.25 + 14px); }
  .credits { grid-column: 1 / -1; }
}
.about-text { display: grid; gap: 12px; align-content: start; max-width: var(--measure); color: var(--ink-2); }
.about-text h2 { color: var(--ink); margin-bottom: 2px; }

.specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 32px;
  align-content: start;
}
.specs dt { font-size: 0.875rem; color: var(--ink-2); }
.specs dd { margin-top: 2px; }
@media (max-width: 560px) {
  .specs { grid-template-columns: minmax(0, 1fr); }
}

.credits {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 32px;
  padding-top: 24px;
  border-top: 1px solid var(--hair);
  color: var(--ink-2);
  font-size: 0.9375rem;
}
.credits .logos { margin-right: auto; }
.logos { display: flex; flex-wrap: wrap; align-items: center; gap: 32px; }
.logos img { display: block; width: auto; }
.logo-dark { display: none !important; }
.logo-hdcam { filter: invert(1) brightness(0.3); }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
:root[data-theme="dark"] .logo-hdcam { filter: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
  :root:not([data-theme="light"]) .logo-hdcam { filter: none; }
}

/* ---------- Nastavení ---------- */

.settings {
  width: min(30rem, calc(100vw - var(--gutter-l) - var(--gutter-r)));
  /* Okno se drží mezi stavovým řádkem a spodní lištou: v PWA na iPhonu je stránka i pod nimi
     a horní okraj vysokého okna (s křížkem) by jinak zmizel pod hodinami. */
  top: var(--safe-top);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
  right: env(safe-area-inset-right, 0px);
  max-height: calc(100dvh - var(--safe-top) - env(safe-area-inset-bottom, 0px) - 32px);
  padding: 0;
  border: 1px solid var(--hair);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
}
/* Za otevřeným oknem se stránka rozmaže, okno tak víc vystoupí. */
.settings::backdrop {
  background: rgba(10, 18, 22, 0.32);
  -webkit-backdrop-filter: blur(8px) saturate(0.85);
  backdrop-filter: blur(8px) saturate(0.85);
}
@media (prefers-reduced-transparency: reduce) {
  .settings::backdrop { background: rgba(10, 18, 22, 0.6); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.settings form { padding: 20px 24px 24px; display: grid; gap: 20px; }
/* Hlavička s křížkem zůstává nahoře i při posouvání dlouhého okna; záporné okraje jen roztáhnou
   její pozadí přes odsazení formuláře, rozložení se nemění. */
.settings header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 2;
  margin: -20px -24px -10px;
  padding: 20px 24px 10px;
  background: var(--surface);
}
/* Po posunutí obsahu oddělí hlavičku tenká linka (jen kde prohlížeč umí animace podle posunu). */
@supports (animation-timeline: scroll()) {
  .settings header { animation: header-edge linear both; animation-timeline: scroll(nearest block); animation-range: 0 24px; }
  @keyframes header-edge { from { box-shadow: 0 1px 0 transparent; } to { box-shadow: 0 1px 0 var(--hair); } }
}
.close {
  /* Pevný čtverec: inline SVG by jinak přidal výšku řádku a kruh by se protáhl do oválu. */
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: -8px;
  border-radius: 50%;
  cursor: pointer;
}
.close svg { display: block; }
.close:hover { background: var(--surface-2); }

.settings fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.settings legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.settings fieldset.stack { display: grid; }
.settings label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.settings fieldset:not(.stack) label {
  padding: 6px 14px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  font-size: 0.9375rem;
}
.settings fieldset:not(.stack) label:has(input:checked) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.settings fieldset:not(.stack) input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.settings fieldset:not(.stack) label:has(input:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.settings input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--ink);
}
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; min-width: 0; accent-color: var(--ink); }
.range-row output { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.field-hint { color: var(--ink-2); font-size: 0.875rem; max-width: 38ch; }

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  cursor: pointer;
}
.link-btn:hover { text-decoration-thickness: 2px; }

/* ---------- Diagnostika ---------- */

.diag-body { display: grid; gap: 20px; }
.diag-group h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.diag-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--hair);
}
.diag-list dt { color: var(--ink-2); }
.diag-list dd { margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
/* stav má tečku i slovo, barva nikdy nenese význam sama */
.diag-list dd[data-state]::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--good);
}
.diag-list dd[data-state="bad"] { color: var(--red); }
.diag-list dd[data-state="bad"]::before { background: var(--red); }
.install { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--hair); }
.install p { color: var(--ink-2); }
.settings footer { display: flex; justify-content: flex-end; }

.primary {
  border: 0;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--surface);
  font-weight: 500;
  cursor: pointer;
  justify-self: start;
}

/* ---------- Widget na cizí web ---------- */

.embed-gen { width: min(66rem, calc(100vw - var(--gutter-l) - var(--gutter-r))); }
.embed-gen [hidden] { display: none !important; }
.embed-intro { margin-top: -8px; max-width: 46rem; color: var(--ink-2); }

/* Na mobilu náhled nahoře, ať je změna voleb hned vidět; na šířku volby vlevo. */
.embed-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "view" "options" "get";
  gap: 24px;
}
@media (min-width: 900px) {
  .embed-grid {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "options view" "options get";
    column-gap: 32px;
  }
}
.embed-options { grid-area: options; display: grid; gap: 20px; align-content: start; }
.embed-view { grid-area: view; min-width: 0; }
.embed-get { grid-area: get; min-width: 0; }
.embed-view h3, .embed-get h3 { margin-bottom: 8px; }
.embed-hint { margin-top: 8px; max-width: none; }
.embed-hint:empty { display: none; }
.embed-check { margin-top: 12px; }
.embed-custom { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.embed-custom input {
  width: 6.5em;
  padding: 6px 10px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.embed-preview {
  display: grid;
  place-items: center;
  min-height: 140px;
  padding: 20px;
  border: 1px dashed var(--hair);
  border-radius: 12px;
  background: var(--bg);
}
.embed-stage { overflow: hidden; border-radius: 12px; }
.embed-stage iframe { display: block; border: 0; border-radius: 12px; transform-origin: 0 0; }
.embed-view .field-hint { margin-top: 8px; max-width: none; }

.embed-code {
  display: block;
  width: 100%;
  min-height: 8.5em;
  padding: 10px 12px;
  resize: vertical;
  border: 1px solid var(--hair);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: 0.8125rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}
.embed-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 12px 0 10px; }
.embed-copied { font-size: 0.875rem; color: var(--good); }
.embed-copied[data-state="bad"] { color: var(--red); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 10px 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9375rem;
  width: max-content;
  max-width: calc(100vw - var(--gutter-l) - var(--gutter-r));
}
.toast[hidden] { display: none; }
.toast button {
  border: 0;
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .arrow, .avg-mark, .bft-toggle .chev { transition: none; }
}

@media (forced-colors: active) {
  .segmented button[aria-checked="true"] { outline: 2px solid CanvasText; }
}
