* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#stale-banner {
  display: none;
  position: fixed;
  bottom: 20%;
  left: 0;
  right: 0;
  height: 10vh;
  z-index: 9999;
  background: rgba(30, 30, 30, 0.88);
  color: #ccc;
  font-size: 1.1rem;
  font-weight: 500;
  gap: 10px;
  align-items: center;
  justify-content: center;
  direction: rtl;
  pointer-events: none;
}
#stale-banner.visible {
  display: flex;
}
.stale-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(200,200,200,0.3);
  border-top-color: #ccc;
  border-radius: 50%;
  animation: staleSpin 0.8s linear infinite;
}
@keyframes staleSpin {
  to { transform: rotate(360deg); }
}

html, body {
  height: 100%;
  width: 100%;
}

body {
  background: #0a0a0a;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

header {
  text-align: center;
  padding: 12px 16px 8px;
  border-bottom: 1px solid #222;
}

header h1 {
  font-size: 1.4rem;
  color: #ff2020;
  letter-spacing: 0.05em;
}

.subtitle {
  font-size: 0.8rem;
  color: #666;
  margin-top: 2px;
}

main {
  margin: 0 auto;
  position: relative;
}

/* Map (Leaflet) */
#map {
  position: relative;
  width: 100%;
  background: #0a0a0a;
}

/* AOI panel */
#aoi-panel {
  display: contents;
}

/* Drawer knob (mobile only) */
.drawer-knob {
  display: none;
}

/* Wide screen: 3-column */
@media (min-width: 900px) {
  main {
    display: flex;
    height: 100%;
    direction: ltr;
  }
  #aoi-panel {
    display: block;
    flex: 0 0 15%;
    height: 100%;
    overflow-y: auto;
    background: #111;
    padding: 8px;
  }
  #aoi-search {
    position: static;
    width: 100%;
  }
  #aoi-chips {
    max-width: 100%;
  }
  #map {
    flex: 0 0 50%;
    min-width: 0;
    height: 100%;
  }
  #feed-drawer {
    flex: 0 0 35%;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    direction: rtl;
  }
}

/* Narrow screen: map fullscreen + bottom drawer */
@media (max-width: 899px) {
  main {
    position: relative;
    overflow: hidden;
    height: 100%;
  }
  #aoi-panel {
    display: contents;
  }
  #aoi-search {
    position: absolute;
    z-index: 1000;
  }
  #map {
    height: calc(100% - 40px);
  }
  #feed-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translateY(calc(100% - 40px));
    transition: transform 0.3s ease;
    background: #0a0a0a;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overscroll-behavior-y: contain;
  }
  #feed-drawer.drawer-open {
    transform: translateY(0);
  }
  #feed-drawer #feed {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }
  .drawer-knob {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 44px;
    cursor: pointer;
    flex-shrink: 0;
    background: #1a1a1a;
    border-top: 1px solid #3a3a3a;
    border-radius: 12px 12px 0 0;
  }
  .drawer-hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .drawer-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #ccc;
    border-radius: 1px;
  }
  .drawer-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ddd;
    letter-spacing: 0.02em;
    line-height: 1;
    align-self: center;
    display: none;
  }
  #feed-drawer.drawer-open .drawer-label {
    display: block;
  }
}


/* Areas of Interest search */
#aoi-search {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 1000;
  width: 160px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#aoi-chips {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  direction: ltr;
  max-width: 160px;
}

.aoi-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #555;
  color: #ddd;
  font-size: 0.84rem;
  padding: 1px 3px;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: default;
  user-select: none;
  max-width: 100%;
  transition: background 0.4s, border-color 0.4s, border-width 0.2s, box-shadow 0.4s, color 0.3s, font-weight 0.3s;
}
.chip-label-clip {
  overflow: hidden;
  min-width: 0;
  flex: 1;
}
.chip-label {
  display: inline-block;
}
.chip-ticker {
  display: inline-block;
  animation: chipTicker 14s linear infinite reverse;
}
@keyframes chipTicker {
  0%   { transform: translateX(0); }
  100% { transform: translateX(var(--ticker-dist)); }
}


.aoi-chip-x {
  background: #444;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  width: 1.1em;
  height: 1.1em;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}

.aoi-chip-x:hover {
  color: #ff6666;
}

#aoi-input {
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 0.8rem;
  padding: 6px 10px;
  outline: none;
  flex: 1;
  min-width: 0;
}

#aoi-input-row {
  display: flex;
  align-items: stretch;
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid #444;
  border-radius: 6px;
  overflow: hidden;
}


#aoi-input-divider {
  width: 1px;
  background: #444;
  flex-shrink: 0;
}

#aoi-toggle:focus {
  outline: none;
}

#aoi-toggle {
  -webkit-tap-highlight-color: transparent;
  background: none;
  border: none;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 800;
  font-family: Georgia, "Times New Roman", serif;
  padding: 0 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s;
}

#aoi-toggle:hover {
  color: #fff !important;
}
#aoi-toggle .aoi-hide-line {
  display: none;
}
#aoi-toggle.hidden .aoi-hide-line {
  display: block;
}
#aoi-toggle.hidden {
  color: #666;
}

#notif-toggle {
  -webkit-tap-highlight-color: transparent;
  background: none;
  border: none;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s;
}

#notif-toggle:focus {
  outline: none;
}
#notif-toggle .notif-mute-line {
  display: none;
}
#notif-toggle.muted .notif-mute-line {
  display: block;
}
#notif-toggle.muted {
  color: #666;
}
#notif-toggle:hover {
  color: #fff !important;
}

#aoi-results {
  background: rgba(20, 20, 20, 0.92);
  border-radius: 6px;
  overflow: hidden;
}

.aoi-result {
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #333;
  direction: rtl;
}

.aoi-result:first-child {
  border-top: none;
}

.aoi-result:hover {
  background: rgba(79, 195, 247, 0.15);
}

.aoi-result-type {
  font-size: 0.65rem;
  color: #777;
}

.aoi-no-results {
  padding: 6px 10px;
  font-size: 0.75rem;
  color: #666;
  text-align: center;
  direction: rtl;
}

/* Leaflet AOI labels (divIcon) */
.aoi-label {
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  white-space: nowrap;
  background: none !important;
  border: none !important;
  pointer-events: none;
  transition: font-size 0.2s;
}

.aoi-label.aoi-enlarged {
  font-size: 1.2rem;
}

/* Leaflet tooltip for area names */
.area-tooltip {
  background: rgba(20, 20, 20, 0.9) !important;
  border: 1px solid #555 !important;
  color: #e0e0e0 !important;
  font-size: 0.8rem !important;
  border-radius: 4px !important;
  padding: 4px 8px !important;
  direction: rtl;
}

.area-tooltip::before {
  border-top-color: #555 !important;
}

/* Location pin glow */
.location-pin {
  filter: drop-shadow(0 0 4px rgba(0, 204, 85, 0.9));
}

/* Radar */
.radar-icon { background: none !important; border: none !important; pointer-events: none; }
.radar-scanner { width: 100%; height: 100%; clip-path: circle(50% at 50% 50%); position: relative; }
.radar-sweep { position: absolute; inset: 0; background: conic-gradient(from 0deg, transparent 0deg, transparent 280deg, rgba(0,120,50,0.05) 310deg, rgba(0,120,50,0.5) 348deg, rgba(0,120,50,0.9) 360deg); will-change: transform; animation: radarSpin 4.2s linear infinite; transform: translateZ(0); }
.radar-ring { position: absolute; inset: 28%; border-radius: 50%; border: 1px solid rgba(255,255,255,0.15); pointer-events: none; }
.radar-center { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: #fff; top: 50%; left: 50%; transform: translate(-50%,-50%); box-shadow: 0 0 4px rgba(0,0,0,0.6); }
@keyframes radarSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Location toast */
#loc-toast {
  position: absolute;
  top: 70px;
  right: 8px;
  z-index: 1001;
  background: rgba(20,20,20,0.88);
  color: #e0e0e0;
  font-size: 0.85rem;
  padding: 7px 13px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  direction: rtl;
}
#loc-toast.show { animation: locToastFade 2.4s ease forwards; }
@keyframes locToastFade {
  0%   { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
@media (min-width: 900px) { #loc-toast { display: none; } }

/* Location toggle button */
#loc-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  touch-action: manipulation;
  background: rgba(20,20,20,0.85);
  border: 1px solid #444;
  border-radius: 8px;
  color: #e0e0e0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#loc-toggle svg path { fill: #e0e0e0; transition: fill 0.2s; }
#loc-toggle.active { border-color: #00cc55; }
#loc-toggle.active svg path { fill: #00cc55; }
@media (min-width: 900px) { #loc-toggle { display: none; } }

/* Alert feed */
#feed {
  padding: 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feed-empty {
  text-align: center;
  color: #555;
  padding: 24px;
  font-size: 0.9rem;
}

.alert-card {
  background: #151515;
  border-radius: 8px;
  padding: 10px 14px;
  border-right: 4px solid #333;
  animation: slideIn 0.3s ease-out;
}

.alert-card.cat-1 { border-right-color: #ff2020; }
.alert-card.cat-2,
.alert-card.cat-6 { border-right-color: #ff8c00; }
.alert-card.cat-3 { border-right-color: #9b30ff; }
.alert-card.cat-10 { border-right-color: #cc0000; }
.alert-card.cat-13 { border-right-color: #bb00ff; }
.alert-card.cat-11,
.alert-card.cat-101 { border-right-color: #ffdd00; }
.alert-card.cat-12,
.alert-card.cat-102,
.alert-card.cat-103 { border-right-color: #888; }
.alert-card.cat-98 { border-right-color: #ffdd00; }
.alert-card.cat-99 { border-right-color: #2090ff; }
.alert-card.evt-rockets { border-right-color: #ff2020; }
.alert-card.evt-uav { border-right-color: #ff8c00; }
.alert-card.evt-infiltration { border-right-color: #bb00ff; }
.alert-card.evt-pre_warning { border-right-color: #ffdd00; }
.alert-card.evt-test { border-right-color: #2090ff; }
.alert-card.evt-standdown { border-right-color: #888; }

.alert-cat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  color: #888;
}

.cat-1 .alert-cat-label { color: #ff2020; }
.cat-2 .alert-cat-label,
.cat-6 .alert-cat-label { color: #ff8c00; }
.cat-3 .alert-cat-label { color: #9b30ff; }
.cat-10 .alert-cat-label { color: #cc0000; }
.cat-13 .alert-cat-label { color: #bb00ff; }
.cat-11 .alert-cat-label,
.cat-101 .alert-cat-label { color: #ffdd00; }
.cat-12 .alert-cat-label,
.cat-102 .alert-cat-label,
.cat-103 .alert-cat-label { color: #888; }  /* stand-down / all-clear */
.cat-98 .alert-cat-label { color: #ffdd00; }
.cat-99 .alert-cat-label { color: #2090ff; }
.evt-rockets .alert-cat-label { color: #ff2020; }
.evt-uav .alert-cat-label { color: #ff8c00; }
.evt-infiltration .alert-cat-label { color: #bb00ff; }
.evt-pre_warning .alert-cat-label { color: #ffdd00; }
.evt-test .alert-cat-label { color: #2090ff; }
.evt-standdown .alert-cat-label { color: #888; }

.alert-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.alert-districts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
  direction: rtl;
}

.alert-district-pill {
  font-size: 0.7rem;
  color: #ccc;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 1px 8px;
  white-space: nowrap;
}

.alert-areas-toggle {
  margin-bottom: 4px;
}

.alert-areas-toggle summary {
  font-size: 0.8rem;
  color: #777;
  cursor: pointer;
  user-select: none;
}

.alert-areas-toggle summary:hover {
  color: #aaa;
}

.alert-areas {
  font-size: 0.85rem;
  color: #bbb;
  margin-top: 4px;
  line-height: 1.4;
}

.alert-desc {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 4px;
}

.alert-time-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.alert-ago {
  font-size: 0.7rem;
  color: #777;
}

.alert-ago-hot {
  background: #cc0000;
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
}

.alert-time {
  font-size: 0.7rem;
  color: #bbb;
  background: #333;
  padding: 1px 6px;
  border-radius: 3px;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #0a0a0a;
}
::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

/* Zoom reset pill */
#threat-tooltip {
  display: none;
  position: absolute;
  bottom: 16px;
  right: 96px;
  z-index: 1001;
  background: rgba(20, 20, 20, 0.9);
  color: #e0e0e0;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #444;
  white-space: nowrap;
  pointer-events: none;
  direction: rtl;
}

#threat-tooltip.visible {
  display: block;
}

/* Icon deck — stacked cards */
#icon-deck {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  cursor: pointer;
  touch-action: manipulation;
  width: 50px;
  height: 50px;
}

#icon-deck .indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
#icon-deck .indicator.active {
  transition: none;
}

/* Stacked offsets (collapsed) — all huddled together */
#pw-indicator { z-index: 4; transform: translate(0, 0); }
#rockets-indicator { z-index: 3; transform: translate(-3px, -3px); }
#uav-indicator { z-index: 2; transform: translate(-6px, -6px); }
#infiltration-indicator { z-index: 1; transform: translate(-8px, -8px); }

/* Expanded — fan out vertically */
#icon-deck.expanded #pw-indicator { transform: translate(0, -150px); }
#icon-deck.expanded #rockets-indicator { transform: translate(0, -100px); }
#icon-deck.expanded #uav-indicator { transform: translate(0, -50px); }
#icon-deck.expanded #infiltration-indicator { transform: translate(0, 0); }

/* Active indicators pop out to their spread position */
#pw-indicator.active { z-index: 10; transform: translate(0, -150px); }
#rockets-indicator.active { z-index: 10; transform: translate(0, -100px); }
#uav-indicator.active { z-index: 10; transform: translate(0, -50px); }

/* Inactive icons get greyed out */
.indicator:not(.active) img {
  filter: grayscale(1) brightness(0.4);
  transition: filter 0.3s;
}
.indicator.active img {
  filter: none;
  transition: filter 0.3s;
}

.indicator img {
  display: block;
  width: 39px;
  height: 39px;
  margin: 6px;
  border-radius: 6px;
  border: 3px solid transparent;
  outline: 1px solid #444;
  background: #1e1e1e;
  transition: border-color 0.3s, filter 0.3s;
}

.indicator img.test-frame {
  border-color: #4dabf7;
}

#zoom-reset {
  display: none;
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(20, 20, 20, 0.85);
  color: #e0e0e0;
  font-size: 1.1rem;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #444;
  border: none;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
}

#zoom-reset img {
  display: block;
  margin: auto;
}

#zoom-reset.visible {
  display: flex;
}

#zoom-reset:hover {
  border-color: #4fc3f7;
}

/* Leaflet overrides for dark theme */
.leaflet-container {
  background: #0a0a0a;
  direction: ltr;
}

.leaflet-interactive:focus {
  outline: none;
}


/* Debug: red outlines around main containers */
.debug #aoi-panel { outline: 1px solid red; }
.debug #map { outline: 1px solid red; }
.debug #feed-drawer { outline: 1px solid red; }
