/* Nearest Forest — dark-first, built to be read in a car at night.
   No webfonts, no external assets. System stack only. */

:root {
  --bg:#0f1a12; --bg2:#16241a; --line:#26382b;
  --fg:#eaf3ec; --dim:#9db3a4; --accent:#6fd08c; --accent-ink:#06210f;
  --warn:#ffcf6b; --bad:#ff8f7a;
  --pad:16px; --radius:14px;
  --safe-t:env(safe-area-inset-top,0px); --safe-b:env(safe-area-inset-bottom,0px);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg:#f6f9f6; --bg2:#fff; --line:#dbe5dd;
    --fg:#12200f; --dim:#5c6f60; --accent:#1c7a3e; --accent-ink:#fff;
  }
}

* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { margin:0; padding:0; background:var(--bg); color:var(--fg); }
body {
  font:400 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y:none;
}
button { font:inherit; color:inherit; }

/* ---------- header ---------- */
.bar {
  position:sticky; top:0; z-index:20; background:var(--bg);
  padding:calc(var(--safe-t) + 10px) var(--pad) 8px;
  border-bottom:1px solid var(--line);
}
.bar__row { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.bar__title { margin:0; font-size:22px; font-weight:700; letter-spacing:-.02em; }
.iconbtn {
  width:44px; height:44px; flex:0 0 44px; border:1px solid var(--line);
  background:var(--bg2); border-radius:50%; display:grid; place-items:center; cursor:pointer;
}
.iconbtn__glyph { font-size:20px; line-height:1; display:block; }
.iconbtn.is-spinning .iconbtn__glyph { animation:spin 1s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

.status { margin:8px 0 0; font-size:14px; color:var(--dim); }
.status--wait { color:var(--warn); }
.status--ok   { color:var(--dim); }
.status--err  { color:var(--bad); font-weight:600; }
.status--stale{ color:var(--warn); font-weight:600; }

.tabs { display:flex; gap:6px; margin:10px 0 0; }
.tab {
  flex:1; min-height:44px; border:1px solid var(--line); background:var(--bg2);
  border-radius:var(--radius); font-weight:600; cursor:pointer; color:var(--dim);
}
.tab.is-active { background:var(--accent); color:var(--accent-ink); border-color:var(--accent); }

.filter {
  width:100%; margin-top:8px; min-height:44px; padding:0 14px; font-size:17px;
  color:var(--fg); background:var(--bg2); border:1px solid var(--line);
  border-radius:var(--radius); -webkit-appearance:none;
}

/* ---------- list ---------- */
.list { list-style:none; margin:0; padding:8px var(--pad) 0; }
.row {
  display:flex; align-items:stretch; gap:10px; margin-bottom:8px;
  background:var(--bg2); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden;
}
.row--nearest { border-color:var(--accent); border-width:2px; }
.row__main { flex:1; min-width:0; padding:12px 4px 12px 14px; text-align:left; background:none; border:0; cursor:pointer; }
.row__name { font-size:18px; font-weight:600; line-height:1.25; }
.row__derived { color:var(--dim); font-style:italic; font-weight:400; }
.row__sub { margin-top:3px; font-size:14px; color:var(--dim); display:flex; gap:8px; flex-wrap:wrap; }
.row__badge { font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--accent); }
.row__closed { color:var(--warn); font-weight:600; }
.row__dist { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:0 4px; min-width:84px; }
.row__mi { font-size:20px; font-weight:700; font-variant-numeric:tabular-nums; }
.row__unit { font-size:11px; color:var(--dim); margin-top:-2px; }
.row__arrow { display:flex; align-items:center; gap:3px; color:var(--accent); line-height:1; margin-top:3px; }
.row__glyph { font-size:19px; }
/* The cardinal letters carry the meaning, so they must survive a sunlit
   windscreen: same weight as the mileage, never dimmed. */
.row__point { font-size:14px; font-weight:700; letter-spacing:.01em; }
.row__go {
  width:60px; flex:0 0 60px; border:0; border-left:1px solid var(--line);
  background:var(--accent); color:var(--accent-ink); font-size:24px; font-weight:700; cursor:pointer;
}
.empty { padding:24px var(--pad); color:var(--dim); text-align:center; }
.foot { padding:18px var(--pad) calc(var(--safe-b) + 28px); color:var(--dim); font-size:12px; line-height:1.5; }
.foot p { margin:0 0 6px; }

/* ---------- sheets ---------- */
/* ---------- map ----------
   z-index 30 sits above the sticky header (20) and below the detail sheet (50),
   so tapping a marker opens the sheet over the map rather than behind it. */
.map { position:fixed; inset:0; z-index:30; background:var(--bg); }
.map__canvas { display:block; width:100%; height:100%; touch-action:none; }
.map__bar {
  position:absolute; left:0; right:0; top:calc(var(--safe-t) + 8px);
  display:flex; gap:8px; justify-content:center; padding:0 var(--pad);
}
.map__btn { padding:8px 14px; font-size:15px; -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px); background:var(--bg2); opacity:.94; }
.map__hint {
  position:absolute; left:0; right:0; bottom:calc(var(--safe-b) + 10px);
  margin:0; text-align:center; font-size:13px; color:var(--dim);
  text-shadow:0 1px 3px var(--bg);
}
/* The list underneath must not scroll while the map has the screen. */
body.is-mapping { overflow:hidden; }

.sheet { position:fixed; inset:0; z-index:50; display:flex; align-items:flex-end; }
.sheet[hidden] { display:none; }
.sheet__scrim { position:absolute; inset:0; background:rgba(0,0,0,.55); }
.sheet__panel {
  position:relative; width:100%; max-height:88vh; overflow-y:auto; background:var(--bg2);
  border-radius:20px 20px 0 0; border-top:1px solid var(--line);
  padding:8px var(--pad) calc(var(--safe-b) + 18px);
  animation:rise .18s ease-out;
}
@keyframes rise { from { transform:translateY(14px); } }
.sheet__grip { width:38px; height:4px; border-radius:2px; background:var(--line); margin:4px auto 12px; }
.sheet__name { margin:0; font-size:22px; line-height:1.2; }
.sheet__sub { margin:4px 0 12px; color:var(--dim); font-size:14px; }
.sheet__actions { display:flex; gap:8px; margin-top:14px; }

.kv { margin:0; }
.kv dt { font-size:12px; text-transform:uppercase; letter-spacing:.07em; color:var(--dim); margin-top:12px; }
.kv dd { margin:3px 0 0; font-size:16px; line-height:1.45; white-space:pre-wrap; }
.kv dd.is-missing { color:var(--dim); font-style:italic; }
.kv a { color:var(--accent); }
.tags { display:flex; flex-wrap:wrap; gap:6px; margin-top:5px; }
.tag { font-size:13px; padding:4px 9px; border:1px solid var(--line); border-radius:999px; color:var(--dim); }

.btn { min-height:52px; padding:0 18px; border-radius:var(--radius); border:1px solid var(--line);
       background:var(--bg); font-weight:600; cursor:pointer; }
.btn--go { flex:1; background:var(--accent); color:var(--accent-ink); border-color:var(--accent); font-size:18px; }
.btn--ghost { flex:0 0 auto; color:var(--dim); }
.btn--map { width:100%; margin-bottom:8px; font-size:18px; }
.chooser { margin-top:6px; }
