:root {
  --bg: #031D3E;
  --bg-elev: #0B2A52;
  --bg-elev-2: #123963;
  --border: #263353;
  --text: #EAF0FF;
  --text-dim: #9BAAC7;
  --text-faint: #6B7A9C;
  --accent: #D4A94A;
  --accent-2: #7FE0D6;
  --warm: #F2B75E;
  --danger: #FF6B6B;
  --good: #3DD16F;
  --radius: 16px;
  --radius-sm: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  padding-bottom: 40px;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #0B2A52 0%, var(--bg) 60%);
}

.icon { width: 22px; height: 22px; flex-shrink: 0; }

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.location-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 6px 4px;
  cursor: pointer;
  max-width: 75vw;
}
.location-btn .icon { color: var(--accent); }
.location-btn .caret { width: 16px; height: 16px; color: var(--text-dim); }
#location-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg-elev); color: var(--text); }
.icon-btn.enabled { color: var(--accent); }

/* ---------- Alert banner ---------- */

.alert-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 12px 16px;
  font-size: 0.92rem;
  cursor: pointer;
}
.alert-banner.hidden { display: none; }
.alert-banner .alert-row { display: flex; align-items: center; gap: 10px; }
.alert-banner .alert-title { font-weight: 700; flex: 1; }
.alert-banner .alert-dismiss { background: none; border: none; color: inherit; opacity: 0.8; cursor: pointer; padding: 4px; }
.alert-banner .alert-detail { margin-top: 8px; font-size: 0.85rem; line-height: 1.5; white-space: pre-wrap; max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
.alert-banner.expanded .alert-detail { max-height: 600px; overflow-y: auto; }

.sev-extreme { background: #6A1B9A; color: #fff; }
.sev-severe { background: #E65100; color: #fff; }
.sev-moderate { background: #F9A825; color: #1a1400; }
.sev-minor { background: #1565C0; color: #fff; }
.sev-unknown { background: #37474F; color: #fff; }

/* ---------- Layout ---------- */

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Hero ---------- */

.hero { text-align: center; padding: 28px 18px 20px; }
.hero-main { display: flex; align-items: center; justify-content: center; gap: 18px; }
.hero-icon svg { width: 84px; height: 84px; }
.hero-temp-block { text-align: left; }
.hero-temp { font-size: 4rem; font-weight: 200; line-height: 1; letter-spacing: -0.02em; }
.hero-condition { font-size: 1.1rem; color: var(--text-dim); margin-top: 4px; }
.hero-meta { margin-top: 14px; color: var(--text-dim); font-size: 0.95rem; }
.hero-meta .dot { margin: 0 8px; opacity: 0.5; }
.hero-updated { margin-top: 6px; font-size: 0.75rem; color: var(--text-faint); }

/* ---------- Hourly strip ---------- */

.hourly-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
}
.hour-item {
  flex: 0 0 auto;
  width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  scroll-snap-align: start;
}
.hour-item .hour-label { font-size: 0.78rem; color: var(--text-dim); }
.hour-item svg { width: 28px; height: 28px; }
.hour-item .hour-temp { font-weight: 600; font-size: 0.95rem; }
.hour-item .hour-pop { font-size: 0.72rem; color: var(--accent); min-height: 14px; }

/* ---------- Nowcast ---------- */

.nowcast-summary { font-size: 0.95rem; color: var(--text-dim); margin-bottom: 10px; }
.nowcast-chart { width: 100%; }
.nowcast-chart svg { width: 100%; height: auto; display: block; }

/* ---------- Radar ---------- */

.radar-map {
  width: 100%;
  height: 340px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #08101f;
}
.radar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.radar-play-btn {
  background: var(--accent);
  border: none;
  color: #041322;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.radar-play-btn .icon { width: 20px; height: 20px; }
#radar-scrub { flex: 1 1 120px; accent-color: var(--accent); min-width: 100px; }
.radar-time { font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; min-width: 70px; text-align: right; }
.radar-layer-toggle { display: flex; gap: 6px; width: 100%; }
.layer-btn {
  flex: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
}
.layer-btn.active { background: var(--accent); color: #041322; border-color: var(--accent); font-weight: 600; }
.layer-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- AQI ---------- */

.aqi-value-row { display: flex; align-items: baseline; gap: 10px; }
.aqi-value { font-size: 2.6rem; font-weight: 300; }
.aqi-label { font-weight: 700; padding: 3px 10px; border-radius: 20px; font-size: 0.8rem; }
.aqi-detail { margin-top: 10px; font-size: 0.82rem; color: var(--text-dim); display: flex; flex-direction: column; gap: 3px; }

/* ---------- Sun / Moon ---------- */

.sun-row { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 6px; }
.sun-row .val { color: var(--text-dim); }
.moon-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.moon-row svg { width: 32px; height: 32px; }
.moon-phase-name { font-size: 0.9rem; }

/* ---------- Hurricane ---------- */

.hurricane-card.hidden { display: none; }
.storm-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.storm-item:last-child { border-bottom: none; }
.storm-name { font-weight: 700; }
.storm-meta { font-size: 0.82rem; color: var(--text-dim); margin-top: 2px; }

/* ---------- Daily list ---------- */

.daily-list { list-style: none; margin: 0; padding: 0; }
.daily-item { border-bottom: 1px solid var(--border); }
.daily-item:last-child { border-bottom: none; }
.daily-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  color: inherit;
  text-align: left;
  font: inherit;
}
.daily-row .day-name { width: 76px; font-weight: 600; flex-shrink: 0; }
.daily-row svg { width: 26px; height: 26px; flex-shrink: 0; }
.daily-row .day-pop { width: 40px; font-size: 0.78rem; color: var(--accent); flex-shrink: 0; }
.daily-row .day-temps { margin-left: auto; display: flex; gap: 10px; font-variant-numeric: tabular-nums; }
.daily-row .day-lo { color: var(--text-faint); }
.daily-row .chevron { transition: transform 0.2s; color: var(--text-faint); }
.daily-item.open .chevron { transform: rotate(180deg); }
.daily-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.daily-item.open .daily-detail { max-height: 260px; }
.daily-detail-inner { padding: 4px 2px 16px 88px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- Location dialog ---------- */

.location-dialog {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius);
  padding: 18px;
  width: min(440px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
}
.location-dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-header h2 { margin: 0; font-size: 1.1rem; }
.search-row input {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
}
.search-results { list-style: none; margin: 8px 0 0; padding: 0; }
.search-results li {
  padding: 10px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}
.search-results li:hover { background: var(--bg-elev-2); }
.geo-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; margin-top: 14px;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--accent);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.92rem; cursor: pointer;
}
.saved-heading { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin: 16px 0 6px; }
.saved-locations { list-style: none; margin: 0; padding: 0; }
.saved-locations li {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.95rem;
}
.saved-locations li:hover { background: var(--bg-elev-2); }
.saved-locations li.active { color: var(--accent); font-weight: 600; }
.saved-locations li .remove-loc { margin-left: auto; background: none; border: none; color: var(--text-faint); padding: 4px; cursor: pointer; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 20px; font-size: 0.88rem; z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.hidden { display: none; }

.app-footer { text-align: center; color: var(--text-faint); font-size: 0.75rem; padding: 10px 0; }

/* Leaflet dark tweaks */
.leaflet-control-attribution { background: rgba(11,18,32,0.7) !important; color: var(--text-faint) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--text-dim) !important; }
