:root{
  --bg:#f0f4f8;--panel:#fff;--accent:#0ea5e9;--accent-hover:#0284c7;
  --text:#0f172a;--muted:#6b7280;
  --ok:#16a34a;--warn:#f59e0b;--bad:#ef4444;
}
html,body{height:100%;margin:0;font-family:Inter,sans-serif;background:var(--bg);color:var(--text);}
.app{height:100vh;position:relative;}
#map { width:100%; height:100%; position:absolute; z-index:0; }

/* Search Container in Upper Right */
.search-container {
  position: absolute;
  top: 25px;
  right: 25px;
  display: flex;
  align-items: center;/* --- Responsive fixes for phones --- */
  @media(max-width: 768px){
    /* Search box full width */
    .search-container {
      top: 10px;
      right: 10px;
      left: 10px;
      max-width: none;
      padding: 10px 12px;
      gap: 8px;
    }
    
    .search-input {
      font-size: 0.9rem;
      padding: 6px 0;
    }
    
    .search-btn {
      padding: 6px 10px;
      font-size: 0.95rem;
    }
  
    /* Coordinates */
    .coordinates-display {
      bottom: 10px;
      left: 10px;
      font-size: 0.85rem;
      padding: 8px 12px;
      border-radius: 10px;
    }
  
    /* AQI Legend */
    .legend-map {
      bottom: 10px;
      right: 10px;
      max-width: 180px;
      font-size: 0.8rem;
      padding: 12px 15px;
      border-radius: 12px;
    }
    .legend-title {
      font-size: 0.9rem;
      margin-bottom: 10px;
    }
    .legend-item {
      gap: 8px;
      margin-bottom: 6px;
    }
    .sw {
      width: 16px;
      height: 16px;
    }
  
    /* Forecast buttons */
    .forecast-btn {
      font-size: 0.8rem;
      padding: 5px 3px;
    }
  
    /* Popups */
    .leaflet-popup-content-wrapper {
      min-width: 240px;
    }
    .weather-popup-table td {
      font-size: 0.95rem;
    }
    .forecast-data {
      max-height: 150px;
    }
    .forecast-item {
      padding: 6px 0;
    }
    .forecast-temp {
      font-size: 0.9rem;
    }
    .forecast-aqi {
      min-width: 36px;
      font-size: 0.75rem;
    }
  }
  
  gap: 10px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 18px;
  border-radius: 16px;
  box-shadow: 0 6px 25px rgba(0,0,0,0.2);
  backdrop-filter: blur(15px);
  border: 2px solid rgba(255,255,255,0.3);
  max-width: 350px;
  transition: all 0.3s ease;
}

.search-input {
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  width: 100%;
  font-weight: 500;
}

.search-input::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.search-btn {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  color: white;
  font-size: 1rem;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

/* Координати в лівому нижньому куті */
.coordinates-display {
  position: absolute;
  bottom: 25px;
  left: 25px;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.95rem;
  z-index: 1000;
  box-shadow: 0 6px 25px rgba(0,0,0,0.2);
  backdrop-filter: blur(15px);
  border: 2px solid rgba(255,255,255,0.3);
  font-weight: 600;
}

/* Легенда AQI на карті */
.legend-map {
  position: absolute;
  bottom: 25px;
  right: 25px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 20px;
  font-size: 0.9rem;
  box-shadow: 0 6px 25px rgba(0,0,0,0.2);
  z-index: 1000;
  backdrop-filter: blur(15px);
  border: 2px solid rgba(255,255,255,0.3);
  max-width: 220px;
}
.legend-title { 
  font-weight: 700; 
  margin-bottom: 15px; 
  font-size: 1rem;
  color: #2c3e50;
  text-align: center;
}
.legend-item { 
  display:flex; 
  align-items:center; 
  gap:12px; 
  margin-bottom: 10px; 
  padding: 5px 0;
}
.sw { 
  width:20px; 
  height:20px; 
  border-radius:6px; 
  display:inline-block; 
  border: 2px solid rgba(0,0,0,0.1);
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}
.sw.good { background:#00e400; }
.sw.moderate { background:#ffff00; }
.sw.unhealthy1 { background:#ff7e00; }
.sw.unhealthy2 { background:#ff0000; }

/* Стилі для попапів */
.weather-icon{
  width:32px;
  height:32px;
  vertical-align:middle;
  margin-right:6px;
}

/* Popup Header with AQI Color */
.weather-popup-header {
  padding: 12px 0;
  text-align: center;
  margin: -10px -10px 12px -10px;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 12px 12px 0 0;
  color: #333;
  transition: all 0.3s ease;
}

.weather-popup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.05rem;
  margin-bottom: 10px;
}
.weather-popup-table td {
  padding: 6px 10px 6px 0;
  font-size: 1.05rem;
  vertical-align: top;
}
.weather-popup-table td:first-child {
  color: #333;
  font-weight: 400;
  white-space: nowrap;
}
.weather-popup-table td:last-child {
  font-weight: bold;
  padding-left: 10px;
  color: #222;
}

/* Forecast Navigation */
.forecast-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
  border-top: 1px solid rgba(0,0,0,0.1);
  padding-top: 12px;
}

.forecast-btn {
  flex: 1;
  padding: 8px 5px;
  margin: 0 2px;
  border: none;
  border-radius: 8px;
  background: #f0f4f8;
  color: #333;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.forecast-btn:hover {
  background: #e1e8f0;
  transform: translateY(-2px);
}

.forecast-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.3);
}

/* Forecast Data Styles */
.forecast-data {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 10px;
}

.forecast-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.forecast-time {
  font-weight: 600;
  color: #333;
  font-size: 0.9rem;
}

.forecast-temp {
  font-weight: bold;
  color: #2c3e50;
}

.forecast-aqi {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
  min-width: 40px;
  text-align: center;
}

.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  border: 2px solid rgba(255,255,255,0.5);
  min-width: 280px;
}

.leaflet-popup-content {
  margin: 0;
  padding: 10px;
  width: auto !important;
}

.marker-dot {
  display:inline-block;
  width:16px;
  height:16px;
  border:3px solid #fff;
  border-radius:50%;
  box-shadow:0 0 8px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
}
.marker-dot:hover { 
    transform: scale(1.3);
}   

.leaflet-control-geocoder {
  display: none; /* Hide default geocoder */
}

@media(max-width: 768px){
  .search-container {
    top: 15px;
    right: 15px;
    left: 15px;
    max-width: none;
    padding: 10px 15px;
  }
}

@media(max-width: 768px){
  .coordinates-display {
    display: none;
  }

  .legend-map {
    bottom: 70px;
    right: 10px;
    max-width: 160px;   /* smaller width */
    padding: 10px 12px; /* less padding */
    font-size: 0.75rem; /* smaller text */
    border-radius: 10px;
  }

  .legend-title {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }

  .legend-item {
    gap: 6px;
    margin-bottom: 6px;
  }

  .sw {
    width: 14px;
    height: 14px;
  }
}

/* Mobile-friendly popup */
@media(max-width: 768px) {
  .leaflet-popup-content-wrapper {
    min-width: 160px !important;  /* tiny width */
    max-width: 85vw !important;   /* fit most screens */
    padding: 5px !important;
  }

  .leaflet-popup-content {
    font-size: 0.75rem !important; 
    padding: 4px !important;
  }

  .weather-popup-header {
    font-size: 0.85rem !important;
    padding: 4px 0 !important;
  }

  .weather-popup-table td {
    font-size: 0.7rem !important;
    padding: 2px 4px !important;
  }

  .forecast-data {
    max-height: 100px;  /* very small scroll area */
  }

  .forecast-item {
    padding: 2px 0 !important;
    gap: 4px;
  }

  .forecast-temp, .forecast-aqi, .forecast-time {
    font-size: 0.65rem !important;
  }

  .weather-icon {
    width: 20px !important;
    height: 20px !important;
    margin-right: 3px !important;
  }
}

