html, body { margin: 0; height: 100%; font-family: system-ui, sans-serif; }
#map { height: 100%; }

#status {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 1000; max-width: calc(100vw - 20px);
  background: rgba(255, 255, 255, 0.92); color: #333;
  padding: 6px 12px; border-radius: 6px; font-size: 13px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* loader pod stavovym pruhem, at se neprekryvaji */
#loader {
  position: absolute; top: 46px; left: 50%; transform: translateX(-50%);
  z-index: 1200; background: rgba(255, 255, 255, 0.95);
  border-radius: 999px; padding: 7px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
}
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid #cbd5e1; border-top-color: #2563eb;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.wind-arrow { display: inline-block; margin-right: 3px; font-weight: 700; }

#radar-ctl {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 1000; background: rgba(30, 41, 59, 0.88); color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 13px;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 9px;
}
#radar-ctl[hidden] { display: none; }
#radar-play {
  border: 0; background: none; color: #fff; font-size: 15px;
  cursor: pointer; padding: 0; line-height: 1; width: 20px;
}
#radar-slider { width: 170px; accent-color: #60a5fa; cursor: pointer; }
#radar-label { min-width: 42px; text-align: right; }

@media (max-width: 640px) {
  #radar-slider { width: 34vw; }
}

.temp-label {
  /* vycentrovat na souradnice stanice (kotva ikony je vlevo nahore) */
  transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-weight: 600; font-size: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.25);
  white-space: nowrap; cursor: pointer;
}
.temp-label.stale { opacity: 0.45; filter: grayscale(0.8); }

.elements {
  display: flex; flex-direction: column; gap: 4px;
  background: rgba(255, 255, 255, 0.92); padding: 6px; border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.elements button {
  border: 1px solid #ccc; background: #fff; border-radius: 5px;
  padding: 4px 9px; font-size: 12px; cursor: pointer; color: #333;
  text-align: left; white-space: nowrap;
}
.elements button:hover { background: #eef2f9; }
.elements button.active { background: #2563eb; border-color: #2563eb; color: #fff; }

.legend {
  background: rgba(255, 255, 255, 0.92); color: #333;
  padding: 8px 10px; border-radius: 6px; font-size: 12px; line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.legend-title { font-weight: 600; margin-bottom: 5px; line-height: 1.1; }
/* prvek prepinani vrstev nesmi kolidovat se stavovym boxem vpravo nahore */
.leaflet-top.leaflet-right { margin-top: 36px; }

.legend .bar { height: 10px; width: 220px; border-radius: 3px; margin-bottom: 4px; }
.legend .ticks { display: flex; justify-content: space-between; }

.records {
  background: rgba(255, 255, 255, 0.94); color: #333;
  padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.65;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3); max-width: 340px;
}
.records-head { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.records-title { font-weight: 600; font-size: 15px; margin-right: 3px; }
.records-head button {
  border: 1px solid #ccc; background: #fff; border-radius: 5px;
  padding: 3px 10px; font-size: 13px; cursor: pointer; color: #333;
}
.records-head button.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.record-row { cursor: default; border-radius: 4px; padding: 0 3px; margin: 0 -3px; }
.record-row:hover { background: #e8effd; }

@keyframes record-pulse {
  0% { stroke-opacity: 1; }
  50% { stroke-opacity: 0.25; }
  100% { stroke-opacity: 1; }
}
.record-pulse { animation: record-pulse 1.1s ease-in-out infinite; }

.popup-name { font-weight: 600; margin-bottom: 2px; }
.popup-meta { color: #666; font-size: 12px; }

#panel {
  position: absolute; top: 10px; right: 10px; bottom: auto; z-index: 1100;
  /* border-box: pri pretahovani se fixuje sirka a nesmi ji zvetsit padding */
  box-sizing: border-box;
  width: 400px; max-width: calc(100vw - 20px);
  background: rgba(255, 255, 255, 0.97); color: #222;
  border-radius: 8px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  padding: 10px 12px; font-size: 13px;
}
#panel-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  cursor: grab; user-select: none; touch-action: none;
}
#panel-head:active { cursor: grabbing; }
#panel-close { cursor: pointer; }
#panel-name { font-weight: 600; font-size: 15px; }
#panel-meta { color: #666; font-size: 12px; margin-top: 1px; }
#panel-close {
  border: 0; background: none; font-size: 20px; line-height: 1;
  cursor: pointer; color: #666; padding: 0 2px;
}
#panel-close:hover { color: #000; }
#panel-ranges { margin: 8px 0 4px; display: flex; gap: 6px; }
#panel-ranges button {
  border: 1px solid #ccc; background: #fff; border-radius: 5px;
  padding: 3px 10px; font-size: 12px; cursor: pointer; color: #333;
}
#panel-ranges button.active { background: #2563eb; border-color: #2563eb; color: #fff; }
#panel-hover {
  font-size: 12px; color: #222; margin-top: 4px; min-height: 16px;
  font-variant-numeric: tabular-nums;
}
#panel-hover b { font-size: 13px; }
#panel-chart { margin-top: 2px; }
#panel-stats { color: #444; font-size: 12px; margin-top: 6px; }

/* --- mobilni zarizeni (musi byt az za zakladnimi pravidly, prebiji je) --- */
@media (max-width: 640px) {
  /* prepinac velicin: kompaktni radky, at nezabira pul mapy */
  .elements {
    flex-direction: row; flex-wrap: wrap; gap: 3px;
    max-width: calc(100vw - 120px);
  }
  .elements button { padding: 6px 8px; font-size: 11px; }

  #status { font-size: 11px; padding: 4px 8px; max-width: 72vw; }

  /* panel detailu jako spodni list pres celou sirku */
  #panel {
    top: auto; bottom: 0; left: 0; right: 0;
    width: auto; max-width: none;
    border-radius: 12px 12px 0 0;
    max-height: 62vh; overflow-y: auto;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  #panel-ranges button { padding: 6px 12px; }

  .legend { padding: 6px 8px; }
  .legend .bar { width: 34vw; }
  .legend .ticks { font-size: 10px; }

  .records { max-width: 55vw; font-size: 12px; padding: 8px 10px; }
  .records-head button { padding: 2px 8px; font-size: 11px; }

  .leaflet-control-layers { font-size: 11px; }
}
