:root {
  --bg: #0c0f14;
  --panel: #12161d;
  --panel-2: #171c25;
  --line: #262c38;
  --text: #e7e6e2;
  --text-dim: #8b93a1;
  --text-faint: #5c6472;
  --ember: #e85d3d;
  --ember-dim: #a8402a;
  --amber: #e8a33d;
  --cyan: #3fc1c9;
  --deep-blue: #6a7dff;
  --good: #4caf7d;
  --radius: 10px;
  --font-ui: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

/* CSS specificity gotcha guard: several elements use `hidden` for their
   default state but also carry a class that sets `display` (.btn-icon,
   .radar-controls, etc). Author styles beat the UA's built-in
   `[hidden] { display: none }` at equal specificity, which would silently
   make those elements visible regardless of the attribute. This rule
   makes `hidden` win unconditionally. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 15% 8%, rgba(63,193,201,0.05), transparent 40%),
    radial-gradient(circle at 85% 92%, rgba(232,93,61,0.06), transparent 45%);
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: var(--cyan); }

button { font-family: inherit; }

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #10141b, #0d1117);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { flex: 0 0 auto; display: block; height: 28px; width: auto; }
.brand-tagline {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ticker {
  display: flex;
  gap: 22px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1 1 auto;
  padding: 0 6px;
}
.ticker::-webkit-scrollbar { display: none; }

.ticker-item {
  display: flex;
  flex-direction: column;
  white-space: nowrap;
}
.ticker-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: none;
}
.ticker-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 6px var(--good);
}
.conn-dot.bad { background: var(--ember); box-shadow: 0 0 6px var(--ember); }

.btn-icon {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.btn-icon:hover { border-color: var(--cyan); color: var(--cyan); }
.btn-icon:focus-visible, .btn:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ===== Body layout ===== */
.body {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

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

.leaflet-container { background: #0a0d12; font-family: var(--font-ui); }

.offline-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a1a12;
  border: 1px solid var(--ember-dim);
  color: #ffcbb8;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  z-index: 500;
}

/* ===== Legend ===== */
.legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 400;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  max-width: min(560px, calc(100% - 24px));
}
.legend-block {
  background: rgba(18, 22, 29, 0.88);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-width: 168px;
}
.legend-block h3 {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text);
  margin: 3px 0;
}
.legend-note {
  margin: 6px 0 0;
  font-size: 10.5px;
  color: var(--text-faint);
}
.swatch {
  width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto;
}
.tri {
  width: 11px; height: 11px; flex: 0 0 auto;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

/* ===== Settings drawer ===== */
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 11, 0.55);
  z-index: 940;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.drawer-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 88vw);
  flex: 0 0 auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 950;
  box-shadow: -16px 0 34px rgba(0, 0, 0, 0.4);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.sidebar.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.drawer-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
#btn-drawer-close { padding: 7px 8px; }

.panel {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.panel h2 {
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.02em;
  margin: 0 0 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-note {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 4px 0 0;
}

.field {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.field > span { display: block; margin-bottom: 5px; }
.field select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 9px;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.field.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.field.toggle span { margin: 0; color: var(--text); font-size: 13px; }
.field.toggle input { width: 34px; height: 19px; accent-color: var(--ember); cursor: pointer; }

.btn {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
  margin-top: 2px;
}
.btn:hover { border-color: var(--cyan); color: var(--cyan); }

.pill {
  font-family: var(--font-mono);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text-dim);
}

.radar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -4px 0 12px;
}
.radar-controls .btn-icon {
  padding: 5px 9px;
  font-size: 13px;
  line-height: 1;
}
.radar-timestamp {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  margin-left: 4px;
}

.legend-gradient {
  height: 8px;
  border-radius: 4px;
  margin: 4px 0 3px;
}

.weather-pin {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid #0c0f14;
  box-shadow: 0 0 0 2px rgba(63, 193, 201, 0.35);
}

.panel.feed { flex: 1 1 auto; min-height: 220px; display: flex; flex-direction: column; }
.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
}
.feed-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.feed-item:hover { background: var(--panel-2); border-color: var(--line); }
.feed-mag {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  width: 38px;
  flex: 0 0 auto;
  text-align: center;
  border-radius: 6px;
  padding: 3px 0;
  color: #1a1005;
}
.feed-body { min-width: 0; flex: 1 1 auto; }
.feed-place {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-time {
  font-size: 10.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}
.feed-empty {
  color: var(--text-faint);
  font-size: 12px;
  padding: 10px 4px;
}

.sources {
  padding: 14px 16px 20px;
  font-size: 10.5px;
  color: var(--text-faint);
  line-height: 1.7;
}
.sources p { margin: 0; }
.sources a { color: var(--text-dim); }

/* ===== Loading ===== */
.loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 1000;
  transition: opacity 0.35s ease;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading p { color: var(--text-dim); font-size: 13px; font-family: var(--font-mono); }
.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--ember);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Leaflet marker helpers ===== */
.quake-marker { border-radius: 50%; }
.quake-pulse {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--ember);
  animation: pulse-ring 1.8s ease-out infinite;
  pointer-events: none;
}
@keyframes pulse-ring {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(2.6); opacity: 0; }
}
.volcano-icon { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }

.leaflet-popup-content-wrapper {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.leaflet-popup-tip { background: var(--panel-2); }
.popup h4 { margin: 0 0 4px; font-size: 13px; }
.popup p { margin: 2px 0; font-size: 12px; color: var(--text-dim); }
.popup .popup-mono { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); }
.popup a { color: var(--cyan); font-size: 12px; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .ticker-item:nth-child(3) { display: none; }
  .brand-tagline { display: none; }
  .legend { max-width: calc(100% - 24px); }
  .btn-icon { min-height: 34px; min-width: 34px; justify-content: center; }
}

/* Only dim/block the map behind the drawer on narrower viewports — on wide
   screens the drawer leaves most of the map visible, so a backdrop would
   just get in the way of using both at once. */
@media (min-width: 861px) {
  .drawer-backdrop { display: none; }
}

@media (max-width: 520px) {
  .ticker-item:nth-child(2) { display: none; }
  .legend { flex-direction: column; }
  .sidebar { width: min(320px, 90vw); }
}

@media (max-width: 380px) {
  .brand-logo { height: 22px; }
  .ticker { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .quake-pulse { animation: none; display: none; }
  .spinner { animation: none; }
  .sidebar, .drawer-backdrop { transition: none; }
  * { transition: none !important; }
}

