html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

:root {
  --topbar-offset: 86px;
}

#map {
  position: absolute;
  inset: 0;
}

/* ===== Topbar ===== */
#topbar {
  position: absolute;
  z-index: 1000;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: fit-content;
  max-width: calc(100% - 28px);
  min-height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  text-align: center;
  background: rgba(255,255,255,0.92);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  box-sizing: border-box;
}

#topbar .spacer {
  display: none;
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1;
  white-space: nowrap;
}

.hint {
  font-size: 15px;
  line-height: 1.15;
}

.helpbtn {
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.85);
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.helpbtn:hover {
  background: rgba(255,255,255,1);
}

.lang-switch{
  display:flex;
  align-items:center;
  gap:6px;
}

.langbtn{
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.85);
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  min-width: 44px;
}

.langbtn.is-active{
  background: rgba(17,24,39,.92);
  color: #fff;
}

@media (max-width: 900px) {
  #topbar {
    flex-wrap: wrap;
    row-gap: 6px;
  }
}

/* ===== Generic UI ===== */
.popup h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.popup ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.popup li {
  margin: 0;
}

.small {
  font-size: 12px;
  opacity: .85;
}

.btn {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.15);
  background: rgba(255,255,255,.9);
  cursor: pointer;
  user-select: none;
  font-size: 12px;
}

.btn:active {
  transform: translateY(1px);
}

.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(0,0,0,.15);
  margin-right: 6px;
}

/* program badges (popup) */
.badge.prog-bota { background: rgba(184,107,50,.20); border-color: rgba(184,107,50,.70); color: rgba(120,68,26,.98); }
.badge.prog-tota { background: rgba(239,75,143,.18); border-color: rgba(239,75,143,.70); color: rgba(172,34,92,.98); }
.badge.prog-wwff { background: rgba(57,198,74,.18); border-color: rgba(57,198,74,.70); color: rgba(22,120,35,.98); }
.badge.prog-sota { background: rgba(245,158,11,.18); border-color: rgba(245,158,11,.75); color: rgba(150,92,0,.98); }
.badge.prog-gma { background: rgba(239,68,68,.18); border-color: rgba(239,68,68,.75); color: rgba(153,27,27,.98); }
.badge.prog-pota { background: rgba(1,120,255,.12); border-color: rgba(1,120,255,.75); color: #0178ff; }

/* ===== Map markers ===== */
.ota-divicon {
  background: transparent !important;
  border: none !important;
}

.ota-marker {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.95);
  box-shadow: 0 6px 14px rgba(0,0,0,0.18);
}

/* SOTA ikonka vrcholu (SVG) */
.ota-sota-svg {
  display: block;
  overflow: visible;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.22));
}

.ota-sota-svg path {
  fill: #f2a51a;
  stroke: rgba(255,255,255,0.96);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.ota-sota-svg path.peak {
  fill: rgba(255,255,255,0.70);
  stroke: rgba(255,255,255,0.98);
  stroke-width: 1.2;
}

/* barvy programů */
.ota-tota { background: #ef4b8f; }
.ota-bota { background: #a86a32; }
.ota-wwff { background: #005a24; }
.ota-sota { background: #f2a51a; }
.ota-gen  { background: #64748b; }

/* ikonky OTA programů (uvnitř markerů / jinde) */
.ota-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.ota-img-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* ===== Controls ===== */
.leaflet-top.leaflet-left {
  margin-top: var(--topbar-offset);
}

.leaflet-control {
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  border-radius: 12px;
  overflow: hidden;
}

.leaflet-control-geocoder,
.leaflet-control-layers,
.locate-btn {
  font-size: 14px;
}

.leaflet-control-geocoder,
.leaflet-control-layers {
  width: min(280px, 82vw);
}

.leaflet-control-geocoder-form input {
  width: 100% !important;
}

.leaflet-control-geocoder-icon {
  display: none;
}

.leaflet-control-layers{
  pointer-events: auto;
}

/* layers panel: hide the built-in close/toggle icon */
.leaflet-control-layers .leaflet-control-layers-toggle{
  display: none !important;
}

.leaflet-control-layers label,
.leaflet-control-layers input,
.leaflet-control-layers .leaflet-control-layers-selector,
.leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers .leaflet-control-layers-base,
.leaflet-control-layers .leaflet-control-layers-overlays{
  pointer-events: auto;
  touch-action: manipulation;
}


/* Layers control */
.leaflet-control-layers-expanded {
  width: min(280px, 82vw);
  max-height: 75vh;
  overflow: auto;
  padding: 8px 10px;
  box-sizing: border-box;
}

@media (min-width: 1367px){
  .leaflet-control-layers .leaflet-control-layers-toggle {
    display: none !important;
  }
}

.leaflet-control-layers-separator {
  margin: 6px 0;
}

.leaflet-control-layers label {
  font-weight: 400;
}

.leaflet-control-layers input:checked + span {
  font-weight: 700;
}

.leaflet-control-layers-overlays label,
.leaflet-control-layers-base label {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  font-size: 14px;
  padding: 4px 0;
}

.leaflet-control-layers label span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* skutečné ikony v levém panelu */
.leaflet-control-layers .layer-panel-icon {
  display: inline-block;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 4px 0 0;
}

/* barevné tečky v levém panelu */
.layer-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  min-width: 12px;
  min-height: 12px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.dot-tota { background: #ef4b8f; }
.dot-bota { background: #a86a32; }
.dot-wwff { background: #005a24; }
.dot-sota { background: #f2a51a; }
.dot-gma { background: #ef4444; }
.dot-pota { background: #0178ff; }

/* ring variant for circle overlays */
.dot-ring {
  background: transparent !important;
  border: 2px solid currentColor;
}

.dot-ring.dot-tota { color: #ef4b8f; }
.dot-ring.dot-bota { color: #a86a32; }
.dot-ring.dot-gma { color: #ef4444; }
.dot-ring.dot-pota { background: #0178ff; }
.dot-ring.dot-ring-black { color: #444444; }

.leaflet-control-layers input[type="checkbox"],
.leaflet-control-layers input[type="radio"] {
  margin: 0 1px 0 0;
  transform: scale(1);
  transform-origin: center;
}

/* ===== Popup layout ===== */
.refs-popup .leaflet-popup-content,
.leaflet-popup-content {
  width: min(760px, 92vw);
  max-height: 72vh;
  overflow: auto;
}

.popup {
  display: flex;
  flex-direction: column;
}

.popup h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.popup ul.result-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}

.res-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.92);
}

.res-item.prog-bota { box-shadow: inset 4px 0 0 rgba(184,107,50,.55); }
.res-item.prog-tota { box-shadow: inset 4px 0 0 rgba(239,75,143,.55); }
.res-item.prog-wwff { box-shadow: inset 4px 0 0 rgba(57,198,74,.55); }
.res-item.prog-sota { box-shadow: inset 4px 0 0 rgba(245,158,11,.55); }
.res-item.prog-pota { box-shadow: inset 4px 0 0 #0178ff; }

.res-left {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.res-ref {
  font-weight: 800;
  letter-spacing: 0.2px;
}

.res-sep {
  opacity: .6;
}

.res-dist {
  font-weight: 700;
  white-space: nowrap;
}

.iconbtn {
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(255,255,255,.9);
  border-radius: 10px;
  min-width: 34px;
  min-height: 30px;
  padding: 4px 7px;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  flex: 0 0 auto;
}

.iconbtn:active {
  transform: translateY(1px);
}

@media (max-width: 900px){
  .refs-popup .leaflet-popup-content,
  .leaflet-popup-content {
    width: min(92vw, 560px);
  }

  .popup ul.result-list {
    grid-template-columns: 1fr;
  }
}

/* ===== Help modal ===== */
#helpModal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.35);
}

#helpModal.open {
  display: flex;
}

#helpModal .panel {
  width: min(720px, 100%);
  background: rgba(255,255,255,0.98);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.22);
  padding: 14px 14px 10px;
}

#helpModal .panel h3 {
  margin: 2px 0 10px;
  font-size: 18px;
}

#helpModal .panel ul {
  margin: 0 0 10px 18px;
  padding: 0;
  line-height: 1.35;
  font-size: 14px;
}

#helpModal .panel .row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

#helpClose {
  border: 0;
  background: rgba(0,0,0,0.06);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}


/* ===== Responsive / mobil ===== */
@media (min-width: 769px) and (max-width: 1366px){
  #topbar{
    gap: 8px;
    padding: 8px 12px;
    max-width: calc(100% - 20px);
  }

  .brand{ font-size: 16px; }
  .hint{ font-size: 13px; }

  .helpbtn,
  .langbtn{
    font-size: 13px;
    padding: 6px 9px;
  }

  .leaflet-control-geocoder,
  .leaflet-control-layers{
    width: 270px !important;
    max-width: min(270px, calc(100vw - 24px));
  }

  .leaflet-control-layers-expanded{
    width: 270px !important;
    max-width: min(270px, calc(100vw - 24px));
    max-height: 52vh;
    padding: 6px 8px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .leaflet-control-layers .leaflet-control-layers-toggle{
    display: none !important;
  }

  .leaflet-control-layers-list,
  .leaflet-control-layers-base,
  .leaflet-control-layers-overlays{
    max-height: none !important;
    overflow: visible !important;
  }

  .leaflet-control-layers-overlays label,
  .leaflet-control-layers-base label{
    font-size: 13px;
    padding: 3px 0;
    line-height: 1.1;
  }

  .leaflet-control-layers .layer-panel-icon{
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
  }

  .leaflet-popup-content{
    width: min(760px, 94vw);
  }
}

@media (max-width: 1024px){
  #topbar{
    gap: 10px;
    padding: 9px 14px;
  }

  .brand{ font-size: 17px; }
  .hint{ font-size: 14px; }

  .leaflet-control-geocoder,
  .leaflet-control-layers{
    width: min(340px, 92vw) !important;
    max-width: calc(100vw - 24px);
  }

  .leaflet-popup-content{
    width: min(760px, 94vw);
  }
}

@media (max-width: 768px){
  #topbar{
    top: 8px;
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    gap: 6px 10px;
    padding: 8px 10px;
    border-radius: 14px;
    align-items: flex-start;
  }

  .brand{
    font-size: 16px;
    white-space: normal;
    width: 100%;
  }

  .hint{
    font-size: 13px;
    line-height: 1.2;
    flex: 1 1 180px;
  }

  .helpbtn{
    font-size: 13px;
    padding: 7px 10px;
    flex: 0 0 auto;
  }

  .lang-switch{
    order: 3;
  }

  .langbtn{
    min-height: 42px;
    padding: 7px 10px;
  }

  .leaflet-top.leaflet-left{
    margin-top: var(--topbar-offset);
  }

  .leaflet-control-geocoder{
    width: min(94vw, 420px) !important;
    max-width: calc(100vw - 16px) !important;
    box-sizing: border-box;
  }

  .leaflet-control-geocoder-form input{
    font-size: 16px !important;
    padding-top: 10px;
    padding-bottom: 10px;
    box-sizing: border-box !important;
  }
}

/* ===== Result bottom sheet ===== */
.results-sheet-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 4290;
}

.results-sheet-backdrop.is-open{
  opacity: 1;
  pointer-events: auto;
}

.results-sheet{
  --sheet-width: 1120px;
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 18px;
  width: min(var(--sheet-width), calc(100vw - 48px));
  min-width: min(560px, calc(100vw - 48px));
  z-index: 4300;
  background: rgba(255,255,255,.97);
  border-radius: 22px;
  box-shadow: 0 18px 42px rgba(0,0,0,.20);
  backdrop-filter: blur(8px);
  transform: translate(-50%, calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
  transition: transform .24s ease, opacity .24s ease;
}

.results-sheet.is-open{
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}

.results-sheet-head{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 8px;
}

.results-sheet-title{
  font-weight: 800;
  font-size: 16px;
}

.results-sheet-close{
  border: 0;
  background: rgba(0,0,0,.06);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  font-size: 20px;
  line-height: 34px;
  cursor: pointer;
}

.results-sheet-body{
  padding: 0 16px 14px;
}

.results-sheet-body .popup h3{
  display: none;
}

.results-sheet-body .popup ul.result-list{
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.results-sheet-body .popup{
  max-height: none;
  overflow: visible;
}

.results-sheet.cols-1{ --sheet-width: 600px; }
.results-sheet.cols-2{ --sheet-width: 1120px; }
.results-sheet.cols-3{ --sheet-width: 1560px; }


.results-sheet.cols-1 .results-sheet-body .popup ul.result-list{
  grid-template-columns: 1fr;
}

@media (min-width: 1400px){
  .results-sheet-body .popup ul.result-list{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px){
  .results-sheet-body{
    padding: 0 16px 16px;
  }

  .results-sheet-body .popup ul.result-list{
    max-height: calc(5 * 56px + 4 * 10px + 8px);
    overflow-y: auto;
    overflow-x: hidden;
    align-content: start;
  }
}

@media (max-width: 768px){
  .results-sheet-backdrop{
    z-index: 4290;
  }

  .results-sheet{
    left: 12px;
    right: 12px;
    width: auto;
    min-width: 0;
    bottom: 84px;
    border-radius: 18px;
    transform: translateY(calc(100% + 24px));
  }

  .results-sheet.is-open{
    transform: translateY(0);
  }

  .results-sheet-head{
    padding: 10px 12px 8px;
  }

  .results-sheet-grabber{
    position: absolute;
    left: 50%;
    top: 6px;
    transform: translateX(-50%);
    width: 42px;
    height: 5px;
    border-radius: 999px;
    background: rgba(100,116,139,.35);
  }

  .results-sheet-title{
    font-size: 14px;
    padding-top: 4px;
  }

  .results-sheet-close{
    width: 32px;
    height: 32px;
    line-height: 32px;
    font-size: 18px;
  }

  .results-sheet-body{
    padding: 0 12px 12px;
  }

  .results-sheet-body .popup{
    max-height: calc(100vh - 260px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .results-sheet-body .popup ul.result-list{
    grid-template-columns: 1fr;
    gap: 8px;
  }
}


/* ===== Moje aktivace ===== */
.ota-my-marker{
  position: relative;
  box-sizing: border-box;
  border-radius: 50%;
  background: #e03131;
  border: var(--ring) solid rgba(255,255,255,.98);
  box-shadow: 0 8px 18px rgba(224,49,49,.30), 0 4px 10px rgba(0,0,0,.16);
}

.ota-my-marker::after{
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--inner);
  height: var(--inner);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
}

.res-item.is-mine{
  border-color: rgba(224,49,49,.35);
  background: linear-gradient(90deg, rgba(224,49,49,.08), rgba(255,255,255,.96) 22%);
}

.my-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  color: #fff;
  background: #e03131;
  box-shadow: 0 3px 8px rgba(224,49,49,.24);
}
