:root {
  --bg: #070b10;
  --panel: rgba(8, 13, 20, 0.93);
  --panel-strong: rgba(10, 16, 25, 0.94);
  --border: rgba(154, 184, 212, 0.2);
  --border-strong: rgba(117, 178, 255, 0.48);
  --text: #f2f7ff;
  --muted: #a7b5c7;
  --dim: #6f8196;
  --blue: #1d91ff;
  --green: #34d058;
  --yellow: #ffd33d;
  --red: #ff4d4d;
  --danger: #ff5f57;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
.map {
  width: 100vw;
  min-width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

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

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
}

.map,
.weather-canvas {
  position: absolute;
  inset: 0;
}

.weather-canvas {
  z-index: 420;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.38;
}

.weather-canvas[hidden] {
  display: none;
}

.leaflet-control-attribution {
  display: none;
}

.leaflet-top,
.leaflet-bottom {
  z-index: 500;
}

.leaflet-top.leaflet-left {
  top: 68px;
}

.leaflet-container {
  background: #071018;
  font: inherit;
}

.leaflet-radar-pane,
.radar-tile {
  mix-blend-mode: screen;
}

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

.leaflet-control-zoom a {
  width: 44px !important;
  height: 42px !important;
  border: 0 !important;
  background: rgba(6, 10, 16, 0.86) !important;
  color: var(--text) !important;
  line-height: 42px !important;
}

.topbar,
.alerts-panel,
.locations-panel,
.radar-controls,
.attribution,
.mobile-alerts-button,
.tornado-safety-alert {
  position: absolute;
  z-index: 650;
}

.topbar {
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: stretch;
  gap: 10px;
  pointer-events: none;
}

.icon-button,
.mobile-alerts-button {
  pointer-events: auto;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.panel-header h2,
.alert-card h3 {
  margin: 0;
}

.section-label,
.alert-card p {
  margin: 0;
}

.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;
}

.location-tabs {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 4px 0;
  pointer-events: auto;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow-x: auto;
  scrollbar-width: thin;
}

#manageLocationsButton,
.locations-panel,
.map-pick-banner {
  display: none !important;
}

.location-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 154px;
  padding: 8px 2px 9px;
  position: relative;
  border: 0;
  border-radius: 0;
  color: var(--text);
  background: transparent;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.82);
  text-align: left;
  cursor: pointer;
}

.current-location-chip {
  min-width: 190px;
}

.location-tab[aria-selected="true"] {
  color: #ffffff;
  box-shadow: inset 0 -2px 0 rgba(117, 178, 255, 0.82);
}

.location-tab:hover {
  color: #ffffff;
}

.location-copy,
.location-copy strong,
.location-place {
  display: block;
  min-width: 0;
  white-space: nowrap;
}

.location-copy {
  overflow: hidden;
}

.location-tab strong {
  font-size: 13px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-place {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.condition-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  color: #ddecff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.condition-badge img,
.condition-dot {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 6px;
}

.condition-badge img {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.68));
}

.condition-dot {
  background: radial-gradient(circle at 35% 35%, rgba(157, 211, 255, 0.9), rgba(29, 145, 255, 0.35) 58%, transparent 62%);
}

.condition-badge.is-loading {
  color: var(--dim);
  opacity: 0.72;
}

.icon-button,
.control-button {
  display: grid;
  width: 48px;
  min-width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  border: 1px solid var(--border);
}

.icon-button.ghost {
  background: transparent;
  box-shadow: none;
}

.alerts-panel {
  top: max(90px, calc(env(safe-area-inset-top) + 90px));
  right: max(12px, env(safe-area-inset-right));
  bottom: 96px;
  display: flex;
  width: min(360px, calc(100vw - 24px));
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  pointer-events: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
  transition: transform 180ms ease, opacity 180ms ease;
}

.locations-panel {
  top: max(90px, calc(env(safe-area-inset-top) + 90px));
  left: max(12px, env(safe-area-inset-left));
  bottom: 228px;
  display: none;
  width: min(380px, calc(100vw - 24px));
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  z-index: 720;
  pointer-events: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.locations-panel.is-open {
  display: flex;
}

.locations-panel .panel-header {
  padding: 0 0 12px;
  border-bottom: 0;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.72);
}

.locations-content {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  overflow: auto;
}

.locations-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.location-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.74);
}

.location-row-main,
.location-edit,
.location-delete,
.location-form button,
.motion-toggle {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
}

.location-row-main {
  min-width: 0;
  padding: 8px 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.location-row-title,
.location-row-main strong,
.location-row-place {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.location-row-place {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.location-list-condition {
  transform: translateY(1px);
}

.location-edit,
.location-delete {
  padding: 8px 9px;
  border-color: rgba(154, 184, 212, 0.16);
  background: rgba(5, 8, 13, 0.34);
  font-size: 12px;
  font-weight: 700;
}

.location-delete {
  color: #ffaaa8;
}

.location-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 0;
}

.location-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.location-form input {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  outline: none;
}

.location-form input:focus {
  border-color: var(--border-strong);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-actions button {
  padding: 9px 12px;
}

.form-actions button[type="submit"] {
  border-color: var(--border-strong);
  background: rgba(29, 145, 255, 0.2);
}

.map-pick-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(117, 178, 255, 0.24);
  border-radius: 8px;
  background: rgba(29, 145, 255, 0.08);
}

.map-pick-row button {
  padding: 9px 12px;
  border-color: var(--border-strong);
  background: rgba(29, 145, 255, 0.18);
  font-weight: 800;
}

.map-pick-row button[aria-pressed="true"] {
  background: rgba(52, 208, 88, 0.18);
  border-color: rgba(52, 208, 88, 0.68);
  color: #a7f3ba;
}

.map-pick-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.alerts-panel.is-collapsed {
  transform: translateX(calc(100% + 18px));
  opacity: 0;
}

.alerts-panel .panel-header {
  padding: 0 0 12px;
  border-bottom: 0;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.72);
}

.alerts-panel .alert-list {
  padding: 0;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.section-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-label.danger {
  color: #ffd6d4;
}

.panel-header h2 {
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.2;
}

.alert-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: auto;
}

.alert-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.alert-card.extreme,
.alert-card.severe {
  border-color: rgba(255, 77, 77, 0.72);
  background: rgba(255, 77, 77, 0.1);
}

.alert-card.moderate {
  border-color: rgba(255, 211, 61, 0.74);
  background: rgba(255, 211, 61, 0.1);
}

.alert-card.minor {
  border-color: rgba(52, 208, 88, 0.68);
  background: rgba(52, 208, 88, 0.09);
}

.alert-symbol {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: currentColor;
  background: rgba(255, 255, 255, 0.07);
}

.alert-symbol svg {
  width: 24px;
  height: 24px;
}

.alert-card h3 {
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
}

.alert-area,
.alert-meta,
.alert-desc {
  margin-top: 5px !important;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.alert-meta {
  color: var(--text);
}

.empty-state {
  margin: auto;
  max-width: 260px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.tornado-safety-alert {
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  background: rgba(3, 6, 10, 0.64);
  pointer-events: auto;
}

.tornado-safety-alert[hidden] {
  display: none;
}

.tornado-safety-card {
  width: min(440px, 100%);
  padding: 18px;
  border: 1px solid rgba(255, 95, 87, 0.72);
  border-radius: 8px;
  background: rgba(16, 8, 10, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.56), 0 0 34px rgba(255, 95, 87, 0.16);
}

.tornado-safety-card h2 {
  margin: 6px 0 12px;
  color: #ffffff;
  font-size: 24px;
  line-height: 1.08;
}

.tornado-safety-body {
  display: grid;
  gap: 12px;
  color: #f8e5e3;
  font-size: 14px;
  line-height: 1.42;
}

.tornado-safety-body p {
  margin: 0;
}

.tornado-safety-items {
  display: grid;
  gap: 8px;
}

.tornado-safety-item {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.tornado-safety-item strong {
  color: #ffffff;
  font-size: 14px;
}

.tornado-safety-item span {
  color: #ffcbc8;
  font-size: 12px;
  font-weight: 700;
}

.acknowledge-alert-button {
  width: 100%;
  margin-top: 16px;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: var(--danger);
  color: #210607;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(255, 95, 87, 0.25);
}

.acknowledge-alert-button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.78);
  outline-offset: 3px;
}

.radar-controls {
  right: max(12px, env(safe-area-inset-right));
  bottom: max(30px, calc(env(safe-area-inset-bottom) + 30px));
  left: max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 12px 16px;
  pointer-events: none;
}

.radar-controls > * {
  pointer-events: auto;
}

.playback {
  display: flex;
  gap: 8px;
}

.control-button,
.time-row button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.control-button.primary {
  border-color: var(--border-strong);
  background: rgba(29, 145, 255, 0.2);
  color: #77c2ff;
}

.control-button.is-playing svg {
  fill: currentColor;
}

.timeline {
  min-width: 0;
}

.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.time-row strong {
  font-size: 14px;
}

.time-row button {
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.frame-ticks {
  display: flex;
  justify-content: space-between;
  min-height: 16px;
  color: var(--dim);
  font-size: 11px;
}

.legend {
  display: grid;
  grid-template-columns: auto 120px auto auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.motion-toggle {
  padding: 9px 12px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.legend-gradient {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1b65d8, #17b978, #e3d128, #ff7a00, #d92323, #f7f2ff);
}

.attribution {
  right: max(18px, env(safe-area-inset-right));
  bottom: 8px;
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  justify-content: center;
  gap: 18px;
  color: rgba(230, 238, 248, 0.62);
  font-size: 11px;
  pointer-events: none;
}

.mobile-alerts-button {
  display: none;
}

.mobile-alerts-button[hidden] {
  display: none !important;
}

.mobile-alerts-button span {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  place-items: center;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.map-pick-banner {
  position: absolute;
  top: max(90px, calc(env(safe-area-inset-top) + 90px));
  left: 50%;
  z-index: 760;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(52, 208, 88, 0.62);
  border-radius: 8px;
  background: rgba(7, 17, 14, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.map-pick-banner[hidden] {
  display: none;
}

.map-pick-banner span {
  white-space: nowrap;
  color: #c6f6d2;
  font-size: 13px;
  font-weight: 800;
}

.map-pick-banner button {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
}

@media (max-width: 820px) {
  .leaflet-top.leaflet-left {
    top: 64px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
  }

  .location-tabs {
    padding: 6px;
  }

  .location-tab {
    min-width: 142px;
    padding: 7px 0 8px;
  }

  #locateButton {
    display: none;
  }

  #manageLocationsButton {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .alerts-panel {
    top: auto;
    right: 8px;
    bottom: 78px;
    left: 8px;
    width: auto;
    max-height: min(48dvh, 420px);
    border-radius: 12px 12px 8px 8px;
    transform: translateY(calc(100% + 90px));
    opacity: 0;
  }

  .locations-panel {
    top: 84px;
    right: 8px;
    bottom: 112px;
    left: 8px;
    width: auto;
  }

  .alerts-panel.is-open {
    transform: translateY(0);
    opacity: 1;
  }

  .alerts-panel.is-collapsed {
    transform: translateY(calc(100% + 90px));
    opacity: 0;
  }

  .mobile-alerts-button {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px));
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
  }

  .map-pick-banner {
    top: 84px;
    right: 8px;
    left: 8px;
    justify-content: space-between;
    transform: none;
  }

  .radar-controls {
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    padding: 10px;
  }

  .legend {
    display: none;
  }

  .motion-toggle {
    padding: 9px 10px;
    font-size: 12px;
  }

  .playback .control-button:not(.primary) {
    display: none;
  }

  .attribution {
    display: none;
  }
}

@media (max-width: 540px) {
  .topbar {
    right: 8px;
    left: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .map-pick-row {
    grid-template-columns: 1fr;
  }

  .map-pick-banner span {
    white-space: normal;
  }

  .location-tabs {
    width: 100%;
  }

  .location-tab {
    min-width: auto;
    max-width: none;
    flex: 0 0 auto;
  }

  .location-place {
    display: none;
  }

  .location-tab strong {
    overflow: visible;
    text-overflow: clip;
  }

  .radar-controls {
    right: 8px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 8px;
  }

  .frame-ticks {
    display: none;
  }
}
