:root {
  color-scheme: dark;
  --bg: #10121a;
  --panel: #181b27;
  --panel-2: #202437;
  --text: #f4f7fb;
  --muted: #a9b2c7;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #fb7185;
  --border: rgba(255, 255, 255, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--text);
  background: radial-gradient(circle at top left, rgba(139, 92, 246, .25), transparent 32rem), var(--bg);
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 18, 26, .88);
  backdrop-filter: blur(10px);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .25rem; font-size: clamp(1.4rem, 3vw, 2rem); }
h2 { font-size: 1rem; }
h3 { margin-bottom: .35rem; font-size: 1rem; }
.topbar p { margin-bottom: 0; color: var(--muted); }

.actions, menu, .location-card__actions { display: flex; gap: .55rem; flex-wrap: wrap; }

button {
  border: 0;
  border-radius: .65rem;
  padding: .65rem .85rem;
  cursor: pointer;
  color: white;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px rgba(0, 0, 0, .2);
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.ghost { background: var(--panel-2); border: 1px solid var(--border); }
button.danger { background: var(--danger); }
button.danger.ghost { background: rgba(251, 113, 133, .14); color: #fecdd3; }

.layout {
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  min-height: calc(100vh - 86px);
  min-height: calc(100svh - 86px);
}

@supports (height: 100dvh) {
  .layout { min-height: calc(100dvh - 86px); }
}

.sidebar {
  overflow-y: auto;
  padding: 1rem;
  border-right: 1px solid var(--border);
  background: rgba(16, 18, 26, .62);
}

.panel {
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(24, 27, 39, .92);
}

.instructions ol { padding-left: 1.25rem; color: var(--muted); }
.list-panel { padding: 0; overflow: hidden; }
.locations-list:empty::before {
  content: "No scouted locations yet. Click the map to add your first phantom signal.";
  display: block;
  padding: 1rem;
  color: var(--muted);
}

.location-card {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .02);
}
.location-card:last-child { border-bottom: 0; }
.location-card .meta, .location-card .latlng, .location-card .notes {
  margin-bottom: .55rem;
  color: var(--muted);
  font-size: .9rem;
}
.location-card .notes { white-space: pre-wrap; }

.map-wrap {
  position: relative;
  min-height: 360px;
  overflow: hidden;
}
#map {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.leaflet-container {
  max-width: 100%;
  touch-action: pan-x pan-y;
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: #151827;
  color: var(--text);
}
.popup-title { font-weight: 800; margin-bottom: .25rem; }
.popup-meta { color: #cbd5e1; margin-bottom: .4rem; }
.popup-notes { white-space: pre-wrap; }

#locationDialog {
  width: min(92vw, 480px);
  border: 1px solid var(--border);
  border-radius: 1rem;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .5);
}
#locationDialog::backdrop { background: rgba(0, 0, 0, .62); backdrop-filter: blur(3px); }

form { display: grid; gap: .85rem; }
label { display: grid; gap: .35rem; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: .65rem;
  padding: .7rem;
  color: var(--text);
  background: #0f1220;
  font: inherit;
}
textarea { resize: vertical; }
.coords { color: var(--accent-2); margin-bottom: 0; }
menu { justify-content: flex-end; padding: 0; margin: .5rem 0 0; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .layout {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .sidebar {
    order: 2;
    overflow: visible;
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  .map-wrap {
    flex: 0 0 auto;
    height: min(420px, 55vh);
    height: min(420px, 55svh);
    min-height: 320px;
    order: 1;
  }
}

@supports (height: 100dvh) {
  @media (max-width: 760px) {
    .map-wrap { height: min(420px, 55dvh); }
  }
}
