/* 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; }
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 status strip ---- */
#status {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(6px + var(--sat)) 12px 6px;
  background: linear-gradient(to bottom, var(--scrim), transparent);
  pointer-events: none;
  /* chips can outgrow a phone: scroll them, never clip them */
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
#status::-webkit-scrollbar { display: none; }
#status > * { pointer-events: auto; flex: none; }
.app-name { font-weight: 700; white-space: nowrap; }
.motto { color: var(--warn); font-size: 12px; white-space: nowrap; }
.chip {
  border: 1px solid var(--danger); color: #fff; background: var(--danger);
  border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 600;
  margin-left: auto; cursor: pointer; white-space: nowrap;
}
.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); }
#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: 14px 0; font-size: 15px; font-weight: 600;
  background: none; border: none; color: var(--dim); cursor: pointer;
}
.nav-btn.active { color: var(--brand); }

/* ---- 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 .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; }
.swatch.bush { background: repeating-linear-gradient(90deg, #a16207 0 6px, transparent 6px 10px); height: 4px; }
.swatch.barrier { background: #dc2626; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; }
.swatch.interior { background: radial-gradient(circle, #22c55e 40%, transparent 45%),
  radial-gradient(circle at 30% 70%, #d97706 20%, transparent 25%); }
.swatch.launch { background: #38bdf8; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; }
.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 { background: #f59e0b; width: 12px; height: 12px; border-radius: 3px; border: 2px solid #fff; }
.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.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; }

/* ---- 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; }
.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)); }
#searchResults li .sub { text-transform: capitalize; }

/* ---- 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: 8px; margin: 4px 0 10px; }
.quick-row .btn { flex: 1; min-height: 40px; padding: 8px 6px; font-size: 13.5px; }

/* 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; }

#attribution {
  position: fixed; bottom: calc(52px + var(--sab)); left: 8px; z-index: 15;
  font-size: 10px; color: var(--dim); background: var(--scrim);
  padding: 2px 6px; border-radius: 4px; pointer-events: none;
}

/* 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; }
}
