/* =========================================================
   Delta Navigator — design tokens
   ========================================================= */
:root {
  --bg: #F3F5F7;
  --bg-2: #E9EDF1;
  --surface: #FFFFFF;
  --surface-2: #F7F9FA;
  --text: #0B1A28;
  --text-2: #3C4C5C;
  --muted: #7A8796;
  --line: rgba(11, 26, 40, .08);
  --line-2: rgba(11, 26, 40, .14);
  --accent: #0A6E9E;
  --accent-2: #0E8BC4;
  --accent-soft: rgba(10, 110, 158, .10);
  --signal: #F25F2C;
  --signal-soft: rgba(242, 95, 44, .12);
  --ok: #15966B;
  --warn: #D9901A;
  --danger: #D23C3C;
  --glass: rgba(255, 255, 255, .82);
  --glass-line: rgba(255, 255, 255, .9);
  --shadow-1: 0 1px 2px rgba(11, 26, 40, .05), 0 4px 16px rgba(11, 26, 40, .06);
  --shadow-2: 0 2px 6px rgba(11, 26, 40, .06), 0 18px 48px rgba(11, 26, 40, .12);
  --rose-tick: #8794A2;
  --rose-major: #0B1A28;
  --radius: 22px;
  --radius-s: 14px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060B11; --bg-2: #0A121B; --surface: #0E1823; --surface-2: #121E2B;
    --text: #E9EFF5; --text-2: #B5C1CD; --muted: #6F7F90;
    --line: rgba(233, 239, 245, .07); --line-2: rgba(233, 239, 245, .13);
    --accent: #47B8F0; --accent-2: #6FCBF7; --accent-soft: rgba(71, 184, 240, .13);
    --signal: #FF7A45; --signal-soft: rgba(255, 122, 69, .15);
    --ok: #34C38F; --warn: #F0B24A; --danger: #FF5F5F;
    --glass: rgba(10, 18, 27, .78); --glass-line: rgba(233, 239, 245, .08);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, .35), 0 24px 60px rgba(0, 0, 0, .45);
    --rose-tick: #4E5E6F; --rose-major: #E9EFF5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #060B11; --bg-2: #0A121B; --surface: #0E1823; --surface-2: #121E2B;
  --text: #E9EFF5; --text-2: #B5C1CD; --muted: #6F7F90;
  --line: rgba(233, 239, 245, .07); --line-2: rgba(233, 239, 245, .13);
  --accent: #47B8F0; --accent-2: #6FCBF7; --accent-soft: rgba(71, 184, 240, .13);
  --signal: #FF7A45; --signal-soft: rgba(255, 122, 69, .15);
  --ok: #34C38F; --warn: #F0B24A; --danger: #FF5F5F;
  --glass: rgba(10, 18, 27, .78); --glass-line: rgba(233, 239, 245, .08);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .35), 0 24px 60px rgba(0, 0, 0, .45);
  --rose-tick: #4E5E6F; --rose-major: #E9EFF5;
  color-scheme: dark;
}

/* =========================================================
   Base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-feature-settings: "cv11", "ss01";
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-user-select: none; user-select: none; }
:where(svg:not(.leaflet-container svg)) { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.mono, .num, .stat-v, .hud-v b, .speed-num, .mode-num, .hd-num { font-variant-numeric: tabular-nums; }

#app { position: fixed; inset: 0; overflow: hidden; }
.view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(8px);
  transition: opacity .28s ease, transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s;
  background: var(--bg);
}
.view.is-active { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition-delay: 0s; }

/* =========================================================
   Common components
   ========================================================= */
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px;
  display: inline-grid; place-items: center;
  color: var(--text);
  transition: background .15s, transform .15s;
}
.icon-btn:active { transform: scale(.94); background: var(--line); }
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow-1);
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 13px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 500; color: var(--text-2);
  white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px transparent; }
.chip-gps.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.chip-gps.weak .dot { background: var(--warn); }
.chip-gps.err .dot { background: var(--danger); }
.chip-sync.on { color: var(--accent); }

.bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 12px) 8px calc(var(--sal) + 8px);
  flex: none;
}
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.bar-title > span { font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.bar-sub { color: var(--muted); font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-space { width: 44px; }

.rec-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 14px 0 11px; border-radius: 99px;
  font-size: 13.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text);
}
.rec-btn svg { width: 18px; height: 18px; color: var(--danger); }
.rec-btn.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.rec-btn.on svg { color: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--line);
}
.seg button {
  height: 32px; padding: 0 12px; border-radius: 9px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.seg-sm button { height: 28px; padding: 0 10px; font-size: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}

.btn {
  height: 50px; padding: 0 20px; border-radius: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px;
  transition: transform .12s, filter .12s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #04121C; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #04121C; } }
.btn-ghost { background: var(--bg-2); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.link-btn { color: var(--accent); font-size: 13px; font-weight: 500; padding: 8px 2px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 14px; border-radius: 99px;
  font-size: 13.5px; font-weight: 600;
  background: var(--bg-2); border: 1px solid var(--line);
}
.pill svg { width: 17px; height: 17px; }

.toggle { display: flex; align-items: center; gap: 12px; font-size: 14px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle > span {
  position: relative; width: 44px; height: 26px; border-radius: 99px; flex: none;
  background: var(--line-2); transition: background .2s;
}
.toggle > span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s cubic-bezier(.2, .8, .2, 1);
}
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(18px); }

.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%; border-radius: 13px; border: 1px solid var(--line-2);
  background: var(--surface); padding: 13px 14px; font-size: 16px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row .field { margin: 6px 0; }

/* =========================================================
   Home
   ========================================================= */
.view-home { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view-home::before {
  content: ""; position: fixed; inset: -20% -10% auto -10%; height: 70%; pointer-events: none;
  background:
    radial-gradient(60% 60% at 15% 10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(50% 50% at 90% 0%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 70%);
}
.home-wrap {
  position: relative;
  width: 100%; max-width: 980px; margin: 0 auto;
  padding: calc(var(--sat) + 20px) calc(var(--sar) + 20px) calc(var(--sab) + 24px) calc(var(--sal) + 20px);
  min-height: 100%;
  display: flex; flex-direction: column; gap: 18px;
}
.home-head { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 46px; height: 46px; stroke-width: 2.4; }
.bm-ring { stroke: var(--line-2); fill: var(--surface); stroke-width: 2; }
.bm-n { fill: var(--accent); stroke: none; }
.bm-s { fill: var(--text); stroke: none; opacity: .9; }
.bm-wave { stroke: var(--surface); stroke-width: 3; }
.brand-name { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.025em; line-height: 1.1; }
.brand-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); font-weight: 500; letter-spacing: .01em; }

.status-row { flex: none; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px; }
.status-row::-webkit-scrollbar { display: none; }
.status-row .chip { flex: none; }

.modes { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 680px) {
  .home-wrap { gap: 22px; }
  .modes { grid-template-columns: 1fr 1fr; flex: 1; max-height: 560px; min-height: 340px; }
  .mode-card { padding: 26px; }
  .mode-num { font-size: 104px; }
  .mode-text h2 { font-size: 26px; }
}
.mode-card {
  position: relative; overflow: hidden; text-align: left;
  min-height: 228px; padding: 20px;
  border-radius: 28px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s;
}
.mode-card:active { transform: scale(.985); }
@media (hover: hover) { .mode-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); } }
.mode-top { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.mode-ico {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.mode-arrow { color: var(--muted); width: 20px; height: 20px; }
.mode-text { position: relative; z-index: 1; }
.mode-text h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.025em; }
.mode-text p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.mode-live { display: flex; align-items: baseline; gap: 6px; }
.mode-num { font-size: 64px; font-weight: 200; letter-spacing: -.045em; line-height: .9; }
.mode-unit { font-size: 16px; color: var(--muted); font-weight: 500; }
.mode-nav { background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%); }
.mode-chart { position: absolute; left: 0; right: 0; top: 16%; width: 100%; height: 52%; stroke-width: 1; }
.mc-river { stroke: var(--accent); stroke-opacity: .16; stroke-width: 18; }
.mc-river-b { stroke-opacity: .08; stroke-width: 30; }
.mc-route { stroke: var(--signal); stroke-width: 2.4; stroke-dasharray: 6 6; }
.mc-wp { fill: var(--surface); stroke: var(--signal); stroke-width: 2.4; }
.mc-wp-end { fill: var(--signal); }

.wx-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.wx-item { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); min-width: 0; }
.wx-item:first-child { border-left: 0; }
.wx-k { font-size: 11.5px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.wx-v { font-size: 17px; font-weight: 550; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick button {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 6px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 550; color: var(--text-2);
  transition: transform .15s;
}
.quick button:active { transform: scale(.96); }
.quick svg { color: var(--accent); }
.home-foot { margin: auto 0 0; padding-top: 6px; text-align: center; font-size: 11.5px; color: var(--muted); }

/* =========================================================
   Speed
   ========================================================= */
.view-speed { overflow-y: auto; }
.speed-layout {
  flex: 1; width: 100%; max-width: 1100px; margin: 0 auto;
  display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr);
  padding: 4px calc(var(--sar) + 18px) calc(var(--sab) + 24px) calc(var(--sal) + 18px);
}
.speed-main, .speed-side { min-width: 0; }
.speed-main { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.speed-readout { display: flex; flex-direction: column; align-items: center; padding: 6px 0 0; }
.speed-num {
  font-size: clamp(96px, 34vw, 200px); font-weight: 200; letter-spacing: -.06em; line-height: .88;
}
.speed-unit { margin-top: 6px; font-size: 13px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
.speed-alt { margin-top: 10px; font-size: 18px; color: var(--muted); }
.speed-alt b { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }

.compass-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 8px; width: 100%; }
.compass { position: relative; width: min(78vw, 330px); aspect-ratio: 1; }
.compass-rose { width: 100%; height: 100%; transition: transform .35s cubic-bezier(.2, .8, .2, 1); stroke-width: 1; }
.compass-rose .tk { stroke: var(--rose-tick); }
.compass-rose .tk-major { stroke: var(--rose-major); stroke-width: 1.6; }
.compass-rose .lbl { fill: var(--muted); stroke: none; font: 500 13px var(--font); }
.compass-rose .lbl-card { fill: var(--rose-major); font-weight: 650; font-size: 17px; }
.compass-rose .lbl-n { fill: var(--signal); }
.compass-rose .ring { stroke: var(--line-2); fill: var(--surface); }
.compass-lubber {
  position: absolute; left: 50%; top: -2px; width: 0; height: 0; transform: translateX(-50%);
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 14px solid var(--signal);
}
.compass-center {
  position: absolute; inset: 30%; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--line);
}
.hd-num { font-size: clamp(30px, 9vw, 44px); font-weight: 300; letter-spacing: -.03em; line-height: 1; }
.hd-num::after { content: "°"; color: var(--muted); font-weight: 300; }
.hd-num.empty::after { content: ""; }
.hd-card { font-size: 12px; font-weight: 650; letter-spacing: .16em; color: var(--accent); margin-top: 4px; }
.hd-note { margin: 0; font-size: 12px; color: var(--muted); text-align: center; max-width: 320px; min-height: 1em; }

.speed-side { display: flex; flex-direction: column; gap: 14px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; display: flex; flex-direction: column;
}
.stat-k { font-size: 11.5px; color: var(--muted); font-weight: 550; text-transform: uppercase; letter-spacing: .06em; }
.stat-v { font-size: 28px; font-weight: 350; letter-spacing: -.03em; margin-top: 4px; line-height: 1.1; }
.stat-u { font-size: 12px; color: var(--muted); font-weight: 500; }
.speed-side .link-btn { align-self: flex-start; margin-top: -6px; }

.pos-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
.pos-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pos-row .mono { font-size: 16px; font-weight: 500; letter-spacing: -.01em; }

.wx-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.wx-temp { display: block; font-size: 42px; font-weight: 250; letter-spacing: -.04em; line-height: 1; }
.wx-desc { display: block; margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.wind-dial svg { width: 60px; height: 60px; }
.wind-dial circle { stroke: var(--line-2); fill: var(--bg); }
.wind-arrow { fill: var(--accent); stroke: none; transform-origin: 30px 30px; transition: transform .6s; }
.wx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
.wx-grid div { display: flex; flex-direction: column; gap: 2px; }
.wx-grid b { font-weight: 550; font-size: 15.5px; }
.wx-hours { display: flex; gap: 6px; overflow-x: auto; margin: 16px -4px 0; padding: 0 4px 2px; scrollbar-width: none; }
.wx-hours::-webkit-scrollbar { display: none; }
.wx-h {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 58px; padding: 9px 6px; border-radius: 13px; background: var(--bg-2);
  font-size: 12px; color: var(--muted);
}
.wx-h b { font-size: 14px; color: var(--text); font-weight: 550; }
.wx-h .w { font-size: 11.5px; }

@media (min-width: 860px) {
  .speed-layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; gap: 36px; }
  .speed-num { font-size: clamp(120px, 15vw, 220px); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .speed-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .speed-num { font-size: 26vh; }
  .compass { width: 46vh; }
}

/* =========================================================
   Navigation (map)
   ========================================================= */
.view-nav { background: var(--bg-2); }
#map { position: absolute; inset: 0; background: var(--bg-2); }
.nav-top {
  position: absolute; z-index: 500; left: 0; right: 0; top: 0;
  display: flex; align-items: flex-start; gap: 8px;
  padding: calc(var(--sat) + 10px) calc(var(--sar) + 10px) 0 calc(var(--sal) + 10px);
  pointer-events: none;
}
.nav-top > * { pointer-events: auto; }
.nav-top .icon-btn { flex: none; border-radius: 15px; }
.nav-top .rec-btn { flex: none; height: 44px; }
.nav-top .rec-btn span { display: none; }
.nav-top .rec-btn { width: 44px; padding: 0; justify-content: center; }
.hud {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: repeat(2, 1fr);
  border-radius: 18px; overflow: hidden;
}
.hud.has-route { grid-template-columns: repeat(3, 1fr); }
.hud-cell { padding: 8px 12px; display: flex; flex-direction: column; min-width: 0; border-left: 1px solid var(--line); }
.hud-cell:nth-child(1) { border-left: 0; }
.hud.has-route .hud-cell:nth-child(4) { border-left: 0; }
.hud.has-route .hud-cell:nth-child(n+4) { border-top: 1px solid var(--line); }
.hud-k { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-v { display: flex; align-items: baseline; gap: 3px; white-space: nowrap; }
.hud-v b { font-size: 22px; font-weight: 450; letter-spacing: -.03em; }
.hud-v small { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.hud-route { display: none; }
.hud.has-route .hud-route { display: flex; }
.hud-xte.warn b { color: var(--signal); }
@media (min-width: 760px) {
  .hud, .hud.has-route { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; max-width: 820px; margin: 0 auto; }
  .hud.has-route .hud-cell:nth-child(4) { border-left: 1px solid var(--line); }
  .hud.has-route .hud-cell:nth-child(n+4) { border-top: 0; }
  .hud-v b { font-size: 26px; }
  .nav-top .rec-btn { width: auto; padding: 0 14px 0 11px; }
  .nav-top .rec-btn span { display: inline; }
}

.map-tools {
  position: absolute; z-index: 500; right: calc(var(--sar) + 10px); top: calc(var(--sat) + 140px);
  display: flex; flex-direction: column; gap: 8px;
}
@media (min-width: 760px) { .map-tools { top: calc(var(--sat) + 84px); } }
.map-tools .icon-btn { border-radius: 14px; }
#btn-follow.on { color: var(--accent); }

.layer-pop {
  position: absolute; z-index: 600; right: calc(var(--sar) + 62px); top: calc(var(--sat) + 140px);
  width: 270px; padding: 14px; border-radius: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
@media (min-width: 760px) { .layer-pop { top: calc(var(--sat) + 84px); } }
.pop-title { margin: 0; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.layer-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layer-opts button { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 550; color: var(--text-2); }
.layer-opts .sw { width: 100%; aspect-ratio: 1.2; border-radius: 12px; border: 2px solid transparent; background-size: cover; }
.layer-opts button.on .sw { border-color: var(--accent); }
.layer-opts button.on { color: var(--accent); }
.sw-carta { background: linear-gradient(135deg, #E8ECEF 0 45%, #AFD3E6 45% 60%, #E8ECEF 60%); }
.sw-sat { background: linear-gradient(135deg, #3B4B2E 0 40%, #4F5B47 40% 55%, #6A6040 55%); }
.sw-osm { background: linear-gradient(135deg, #F2EFE9 0 30%, #AAD3DF 30% 50%, #CDEBB0 50% 75%, #F2EFE9 75%); }
.layer-pop .toggle { font-size: 13.5px; }

.nav-bottom {
  position: absolute; z-index: 500; left: 0; right: 0; bottom: calc(var(--sab) + 16px);
  display: flex; justify-content: center; gap: 8px; pointer-events: none;
}
.nav-bottom .pill { pointer-events: auto; height: 46px; padding: 0 18px; font-size: 14.5px; }

/* boat marker */
.boat-icon { width: 44px; height: 44px; }
.boat-icon .b-rot { width: 44px; height: 44px; transition: transform .4s ease; }
.boat-icon svg { width: 44px; height: 44px; stroke: none; overflow: visible; }
.boat-icon .b-body { fill: var(--accent); stroke: #fff; stroke-width: 2.2; }
.boat-icon .b-halo { fill: var(--accent); opacity: .18; }
.wp-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--signal);
  border: 2.5px solid var(--signal);
  font: 700 12.5px var(--font);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.wp-icon.done { border-color: var(--muted); color: var(--muted); }
.wp-icon.next { background: var(--signal); color: #fff; transform: scale(1.12); }
.leaflet-container { font-family: var(--font); background: var(--bg-2); }
.leaflet-control-attribution {
  background: var(--glass) !important; color: var(--muted) !important; font-size: 9.5px !important;
  border-radius: 8px 0 0 0; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-control-scale { margin-left: calc(var(--sal) + 12px) !important; margin-bottom: calc(var(--sab) + 74px) !important; }
.leaflet-control-scale-line { background: var(--glass); border-color: var(--text-2); color: var(--text-2); font-size: 10px; }
.leaflet-tile-pane { transition: filter .3s; }
.view-nav:has(.sheet:not([hidden])) .leaflet-control-scale { display: none; }
.map-dark .tiles-osm, .map-dark .tiles-seamarks { filter: brightness(.82) contrast(1.05); }

/* sheet */
.sheet {
  position: absolute; z-index: 700; left: 0; right: 0; bottom: 0;
  max-height: 72%;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 26px 26px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
  padding: 0 calc(var(--sar) + 16px) calc(var(--sab) + 14px) calc(var(--sal) + 16px);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
@media (min-width: 760px) {
  .sheet { left: auto; right: calc(var(--sar) + 14px); bottom: calc(var(--sab) + 14px); width: 400px; max-height: calc(100% - var(--sat) - 110px); border-radius: 26px; }
}
.sheet.collapsed .sheet-body { display: none; }
.sheet-handle { display: grid; place-items: center; height: 22px; width: 100%; flex: none; }
.sheet-handle i { width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); }
.sheet-head { display: flex; gap: 8px; align-items: flex-start; flex: none; }
.sheet-titles { flex: 1; min-width: 0; }
.route-name {
  width: 100%; border: 0; outline: none; background: none;
  font-size: 19px; font-weight: 650; letter-spacing: -.02em; padding: 4px 0;
}
.route-name:read-only { pointer-events: none; }
.sheet-sub { margin: 0; font-size: 13px; color: var(--muted); }
.sheet-body { overflow-y: auto; flex: 1; min-height: 0; margin: 10px -4px 0; padding: 0 4px; }
.sheet-foot { display: flex; gap: 10px; flex: none; padding-top: 12px; }
.sheet-foot .btn { flex: 1; }

.wp-list { list-style: none; margin: 0; padding: 0; }
.wp-list li {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-top: 1px solid var(--line);
}
.wp-list li:first-child { border-top: 0; }
.wp-n {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  color: var(--signal); background: var(--signal-soft);
}
.wp-list li.next .wp-n { background: var(--signal); color: #fff; }
.wp-list li.done { opacity: .5; }
.wp-main { flex: 1; min-width: 0; }
.wp-main input { width: 100%; border: 0; background: none; outline: none; font-weight: 550; font-size: 14.5px; padding: 0; }
.wp-main .mono { display: block; font-size: 12px; color: var(--muted); }
.wp-leg { text-align: right; font-size: 12.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.wp-leg small { display: block; color: var(--muted); }
.wp-del { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.wp-del svg { width: 18px; height: 18px; }
.route-tools { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 0 2px; }
.route-tools .pill { height: 36px; font-size: 13px; }

/* =========================================================
   Pages (lists)
   ========================================================= */
.view-page .page {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 6px calc(var(--sar) + 18px) calc(var(--sab) + 30px) calc(var(--sal) + 18px);
}
.view-page .page-narrow { max-width: 560px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 14px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line);
  transition: transform .15s;
}
.item:active { transform: scale(.99); }
.item-thumb {
  width: 64px; height: 64px; border-radius: 15px; flex: none; overflow: hidden;
  background: var(--bg-2); display: grid; place-items: center; color: var(--accent);
}
.item-thumb svg.trk { width: 64px; height: 64px; stroke: var(--accent); stroke-width: 2.4; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item-meta { display: flex; gap: 12px; margin-top: 6px; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.item-meta b { font-weight: 600; }
.item-end { color: var(--muted); display: flex; gap: 4px; align-items: center; }
.item.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.badge { display: inline-block; font-size: 11px; font-weight: 650; padding: 3px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); letter-spacing: .02em; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; stroke-width: 1.3; color: var(--line-2); margin-bottom: 10px; }
.empty h4 { margin: 0 0 4px; color: var(--text); font-size: 16px; font-weight: 600; }
.empty p { margin: 0; font-size: 14px; }
.list-head { font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 14px 4px 2px; }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.totals:empty { display: none; }
.trip-map { height: 300px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 12px; }
#view-trip .stat-grid { margin-bottom: 8px; }
#view-trip .stat-v { font-size: 22px; }

.group { margin: 8px 0 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; }
.group-title { margin: 0 -16px; padding: 14px 16px 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); background: var(--bg); }
.group .group-title:first-child { margin-top: -5px; border-radius: var(--radius) var(--radius) 0 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-height: 56px; }
.group-title + .row { border-top: 0; }
.row > span { font-size: 14.5px; font-weight: 500; }
.row > span small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.fine { text-align: center; color: var(--muted); font-size: 12px; line-height: 1.6; }

.acct-hero { text-align: center; padding: 26px 0 10px; }
.acct-hero .mode-ico { margin: 0 auto 14px; width: 60px; height: 60px; border-radius: 20px; }
.acct-hero .mode-ico svg { width: 28px; height: 28px; }
.acct-hero h3 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -.02em; }
.acct-hero p { margin: 6px auto 0; color: var(--muted); max-width: 380px; font-size: 14.5px; }
.form-err { color: var(--danger); font-size: 13.5px; min-height: 1.3em; margin: 4px 2px 10px; }

/* =========================================================
   Modal + toast
   ========================================================= */
.modal {
  position: fixed; inset: 0; z-index: 2000;
  display: grid; place-items: center; padding: 20px;
  background: rgba(3, 8, 14, .45);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: fade .2s ease;
}
.modal-card {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 26px; padding: 22px;
  box-shadow: var(--shadow-2); animation: pop .25s cubic-bezier(.2, .8, .2, 1);
  max-height: 90vh; overflow-y: auto;
}
.modal-card h3 { margin: 0 0 4px; font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.modal-card p { color: var(--muted); margin: 6px 0 0; font-size: 14.5px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.toast {
  position: fixed; z-index: 3000; left: 50%; top: calc(var(--sat) + 76px);
  transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-2); transition: opacity .25s, transform .25s;
  max-width: calc(100% - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.alert { background: var(--signal); color: #fff; }

@media (max-width: 380px) {
  .wx-item { padding: 12px 9px; }
  .wx-v { font-size: 15px; }
  .quick button { font-size: 11.5px; }
  .mode-num { font-size: 54px; }
}
