/* Theme tokens. Light is the daylight default (phones outdoors run bright);
   dark follows the phone or the in-app setting. html[data-theme] wins. */
:root {
  --bg: #f4f3ec;
  --panel: #ffffff;
  --panel-2: #eef0e6;
  --ink: #212b24;
  --dim: #5c6b60;
  --brand: #1d7a4b;
  --brand-contrast: #ffffff;
  --warn: #b45905;
  --danger: #c02f27;
  --line: #d9dccc;
  --scrim: rgba(244, 243, 236, 0.92);
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #0f1512;
    --panel: #16201b;
    --panel-2: #1b2721;
    --ink: #e8efe9;
    --dim: #9ab0a2;
    --brand: #2f9e63;
    --brand-contrast: #04140b;
    --warn: #d97706;
    --danger: #dc2626;
    --line: #24332b;
    --scrim: rgba(15, 21, 18, 0.92);
  }
}
html[data-theme="dark"] {
  --bg: #0f1512;
  --panel: #16201b;
  --panel-2: #1b2721;
  --ink: #e8efe9;
  --dim: #9ab0a2;
  --brand: #2f9e63;
  --brand-contrast: #04140b;
  --warn: #d97706;
  --danger: #dc2626;
  --line: #24332b;
  --scrim: rgba(15, 21, 18, 0.92);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* the stroke-icon family: one weight, round joins, everywhere */
.i { width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex: none; vertical-align: -3.5px; }
.pop-actions .i { width: 19px; height: 19px; vertical-align: initial; }
html, body { margin: 0; height: 100%; overflow: hidden;
  font: 15px/1.45 system-ui, sans-serif; background: var(--bg); color: var(--ink); }

#map { position: absolute; inset: 0; }

/* ---- top: floating search pill + chip row (Google-Maps pattern) ---- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  padding: calc(8px + var(--sat)) 12px 4px;
  pointer-events: none;
  display: flex; flex-direction: column; gap: 8px;
}
.search-pill {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 520px; margin: 0 auto;
  background: var(--panel); color: var(--dim);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 12px 18px; font-size: 15px; text-align: left; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.sp-logo { width: 22px; height: 22px; flex: none; }
.sp-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chipRow {
  pointer-events: auto;
  display: flex; gap: 8px; align-items: center;
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
  padding-bottom: 4px;
}
#chipRow::-webkit-scrollbar { display: none; }
#chipRow > * { flex: none; }
.chip.update { background: var(--brand); border-color: var(--brand);
  color: var(--brand-contrast); font-weight: 700; }
.chip {
  border: 1px solid var(--danger); color: #fff; background: var(--danger);
  border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
/* one hide rule beats every specificity fight */
.hidden { display: none !important; }
.chip.subtle { background: var(--panel); border-color: var(--line); color: var(--dim); font-weight: 400; }
.chip.clear { background: var(--panel); border-color: var(--brand); color: var(--brand); font-weight: 500; }

/* ---- fab + nav ---- */
.fab {
  position: fixed; right: 14px; bottom: calc(86px + var(--sab)); z-index: 25;
  width: 52px; height: 52px; border-radius: 50%; font-size: 22px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0,0,0,.4); cursor: pointer;
}
.fab.active { color: var(--brand); border-color: var(--brand); }
.fab.spots { bottom: calc(148px + var(--sab)); font-size: 18px; }
/* left-hand map tools: basemap + layers + zoom readout */
#mapTools {
  position: fixed; left: 14px; bottom: calc(86px + var(--sab)); z-index: 25;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.fab.sq {
  position: static; width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
#zoomChip {
  font: 600 11px/1 ui-monospace, monospace; color: var(--dim);
  background: var(--scrim); border-radius: 6px; padding: 3px 6px;
}
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--panel);
  border-top: 1px solid var(--line); padding-bottom: var(--sab);
}
.nav-btn {
  flex: 1; padding: 8px 0 6px; font-size: 11.5px; font-weight: 600;
  background: none; border: none; color: var(--dim); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  letter-spacing: .02em;
}
.nav-btn svg { display: block; }
.nav-btn.active { color: var(--brand); }
.nav-btn.active svg { stroke-width: 2.2; }
/* the raised [+]: field actions get the biggest thumb target */
.nav-btn.plus { overflow: visible; }
.plus-circle {
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--brand); color: var(--brand-contrast);
  margin-top: -26px; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  border: 3px solid var(--panel);
}
#plusMenu {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(64px + var(--sab)); z-index: 45;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35); min-width: 230px;
}
#plusMenu.hidden { display: none; }
#plusMenu .btn { justify-content: flex-start; gap: 8px; }

/* ---- sheets ---- */
.sheet {
  position: fixed; left: 0; right: 0; z-index: 40;
  bottom: calc(49px + var(--sab)); /* sits ABOVE the nav — nav stays usable */
  max-height: 66vh; display: flex; flex-direction: column;
  background: var(--panel); border-radius: 16px 16px 0 0;
  border: 1px solid var(--line); border-bottom: none;
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
  padding-bottom: 10px;
  transition: transform .2s ease-out;
}
.sheet.hidden { display: none; }
/* evidence sheet snap points: peek shows the summary while the map stays live */
#sheet-evidence.snap-peek { max-height: 250px; }
#sheet-evidence.snap-half { max-height: 52vh; }
#sheet-evidence.snap-full { max-height: 86vh; }
.grab { align-self: center; width: 44px; height: 20px; cursor: pointer; position: relative; }
.grab::after { content: ""; position: absolute; left: 4px; right: 4px; top: 8px;
  height: 4px; border-radius: 2px; background: var(--line); }
.sheet-head { display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 8px; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.icon-btn { background: none; border: none; color: var(--dim); font-size: 26px;
  cursor: pointer; padding: 0 4px; min-width: 44px; min-height: 32px; }
.sheet-body { overflow-y: auto; padding: 0 16px 8px; }
.sheet-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--dim); margin: 16px 0 6px; }

.disclaimer { color: var(--warn); font-size: 12.5px;
  border: 1px dashed var(--warn); border-radius: 8px; padding: 8px; margin: 0 0 8px; }
.meta { color: var(--dim); font-size: 12.5px; }

/* ---- controls ---- */
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0;
  min-height: 44px; color: var(--ink); }
.row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); }
.row input[type=range] { flex: 1; accent-color: var(--brand); }
.btn {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 14px; font-size: 14px; cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand);
  color: var(--brand-contrast); font-weight: 700; width: 100%; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.actions-row { display: flex; gap: 10px; margin-bottom: 10px; }
.actions-row.wrap { flex-wrap: wrap; }
.actions-row.wrap .btn { flex: 1 1 40%; }
.actions-row .btn { flex: 1; }
.actions textarea { background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; }
.report-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: var(--dim); font-size: 13px; }

/* ---- legend swatches ---- */
.swatch { width: 22px; height: 14px; border-radius: 3px; flex: none; }
.swatch.patent { background: rgba(220,38,38,.35); border: 1.5px solid #dc2626; }
.swatch.crown { background: rgba(47,158,99,.3); border: 1.5px solid #2f9e63; }
.swatch.conflict { background: rgba(217,119,6,.5); border: 1.5px solid #d97706; }
.swatch.shore { background: linear-gradient(90deg, #a8a29e, #d97706, #22c55e); height: 5px; border-radius: 2px; }
/* legend swatches that look like the map's own markers */
.swatch.tent, .swatch.tent-ok, .swatch.star {
  width: 18px; height: 16px; background-position: center;
  background-size: contain; background-repeat: no-repeat; border-radius: 0; }
.swatch.tent { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M24 6 46 41 H2 Z" fill="%23059669" stroke="white" stroke-width="4" stroke-linejoin="round"/><path d="M24 20 33 41 H15 Z" fill="white"/></svg>'); }
.swatch.tent-ok { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M24 6 46 41 H2 Z" fill="%23d97706" stroke="white" stroke-width="4" stroke-linejoin="round"/><path d="M24 20 33 41 H15 Z" fill="white"/></svg>'); }
.swatch.star { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M24 4l6.2 12.6L44 18.6l-10 9.7 2.4 13.8L24 35.6l-12.4 6.5L14 28.3 4 18.6l13.8-2z" fill="%23f59e0b" stroke="white" stroke-width="3" stroke-linejoin="round"/></svg>'); }
.swatch.track { background: #9333ea; height: 3px; }
.swatch.reserve { background: rgba(124,58,237,.3); border: 1.5px solid #7c3aed; }
.swatch.bush { background: repeating-linear-gradient(90deg, #a16207 0 6px, transparent 6px 10px); height: 4px; }
.swatch.barrier { width: 16px; height: 16px; border-radius: 0;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><circle cx="24" cy="24" r="22" fill="%23c02f27" stroke="white" stroke-width="4"/><rect x="12" y="15" width="4" height="18" fill="white"/><rect x="32" y="15" width="4" height="18" fill="white"/><rect x="14" y="19" width="20" height="3.6" fill="white"/><rect x="14" y="26" width="20" height="3.6" fill="white"/></svg>') center/contain no-repeat; }
.swatch.interior { background: radial-gradient(circle, #22c55e 40%, transparent 45%),
  radial-gradient(circle at 30% 70%, #d97706 20%, transparent 25%); }
.swatch.launch { width: 16px; height: 16px; border-radius: 0;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><circle cx="24" cy="24" r="22" fill="%230e7ec0" stroke="white" stroke-width="4"/><path d="M12 28h24l-4 6H16z" fill="white"/><path d="M23 14v10h10z" fill="white"/><rect x="22" y="12" width="2.6" height="12" fill="white"/></svg>') center/contain no-repeat; }
.swatch.trail { background: repeating-linear-gradient(90deg, #2dd4bf 0 4px, transparent 4px 8px); height: 3px; }
.swatch.wmu { background: repeating-linear-gradient(90deg, #f59e0b 0 8px, transparent 8px 12px); height: 4px; }
.swatch.fmz { background: repeating-linear-gradient(90deg, #818cf8 0 8px, transparent 8px 12px); height: 4px; }
.swatch.issuer { width: 16px; height: 16px; border-radius: 0;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><circle cx="24" cy="24" r="22" fill="%23b45905" stroke="white" stroke-width="4"/><path d="M15 14h13l6 6v14H15z" fill="white"/><path d="M28 14v6h6" fill="%23b45905"/><rect x="19" y="26" width="11" height="2.6" fill="%23b45905"/><rect x="19" y="30.5" width="8" height="2.6" fill="%23b45905"/></svg>') center/contain no-repeat; }
.swatch.preserve { background: rgba(220,38,38,.3); border: 1.5px dashed #dc2626; }
.chip.zone { background: var(--panel); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.swatch.bathy { background: linear-gradient(90deg, #7dd3fc, #0284c7, #1e1b4b); height: 4px; }
.swatch.nonna { background: linear-gradient(90deg, #dc2626, #f59e0b, #22c55e); }
.swatch.osmtrail { background: repeating-linear-gradient(90deg, #a78bfa 0 3px, transparent 3px 7px); height: 3px; }
.swatch.river { background: #60a5fa; height: 3px; }
.swatch.publand { background: rgba(37,99,235,.3); border: 1.5px solid #2563eb; }
.swatch.forest { background: rgba(13,148,136,.3); border: 1.5px dashed #0d9488; }
.swatch.park { background: rgba(21,128,61,.18); border: 1.5px dashed #15803d; }

/* ---- mode switcher ---- */
#modeBar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 2px; }
.mode-btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
  border-radius: 10px; padding: 10px 4px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; }
.mode-btn .i { width: 16px; height: 16px; }
.mode-btn.active { background: var(--brand); border-color: var(--brand);
  color: var(--brand-contrast); }

/* ---- search ---- */
#searchBox { position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: calc(10px + var(--sat)) 14px 10px; max-height: 70vh; overflow-y: auto; }
#searchBox.hidden { display: none; }
#searchInput { width: calc(100% - 52px); font: inherit; font-size: 16px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 14px; }
#searchBox .icon-btn { position: absolute; right: 6px; top: calc(8px + var(--sat)); }
/* the maplibre geolocate widget duplicates our own ◎ button — and shows a
   red slash when GPS is off, which reads as "the app is broken" */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { display: none; }

/* ---- first-run tour ---- */
#tour { position: fixed; inset: 0; z-index: 100; background: var(--scrim);
  display: flex; align-items: center; justify-content: center; padding: 24px; }
#tour.hidden { display: none; }
.tour-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px 22px; max-width: 340px; display: flex; flex-direction: column; gap: 16px; }
.tour-card h2 { margin: 0 0 6px; font-size: 20px; }
.tour-card p { margin: 0; color: var(--dim); font-size: 15px; line-height: 1.5; }
.tour-card .big { font-size: 40px; line-height: 1; }

.quick-row { display: flex; gap: 6px; margin: 4px 0 10px; }
.quick-row .btn { flex: 1; min-height: 40px; padding: 8px 2px; font-size: 12.5px; }

/* ---- waypoint type picker ---- */
#wptPicker {
  position: fixed; left: 12px; right: 12px; bottom: calc(60px + var(--sab));
  z-index: 45; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; box-shadow: 0 -8px 30px rgba(0,0,0,.35);
}
#wptPicker input { width: 100%; font: inherit; background: var(--bg);
  color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px; }
.wpt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
#wptPicker > .btn:last-child { width: 100%; }
@media (min-width: 800px) { #wptPicker { left: auto; right: 12px; width: 400px; } }

/* ---- GOTO bar: the numbers a person walking a bearing needs ---- */
#gotoBar {
  position: fixed; left: 0; right: 0; bottom: calc(49px + var(--sab));
  z-index: 35; display: flex; align-items: center; gap: 6px;
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 10px 14px;
}
#gotoBar .g-stat { flex: 1; display: flex; flex-direction: column; }
#gotoBar .g-label { font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--dim); }
#gotoBar .g-stat span:last-child { font-size: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums; }
#gotoBar .btn.stop { background: var(--danger); border-color: var(--danger);
  color: #fff; font-weight: 700; letter-spacing: .06em; min-height: 44px; }
@media (min-width: 800px) {
  #gotoBar { left: auto; right: 12px; bottom: 70px; width: 400px;
    border: 1px solid var(--line); border-radius: 12px; }
}

/* ---- peek sheet: just the verdict + actions over the map ---- */
#sheet-evidence.snap-peek .sheet-body > :not(#evSummary):not(.quick-row) { display: none; }
.mini-chip { display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 12.5px; font-weight: 600; }
.mini-chip .dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---- the pop-card: the tap answer that POPS ---- */
#popCard {
  position: fixed; left: 10px; right: 10px; bottom: calc(64px + var(--sab));
  z-index: 42; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
#popCard.pop-in { animation: popIn .18s cubic-bezier(.2, .9, .3, 1.25); }
@keyframes popIn {
  from { transform: translateY(16px) scale(.95); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { #popCard.pop-in { animation: none; } }
.pop-head { display: flex; width: 100%; align-items: center; gap: 10px;
  padding: 14px 16px 8px; background: none; border: none; text-align: left;
  color: var(--ink); cursor: pointer; }
#popTitle { font-weight: 700; font-size: 16.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
#popChips { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.pop-chev { font-size: 30px; color: var(--dim); line-height: 1; flex: none; }
.pop-actions { display: flex; gap: 6px; padding: 6px 12px 12px; }
.pop-actions button { flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 2px;
  font-size: 11px; font-weight: 600; color: var(--ink); cursor: pointer; }
.pop-actions .ico { font-size: 17px; }
@media (min-width: 800px) {
  #popCard { left: auto; right: 12px; width: 400px; bottom: 76px; }
}

/* the "what can I do here" summary */
.summary { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 6px; }
.sum-row { display: grid; grid-template-columns: 14px 90px 1fr; gap: 8px;
  align-items: start; font-size: 14.5px; line-height: 1.4; }
.sum-row .dot { width: 11px; height: 11px; border-radius: 50%; margin-top: 5px; }
.dot.green { background: #22c55e; }
.dot.red { background: #ef4444; }
.dot.orange { background: #f59e0b; }
.dot.grey { background: #6b7280; }
.sum-row a { color: var(--brand); }
.sum-note { margin: 0 0 10px; }

/* ---- evidence table ---- */
#evidence a, #evSummary a { color: var(--brand); }
.ev-h { font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--dim); margin: 14px 0 2px; }
#evidence table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 8px; }
#evidence td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
#evidence td:first-child { color: var(--dim); }
.flag-bad { color: var(--warn); font-weight: 600; }
.flag-good { color: var(--brand); font-weight: 600; }
.flag-danger { color: var(--danger); font-weight: 700; }

#evLive .live-card { border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 8px; font-size: 13.5px; background: var(--panel-2); }

/* ---- card lists ---- */
.cards { list-style: none; margin: 8px 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px; }
.cards li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  cursor: pointer; background: var(--panel-2); }
.cards li:active { border-color: var(--brand); }
.cards .sub { color: var(--dim); font-size: 12.5px; }
.cards .verified { color: var(--brand); font-size: 12.5px; }
.empty { color: var(--dim); border: 1px dashed var(--line); border-radius: 10px;
  padding: 16px; text-align: center; }

/* the credits ⓘ: maplibre's compact attribution, dressed for the app —
   a quiet pill beside the scale bar, full credits on tap */
.maplibregl-ctrl-bottom-left { bottom: calc(52px + var(--sab)); left: 60px; }
.maplibregl-ctrl-attrib {
  background: var(--scrim) !important; color: var(--dim);
  border-radius: 999px; font-size: 10.5px;
}
.maplibregl-ctrl-attrib a { color: var(--dim); }
.maplibregl-ctrl-attrib.maplibregl-compact-show { border-radius: 12px; }

/* wider screens: sheets become a right-side panel */
@media (min-width: 800px) {
  .sheet { left: auto; right: 12px; bottom: 70px; width: 400px;
    border-radius: 14px; border-bottom: 1px solid var(--line); max-height: 78vh; }
  #nav { left: auto; right: 12px; bottom: 12px; width: 400px;
    border: 1px solid var(--line); border-radius: 12px; }
  .fab { right: 430px; bottom: 24px; }
  .fab.spots { bottom: 86px; }
  #mapTools { bottom: 90px; }
}
