:root {
  --accent: #e11d48;
  --panel-w: 420px;
  --bg: rgba(20, 22, 28, 0.94);
  --fg: #e6e8ec;
  --muted: #9aa0ac;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
#map { position: fixed; inset: 0; background: #1a1a1a; }

/* ---- top bar ---- */
#topbar {
  position: fixed; top: 12px; left: 56px; z-index: 1000;
  max-width: calc(100vw - 72px);
  background: var(--bg); color: var(--fg);
  padding: 10px 12px; border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; gap: 8px;
}
#topbar .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#topbar h1 { font-size: 15px; margin: 0; font-weight: 600; white-space: nowrap; }
#topbar h1 span { color: var(--accent); }
#topbar select, #topbar button {
  background: #2a2d36; color: var(--fg); border: 1px solid #3a3d48;
  border-radius: 8px; padding: 5px 8px; font-size: 13px; cursor: pointer;
}
#locate { font-size: 15px !important; line-height: 1; }
.src-chip {
  display: inline-flex; align-items: center; gap: 6px; user-select: none;
  font-size: 12px; padding: 4px 9px; border-radius: 999px;
  background: #262a33; color: #cdd2da; cursor: pointer; border: 1px solid transparent;
}
.src-chip input { display: none; }
.src-chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.src-chip.off { opacity: .45; }
.src-chip .n { color: var(--muted); }
#status { font-size: 12px; color: var(--muted); }

/* ---- markers ---- */
.cam-marker {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}
.cam-marker.live::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid currentColor; opacity: .6;
}
.cam-marker.selected { transform: scale(1.5); }

/* ---- side panel ---- */
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-w); max-width: 100vw;
  background: #16181d; color: var(--fg); z-index: 1100;
  transform: translateX(105%); transition: transform .22s ease;
  box-shadow: -6px 0 30px rgba(0, 0, 0, .4); overflow-y: auto;
}
#panel.open { transform: translateX(0); }
#close {
  position: absolute; top: 8px; right: 8px; z-index: 5;
  width: 32px; height: 32px; border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 20px; cursor: pointer;
}
.media { position: relative; background: #000; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.media img, .media video { display: block; width: 100%; height: auto; max-height: 60vh; object-fit: contain; }
.media iframe { display: block; width: 100%; aspect-ratio: 16 / 10; border: 0; }
.media .msg { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
.badge {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 999px; background: #475569;
}
.badge.live { background: var(--accent); }
.badge.live::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #fff; margin-right: 5px; vertical-align: middle; animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .3 } }
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; }
.tabs button {
  flex: 1; background: #262a33; color: #cdd2da; border: 0; border-radius: 8px;
  padding: 7px; font-size: 13px; cursor: pointer;
}
.tabs button.active { background: var(--accent); color: #fff; }
.body { padding: 14px 16px 20px; }
.body h2 { margin: 0 0 6px; font-size: 17px; line-height: 1.3; }
.meta { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.cats { margin: 10px 0; }
.cat { display: inline-block; font-size: 11px; background: #262a33; color: #b8bdc7; padding: 3px 9px; border-radius: 999px; margin: 0 6px 6px 0; }
.links { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.links a, .links button {
  flex: 1; text-align: center; text-decoration: none; white-space: nowrap;
  padding: 9px 10px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: #262a33; color: #cdd2da; border: 0; cursor: pointer;
}
.attribution { margin-top: 16px; font-size: 11px; color: var(--muted); }
.attribution a { color: var(--muted); }

/* ---- toast ---- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #7f1d1d; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; z-index: 1200; display: none; max-width: 90%;
}

/* ---- mobile: panel becomes a bottom sheet ---- */
@media (max-width: 640px) {
  #topbar { left: 12px; right: 12px; top: auto; bottom: 12px; max-width: none; }
  #panel { top: auto; width: 100vw; max-height: 80vh; border-radius: 14px 14px 0 0; transform: translateY(105%); }
  #panel.open { transform: translateY(0); }
}
