:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --secbg: var(--tg-theme-secondary-bg-color, #171a21);
  --text: var(--tg-theme-text-color, #e8eaf0);
  --hint: var(--tg-theme-hint-color, #8a8f9a);
  --link: var(--tg-theme-link-color, #6ab7ff);
  --button: var(--tg-theme-button-color, #2ea6ff);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --sep: rgba(127,127,127,0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { padding: 12px 14px 32px; max-width: 560px; margin: 0 auto; }

h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 4px 0 14px;
}

.card {
  background: var(--secbg);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.seg {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 12px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }

.seg-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--sep);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}
.seg-btn.active {
  background: var(--button);
  border-color: var(--button);
  color: var(--button-text);
  font-weight: 600;
}

.field-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.field-row label {
  flex: 1 1 120px;
  font-size: 12px;
  color: var(--hint);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-row input {
  background: var(--bg);
  border: 1px solid var(--sep);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 15px;
}
.field-row input:focus { outline: 2px solid var(--button); }

.hidden { display: none !important; }

.go-btn {
  width: 100%;
  background: var(--button);
  color: var(--button-text);
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 4px;
}
.go-btn:active { opacity: 0.85; }
.go-btn:disabled { opacity: 0.5; }

#status {
  color: var(--hint);
  font-size: 13px;
  text-align: center;
  margin: 10px 0;
  min-height: 18px;
}
#status.error { color: #ff5b5b; }

.point-card {
  background: var(--secbg);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
}
.point-time {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 8px;
}
.point-loc {
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.stat-tile {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px;
}
.stat-tile .k {
  font-size: 11px;
  color: var(--hint);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}
.stat-tile .v {
  font-size: 17px;
  font-weight: 700;
}
.stat-tile .v .u {
  font-size: 12px;
  font-weight: 400;
  color: var(--hint);
  margin-left: 2px;
}

.hint-alt {
  font-size: 12px;
  color: var(--hint);
  background: var(--secbg);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 4px;
}

.meteogram { width: 100%; border-radius: 12px; margin-top: 4px; display: block; }

.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--sep);
  border-top-color: var(--button);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.top-seg { margin-bottom: 12px; }
.top-seg .seg-btn { flex: 1 1 0; text-align: center; font-size: 14px; padding: 9px 10px; }

/* карта во всю ширину экрана — выходит за паддинги #app */
#mapView {
  margin: 0 -14px 12px;
}
#mapWrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 160px);
  min-height: 360px;
  overflow: hidden;
  background: var(--secbg);
}
#map { width: 100%; height: 100%; }
.leaflet-container { background: var(--secbg); font-family: inherit; }

.map-overlay {
  position: absolute;
  z-index: 900;
  background: rgba(10,12,16,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 12px;
  padding: 8px;
}

/* верхний ряд пилюль-слоёв — как на референсе (единая тёмная плашка, иконка+подпись) */
.pillbar {
  position: absolute;
  z-index: 900;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  background: rgba(10,12,16,0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 6px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.pillbar::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: #cfd3dc;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-ic { font-size: 15px; }
.pill.active { background: #f5c344; color: #171a10; }

.map-overlay-top2 {
  top: 58px;
  left: 10px;
  right: 10px;
}
.map-overlay-top2 .seg { margin: 0; }
.map-overlay-top2 .seg-btn { border-color: rgba(255,255,255,0.25); font-size: 13px; padding: 6px 10px; }

.map-hint {
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #fff;
  white-space: nowrap;
  padding: 6px 12px;
}

.map-overlay-bottom {
  bottom: 72px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-label { font-size: 12px; color: #fff; white-space: nowrap; }
.map-overlay-bottom input[type=range] { flex: 1; accent-color: var(--button); }

.legend {
  bottom: 10px;
  left: 10px;
  right: 10px;
  padding: 8px 12px;
}
.legend-bar {
  height: 10px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.legend-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #dfe2e8;
}

.wx-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  white-space: nowrap;
  padding: 3px 7px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.wx-marker .arrow { display: inline-block; margin-right: 2px; }

.wx-wind {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.wx-arrow {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  transition: transform 0.2s;
}
.wx-wind-label {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  padding: 1px 6px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* без нижней подписи/логотипа Leaflet — атрибуция карты отключена */
.leaflet-control-attribution { display: none !important; }

.map-popup-btn {
  display: block;
  width: 100%;
  background: var(--button);
  color: var(--button-text);
  border: none;
  border-radius: 8px;
  padding: 7px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
}
.leaflet-popup-content-wrapper {
  background: var(--secbg);
  color: var(--text);
  border-radius: 12px;
}
.leaflet-popup-tip { background: var(--secbg); }
.popup-title { font-weight: 700; margin-bottom: 4px; }
.popup-line { font-size: 12px; color: var(--hint); margin-bottom: 2px; }
