/* ============ Tokeny ============ */
:root {
  --bg: #e8edf0;
  --surface: #ffffff;
  --surface-2: #f2f5f7;
  --ink: #17232d;
  --muted: #5b6a76;
  --line: #d3dce2;
  --cold: #2e6db4;
  --warm: #e0533a;
  --accent: #1f7a8c;
  --accent-ink: #ffffff;
  --ok: #2f9461;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4b00;
  --err-bg: #fde3df;
  --err-ink: #8a1f12;
  --t-color: #8aa0b0;

  --f-num: "Bahnschrift", "DIN Alternate", "DIN Next", "Barlow Semi Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d151c;
    --surface: #15202a;
    --surface-2: #1b2833;
    --ink: #e4ecf1;
    --muted: #8d9ca8;
    --line: #273642;
    --cold: #6aa6e8;
    --warm: #ff7a5c;
    --accent: #4cb5c7;
    --accent-ink: #08151b;
    --ok: #4fc387;
    --warn-bg: #3a2f10;
    --warn-ink: #f3d68a;
    --err-bg: #3d1a16;
    --err-ink: #ffb4a8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d151c;
  --surface: #15202a;
  --surface-2: #1b2833;
  --ink: #e4ecf1;
  --muted: #8d9ca8;
  --line: #273642;
  --cold: #6aa6e8;
  --warm: #ff7a5c;
  --accent: #4cb5c7;
  --accent-ink: #08151b;
  --ok: #4fc387;
  --warn-bg: #3a2f10;
  --warn-ink: #f3d68a;
  --err-bg: #3d1a16;
  --err-ink: #ffb4a8;
  color-scheme: dark;
}

/* ============ Základ ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--f-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
b { font-weight: 600; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.main { flex: 1; padding-top: 20px; padding-bottom: 32px; }

/* ============ Horní lišta ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 8px 20px;
  min-height: 60px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--f-num);
  font-size: 1.15rem;
  font-weight: 600;
}
.brand-mark { width: 30px; height: 30px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.lang-switch a {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 9px;
  border-radius: 999px;
}
.lang-switch a[aria-current="true"] { background: var(--ink); color: var(--bg); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:disabled { opacity: .4; cursor: default; }
#themeBtn svg { display: none; }
#themeBtn[data-mode="auto"] .i-auto,
#themeBtn[data-mode="light"] .i-light,
#themeBtn[data-mode="dark"] .i-dark { display: block; }

.btn-ghost, .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn-ghost { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-primary { border: 0; background: var(--accent); color: var(--accent-ink); min-height: 44px; }
.btn-primary:hover { filter: brightness(1.08); }

@media (max-width: 720px) {
  .topbar-inner { padding-top: 8px; padding-bottom: 6px; }
  .nav {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 -4px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .brand span { font-size: 1.05rem; }
}

/* ============ Hlášky ============ */
.banner {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.banner.error { background: var(--err-bg); color: var(--err-ink); border-color: transparent; }
.banner pre { margin: 8px 0 0; overflow-x: auto; }
.banner code { font-size: .9rem; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* ============ Přehled ============ */
.dash { display: grid; gap: 16px; }
.dash[data-empty] > :not(.empty) { display: none; }
.dash:not([data-empty]) > .empty { display: none; }

.hero {
  position: relative;
  border-radius: var(--r-lg);
  padding: 22px clamp(18px, 4vw, 36px) 26px;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in oklab, var(--t-color) 30%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: background-color .6s;
}
.hero-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hero-label { font-size: 1.05rem; font-weight: 600; }
.stamp { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2.4s infinite; }
.stale .pulse { background: var(--warm); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.hero-temp {
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: clamp(5.2rem, 17vw, 9.5rem);
  line-height: .95;
  letter-spacing: -.035em;
  margin: 10px 0 6px;
  color: var(--ink);
}
.hero-unit { font-size: .36em; letter-spacing: 0; margin-left: .12em; vertical-align: .95em; color: var(--muted); }
.hero-facts { display: flex; gap: 8px 28px; flex-wrap: wrap; font-size: 1.05rem; }
.hero-facts b { font-family: var(--f-num); font-size: 1.15rem; font-variant-numeric: tabular-nums; }

/* Teplotní stupnice: celý gradient je pevná škála, zvýrazněný úsek = dnešní rozpětí */
.scale { margin-top: 26px; }
.scale-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #4a5fc1, #3d8fd1 22%, #49b3b0 40%, #9cc45a 55%, #f0b43c 72%, #e5683a 86%, #c43a3a);
  opacity: .9;
}
.scale-span {
  position: absolute;
  top: -4px;
  bottom: -4px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  left: 0;
  width: 0;
  transition: left .6s, width .6s;
}
.scale-now {
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: var(--ink);
  border: 4px solid var(--surface);
  left: 0;
  transition: left .6s;
}
.scale-ends { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: .95rem; flex-wrap: wrap; }
.scale-ends span:last-child { text-align: right; }
.scale-ends b { font-family: var(--f-num); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.scale-ends small { color: var(--muted); }

.tiles {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
}
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tiles { grid-template-columns: minmax(0, 1fr); } }
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tile h2 { color: var(--muted); font-weight: 550; font-size: .95rem; }
.tile-wind { grid-column: span 2; }
@media (max-width: 560px) { .tile-wind { grid-column: auto; } }

.big {
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 2.6rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.02em;
}
.big .u { font-size: .42em; color: var(--muted); margin-left: .2em; letter-spacing: 0; }

.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--cold); border-radius: inherit; transition: width .6s; }

.kv { margin: 0; display: grid; gap: 6px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--f-num); font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.kv-rows > div { padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-rows > div:last-child { border-bottom: 0; }

.trend { display: flex; align-items: center; gap: 8px; }
.trend svg { width: 20px; height: 20px; flex: none; }
.trend.up { color: var(--warm); }
.trend.down { color: var(--cold); }
.trend span { color: var(--ink); }

.wind { display: flex; gap: 20px; align-items: center; }
.compass { width: 150px; height: 150px; flex: none; }
.c-ring { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }
.c-ticks line { stroke: var(--muted); stroke-width: 1; opacity: .55; }
.c-lbl { fill: var(--muted); font: 600 10px var(--f-body); text-anchor: middle; }
.c-deg { fill: var(--ink); font: 500 17px var(--f-num); text-anchor: middle; }
.c-needle {
  fill: var(--warm);
  transform-box: view-box;
  transform-origin: 50% 50%;
  transition: transform .8s cubic-bezier(.3, 1.3, .5, 1);
}
.wind-data { flex: 1; display: grid; gap: 8px; min-width: 0; }
@media (max-width: 400px) { .compass { width: 120px; height: 120px; } .wind { gap: 14px; } }

.uv { display: flex; align-items: center; gap: 10px; }
.uv-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .9rem;
  background: var(--surface-2);
}
.uv-badge[data-l="0"] { background: #3ea055; color: #fff; }
.uv-badge[data-l="1"] { background: #f2c230; color: #2b2300; }
.uv-badge[data-l="2"] { background: #f08a24; color: #2b1600; }
.uv-badge[data-l="3"] { background: #d8352a; color: #fff; }
.uv-badge[data-l="4"] { background: #8e4bb4; color: #fff; }

.lightning-when { font-family: var(--f-num); font-size: 1.6rem; line-height: 1.1; }

/* Dnešní min/max */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px;
}
.panel > h2 { margin-bottom: 12px; }
.minmax { display: grid; }
.mm-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.2fr) 1fr 1fr;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  align-items: baseline;
}
.mm-row:first-child { border-top: 0; }
.mm-head { color: var(--muted); font-size: .85rem; padding-top: 0; }
.mm-val { font-family: var(--f-num); font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.mm-val small { font-family: var(--f-body); color: var(--muted); font-size: .8rem; margin-left: 6px; }
.mm-val.min { color: var(--cold); }
.mm-val.max { color: var(--warm); }
.mm-val .na { color: var(--muted); }
@media (max-width: 520px) {
  .mm-row { grid-template-columns: 1fr 1fr; }
  .mm-row > :first-child { grid-column: 1 / -1; font-weight: 550; }
  .mm-head > :first-child { display: none; }
}

/* ============ Podstránky ============ */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.date-nav { display: flex; gap: 6px; align-items: center; }
.date-nav input {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  height: 38px;
}
.period { font-family: var(--f-num); font-size: 1.25rem; margin-bottom: 12px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.stats dt { color: var(--muted); font-size: .85rem; }
.stats dd { margin: 2px 0 0; font-family: var(--f-num); font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.stats dd small { font-family: var(--f-body); font-size: .78rem; color: var(--muted); display: block; }

.charts { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-wide { grid-column: 1 / -1; }
@media (max-width: 860px) { .charts { grid-template-columns: minmax(0, 1fr); } }
.chart-panel h2 small { font-weight: 400; }
.chart-box { position: relative; height: 260px; }
.chart-wide .chart-box { height: 320px; }
.chart-square { height: 300px; }
.charts.loading { opacity: .55; transition: opacity .2s; }

.records { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.rec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; }
.rec h2 { font-size: .95rem; font-weight: 550; margin-bottom: 10px; }
.rec-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rec-cols p:first-child { color: var(--muted); font-size: .8rem; }
.rec-v { font-family: var(--f-num); font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rec-v .u { font-size: .55em; color: var(--muted); margin-left: .15em; }
.rec-d { color: var(--muted); font-size: .8rem; }

.sys-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* Přihlášení */
.login-wrap { display: grid; place-items: center; padding: 6vh 0; }
.login { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 26px; border-radius: var(--r-lg); }
.login h1 { font-family: var(--f-num); font-weight: 500; }
.field { display: grid; gap: 6px; }
.field span { font-size: .9rem; font-weight: 550; }
.field input {
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  height: 44px;
  padding: 0 12px;
}
.link-quiet { color: var(--muted); text-align: center; font-size: .9rem; }

.footer { padding-top: 16px; padding-bottom: max(20px, env(safe-area-inset-bottom)); color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

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