:root {
  --bg: #0d1520;
  --panel: #131e2d;
  --panel-2: #1a2738;
  --line: #243449;
  --text: #e9eff7;
  --muted: #8a9bb0;
  --accent: #4aa3ff;

  --c-missile: #ff4157;
  --c-uav: #ff9a1f;
  --c-sighting: #f4d03f;
  --c-shootdown: #2fd27a;
  --c-clear: #7f8da1;

  --vis: 132px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }

#map { position: fixed; inset: 0; background: #aad3df; }
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { font-size: 10px; opacity: .8; }
.leaflet-bottom.leaflet-right { bottom: calc(var(--vis) + var(--safe-bottom) * 0); transition: bottom .25s ease; }

.topbar {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 10px;
  right: 10px;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(13, 21, 32, .88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: .01em; }
.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 transparent;
}
.live-dot.ok { background: var(--c-shootdown); animation: beat 2s infinite; }
.live-dot.bad { background: var(--c-missile); }
@keyframes beat {
  0% { box-shadow: 0 0 0 0 rgba(47, 210, 122, .55); }
  70% { box-shadow: 0 0 0 9px rgba(47, 210, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 210, 122, 0); }
}
.status { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.alert-strip {
  position: fixed;
  top: calc(var(--safe-top) + 62px);
  left: 10px;
  right: 10px;
  z-index: 790;
  padding: 7px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  background: rgba(255, 65, 87, .92);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
  pointer-events: none;
}
.alert-strip[hidden] { display: none; }

.controls {
  position: fixed;
  right: 10px;
  bottom: calc(var(--vis) + 12px);
  z-index: 780;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: bottom .25s ease;
}
.ctl {
  position: relative;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: rgba(13, 21, 32, .92);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
}
.ctl:active { background: var(--panel-2); }
.ctl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctl-tag {
  position: absolute;
  left: -2px; bottom: -7px;
  padding: 1px 6px;
  font-size: 10.5px; font-weight: 600;
  background: var(--accent); color: #07121f;
  border-radius: 8px;
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 790;
  height: var(--full, 86dvh);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
  transform: translateY(calc(var(--full, 86dvh) - var(--vis)));
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  will-change: transform;
}
.sheet.dragging { transition: none; }

.sheet-head { padding: 8px 14px 6px; touch-action: none; cursor: grab; flex: none; }
.grabber { width: 40px; height: 4px; border-radius: 2px; background: #3a4d68; margin: 0 auto 8px; }
.sheet-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.sheet-title h1 { margin: 0; font-size: 17px; font-weight: 600; }
.count { font-size: 12.5px; color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; touch-action: pan-x; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 6px 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
}
.chip.on { background: var(--text); color: #0d1520; border-color: var(--text); font-weight: 500; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.feed {
  list-style: none;
  margin: 0;
  padding: 4px 10px calc(24px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1;
  touch-action: pan-y;
}
.item {
  display: grid;
  grid-template-columns: 6px 1fr;
  gap: 12px;
  padding: 11px 6px 11px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.item:last-child { border-bottom: 0; }
.item:active { background: var(--panel-2); }
.bar { border-radius: 3px; background: var(--c); }
.item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { font-weight: 600; font-size: 14px; color: var(--c); }
.when { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.place { font-size: 15.5px; font-weight: 500; margin: 1px 0 3px; }
.place .n { color: var(--muted); font-weight: 400; }
.snip {
  margin: 0; font-size: 13.5px; color: #b6c3d4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { margin-top: 5px; font-size: 12px; color: var(--muted); display: flex; gap: 12px; align-items: center; }
.meta a { color: var(--accent); text-decoration: none; }
.now {
  padding: 1px 7px; border-radius: 8px;
  background: var(--c); color: #0d1520; font-size: 11.5px; font-weight: 600;
}
.item.past .badge { opacity: .75; }
.empty { padding: 28px 10px; color: var(--muted); text-align: center; }

.t-alert_missile { --c: var(--c-missile); }
.t-alert_uav { --c: var(--c-uav); }
.t-sighting { --c: var(--c-sighting); }
.t-shootdown { --c: var(--c-shootdown); }
.t-clear { --c: var(--c-clear); }

.mk { position: relative; width: 34px; height: 34px; }
.mk .core {
  position: absolute; inset: 3px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
  font-size: 15px; line-height: 1;
  color: #0d1520;
}
.mk.old { opacity: .6; }
.mk.live::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--c); opacity: .5;
  animation: ping 1.8s ease-out infinite;
}
@keyframes ping {
  0% { transform: scale(.6); opacity: .6; }
  100% { transform: scale(2.1); opacity: 0; }
}
.zone { animation: zonepulse 2.4s ease-in-out infinite; }
@keyframes zonepulse { 50% { fill-opacity: .06; } }

.you {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(74, 163, 255, .25);
}

.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: 14px; }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13.5px; line-height: 1.4; min-width: 200px; }
.pop-b { font-weight: 600; color: var(--c); }
.pop-p { font-weight: 500; font-size: 15px; margin: 2px 0 4px; }
.pop-note { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

.toast {
  position: fixed;
  left: 10px; right: 10px;
  top: calc(var(--safe-top) + 62px);
  z-index: 900;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--c, var(--line));
  border-left: 6px solid var(--c, var(--line));
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
  font-size: 14px;
  cursor: pointer;
}
.toast[hidden] { display: none; }
.toast b { color: var(--c); }

.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; align-items: end;
  background: rgba(3, 8, 14, .6);
}
.modal[hidden] { display: none; }
.modal-card {
  max-height: 88dvh; overflow-y: auto;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
}
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card h3 { margin: 16px 0 6px; font-size: 14px; color: var(--muted); font-weight: 500; }
.modal-card p { margin: 0 0 10px; color: #c3cfde; font-size: 14px; }
.src { list-style: none; margin: 0 0 16px; padding: 0; font-size: 13.5px; }
.src li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.src .ok { color: var(--c-shootdown); }
.src .no { color: var(--c-missile); text-align: right; }
.btn {
  width: 100%; padding: 12px; border: 0; border-radius: 12px;
  background: var(--text); color: #0d1520; font-weight: 600; cursor: pointer;
}

.post-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.post-link:hover {
  opacity: 0.8;
}

@media (min-width: 720px) {
  .sheet { left: auto; right: 12px; width: 420px; border-radius: 20px; bottom: 12px; border: 1px solid var(--line); }
  .modal { place-items: center; }
  .modal-card { width: 460px; border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot.ok, .mk.live::before, .zone { animation: none; }
  .sheet, .controls { transition: none; }
}
