:root {
  --bg: #f4f5f1; --card: #ffffff; --ink: #18211d; --ink-2: #56625d; --line: #e2e4dc; --line-2: #c9ccc0;
  --accent: #14532d; --accent-2: #15803d; --accent-soft: #e4f3e8; --warn: #b45309; --bad: #b91c1c;
  --field: #ffffff; --glass: rgba(255,255,255,.94); --subtle: #f3f4f1; --hover: #f0f2ec;
  --tint-warn: #fef3c7; --tint-bad: #fee2e2; --tint-blue: #e0f2fe; --tint-good: #dcfce7;
  --top-bg: linear-gradient(90deg, #123f24, #166534); --dark-chip: #111827;
  --ui-zoom: 1; color-scheme: light;
  --water: #0284c7; --camp: #15803d; --shelter: #7c3aed; --bike: #c2410c; --community: #db2777;
  --radius: 12px; --panel-w: 420px; --top-h: 56px;
  --shadow: 0 1px 2px rgba(20,30,25,.06), 0 4px 16px rgba(20,30,25,.10);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
:root[data-theme="dark"] {
  --bg: #0f1412; --card: #171e1b; --ink: #e7ece9; --ink-2: #9fb0a8; --line: #2a3530; --line-2: #3a4842;
  --accent: #0d2e1a; --accent-2: #178a45; --accent-soft: #163824; --warn: #f59e0b; --bad: #f87171;
  --field: #111816; --glass: rgba(23,30,27,.94); --subtle: #1d2622; --hover: #202b26;
  --tint-warn: #3b2e10; --tint-bad: #3f1d1d; --tint-blue: #0f2a3a; --tint-good: #133222;
  --top-bg: linear-gradient(90deg, #0b2615, #0f3a20); --dark-chip: #000;
  --water: #38bdf8; --community: #f472b6;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.45); color-scheme: dark;
}
:root[data-contrast="more"] { --ink-2: var(--ink); --line: var(--line-2); }
:root[data-contrast="more"] .btn, :root[data-contrast="more"] .card { border-width: 2px; }
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
:root[data-theme="dark"][data-dim-map="1"] .leaflet-tile-pane { filter: brightness(.72) contrast(1.08) saturate(.85); }
:root[data-big-icons="1"] .poi-icon { transform: scale(1.3); }
.panel, dialog, .topbar, .map-chips, .search-results { zoom: var(--ui-zoom); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 12px; background: var(--top-bg); color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.15); position: relative; z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 750; letter-spacing: .2px; font-size: 18px; }
.search { flex: 1; position: relative; max-width: 560px; }
.search input { width: 100%; height: 40px; border-radius: 20px; border: 1px solid transparent; padding: 0 16px 0 40px; background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378857f' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center / 18px; color: var(--ink); box-shadow: inset 0 1px 2px rgba(0,0,0,.06); }
.search input::placeholder { color: var(--ink-2); opacity: .9; }
.search input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(34,163,90,.25); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--card); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 60vh; overflow: auto; }
.search-results .res { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.search-results .res:last-child { border-bottom: 0; }
.search-results .res .grow { flex: 1; min-width: 0; }
.search-results .res small { color: var(--ink-2); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* layout */
.layout { position: absolute; top: calc(var(--top-h) + env(safe-area-inset-top)); bottom: 0; left: 0; right: 0; display: flex; }
.panel { width: var(--panel-w); background: var(--bg); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 1000; }
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: var(--subtle); }
.sheet-handle { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--card); }
.tabs button { flex: 1; padding: 12px 6px; border: 0; background: none; font-weight: 600; color: var(--ink-2); border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent-2); }
.panel-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.tab { display: none; padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }
.tab.active { display: block; }

/* generic UI */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn { color: var(--ink); transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--line-2); background: var(--hover); }
.btn-accent:hover { background: var(--accent); }
.btn:focus-visible, .chip:focus-visible, .tabs button:focus-visible { outline: 3px solid rgba(34,163,90,.45); outline-offset: 1px; }
.topbar .btn { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.35); }
.topbar .btn:hover { background: rgba(255,255,255,.24); }
.topbar .btn-accent { background: #fff; color: var(--accent); }
.btn-accent { background: var(--accent-2); color: #fff; border-color: transparent; }
.btn-accent:hover { background: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 9px; font-size: 13px; border-radius: 8px; }
.btn-danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: inherit; font-weight: 700; }
.icon-btn.sm { width: 26px; height: 26px; background: transparent; font-size: 18px; color: var(--ink-2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
h2 { font-size: 18px; margin: 4px 0 10px; }
.muted { color: var(--ink-2); font-size: 13px; }
.small { font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.pill.warn { background: var(--tint-warn); color: var(--warn); }
.pill.bad { background: var(--tint-bad); color: var(--bad); }
.pill.blue { background: var(--tint-blue); color: var(--water); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 13px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent); font-weight: 600; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field input:not([type=checkbox]):not([type=range]), .field select, .field textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); background: var(--field); color: var(--ink); border-radius: 8px; background: #fff; }
.field textarea { min-height: 80px; resize: vertical; }
.empty { text-align: center; color: var(--ink-2); padding: 18px 8px; }
.list-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item .t { font-weight: 600; }
.list-item:hover .t { color: var(--accent-2); }
.stars { color: #d97706; letter-spacing: 1px; }
.back { margin-bottom: 8px; }

/* planner */
.wp-list { list-style: none; margin: 0 0 8px; padding: 0; }
.wp { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.wp .n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-2); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.wp.start .n { background: #16a34a; } .wp.end .n { background: #b91c1c; }
.wp .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.wp .leg { font-size: 12px; color: var(--ink-2); }
.wp button { border: 0; background: none; color: var(--ink-2); padding: 2px 5px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 11px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; }
.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); margin: 6px 0 8px; }
.bar > div { height: 100%; }
.legend-rows { display: grid; grid-template-columns: auto 1fr auto auto; gap: 3px 8px; font-size: 13px; align-items: center; }
.legend-rows .r { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 6px 0; }
.progress > div { height: 100%; background: var(--accent-2); transition: width .2s; }
.gap-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.gap-row:last-child { border-bottom: 0; }
.gap-row .km { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.gap-row .gap { font-weight: 600; font-variant-numeric: tabular-nums; }
.gap-row .gap.long { color: var(--bad); }
.day { border-left: 3px solid var(--accent-2); padding: 6px 10px; margin: 8px 0; background: var(--card); border-radius: 0 8px 8px 0; cursor: pointer; }
.day.missing { border-left-color: var(--warn); }
.day b { display: block; }
.range-row { display: flex; gap: 10px; align-items: center; }
.range-row input[type=range] { flex: 1; accent-color: var(--accent-2); }

/* checklist (tri-state) */
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tri { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; background: var(--card); text-align: left; font-size: 13px; }
.tri .box { width: 18px; height: 18px; border-radius: 4px; border: 2px solid #b8b5a8; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none; color: #fff; }
.tri[data-v="yes"] { border-color: var(--accent-2); background: var(--accent-soft); }
.tri[data-v="yes"] .box { background: var(--accent-2); border-color: var(--accent-2); }
.tri[data-v="no"] { border-color: #fca5a5; background: var(--tint-bad); }
.tri[data-v="no"] .box { background: var(--bad); border-color: var(--bad); }
.agg { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; font-size: 13px; }
.agg .y { color: var(--accent-2); font-weight: 600; } .agg .n { color: var(--bad); font-weight: 600; } .agg .u { color: var(--ink-2); }
.star-input { display: inline-flex; gap: 2px; font-size: 24px; }
.star-input button { border: 0; background: none; color: #d6d3c4; padding: 0 1px; line-height: 1; }
.star-input button.on { color: #d97706; }
.review { border-top: 1px solid var(--line); padding: 10px 0; }
.review .meta { font-size: 12px; color: var(--ink-2); }
.review p { margin: 6px 0 0; white-space: pre-wrap; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 13px; }
.facts dt { color: var(--ink-2); } .facts dd { margin: 0; }

/* map controls */
.map-controls { position: absolute; top: 12px; right: 12px; z-index: 900; display: flex; flex-direction: column; gap: 8px; }
.map-btn { width: 42px; height: 42px; border-radius: 10px; border: 0; background: var(--card); box-shadow: var(--shadow); font-size: 22px; font-weight: 600; display: grid; place-items: center; }
.map-btn svg { width: 22px; height: 22px; fill: var(--ink); }
.layers-menu { position: absolute; top: 12px; right: 64px; z-index: 950; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; width: 280px; max-height: calc(100% - 24px); overflow: auto; font-size: 14px; }
.layers-menu h4 { margin: 8px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-2); }
.layers-menu label { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.layers-menu input { accent-color: var(--accent-2); }
.map-chips { position: absolute; top: 12px; left: 12px; right: 66px; z-index: 900; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 3px 3px 6px; }
.map-chips::-webkit-scrollbar { display: none; }
.map-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 7px 12px; background: var(--glass); color: var(--ink); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; color: var(--ink-2); }
.map-chip i { width: 10px; height: 10px; border-radius: 50%; opacity: .35; }
.map-chip.on { background: var(--card); color: var(--ink); outline: 2px solid var(--accent-2); }
.map-chip.on i { opacity: 1; }
.map-status.clickable { cursor: pointer; background: var(--accent); }
.map-status { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 900; background: rgba(28,35,33,.88); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; }
.leaflet-container { font: inherit; }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; min-width: 200px; }
.leaflet-popup-content h4 { margin: 0 0 4px; font-size: 15px; }
.leaflet-popup-content .row { margin-top: 8px; }

/* markers */
.poi-icon { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); position: relative; }
.poi-icon svg { width: 15px; height: 15px; fill: #fff; }
.poi-icon.camp { background: var(--camp); } .poi-icon.water { background: var(--water); width: 22px; height: 22px; }
.poi-icon.shelter { background: var(--shelter); } .poi-icon.bike { background: var(--bike); width: 22px; height: 22px; }
.poi-icon.community { outline: 2px solid var(--community); }
.poi-icon.broken { background: #9ca3af; }
.poi-icon.great { box-shadow: 0 0 0 3px #facc15, 0 1px 4px rgba(0,0,0,.35); }
.poi-icon .badge { position: absolute; top: -8px; right: -10px; background: #111827; color: #facc15; font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 6px; white-space: nowrap; }
.cluster { border-radius: 50%; color: #fff; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.35); font-size: 12px; }
.wp-icon { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-2); color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.4); }
.wp-icon.start { background: #16a34a; } .wp-icon.end { background: #b91c1c; }
.wp-icon.shaping { width: 12px; height: 12px; background: #fff; border: 3px solid var(--accent-2); }
.route-start { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--community); border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.4); display: grid; place-items: center; }
.route-start svg { transform: rotate(45deg); width: 16px; height: 16px; fill: #fff; }
.day-icon { background: #111827; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* elevation profile */
.profile-strip { position: absolute; left: 12px; right: 66px; bottom: 12px; height: 190px; z-index: 850; background: var(--glass); backdrop-filter: blur(8px); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; padding: 6px 8px 4px; }
.profile-head { display: flex; align-items: center; gap: 10px; }
.profile-strip canvas { flex: 1; width: 100%; min-height: 0; touch-action: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.seg button { border: 0; background: var(--card); padding: 4px 9px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--accent-2); color: #fff; }
.legend { display: flex; gap: 10px; flex-wrap: nowrap; overflow-x: auto; font-size: 11px; color: var(--ink-2); flex: 1; scrollbar-width: none; }
.legend span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.profile-open { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 850; border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 13px; }

/* dialog */
dialog { border: 0; border-radius: 18px; padding: 0; background: var(--card); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 20, 15, .45); }
dialog form { padding: 18px; overflow: auto; max-height: calc(100vh - 40px); }
dialog h2 { margin-top: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; position: sticky; bottom: -18px; background: var(--card); padding: 10px 0; }
.toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(120px); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 3000; transition: transform .25s; max-width: calc(100vw - 32px); font-size: 14px; }
.toast.show { transform: translateX(-50%) translateY(0); }

/* mobile: bottom sheet */
@media (max-width: 760px) {
  :root { --top-h: 52px; }
  .brand span { display: none; }
  .layout { display: block; }
  .map-wrap { position: absolute; inset: 0; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; border-right: 0; border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,.15); transition: height .25s ease; height: 50%;
  }
  .panel[data-sheet="peek"] { height: 96px; }
  .panel[data-sheet="full"] { height: calc(100% - 8px); }
  .sheet-handle { display: grid; place-items: center; height: 18px; cursor: grab; touch-action: none; }
  .sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); }
  .map-controls { top: 10px; right: 10px; }
  .map-chips { top: 10px; left: 8px; right: 58px; }
  .map-chip { padding: 7px 10px; font-size: 12px; }
  .map-btn { width: 40px; height: 40px; }
  .layers-menu { right: 58px; top: 10px; width: calc(100vw - 72px); max-height: 60vh; }
  .profile-strip { left: 6px; right: 6px; height: 160px; bottom: calc(50% + 8px); }
  .panel[data-sheet="peek"] ~ .map-wrap .profile-strip { bottom: 104px; }
  .panel[data-sheet="full"] ~ .map-wrap .profile-strip { display: none; }
  .profile-open { bottom: calc(50% + 10px); }
  .panel[data-sheet="peek"] ~ .map-wrap .profile-open { bottom: 106px; }
  .edit-bar { top: 54px; left: 8px; right: 8px; transform: none; flex-wrap: wrap; }
  .nav-bar { left: 6px; right: 6px; top: 6px; width: auto; }
  .profile-head .legend { display: none; }
  .checklist { grid-template-columns: 1fr; }
  .stat b { font-size: 16px; }
}

/* ── v3 additions ─────────────────────────────────────────────── */
.poi-icon.stay { background: var(--stay, #be185d); } .poi-icon.shop { background: #ca8a04; } .poi-icon.station { background: #475569; }
.poi-icon.hazard { background: #dc2626; border-radius: 6px; } .poi-icon.journal { background: #0f766e; }
.poi-icon svg { width: 60%; height: 60%; }
.map-btn.edit-btn.on { background: var(--accent-2); }
.map-btn.edit-btn.on svg { fill: #fff; }
body.editing #map { cursor: crosshair; }
.edit-toggle { width: 100%; justify-content: center; margin: 4px 0 12px; padding: 10px; }
.edit-bar { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 910; background: var(--card); border: 2px solid var(--accent-2); box-shadow: var(--shadow);
  border-radius: 14px; padding: 8px 10px 8px 14px; display: flex; gap: 10px; align-items: center; font-size: 13px; max-width: calc(100% - 90px); }
.nav-bar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 80px)); z-index: 1200; background: #111827; color: #fff; border-radius: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.35); padding: 10px 12px; }
.nav-main { display: flex; align-items: center; gap: 12px; }
.nav-main.off { color: #fca5a5; }
.nav-arrow { width: 54px; height: 54px; border-radius: 12px; background: var(--accent-2); display: grid; place-items: center; flex: none; font-size: 28px; }
.nav-main.off .nav-arrow { background: #7f1d1d; }
.nav-arrow svg { width: 38px; height: 38px; fill: #fff; transition: transform .2s; }
.nav-text b { display: block; font-size: 26px; line-height: 1.1; }
.nav-text span { font-size: 15px; }
.nav-sub { font-size: 13px; color: #cbd5e1; margin: 6px 0; }
.nav-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btns .btn { background: #1f2937; color: #fff; border-color: #374151; }
.nav-btns .btn-accent { background: var(--accent-2); }
.nav-me { width: 22px; height: 22px; border-radius: 50%; background: #2563eb; border: 4px solid #fff; box-shadow: 0 0 0 6px rgba(37,99,235,.25), 0 1px 6px rgba(0,0,0,.4); }
.turn-ico { display: inline-grid; width: 18px; height: 18px; background: var(--accent-2); border-radius: 4px; vertical-align: middle; place-items: center; }
.turn-ico svg { width: 13px; height: 13px; fill: #fff; }
.photos { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.photos img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; cursor: zoom-in; border: 1px solid var(--line); }
.leaflet-popup-content .photos img { width: 60px; height: 60px; }
.warn-card { border-color: #fca5a5; background: var(--tint-bad); }
.wx { font-size: 12px; margin-top: 4px; }
.wind.bad { color: var(--bad); font-weight: 700; } .wind.warn { color: var(--warn); font-weight: 600; } .wind.good { color: var(--accent-2); font-weight: 700; }
.map-status.clickable { cursor: pointer; }
.print-view { display: none; }
@media print {
  body.printing { overflow: visible !important; height: auto !important; background: #fff; }
  body.printing > *:not(.print-view) { display: none !important; }
  body.printing .print-view { display: block; font: 11pt/1.4 system-ui, sans-serif; color: #111; }
  .ppage { page-break-after: always; }
  .ppage h1 { font-size: 20pt; margin: 0 0 4px; } .ppage h2 { font-size: 15pt; margin: 0 0 4px; } .ppage h3 { font-size: 11pt; margin: 12px 0 4px; }
  .pmeta { margin: 2px 0 8px; } .pwarn { color: #b91c1c; font-weight: 600; }
  .pprofile { width: 100%; border: 1px solid #ddd; } .pprofile.small { width: 56%; } .psketch { width: 42%; border: 1px solid #ddd; }
  .prow { display: flex; gap: 2%; align-items: flex-start; margin: 6px 0; }
  .pbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; } .pbar div { height: 100%; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .plegend { font-size: 9pt; display: flex; gap: 10px; flex-wrap: wrap; } .plegend i { display: inline-block; width: 8px; height: 8px; margin-right: 3px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ptable { width: 100%; border-collapse: collapse; font-size: 9.5pt; margin-top: 6px; } .ptable th, .ptable td { border-bottom: 1px solid #ddd; padding: 3px 5px; text-align: left; vertical-align: top; }
  .ptable.cues { font-size: 8.5pt; } .pfoot { font-size: 8pt; color: #666; }
}
body.navigating .map-chips, body.navigating #mapStatus, body.navigating #editBar { display: none !important; }

/* ── v4: route preferences, trip logs, import ─────────────────── */
.prefs summary { cursor: pointer; list-style: none; }
.prefs summary::-webkit-details-marker { display: none; }
.prefs summary::before { content: '⚙️ '; }
.pref-row { margin: 10px 0; }
.pref-row > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.seg.wrap { display: flex; flex-wrap: wrap; border: 0; gap: 4px; overflow: visible; }
.seg.wrap button { border: 1px solid var(--line); border-radius: 8px; }
.imp-list { max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.imp-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.imp-row:last-child { border-bottom: 0; }
.imp-row input { margin-top: 4px; accent-color: var(--accent-2); }
.imp-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
.stop-card { padding: 10px; }
.stop-card.flash { outline: 3px solid #facc15; }
.stop-ico { font-size: 20px; width: 30px; text-align: center; cursor: pointer; flex: none; }
.stop-input { width: 100%; margin-top: 6px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; }
.small-stars { font-size: 18px; }
.stop-marker { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid #ea580c; display: grid; place-items: center; font-size: 15px; box-shadow: 0 1px 5px rgba(0,0,0,.35); position: relative; }
.stop-marker.slept { border-color: #15803d; } .stop-marker.ate, .stop-marker.coffee { border-color: #ca8a04; } .stop-marker.water { border-color: #0284c7; }
.stop-marker b { position: absolute; top: -7px; right: -7px; background: #111827; color: #fff; font-size: 9px; border-radius: 6px; padding: 0 4px; }
.log-start { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: #ea580c; border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.4); display: grid; place-items: center; font-size: 14px; }
.log-start.small-ico { transform: none; border-radius: 50%; width: 26px; height: 26px; flex: none; }
.day-block { border-left: 3px solid #ea580c; padding-left: 10px; margin: 10px 0 14px; }
.day-head { font-weight: 700; margin-bottom: 4px; }
.tl-stop { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.tl-stop:last-child { border-bottom: 0; }
.wx-day { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.wx-day:last-of-type { border-bottom: 0; }

/* touring styles & re-plan */
.style-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 10px; }
.style-chip { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 4px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1.2; }
.style-chip span { font-size: 20px; }
.style-chip.on { border-color: var(--accent-2); background: var(--accent-soft); color: var(--accent); }
.replan-card { border-color: #93c5fd; background: var(--tint-blue); }
.daily-row { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.daily-row:last-child { border-bottom: 0; }
.conditions { color: var(--ink-2); margin: 2px 0 4px; }

/* logistics */
.warn-text { color: var(--warn); }
.day-extras { margin-top: 3px; }
.wild { font-size: 13px; padding: 5px 0 5px 10px; border-left: 4px solid #d6d3c4; margin: 4px 0; }
.wild.yes { border-color: #16a34a; } .wild.partly { border-color: #f59e0b; } .wild.no { border-color: #dc2626; }
.cost-in { width: 64px; padding: 4px 6px; }
.poi-icon.ferry { background: #0e7490; } .poi-icon.charge { background: #65a30d; }

/* route finder */
.sg-big { width: 100%; justify-content: center; flex-direction: column; padding: 12px; margin: 8px 0 12px; font-size: 15px; }
.sg-big .small { font-weight: 400; opacity: .9; }
.sg-form .row { gap: 6px; }
.sg-form .chip input { display: none; }
.sg-why { margin: 6px 0; padding-left: 18px; font-size: 13px; }
.sg-why li { margin: 2px 0; }

/* group trips */
.poll { margin: 10px 0; }
.poll-opt { position: relative; display: flex; justify-content: space-between; width: 100%; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 7px 10px; margin-top: 5px; overflow: hidden; text-align: left; font-size: 13px; }
.poll-opt.on { border-color: var(--accent-2); font-weight: 700; }
.poll-opt .bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); z-index: 0; }
.poll-opt .po-l, .poll-opt .po-r { position: relative; z-index: 1; } .poll-opt .po-r { color: var(--ink-2); font-size: 12px; }
.booking { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.chat { max-height: 300px; overflow: auto; }
.msg { padding: 6px 8px; border-radius: 8px; background: var(--subtle); margin: 4px 0; font-size: 13px; }
.msg.me { background: var(--accent-soft); }
.poi-icon.airport { background: #1d4ed8; }
.sg-hubs { background: var(--subtle); border-radius: 8px; padding: 6px 8px; margin: 6px 0; line-height: 1.5; }
.sg-near[hidden] { display: none; }

/* accounts, money, gear */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.stats-grid .stat b { font-size: 15px; }
@media (max-width: 420px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-2); color: #fff; font-weight: 700; }
#btnAccount.icon-btn { padding: 0; background: none; border: 0; }
.bal-row, .mn-entry, .gear-item, .pop-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bal-row .bar, .bar-row .bar, .cmp-cat .bar { height: 6px; margin: 4px 0 0; }
.bal-row .bar > div, .bar-row .bar > div, .cmp-cat .bar > div { background: var(--accent-2); }
.bal { font-weight: 700; white-space: nowrap; font-size: 14px; }
.bal.pos { color: #15803d; } .bal.neg { color: #b91c1c; }
.right { text-align: right; white-space: nowrap; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 40%) 1fr auto; gap: 8px; align-items: center; font-size: 13px; margin: 4px 0; }
.bar-row .bar { margin: 0; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--subtle); margin-left: 4px; }
.tag.good { background: var(--tint-good); } .tag.bad { background: var(--tint-bad); }
.gear-edit { border-bottom: 1px dashed var(--line); padding: 8px 0; }
.gear-edit input, .gear-edit select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; min-width: 0; }
.gear-edit .row { gap: 6px; margin-bottom: 4px; align-items: center; }
.gear-edit .w-g { width: 72px; } .gear-edit .w-q { width: 52px; }
.cmp { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.cmp td, .cmp th { padding: 5px; border-bottom: 1px solid var(--line); text-align: left; }
.cmp-head { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.cmp-cat { display: grid; grid-template-columns: minmax(100px, 35%) 1fr; gap: 2px 8px; align-items: center; font-size: 13px; margin: 6px 0; }
.cmp-cat > span:first-child { grid-row: span 2; } .cmp-cat > span:last-child { grid-column: 2; color: var(--ink-2); }
.cmp-cat .bar.b > div { background: #ea580c; } .cmp-cat .bar.a > div { background: #2563eb; }
.good-text { color: #15803d; } .bad-text { color: #b91c1c; }
.tabs button { min-width: 0; padding-left: 2px; padding-right: 2px; }

/* ── Theme & polish (v8) ── */
body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
select.btn, input.btn, textarea { background-color: var(--field); color: var(--ink); }
.card { box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.list-item:hover { background: var(--hover); }
.tabs { gap: 2px; padding: 0 4px; }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12.5px; padding: 9px 2px 8px; }
.tabs button svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.top-actions .icon-btn { display: grid; place-items: center; }
.top-actions .icon-btn svg { width: 19px; height: 19px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 8px 0; line-height: 1.4; }
.check input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent-2); flex: none; }
.announce { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); z-index: 905; width: min(560px, calc(100% - 24px)); display: flex; gap: 10px; align-items: center;
  background: var(--card); color: var(--ink); border-left: 4px solid var(--accent-2); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px; font-size: 14px; }
.announce .grow { flex: 1; } .announce button { border: 0; background: none; color: var(--ink-2); font-size: 18px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-2); }
.leaflet-control-attribution { background: var(--glass) !important; color: var(--ink-2); }
.leaflet-control-attribution a { color: var(--ink-2); }
:root[data-theme="dark"] .map-btn { background: var(--card); color: var(--ink); }
:root[data-theme="dark"] .map-btn svg { fill: var(--ink); }
:root[data-theme="dark"] .stop-marker, :root[data-theme="dark"] .wp-icon.shaping { background: var(--card); }
:root[data-theme="dark"] .poi-icon { border-color: #e7ece9; }
:root[data-theme="dark"] a { color: #4ade80; }
:root[data-theme="dark"] .bal.pos, :root[data-theme="dark"] .good-text { color: #4ade80; } :root[data-theme="dark"] .bal.neg, :root[data-theme="dark"] .bad-text { color: #f87171; }
:root[data-theme="dark"] .tri[data-v="yes"] { background: var(--tint-good); }
.view-opts .opt { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.view-opts .opt > div:first-child { flex: 1; } .view-opts .opt small { display: block; color: var(--ink-2); }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 13px; transition: background .15s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent-2); } .switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid rgba(34,163,90,.45); }
:root[data-theme="dark"] .chip.on, :root[data-theme="dark"] .tabs button.active { color: #86efac; }
.seg.big button { padding: 7px 11px; font-size: 13px; }
body.no-chips #mapChips { display: none; }
@media (max-width: 520px) {
  .topbar { gap: 8px; padding-left: 8px; padding-right: 8px; }
  .top-actions { gap: 6px; }
  #btnAccount.btn { padding: 0; width: 34px; height: 34px; border-radius: 50%; justify-content: center; font-size: 0; }
  #btnAccount.btn::before { content: ''; width: 18px; height: 18px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E") center / contain no-repeat; }
  .search input { padding-left: 36px; background-position: 11px center; }
}
:root[data-theme="dark"] .brand, :root[data-theme="dark"] .top a { color: #fff; }
