:root {
  --bg: #10141a;
  --panel: #181e27;
  --panel-2: #1f2733;
  --border: #2c3646;
  --text: #dde5ee;
  --muted: #8b98a9;
  --accent: #4da3ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}
body { display: flex; flex-direction: column; }

#topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  min-height: 44px; padding: 6px 12px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
#brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
#layer-toggles { display: flex; gap: 12px; flex-wrap: wrap; }
#layer-toggles label {
  display: flex; align-items: center; gap: 4px;
  color: var(--muted); cursor: pointer; white-space: nowrap; user-select: none;
}
#layer-toggles input { accent-color: var(--accent); }
#status { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

#main { display: flex; flex: 1; min-height: 0; }

#sidebar {
  width: 320px; min-width: 320px;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
#tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; padding: 8px 4px; background: none; border: none;
  color: var(--muted); cursor: pointer; font: inherit; font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.panel { display: none; overflow-y: auto; flex: 1; }
.panel.active { display: block; }
.empty { padding: 16px; color: var(--muted); }

#alert-filter { padding: 8px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--border); }
#alert-filter select, #alert-filter input {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px; padding: 5px 8px; font: inherit; font-size: 13px;
}

.item {
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  cursor: pointer; border-left: 4px solid transparent;
}
.item:hover { background: var(--panel-2); }
.item .title { font-weight: 600; font-size: 13px; }
.item .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.item .badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 1px 6px; border-radius: 3px; margin-right: 6px; color: #10141a;
}

#map { flex: 1; background: #0b0e13; }

#timeline {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px;
  background: var(--panel); border-top: 1px solid var(--border);
}
#play-btn {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  width: 30px; height: 26px; cursor: pointer; font-size: 12px;
}
#frame-slider { flex: 1; accent-color: var(--accent); }
#frame-time { color: var(--muted); font-size: 12px; min-width: 110px; text-align: right; }

#credits {
  position: fixed; bottom: 44px; right: 6px; z-index: 1000;
  font-size: 10px; color: var(--muted);
  background: rgba(16, 20, 26, .7); padding: 2px 6px; border-radius: 3px;
  pointer-events: none;
}

/* Leaflet dark-theme adjustments */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel); color: var(--text);
  box-shadow: 0 2px 12px rgba(0,0,0,.5);
}
.leaflet-popup-content { margin: 10px 14px; font: 13px/1.45 "Segoe UI", system-ui, sans-serif; }
.leaflet-container a { color: var(--accent); }
.leaflet-bar a { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--border); }
.leaflet-control-attribution { background: rgba(16,20,26,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

/* Phone layout: map on top, panels as a bottom sheet */
@media (max-width: 700px) {
  #main { flex-direction: column; }
  #map { order: 1; flex: 1; min-height: 0; }
  #sidebar {
    order: 2; width: 100%; min-width: 0; height: 40%;
    border-right: none; border-top: 1px solid var(--border);
  }
  #topbar { gap: 8px 12px; }
  #brand { font-size: 14px; }
  #status { flex-basis: 100%; margin-left: 0; }
  #credits { display: none; }
  #frame-time { min-width: 90px; }
}

.storm-icon {
  font-size: 26px; line-height: 1; text-align: center;
  filter: drop-shadow(0 0 4px rgba(255,80,80,.9));
  animation: spin 3s linear infinite;
}
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(-360deg); } }

.gdacs-icon {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 12px; border: 2px solid #10141a;
}

.popup-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.popup-kv { color: var(--muted); }
.popup-kv b { color: var(--text); font-weight: 600; }
.wx-days { display: flex; gap: 8px; margin-top: 8px; }
.wx-day { text-align: center; font-size: 11px; color: var(--muted); }
.wx-day .emoji { font-size: 18px; }
.wx-day b { color: var(--text); }
