:root {
  color-scheme: light;
  --text: #12151a;
  --secondary: rgba(18, 21, 26, 0.58);
  --tertiary: rgba(18, 21, 26, 0.38);
  --blue: #0a84ff;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff453a;
  --glass: rgba(249, 251, 255, 0.70);
  --glass-strong: rgba(250, 252, 255, 0.88);
  --glass-border: rgba(255, 255, 255, 0.76);
  --hairline: rgba(23, 30, 39, 0.11);
  --shadow: 0 10px 34px rgba(28, 38, 52, 0.18), 0 2px 8px rgba(28, 38, 52, 0.08);
  --timeline-history: rgba(10, 132, 255, 0.78);
  --timeline-forecast: rgba(255, 159, 10, 0.82);
  --panel-radius: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--text); background: #dbe2ea; -webkit-font-smoothing: antialiased; }
button, input, output { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell, #map { position: fixed; inset: 0; }
#map { background: #dfe6ed; }
.leaflet-container { font: inherit; }
.leaflet-control-zoom { display: none; }
.leaflet-pane.leaflet-radar-pane img { image-rendering: auto; }
.radar-image { transition: opacity 0.18s linear; }
.leaflet-control-attribution {
  left: max(8px, env(safe-area-inset-left));
  right: auto !important;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 128px);
  padding: 3px 7px !important;
  border-radius: 8px 8px 0 0;
  background: rgba(248, 250, 253, 0.72) !important;
  color: rgba(18, 21, 26, 0.48) !important;
  backdrop-filter: blur(15px) saturate(150%);
  -webkit-backdrop-filter: blur(15px) saturate(150%);
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: rgba(10, 84, 170, 0.78) !important; }

.liquid-glass {
  position: relative;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.58), rgba(238, 244, 251, 0.34)),
    var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(180%) contrast(104%);
  -webkit-backdrop-filter: blur(28px) saturate(180%) contrast(104%);
  isolation: isolate;
}
.liquid-glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.64), transparent 42%, rgba(255, 255, 255, 0.16));
  opacity: 0.58;
  z-index: -1;
}

.map-control {
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: contain;
}

.status-card {
  position: fixed;
  z-index: 900;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  width: fit-content;
  padding: 12px 14px 11px;
  border-radius: 22px;
}
.frame-kind {
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.frame-kind.is-forecast { color: #d66d00; }
.frame-time-row { display: flex; align-items: center; gap: 7px; min-height: 35px; }
.frame-time {
  font-size: 29px;
  line-height: 1;
  font-weight: 760;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}
.frame-date {
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--secondary);
  font-size: 11px;
  line-height: 1.35;
}
.status-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
  color: var(--secondary);
  font-size: 10px;
  white-space: nowrap;
}
.status-line span:last-child { overflow: hidden; text-overflow: ellipsis; }
.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8e8e93;
  box-shadow: 0 0 0 3px rgba(142, 142, 147, 0.12);
}
.status-dot.is-ok { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.13); }
.status-dot.is-error { background: var(--red); box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.13); }
.loading-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(10, 132, 255, 0.20);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-spinner.is-visible { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.map-tools {
  position: fixed;
  z-index: 920;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 8px;
}
.glass-icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  color: #11151b;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.16s ease, filter 0.16s ease;
}
.glass-icon-button:hover { filter: brightness(1.025); }
.glass-icon-button:focus-visible { outline: 3px solid rgba(10, 132, 255, 0.35); outline-offset: 2px; }
.glass-icon-button:active { transform: scale(0.93); }
.glass-icon-button svg { width: 19px; height: 19px; fill: currentColor; }

.timeline-panel {
  position: fixed;
  z-index: 910;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  min-height: 119px;
  padding: 14px;
  border-radius: 25px;
  touch-action: none;
}
.timeline-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.timeline-title { min-width: 0; }
.timeline-title strong { display: block; font-size: 16px; line-height: 1.2; letter-spacing: -0.015em; }
.timeline-title span { display: block; margin-top: 2px; color: var(--secondary); font-size: 11px; }
.play-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 5px 16px rgba(10, 132, 255, 0.28);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.play-button:active { transform: scale(0.93); }
.play-button:disabled { opacity: 0.45; cursor: default; }
.play-button svg { width: 18px; height: 18px; fill: currentColor; }
.play-button .pause-icon { display: none; }
.play-button.is-playing .play-icon { display: none; }
.play-button.is-playing .pause-icon { display: block; }
.timeline-wrap { margin-top: 13px; }
#timeline {
  --history-ratio: 78%;
  width: 100%;
  height: 20px;
  margin: 0;
  padding: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  touch-action: none;
}
#timeline::-webkit-slider-runnable-track {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--timeline-history) 0 var(--history-ratio),
    var(--timeline-forecast) var(--history-ratio) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34);
}
#timeline::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(25, 32, 42, 0.10);
  box-shadow: 0 2px 8px rgba(24, 32, 44, 0.28);
}
#timeline::-moz-range-track {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--timeline-history) 0 var(--history-ratio),
    var(--timeline-forecast) var(--history-ratio) 100%);
}
#timeline::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(25, 32, 42, 0.10);
  box-shadow: 0 2px 8px rgba(24, 32, 44, 0.28);
}
.timeline-labels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  margin-top: 1px;
  color: var(--secondary);
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.timeline-labels span:nth-child(2) { text-align: center; }
.timeline-labels span:nth-child(3) { text-align: right; }
.timeline-now { font-size: 9px; font-weight: 760; letter-spacing: 0.08em; }

.settings-backdrop {
  position: fixed;
  z-index: 1050;
  inset: 0;
  background: rgba(13, 18, 25, 0.20);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.settings-backdrop[hidden], .settings-sheet[hidden] { display: none; }
.settings-sheet {
  position: fixed;
  z-index: 1080;
  top: 50%;
  left: 50%;
  width: min(430px, calc(100vw - 24px));
  max-height: min(690px, calc(100vh - 32px));
  padding: 9px 12px 14px;
  border-radius: 28px;
  transform: translate(-50%, -50%);
  overflow: auto;
  touch-action: pan-y;
}
.sheet-handle { display: none; width: 36px; height: 5px; margin: 2px auto 7px; border-radius: 999px; background: rgba(20, 25, 32, 0.18); }
.settings-header { display: flex; align-items: center; justify-content: space-between; padding: 5px 5px 10px; }
.settings-header h2 { margin: 0; font-size: 20px; letter-spacing: -0.025em; }
.close-button {
  border: 0;
  padding: 7px 8px;
  border-radius: 10px;
  color: var(--blue);
  background: transparent;
  font-weight: 650;
  cursor: pointer;
}
.settings-section {
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.66);
}
.settings-section h3 {
  margin: 9px 0 6px;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.setting-row, .about-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--hairline);
}
.settings-section h3 + .setting-row,
.settings-section h3 + .about-row { border-top: 0; }
.setting-row > span:first-child { min-width: 0; }
.setting-row strong { display: block; font-size: 14px; font-weight: 520; }
.setting-row small { display: block; margin-top: 2px; color: var(--secondary); font-size: 11px; }
.setting-range { min-height: 39px; border: 0; font-size: 14px; }
.setting-range output { color: var(--secondary); font-variant-numeric: tabular-nums; }
.settings-section > input[type="range"] { width: 100%; margin: 2px 0 12px; accent-color: var(--blue); }
.ios-switch { position: relative; flex: 0 0 auto; width: 51px; height: 31px; }
.ios-switch input { position: absolute; opacity: 0; pointer-events: none; }
.ios-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.28);
  transition: background 0.18s ease;
  cursor: pointer;
}
.ios-switch span::after {
  content: "";
  position: absolute;
  width: 27px;
  height: 27px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.20);
  transition: transform 0.18s ease;
}
.ios-switch input:checked + span { background: var(--green); }
.ios-switch input:checked + span::after { transform: translateX(20px); }
.ios-switch input:focus-visible + span { outline: 3px solid rgba(10, 132, 255, 0.32); outline-offset: 2px; }
.legend-section img { display: block; width: fit-content; max-width: fit-content; height: auto; margin: 8px auto 12px; border-radius: 8px; }
.about-row { color: inherit; text-decoration: none; font-size: 14px; }
.about-row span { color: var(--text); }
.about-row strong { max-width: 66%; color: var(--secondary); font-weight: 500; text-align: right; overflow-wrap: anywhere; }
a.about-row strong { color: var(--blue); }
.about-note { padding: 11px 0 8px; border-top: 1px solid var(--hairline); color: var(--secondary); font-size: 10px; line-height: 1.45; }

.toast {
  position: fixed;
  z-index: 1200;
  left: 50%;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 133px);
  max-width: calc(100vw - 30px);
  padding: 10px 14px;
  border-radius: 999px;
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.user-position { filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.30)); }
.user-position div {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid #fff;
  box-shadow: 0 0 0 8px rgba(10, 132, 255, 0.17);
}

body.dark-map {
  --glass: rgba(30, 34, 41, 0.72);
  --glass-strong: rgba(30, 34, 41, 0.88);
  --glass-border: rgba(255, 255, 255, 0.19);
  --hairline: rgba(255, 255, 255, 0.12);
  --text: #f6f7f9;
  --secondary: rgba(246, 247, 249, 0.62);
  --tertiary: rgba(246, 247, 249, 0.42);
}
body.dark-map .liquid-glass {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.025)),
    var(--glass);
}
body.dark-map .glass-icon-button { color: #fff; }
body.dark-map .settings-section { background: rgba(22, 25, 31, 0.58); border-color: rgba(255, 255, 255, 0.10); }
body.dark-map .leaflet-control-attribution { background: rgba(22, 25, 31, 0.72) !important; color: rgba(255,255,255,.55) !important; }
body.dark-map .leaflet-control-attribution a { color: rgba(153, 202, 255, 0.82) !important; }


@media (min-width: 721px) {
  .timeline-panel {
    max-width: 720px;
    margin: 0 auto;
  }
}

@media (max-width: 720px) {
  .status-card { width: fit-content; padding: 10px 12px 9px; border-radius: 20px; }
  .frame-time { font-size: 27px; }
  .frame-date { font-size: 10px; }
  .status-line { margin-top: 7px; padding-top: 7px; font-size: 9px; }
  .map-tools { gap: 6px; }
  .glass-icon-button { width: 41px; height: 41px; }
  .glass-icon-button svg { width: 18px; height: 18px; }
  .timeline-panel { padding: 13px 14px 11px; border-radius: 23px; }
  .timeline-title strong { font-size: 15px; }
  .leaflet-control-attribution { bottom: calc(max(10px, env(safe-area-inset-bottom)) + 124px); }
}

@media (max-width: 460px) {
  .status-card { width: fit-content; }
  .frame-kind { font-size: 11px; }
  .frame-time { font-size: 25px; }
  .map-tools { gap: 5px; }
  .glass-icon-button { width: 38px; height: 38px; }
  .glass-icon-button svg { width: 17px; height: 17px; }
  .timeline-panel { left: 9px; right: 9px; bottom: max(9px, env(safe-area-inset-bottom)); }
  .timeline-title span { font-size: 10px; }
  .settings-sheet {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    max-height: min(82vh, 720px);
    border-radius: 28px;
    transform: none;
  }
  .sheet-handle { display: block; }
  .toast { bottom: calc(max(9px, env(safe-area-inset-bottom)) + 128px); }
}

@media (max-width: 370px) {
  .status-card { width: 140px; }
  .frame-date { display: none; }
  .map-tools { display: grid; grid-template-columns: repeat(2, 38px); }
  .timeline-title span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .liquid-glass { background: rgba(249, 251, 255, 0.94); }
  body.dark-map .liquid-glass { background: rgba(30, 34, 41, 0.94); }
}

/* Web 2.1: stav automatického hledání polohy */
.glass-icon-button.is-locating svg {
  animation: locate-pulse 0.9s ease-in-out infinite alternate;
}
@keyframes locate-pulse {
  from { opacity: 0.45; transform: scale(0.90); }
  to { opacity: 1; transform: scale(1.05); }
}
@media (prefers-reduced-motion: reduce) {
  .glass-icon-button.is-locating svg { animation: none; opacity: 0.65; }
}

.info-button {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1200;

  width: 44px;
  height: 44px;
  padding: 0;

  display: grid;
  place-items: center;

  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);

  color: #1c1c1e;
  font-size: 20px;
  font-weight: 700;
  font-family: Georgia, serif;

  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.info-button:hover {
  transform: scale(1.04);
}

.info-button:active {
  transform: scale(0.96);
}

.info-dialog[hidden] {
  display: none;
}

.info-dialog {
  position: fixed;
  inset: 0;
  z-index: 2000;

  display: grid;
  place-items: center;
  padding: 20px;
}

.info-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.info-card {
  position: relative;
  z-index: 1;
  background: white;

  width: min(100%, 360px);
  padding: 28px 22px 22px;

  border-radius: 28px;
  text-align: center;
  color: #1c1c1e;

  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.info-card h2 {
  margin: 10px 0 22px;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.info-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto;

  display: grid;
  place-items: center;

  border-radius: 16px;
  background: rgba(0, 122, 255, 0.14);
  color: #007aff;

  font-family: Georgia, serif;
  font-size: 28px;
  font-weight: 700;
}

.info-close {
  position: absolute;
  top: 12px;
  right: 14px;

  width: 34px;
  height: 34px;
  padding: 0;

  border: 0;
  border-radius: 50%;
  background: rgba(120, 120, 128, 0.14);

  color: #3a3a3c;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.info-details {
  display: grid;
  gap: 10px;
  text-align: left;
}

.info-details > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;

  padding: 13px 14px;
  border-radius: 15px;
  background: rgba(120, 120, 128, 0.09);
}

.info-details span {
  color: #6e6e73;
  font-size: 14px;
}

.info-details strong,
.info-details a {
  color: #1c1c1e;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  text-decoration: none;
}

.info-details a:hover {
  text-decoration: underline;
}

/* Pokud tlačítko koliduje se spodní timeline */
@media (max-width: 720px) {
  .info-button {
    bottom: calc(150px + env(safe-area-inset-bottom));
  }
}

body.info-dialog-open {
  overflow: hidden;
}

div.status-line, div.frame-date {display: none;}