html,
body {
  overscroll-behavior: none;
  height: var(--app-height, 100dvh);
  min-height: 100%;
}

:root {
  color-scheme: dark;
  --panel: #101010;
  --panel-2: #181818;
  --text: #f2f5f8;
  --muted: #a8b0b8;
  --line: rgba(255, 255, 255, 0.14);
  --blue: #2f86ff;
  --video: #26b96f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@property --boot-progress {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  background: #05070a;
  color: var(--text);
}

.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 24px;
  isolation: isolate;
  background: rgba(0, 0, 0, 0.72);
  transition: opacity 360ms ease, visibility 0s linear 0s;
}

.boot-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition-delay: 0s, 360ms;
}

.boot-loader-card {
  width: min(240px, calc(100vw - 48px));
  aspect-ratio: 1;
  padding: 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #101010;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.34);
}

.boot-loader-mark {
  --boot-progress: 0%;
  position: relative;
  width: 32px;
  height: 32px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(from -90deg, var(--blue) 0 var(--boot-progress), rgba(242, 245, 248, 0.22) var(--boot-progress) 100%);
  transition: --boot-progress 650ms cubic-bezier(0.22, 1, 0.36, 1);
}

.boot-loader-mark::before {
  content: '';
  position: absolute;
  inset: 3px;
  background: #101010;
  border-radius: 50%;
}

.boot-loader-brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.boot-loader-status {
  min-height: 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
}

.app-shell,
#map {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  height: var(--app-height, 100dvh);
}

.topbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 12px;
  pointer-events: none;
}

.topbar > *,
.stats,
.camera-window {
  pointer-events: auto;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 1px 4px #000;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-shadow: 0 1px 4px #000;
}

.right-controls {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-left: auto;
  max-width: min(700px, calc(100vw - 300px));
}

.map-controls {
  display: none;
  pointer-events: auto;
}

.map-controls.search-open {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 80;
  display: block;
  width: min(620px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
}

.menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  min-width: 186px;
  background: rgba(16, 16, 16, 0.96);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}

.menu-dropdown.hidden {
  display: none;
}

.menu-dropdown button,
.menu-dropdown select {
  width: 100%;
  height: 36px;
  text-align: left;
}

.menu-dropdown button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}

.menu-item-icon {
  flex: 0 0 auto;
  color: var(--muted);
}

.my-location-marker {
  width: 17px;
  height: 17px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 6px rgba(47, 134, 255, 0.22);
  pointer-events: none;
}

.menu-dropdown button:hover,
.menu-dropdown button:focus-visible {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.08);
}

.menu-dropdown button:focus,
.menu-dropdown button:focus-visible {
  outline: none;
}

.menu-dropdown #myLocationBtn.active {
  background: var(--blue);
  color: #fff;
}

.menu-divider {
  height: 1px;
  margin: 4px 4px;
  background: var(--line);
}

.menu-more-toggle {
  justify-content: space-between !important;
}

.menu-more-dots {
  color: var(--muted);
  letter-spacing: 0.14em;
}

.menu-more {
  display: grid;
  gap: 2px;
  padding-top: 2px;
}

.menu-more.hidden {
  display: none;
}

.menu-submenu {
  display: grid;
  gap: 2px;
  margin: 0 2px 2px 8px;
  padding: 3px 0 3px 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.menu-submenu.hidden {
  display: none;
}

.menu-submenu-toggle {
  justify-content: space-between !important;
}

.menu-submenu-chevron {
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transform: translateY(-1px);
  transition: transform 160ms ease;
}

.menu-submenu-toggle[aria-expanded="true"] .menu-submenu-chevron {
  transform: translateY(-1px) rotate(90deg);
}

.menu-submenu button {
  height: 34px;
  color: var(--muted);
  font-size: 13px;
}

.menu-layer-toggle {
  justify-content: space-between !important;
}

.menu-dropdown button.menu-layer-toggle.active {
  background: rgba(47, 134, 255, 0.12);
  color: var(--muted);
}

.menu-switch {
  position: relative;
  width: 32px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 160ms ease, border-color 160ms ease;
}

.menu-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #dbe4ee;
  transition: transform 160ms ease;
}

.menu-layer-toggle.active .menu-switch {
  border-color: transparent;
  background: var(--blue);
}

.menu-layer-toggle.active .menu-switch-thumb {
  transform: translateX(14px);
}

.menu-more .menu-secondary {
  color: var(--muted);
  font-size: 13px;
}

.menu-submenu .menu-secondary {
  color: var(--muted);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.menu-dropdown,
.menu-more,
.camera-actions-menu,
.city-results,
.modal-backdrop {
  opacity: 1;
  transition: opacity 180ms ease;
}

.menu-dropdown.is-closing,
.menu-more.is-closing,
.camera-actions-menu.is-closing,
.city-results.is-closing,
.modal-backdrop.is-closing {
  opacity: 0;
  pointer-events: none;
}

.modal-box {
  background: #181818;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 28px 28px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.4);
}

.modal-box--wide {
  max-width: 520px;
  max-height: 88vh;
  max-height: 88svh;
  display: flex;
  flex-direction: column;
}

.privacy-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  margin-bottom: 20px;
  padding-right: 4px;
}

.privacy-body p {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  text-shadow: none;
}

.privacy-body p:last-child {
  margin-bottom: 0;
}

.btn-primary:disabled {
  background: #2a4a7a;
  color: rgba(255, 255, 255, 0.45);
  cursor: not-allowed;
}

.modal-box h2 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  text-shadow: none;
}

.modal-note {
  margin: 0 0 22px;
  font-size: 12px;
  color: var(--muted);
  text-shadow: none;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-primary {
  padding: 0 16px;
  height: 38px;
  background: var(--blue);
  border: none;
  border-radius: 8px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* One-time "what's new" update popup */
.update-modal-box {
  max-width: 400px;
}

.update-feature-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.update-feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.update-feature-list strong {
  display: block;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 2px;
}

.update-feature-list span:not(.update-dot) {
  display: block;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.update-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.update-dot--green {
  background: #26b96f;
}

.update-dot--red {
  background: #ef4444;
}

.btn-primary:hover {
  background: #4a9bff;
}

.btn-secondary {
  padding: 0 14px;
  height: 38px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--text);
}

button,
input,
select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(16, 16, 16, 0.94);
  color: var(--text);
  font: inherit;
}

button {
  padding: 0 12px;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  border-color: rgba(47, 134, 255, 0.9);
}

input,
select {
  min-width: 0;
  padding: 0 10px;
}

input {
  width: 260px;
}

.city-search-wrap {
  position: relative;
  width: 42px;
  flex: 0 0 42px;
  transition: width 160ms ease, flex-basis 160ms ease;
}

.city-search-wrap.expanded,
.city-search-wrap:focus-within {
  width: 260px;
  flex-basis: 260px;
}

.search-toggle {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 2;
  width: 42px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}

.city-search-wrap input {
  width: 100%;
  padding-left: 40px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.city-search-wrap.expanded input,
.city-search-wrap:focus-within input {
  opacity: 1;
  pointer-events: auto;
}

.map-controls.search-open .city-search-wrap {
  width: 100%;
  min-width: 0;
  flex: none;
}

.map-controls.search-open .city-search-wrap input {
  opacity: 1;
  pointer-events: auto;
}

.map-controls.search-open .search-toggle {
  border-color: transparent;
  background: transparent;
  pointer-events: none;
}

.city-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  background: rgba(16, 16, 16, 0.97);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
  max-height: 280px;
  overflow-y: auto;
}

.city-results.hidden {
  display: none;
}

.city-results li {
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  line-height: 1.3;
}

.city-results li:hover,
.city-results li.active {
  background: rgba(47, 134, 255, 0.25);
  color: #fff;
}

select {
  width: 128px;
}

.stats {
  position: absolute;
  left: 14px;
  bottom: 8px;
  z-index: 5;
  display: flex;
  gap: 8px;
}

.stats span,
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(16, 16, 16, 0.9);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}

.badge.video {
  color: #07120d;
  background: var(--video);
  border-color: rgba(255, 255, 255, 0.4);
}

.badge.dir {
  color: var(--text);
  background: #2a2a40;
  border-color: rgba(255, 255, 255, 0.25);
}

.filter-modal-box {
  max-width: 430px;
  width: 100%;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.filter-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.filter-toggle,
.filter-all-button,
.filter-state-row {
  color: #dbeafe;
}

.filter-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  margin-bottom: 8px;
  cursor: pointer;
  background: transparent;
  border-color: transparent;
  border-radius: 0;
}

.filter-toggle:hover,
.filter-all-button:hover,
.filter-state-row:hover {
  border-color: transparent;
}

.filter-toggle.active {
  color: #dbeafe;
  background: transparent;
  border-color: transparent;
}

.filter-all-button {
  border: 1px solid #2d3a4a;
  background: #121821;
  border-radius: 6px;
  width: 100%;
  height: 36px;
  margin-bottom: 10px;
  cursor: pointer;
}

.filter-switch {
  flex: 0 0 auto;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #6b7280;
  box-shadow: inset 0 0 0 1px #9ca3af;
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

.filter-switch::before {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  margin: 2px;
  border-radius: 50%;
  background: #f8fafc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.16s ease;
}

.filter-toggle.active .filter-switch,
.filter-state-row.active .filter-switch {
  background: #3b82f6;
  box-shadow: inset 0 0 0 1px #60a5fa;
}

.filter-toggle.active .filter-switch::before,
.filter-state-row.active .filter-switch::before {
  transform: translateX(20px);
}

.filter-search {
  width: 100%;
  height: 38px;
  margin-bottom: 10px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #2d3a4a;
  background: #0f141c;
  color: #f8fafc;
}

.filter-state-list {
  display: grid;
  gap: 6px;
  max-height: 310px;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: #374151 transparent;
}

.filter-state-list::-webkit-scrollbar { width: 5px; }
.filter-state-list::-webkit-scrollbar-track { background: transparent; }
.filter-state-list::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }
.filter-state-list::-webkit-scrollbar-thumb:hover { background: #4b5563; }

.filter-state-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 10px;
  cursor: pointer;
  border: 0;
  background: transparent;
  border-radius: 0;
}

.filter-state-row.active {
  background: transparent;
}

.filter-state-row > span:first-child {
  font-size: 13px;
}

.direction-row {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  flex-wrap: wrap;
  align-items: center;
}

.direction-row-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
  margin-right: 2px;
}

.dir-btn {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 5px;
}

.dir-btn.active {
  background: var(--blue);
  border-color: transparent;
  color: #fff;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #05070a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-overlay.hidden {
  display: none;
}
.login-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 44px 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(340px, 90vw);
  text-align: center;
}
.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 12px;
}
.login-box h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--fg);
  margin: 0;
}
.login-subtitle {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}
.login-error {
  color: #e55;
  font-size: 0.83rem;
  margin: 0;
  max-width: 260px;
}

.offline-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0d0d0d;
}

.camera-window {
  position: absolute;
  z-index: 10;
  right: 14px;
  bottom: 14px;
  width: min(760px, calc(100vw - 40px));
  min-width: 320px;
  max-height: calc(100vh - 90px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.38);
  overflow: hidden;
  touch-action: manipulation;
  opacity: 1;
  transition: opacity 180ms ease;
}

.camera-window.hidden {
  display: none;
}

.camera-window.is-closing {
  opacity: 0;
  pointer-events: none;
}

.camera-window.dragging {
  will-change: left, top;
  user-select: none;
}

.camera-window.dragging video,
.camera-window.dragging img,
.camera-window.dragging canvas {
  pointer-events: none;
}

.camera-window-head {
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 16, 16, 0.98);
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.camera-window-head h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
}

.window-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.window-actions button {
  height: 30px;
  padding: 0 9px;
}

.window-actions .icon-btn {
  width: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.window-actions #cameraRetry:disabled {
  opacity: 0.55;
  cursor: wait;
}

.window-actions #cameraRetry.is-retrying svg {
  animation: camera-retry-spin 800ms linear infinite;
}

@keyframes camera-retry-spin {
  to { transform: rotate(360deg); }
}

.camera-actions-legacy {
  display: none !important;
}

.camera-actions-wrap {
  position: relative;
  flex: 0 0 auto;
}

.camera-actions-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 178px;
  padding: 6px;
  background: rgba(16, 16, 16, 0.98);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}

.camera-actions-menu.hidden {
  display: none;
}

.camera-actions-menu button {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}

.camera-actions-menu button:hover,
.camera-actions-menu button:focus-visible {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.08);
}

button.active {
  background: var(--blue);
  border-color: transparent;
  color: #fff;
}

.details {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.meta-row {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.viewer {
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(540px, calc(100vh - 240px));
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #000;
}

.viewer video,
.viewer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.viewer-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.viewer-state.resolving {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.resolving-dots {
  display: inline-flex;
  gap: 3px;
}

.resolving-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.28;
  animation: resolving-dot 1.05s ease-in-out infinite;
}

.resolving-dots span:nth-child(2) { animation-delay: 0.14s; }
.resolving-dots span:nth-child(3) { animation-delay: 0.28s; }

@keyframes resolving-dot {
  0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.camera-log {
  min-height: 24px;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
}

.mapboxgl-ctrl-logo,
.mapboxgl-ctrl-attrib,
.maplibregl-ctrl-logo,
.maplibregl-ctrl-attrib {
  display: none !important;
}

.mapboxgl-popup-content,
.maplibregl-popup-content {
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}

.mapboxgl-popup-tip,
.maplibregl-popup-tip {
  border-top-color: var(--panel) !important;
}

.camera-name-popup .mapboxgl-popup-content,
.camera-name-popup .maplibregl-popup-content {
  min-width: 220px;
  max-width: min(300px, calc(100vw - 24px));
  padding: 0;
  border-radius: 10px;
  background: rgba(16, 16, 16, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.36);
}

.camera-name-popup .mapboxgl-popup-tip,
.camera-name-popup .maplibregl-popup-tip {
  border-top-color: rgba(16, 16, 16, 0.96) !important;
}

.camera-popup-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
}

.camera-popup-text {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.camera-popup-title {
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.camera-popup-kind {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.camera-popup-coords {
  line-height: 1.2;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 11px;
  font-weight: 600;
}

.camera-popup-play {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: #1d8fff;
  box-shadow: none;
  padding: 0;
  cursor: pointer;
}

.camera-popup-play:hover {
  background: #318fff;
}

.camera-popup-play::before {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  margin-left: 2px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M8 6L18 12L8 18Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.modal-box--alerts {
  max-width: 560px;
  width: 100%;
  max-height: 82vh;
  max-height: 82svh;
  display: flex;
  flex-direction: column;
}

.alerts-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.alerts-map-toggle {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 100px;
  border: none;
  outline: none;
  background: #4b5563;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.alerts-map-toggle .toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  pointer-events: none;
}
.alerts-map-toggle.active {
  background: #3b82f6;
}
.alerts-map-toggle.active .toggle-thumb {
  transform: translateX(18px);
}

.alerts-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-right: 6px;
  margin-right: -6px;
  scrollbar-width: thin;
  scrollbar-color: #374151 transparent;
}
.alerts-list::-webkit-scrollbar { width: 5px; }
.alerts-list::-webkit-scrollbar-track { background: transparent; }
.alerts-list::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }
.alerts-list::-webkit-scrollbar-thumb:hover { background: #4b5563; }

.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.alert-goto-btn {
  flex-shrink: 0;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid #374151;
  background: #1e2633;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
}
.alert-goto-btn:hover {
  background: #2d3a4a;
  color: #f1f5f9;
  border-color: #4b5563;
}

.alert-row:last-child {
  border-bottom: none;
}

.alert-swatch {
  width: 14px;
  height: 14px;
  border: none;
  flex-shrink: 0;
  margin-top: 3px;
  border-radius: 3px;
}

.alert-row-info {
  flex: 1;
  min-width: 0;
}

.alert-row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}

.alert-code {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.alert-row-meta {
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
}

.alert-row-area {
  font-size: 11px;
  color: #475569;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-hazards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.alert-hazard-tag {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
}

.alerts-loading,
.alerts-empty {
  text-align: center;
  padding: 36px 16px;
  color: #64748b;
  font-size: 14px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alerts-error {
  text-align: center;
  padding: 36px 16px;
  color: #ef4444;
  font-size: 14px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 820px) {
  .topbar {
    gap: 6px;
  }

  .right-controls {
    max-width: calc(100vw - 28px);
    width: 100%;
    justify-content: flex-end;
  }

  .map-controls {
    display: none;
  }

  .map-controls.search-open {
    display: block;
    top: 46%;
    width: calc(100vw - 28px);
  }

  input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 130px;
  }

  .city-search-wrap {
    flex: 0 0 42px;
    width: 42px;
    min-width: 42px;
  }

  .city-search-wrap:not(.expanded):not(:focus-within) {
    min-width: 42px;
  }

  .city-search-wrap.expanded,
  .city-search-wrap:focus-within {
    flex: 1 1 auto;
    width: 100%;
    min-width: 130px;
  }

  .city-search-wrap:not(.expanded):not(:focus-within) input {
    width: 42px;
    padding: 0;
  }

  .city-search-wrap.expanded .search-toggle,
  .city-search-wrap:focus-within .search-toggle {
    border-color: transparent;
    background: transparent;
    pointer-events: none;
  }

  select {
    width: 92px;
    flex-shrink: 0;
  }

  button,
  input,
  select {
    height: 42px;
  }

  /* Bottom sheet on mobile */
  .camera-window {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    min-width: unset;
    top: auto !important;
    bottom: 0;
    max-height: 75vh;
    border-radius: 14px 14px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .camera-window.floating-mobile {
    width: min(420px, calc(100vw - 16px)) !important;
    max-width: calc(100vw - 16px);
    border-radius: 14px;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    overscroll-behavior: contain;
  }

  .camera-window-head {
    height: 52px;
    cursor: move;
    position: relative;
    touch-action: none;
  }

  .details {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* Privacy modal — full-screen sheet on mobile */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .modal-box {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 24px 20px 28px;
  }

  .modal-box--wide {
    max-height: 92vh;
    max-height: 92svh;
    width: 100%;
    border-radius: 20px 20px 0 0;
  }

  .privacy-body p {
    font-size: 15px;
    line-height: 1.7;
  }

  .modal-body {
    font-size: 15px;
  }

  .modal-actions {
    justify-content: stretch;
  }

  .modal-actions .btn-primary,
  .modal-actions .btn-secondary {
    flex: 1;
    height: 50px;
    font-size: 15px;
    justify-content: center;
    display: flex;
    align-items: center;
  }
}

.dashboard-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 7px;
  padding: 0 6px;
  border-radius: 999px;
  background: #2563eb;
  color: white;
  font-size: 11px;
  font-weight: 800;
}

.camera-dashboard {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #07090d;
  color: #f8fafc;
}

.camera-dashboard.hidden { display: none; }

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  background: rgba(15, 18, 25, .98);
}

.dashboard-header h1 { margin: 2px 0 0; font-size: 22px; line-height: 1.1; }
.dashboard-header p { margin: 5px 0 0; color: #94a3b8; font-size: 13px; }
.dashboard-kicker { color: #60a5fa; font-size: 10px; font-weight: 900; letter-spacing: .16em; }
.dashboard-actions { display: flex; align-items: center; gap: 10px; }
.dashboard-actions label { display: flex; align-items: center; gap: 8px; color: #94a3b8; font-size: 12px; }
.dashboard-actions select { width: auto; min-width: 112px; background: #151923; border-color: #2a3140; color: #e2e8f0; }

.dashboard-grid {
  --dashboard-columns: 2;
  display: grid;
  grid-template-columns: repeat(var(--dashboard-columns), minmax(0, 1fr));
  grid-auto-rows: minmax(230px, 1fr);
  gap: 10px;
  flex: 1;
  min-height: 0;
  padding: 10px;
  overflow: auto;
}

.dashboard-tile {
  min-width: 0;
  min-height: 230px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #242b38;
  border-radius: 10px;
  background: #0c1017;
  box-shadow: 0 12px 35px rgba(0, 0, 0, .28);
}

.dashboard-tile > header { height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 9px 7px 13px; background: #121721; }
.dashboard-tile > header div { min-width: 0; display: flex; flex-direction: column; }
.dashboard-tile strong { overflow: hidden; color: #f1f5f9; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-tile header span { margin-top: 2px; color: #64748b; font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.dashboard-remove { width: 32px; min-width: 32px; height: 32px; padding: 0; border: 0; background: transparent; color: #64748b; }
.dashboard-remove:hover { color: #f8fafc; background: rgba(255,255,255,.07); }
.dashboard-media { position: relative; display: grid; place-items: center; flex: 1; min-height: 0; overflow: hidden; background: #030507; }
.dashboard-media img, .dashboard-media video { width: 100%; height: 100%; object-fit: contain; background: #030507; }
.dashboard-offline { color: #64748b; font-size: 13px; }
.dashboard-empty { margin: auto; max-width: 430px; padding: 32px; text-align: center; color: #94a3b8; }
.dashboard-empty.hidden, .dashboard-grid.hidden { display: none; }
.dashboard-empty h2 { margin: 8px 0; color: #f8fafc; font-size: 20px; }
.dashboard-empty p { margin: 0; line-height: 1.55; }
.dashboard-empty-icon { color: #3b82f6; font-size: 48px; }

@media (max-width: 820px) {
  .dashboard-header { align-items: flex-start; padding: 14px; }
  .dashboard-header p, .dashboard-actions label, #dashboardClear { display: none; }
  .dashboard-actions { margin-left: auto; }
  .dashboard-grid { grid-template-columns: 1fr; grid-auto-rows: minmax(240px, 42vh); }
}
