:root {
  --bg: #0b3d5c;
  --bg2: #0e4d73;
  --card: #ffffff;
  --ink: #0f2433;
  --muted: #5a7385;
  --accent: #1f8fbf;
  --deep: #063552;
  --ok: #1a7f4b;
  --warn: #b45309;
  --shadow: 0 8px 28px rgba(6, 30, 48, 0.28);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--ink); background: #041824; }
#map { position: absolute; inset: 0; z-index: 0; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: calc(10px + var(--safe-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(11,61,92,.96), rgba(11,61,92,.88) 70%, rgba(11,61,92,0));
  color: #fff; pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand h1 { margin: 0; font-size: 1.05rem; letter-spacing: .2px; }
.brand .tag { margin: 0; font-size: .72rem; opacity: .85; }
.hook { font-size: 1.4rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); }
.top-actions { display: flex; gap: 6px; }
.top-actions button, .troll-controls button, #btnClosePanel {
  border: 0; border-radius: 12px; width: 42px; height: 42px;
  background: rgba(255,255,255,.95); color: var(--deep);
  font-size: 1.1rem; cursor: pointer; box-shadow: var(--shadow);
}
.top-actions button.troll-btn.active { background: #f0b429; }
.top-actions button:active { transform: scale(.96); }

.panel {
  position: absolute; z-index: 1100; top: calc(64px + var(--safe-top)); left: 10px;
  width: min(360px, calc(100vw - 20px)); max-height: calc(100vh - 110px);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel.hidden { display: none; }
.panel-head { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid #e6eef4; }
#lakeSearch {
  flex: 1; border: 1px solid #c9d8e3; border-radius: 10px; padding: 10px 12px; font-size: 1rem;
}
.filters { display: flex; gap: 14px; padding: 8px 12px; font-size: .85rem; color: var(--muted); }
#lakeList { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
#lakeList li {
  padding: 12px 14px; border-bottom: 1px solid #eef3f7; cursor: pointer;
}
#lakeList li:hover, #lakeList li:active { background: #f3f9fc; }
#lakeList .name { font-weight: 650; }
#lakeList .meta { font-size: .8rem; color: var(--muted); margin-top: 2px; }
#lakeList .badge {
  display: inline-block; font-size: .68rem; font-weight: 700; padding: 2px 6px;
  border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.badge.contour { background: #d7f0ff; color: #0b5f86; }
.badge.pdf { background: #fff1d6; color: #8a5a00; }
.badge.review { background: #ffe0e0; color: #9b1c1c; }
.review-notes { margin: 0.4rem 0 0.6rem; padding: 0.45rem 0.6rem; background: #fff5f5; border-left: 3px solid #c53030; font-size: 0.85rem; color: #7b271c; }
.panel-foot { padding: 10px 12px; background: #f7fafc; color: var(--muted); }

.card {
  position: absolute; z-index: 1050; left: 10px; right: 10px;
  bottom: calc(14px + var(--safe-bottom));
  max-width: 420px; margin: 0 auto;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 14px 12px;
}
.card.hidden { display: none; }
.card h2 { margin: 0 0 4px; font-size: 1.15rem; }
.card .county { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.card .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 8px 0 12px; font-size: .9rem; }
.card .stats strong { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card .actions a, .card .actions button {
  flex: 1 1 auto; text-align: center; text-decoration: none; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 650; border-radius: 11px;
  padding: 11px 12px; font-size: .92rem;
}
.card .actions button.secondary, .card .actions a.secondary { background: #e8f2f8; color: var(--deep); }
.card .source { margin-top: 10px; font-size: .72rem; color: var(--muted); line-height: 1.35; }
.card .close {
  position: absolute; top: 8px; right: 8px; border: 0; background: transparent;
  font-size: 1.1rem; cursor: pointer; color: var(--muted); width: 32px; height: 32px;
}

.legend {
  position: absolute; z-index: 900; right: 10px; bottom: calc(18px + var(--safe-bottom));
  background: rgba(255,255,255,.92); border-radius: 10px; padding: 8px 10px;
  box-shadow: var(--shadow); font-size: .72rem; width: 110px;
}
.legend-title { font-weight: 700; margin-bottom: 4px; }
.ramp {
  height: 10px; border-radius: 999px;
  background: linear-gradient(90deg, #c8e7ff, #4aa3d9, #1a5f9e, #08365f);
}
.legend-scale { display: flex; justify-content: space-between; margin-top: 3px; color: var(--muted); }
body.trolling .legend { bottom: calc(150px + var(--safe-bottom)); }

.troll-hud {
  position: absolute; z-index: 1060; left: 10px; right: 10px;
  bottom: calc(10px + var(--safe-bottom));
  background: rgba(6, 34, 52, .94); color: #eaf6ff; border-radius: 16px;
  padding: 12px 14px; box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.troll-hud.hidden { display: none; }
.troll-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { text-align: center; }
.metric .label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; opacity: .75; }
.metric .value { font-size: 1.45rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.metric .unit { font-size: .72rem; opacity: .7; margin-left: 2px; }
.troll-controls { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.troll-controls .toggle { font-size: .85rem; margin-right: auto; }
.troll-controls button {
  width: auto; padding: 8px 12px; height: auto; font-size: .85rem; font-weight: 650;
}
.troll-note { margin: 8px 0 0; font-size: .68rem; opacity: .7; line-height: 1.3; }

.toast {
  position: absolute; z-index: 2000; left: 50%; top: calc(70px + var(--safe-top));
  transform: translateX(-50%); background: #102a3c; color: #fff;
  padding: 10px 14px; border-radius: 10px; font-size: .88rem; max-width: 90vw;
  box-shadow: var(--shadow);
}
.toast.hidden { display: none; }

.leaflet-control-attribution { font-size: 10px !important; max-width: 70vw; }
.contour-label {
  background: transparent !important; border: 0 !important;
  color: #063552; font-weight: 700; font-size: 11px;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 1px 1px 0 #fff, -1px -1px 0 #fff;
  box-shadow: none !important;
}
.contour-label span { font-size: inherit; }
/* When the map is deeply zoomed (trolling), Leaflet still uses these markers —
   bump readability a touch via a larger default size set from JS if needed. */
.boat-marker {
  width: 0; height: 0;
}
.boat-arrow {
  width: 28px; height: 28px; margin-left: -14px; margin-top: -14px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.45));
}
.boat-arrow svg { width: 28px; height: 28px; transform-origin: 50% 50%; }

@media (min-width: 800px) {
  .card { left: 16px; right: auto; bottom: 24px; width: 380px; margin: 0; }
  .panel { top: 78px; left: 16px; }
}

.top-actions button.active { outline: 2px solid #f0b429; outline-offset: 1px; }
.legend { width: 130px; }
.legend-launches { margin-top: 8px; padding-top: 6px; border-top: 1px solid #e5eef4; line-height: 1.45; }
.legend-launches .dot, .nearby-item .dot, .access-badge::before {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 5px; vertical-align: middle; border: 1px solid rgba(0,0,0,.25);
}
.dot.public, .access-badge.public { --c: #1a7f4b; }
.dot.private, .access-badge.private { --c: #d97706; }
.dot.unknown, .access-badge.unknown { --c: #6b7280; }
.dot.public, .dot.private, .dot.unknown { background: var(--c); }

.launch-marker { background: transparent !important; border: 0 !important; }
.launch-pin {
  display: block; width: 14px; height: 14px; border-radius: 50% 50% 50% 0;
  background: var(--fill); border: 2px solid var(--stroke);
  transform: rotate(-45deg);
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.launch-cluster {
  background: transparent !important; border: 0 !important;
}
.launch-cluster div {
  background: rgba(11, 61, 92, .92); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.launch-cluster-sm div { width: 34px; height: 34px; font-size: 12px; }
.launch-cluster-md div { width: 40px; height: 40px; font-size: 13px; }
.launch-cluster-lg div { width: 46px; height: 46px; font-size: 14px; }

.launch-popup strong { display: block; margin-bottom: 4px; font-size: .95rem; }
.access-badge {
  display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 7px;
  border-radius: 999px; margin-bottom: 6px; color: #fff; background: var(--c, #6b7280);
}
.access-badge.public { background: #1a7f4b; }
.access-badge.private { background: #d97706; }
.access-badge.unknown { background: #6b7280; }
.launch-popup .launch-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.launch-popup .launch-actions a {
  flex: 1; text-align: center; text-decoration: none; background: var(--accent);
  color: #fff; font-weight: 650; border-radius: 8px; padding: 8px 10px; font-size: .82rem;
}
.launch-popup .launch-actions a.secondary { background: #e8f2f8; color: var(--deep); }
.launch-source { margin: 6px 0 0; font-size: .68rem; color: var(--muted); }
.launch-notes { margin: 4px 0 0; font-size: .72rem; color: var(--muted); line-height: 1.3; }

.nearby-launches { margin-top: 10px; }
.nearby-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 4px;
}
.nearby-item {
  display: flex; align-items: center; gap: 6px; width: 100%;
  border: 0; background: #f3f8fb; border-radius: 8px; padding: 7px 8px;
  margin-bottom: 4px; cursor: pointer; text-align: left; font-size: .82rem;
}
.nearby-item:hover { background: #e5f1f8; }
.nearby-name { flex: 1; font-weight: 600; color: var(--ink); }
.nearby-mi { color: var(--muted); font-variant-numeric: tabular-nums; }


.badge.review-high { background: #ffedd5; color: #9a3412; border: 1px solid #fb923c; }
.approx-banner {
  margin: 0.5rem 0 0.65rem;
  padding: 0.55rem 0.7rem;
  background: #fff7ed;
  border: 1px solid #fb923c;
  border-left: 4px solid #ea580c;
  border-radius: 6px;
  font-size: 0.86rem;
  color: #7c2d12;
  line-height: 1.35;
}
