:root {
  color-scheme: light dark;
  --bg: #07111c;
  --panel: rgba(8, 19, 31, 0.96);
  --panel-soft: rgba(15, 31, 48, 0.92);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f5f9fc;
  --muted: #9fb1c2;
  --accent: #38a9f3;
  --accent-dark: #147fbd;
  --danger: #ff6d6d;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  color: inherit;
}

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

.leaflet-control-container {
  position: relative;
  z-index: 18;
}

.leaflet-top.leaflet-right {
  top: 78px;
  right: 14px;
}

.leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid var(--line) !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
  border-color: var(--line) !important;
  background: rgba(7, 17, 28, 0.92) !important;
  color: white !important;
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.85) !important;
  color: #29333d;
  font-size: 9px;
}

.topbar {
  position: absolute;
  z-index: 1000;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 65px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, rgba(4, 11, 18, 0.96), rgba(4, 11, 18, 0.76));
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.brand,
.header-actions {
  display: flex;
  align-items: center;
  pointer-events: auto;
}

.brand {
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(99, 204, 255, 0.62);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fff3a6, #ffb932 35%, #118bd0 67%, #073b60);
  box-shadow: 0 0 28px rgba(40, 169, 244, 0.34);
  color: #07111c;
  font-size: 21px;
}

.brand div {
  display: flex;
  flex-direction: column;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.header-actions {
  gap: 8px;
}

.round-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(8, 20, 32, 0.9);
  box-shadow: 0 7px 24px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.round-button:hover,
.round-button:focus-visible {
  border-color: var(--accent);
  background: #14334c;
}

.search-shell {
  position: absolute;
  z-index: 1100;
  top: 77px;
  left: 18px;
  width: min(430px, calc(100vw - 386px));
}

.search-box {
  display: grid;
  grid-template-columns: 28px 1fr 30px;
  align-items: center;
  min-height: 48px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(7, 17, 28, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.search-box > span {
  color: var(--muted);
  text-align: center;
  font-size: 22px;
}

.search-box input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: white;
}

.search-box input::placeholder {
  color: #8da0b2;
}

.search-box button {
  border: 0;
  background: transparent;
  color: #9aabba;
  font-size: 22px;
  cursor: pointer;
}

.search-results {
  max-height: min(430px, calc(100vh - 155px));
  margin-top: 7px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(7, 17, 28, 0.98);
  box-shadow: var(--shadow);
}

.search-result {
  display: grid;
  width: 100%;
  grid-template-columns: 39px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result:focus-visible {
  background: rgba(45, 157, 225, 0.15);
}

.search-result-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #163850;
  font-size: 18px;
}

.search-result-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.search-result-copy strong {
  overflow: hidden;
  color: white;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-copy small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-temp {
  color: #d7ecfb;
  font-size: 12px;
  font-weight: 700;
}

.control-panel {
  position: absolute;
  z-index: 1000;
  top: 77px;
  right: 18px;
  width: 330px;
  max-height: calc(100vh - 95px);
  padding: 17px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-heading,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.panel-heading div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.panel-heading strong {
  font-size: 15px;
}

.panel-heading small {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-panel section {
  padding-top: 15px;
}

.control-panel h2 {
  margin: 0 0 9px;
  color: #b6c5d3;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.stats-grid article {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 10px 7px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
}

.stats-grid strong {
  font-size: 16px;
}

.stats-grid span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  background: #122436;
}

select:focus {
  border-color: var(--accent);
}

.toggle-row {
  position: relative;
  min-height: 48px;
  cursor: pointer;
}

.toggle-row + .toggle-row {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.toggle-row > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.toggle-row strong {
  font-size: 12px;
}

.toggle-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 42px;
  height: 23px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #3b4855;
  transition: background 150ms ease;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: white;
  content: "";
  transition: transform 150ms ease;
}

.toggle-row input:checked + .switch {
  background: var(--accent-dark);
}

.toggle-row input:checked + .switch::after {
  transform: translateX(19px);
}

.field-label {
  display: block;
  margin: 10px 0 5px;
  color: #aebdcc;
  font-size: 10px;
}

.secondary-button {
  width: 100%;
  min-height: 39px;
  margin-top: 11px;
  border: 1px solid rgba(72, 180, 246, 0.46);
  border-radius: 11px;
  background: rgba(36, 134, 193, 0.13);
  cursor: pointer;
}

.secondary-button:hover {
  background: rgba(36, 134, 193, 0.25);
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  color: #c5d0da;
  font-size: 10px;
}

.legend-grid span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-icon {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  color: white;
  font-size: 14px;
  font-style: normal;
}

.legend-icon.clear { background: #f5a623; }
.legend-icon.partly { background: #57a8d9; }
.legend-icon.cloudy { background: #708090; }
.legend-icon.rain { background: #2877c7; }
.legend-icon.storm { background: #7644b6; }
.legend-icon.snow { background: #70c8dc; }
.legend-icon.fog { background: #83939c; }
.legend-icon.unknown { background: #5a626a; }

.update-box {
  display: flex;
  flex-direction: column;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.04);
}

.update-box span {
  color: var(--muted);
  font-size: 9px;
}

.update-box strong {
  margin-top: 4px;
  font-size: 12px;
}

.update-box small {
  margin-top: 5px;
  color: #7f92a3;
  font-size: 9px;
  line-height: 1.4;
}

.control-panel footer {
  margin-top: 15px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  color: #718496;
  font-size: 8px;
  line-height: 1.4;
}

.weather-div-icon,

.weather-div-icon,
.station-div-icon {
  border: 0 !important;
  background: transparent !important;
}

.weather-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 36px;
  height: 34px;
  padding: 0 11px;
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  background: var(--marker-color, #52616d);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(0, 0, 0, 0.18);
  color: #fff;
  white-space: nowrap;
}

.weather-chip__glyph {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 16px;
  height: 16px;
  line-height: 1;
}

.weather-chip__glyph svg {
  width: 16px;
  height: 16px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.weather-chip__temp {
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}

.weather-chip.no-temp {
  min-width: 34px;
  padding-right: 9px;
  padding-left: 9px;
}

.weather-chip.no-temp .weather-chip__temp {
  display: none;
}

.weather-chip.stale {
  filter: grayscale(0.45);
  opacity: 0.78;
}

.weather-chip.station {
  height: 38px;
  padding-right: 12px;
  padding-left: 12px;
  border-width: 3px;
  box-shadow:
    0 5px 14px rgba(0, 0, 0, 0.38),
    0 0 0 4px rgba(29, 155, 224, 0.20);
}

.marker-clear { --marker-color: #f2ab20; }
.marker-clear-night { --marker-color: #0b1b3e; }
.marker-partly { --marker-color: #66a8d6; }
.marker-cloudy { --marker-color: #7a8792; }
.marker-rain { --marker-color: #2375bd; }
.marker-storm { --marker-color: #6f43b4; }
.marker-snow { --marker-color: #57b7d8; }
.marker-fog { --marker-color: #7c8d97; }
.marker-wind { --marker-color: #1f9d93; }
.marker-unknown { --marker-color: #565f66; }

.marker-cluster {
  background: rgba(32, 142, 205, 0.2) !important;
}

.marker-cluster div {
  display: grid !important;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: linear-gradient(145deg, #24a3e9, #075b8c) !important;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.38);
  color: white !important;
  font-weight: 800;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(41, 158, 222, 0.22) !important;
}

.weather-popup .leaflet-popup-content-wrapper,
.weather-popup .leaflet-popup-tip {
  background: #081522;
  color: white;
}

.weather-popup .leaflet-popup-content-wrapper {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 17px;
  box-shadow: var(--shadow);
}

.weather-popup .leaflet-popup-content {
  width: min(315px, calc(100vw - 70px)) !important;
  margin: 0;
}

.popup-card {
  padding: 15px;
}

.popup-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.popup-title-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.popup-title h3 {
  margin: 0;
  font-size: 16px;
}

.popup-title small {
  margin-top: 3px;
  color: #a2b3c2;
  font-size: 10px;
  line-height: 1.4;
}

.popup-condition-icon {
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #1e719f;
  font-size: 23px;
}

.popup-main {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.popup-temperature {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.popup-condition {
  display: flex;
  flex-direction: column;
  padding-bottom: 2px;
}

.popup-condition strong {
  font-size: 12px;
}

.popup-condition span {
  margin-top: 2px;
  color: #9db1c2;
  font-size: 9px;
}

.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 14px;
}

.popup-grid article {
  display: flex;
  flex-direction: column;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
}

.popup-grid span {
  color: #8fa4b6;
  font-size: 8px;
  text-transform: uppercase;
}

.popup-grid strong {
  margin-top: 3px;
  font-size: 11px;
}

.popup-station {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #a9bac8;
  font-size: 9px;
  line-height: 1.5;
}

.popup-no-data {
  margin-top: 14px;
  padding: 11px;
  border: 1px solid rgba(255, 167, 38, 0.3);
  border-radius: 11px;
  background: rgba(255, 167, 38, 0.08);
  color: #f3c98f;
  font-size: 10px;
  line-height: 1.45;
}

.loading-overlay {
  position: absolute;
  z-index: 2000;
  top: 50%;
  left: 50%;
  display: flex;
  width: min(410px, calc(100vw - 34px));
  flex-direction: column;
  align-items: center;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(7, 17, 28, 0.97);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translate(-50%, -50%);
  transition: opacity 220ms ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader {
  width: 43px;
  height: 43px;
  margin-bottom: 12px;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay strong {
  font-size: 15px;
}

.loading-overlay span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.loading-progress {
  width: 100%;
  height: 6px;
  margin-top: 15px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.loading-progress span {
  display: block;
  width: 5%;
  height: 100%;
  margin: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #1487cc, #53c2ff);
  transition: width 180ms ease;
}

.toast {
  position: absolute;
  z-index: 2200;
  right: 18px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(7, 17, 28, 0.96);
  box-shadow: var(--shadow);
  color: white;
  font-size: 11px;
}

.map-note {
  position: absolute;
  z-index: 800;
  bottom: 18px;
  left: 18px;
  display: flex;
  max-width: min(420px, calc(100vw - 386px));
  flex-direction: column;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(7, 17, 28, 0.86);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
  pointer-events: none;
}

.map-note strong {
  font-size: 10px;
}

.map-note span {
  margin-top: 2px;
  color: #9eb0bf;
  font-size: 9px;
}

.panel-close {
  border: 0;
  background: transparent;
  font-size: 25px;
  cursor: pointer;
}

.mobile-only {
  display: none;
}

@media (max-width: 850px) {
  .mobile-only {
    display: grid;
  }

  .brand small {
    display: none;
  }

  .topbar {
    min-height: 62px;
    padding: 7px 10px;
  }

  .brand-mark {
    width: 39px;
    height: 39px;
  }

  .search-shell {
    top: 70px;
    right: 10px;
    left: 10px;
    width: auto;
  }

  .control-panel {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100vh - 82px);
    border-radius: 24px;
    transform: translateY(calc(100% + 20px));
    transition: transform 210ms ease;
  }

  .control-panel.open {
    transform: translateY(0);
  }

  .map-note {
    right: 10px;
    bottom: 11px;
    left: 10px;
    max-width: none;
  }

  .leaflet-top.leaflet-right {
    top: 129px;
    right: 8px;
  }

  .toast {
    right: 10px;
    bottom: 70px;
    left: 10px;
    max-width: none;
  }
}

@media (max-width: 470px) {
  .brand strong {
    font-size: 14px;
  }

  .weather-chip {
    height: 31px;
    padding-right: 9px;
    padding-left: 9px;
    gap: 6px;
  }

  .weather-chip.station {
    height: 33px;
  }

  .weather-chip__glyph,
  .weather-chip__glyph svg {
    width: 15px;
    height: 15px;
  }

  .weather-chip__temp {
    font-size: 11px;
  }
}
