:root {
  --brand: #0176d0;
  --brand-dark: #005ba3;
  --accent: #fb6a00;
  --ink: #0b2533;
  --ink-soft: #46606d;
  --paper: #ffffff;
  --paper-2: #f3f6f7;
  --line: #dde5e8;
  --ok: #15803d;
  --warn: #f59e0b;
  --danger: #dc2626;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --shadow: 0 6px 24px rgba(11, 37, 51, .18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--ink); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }

#map { position: fixed; inset: 0; bottom: calc(var(--tabbar-h) + var(--safe-b)); background: #123; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; z-index: 1000; left: 10px; right: 10px; top: calc(10px + var(--safe-t));
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(255, 255, 255, .96); border-radius: 16px; padding: 8px 10px 8px 12px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; border-radius: 10px; background: #fff url("assets/logo-mark.png") center/cover; box-shadow: inset 0 0 0 1px var(--line); }
.brand-name { font-weight: 750; font-size: 15px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.return-pill {
  display: flex; flex-direction: column; align-items: center; line-height: 1.05;
  background: var(--paper-2); border-radius: 10px; padding: 4px 8px; font-size: 11px; color: var(--ink-soft);
}
.return-pill strong { font-size: 15px; color: var(--ink); }
.return-pill.late { background: #fee2e2; }
.return-pill.late strong { color: var(--danger); }
#langSelect {
  appearance: none; -webkit-appearance: none; border: 1px solid var(--line); background: var(--paper);
  border-radius: 10px; padding: 8px 8px; font-weight: 700; font-size: 13px; color: var(--ink);
}

/* ---------- Demo badge ---------- */
.demo-badge {
  position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%);
  top: calc(72px + var(--safe-t)); display: flex; align-items: center; gap: 8px;
  background: rgba(11, 37, 51, .88); color: #fff; font-size: 12px; padding: 5px 6px 5px 12px; border-radius: 999px; white-space: nowrap;
}
.demo-badge button { border: 0; background: #ffb020; color: var(--ink); font-weight: 700; font-size: 12px; padding: 5px 10px; border-radius: 999px; }

/* ---------- Zone alert ---------- */
.zone-alert {
  position: fixed; z-index: 1001; left: 10px; right: 10px; top: calc(108px + var(--safe-t));
  border-radius: 14px; padding: 12px 14px; color: #fff; box-shadow: var(--shadow);
  background: var(--warn); color: #1f1300;
}
.zone-alert.danger { background: var(--danger); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.zone-alert-title { font-weight: 800; font-size: 16px; }
.zone-alert-text { font-size: 14px; margin-top: 2px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, .25); } }
@media (prefers-reduced-motion: reduce) { .zone-alert.danger { animation: none; } }

/* ---------- Map buttons ---------- */
.map-buttons { position: fixed; z-index: 999; right: 12px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); display: flex; flex-direction: column; gap: 10px; }
.round-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); display: grid; place-items: center; }
.round-btn.on { color: #fff; background: #1d8fe0; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; z-index: 1002; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--paper); border-top: 1px solid var(--line);
}
.tab[hidden] { display: none; }
.tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--brand); }
.tab-sos { color: var(--danger); }
.tab-sos.active { color: var(--danger); }

/* ---------- Bottom sheet ---------- */
.sheet {
  position: fixed; z-index: 1001; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b));
  max-height: 72vh; background: var(--paper); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(11, 37, 51, .25);
  transform: translateY(110%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column;
}
.sheet.open { transform: translateY(0); }
.sheet.compact { max-height: 40vh; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 4px; flex: none; }
.sheet-close { position: absolute; right: 10px; top: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--paper-2); font-size: 22px; line-height: 1; z-index: 2; }
.sheet-body { overflow-y: auto; padding: 4px 16px 18px; -webkit-overflow-scrolling: touch; }
.sheet h2 { margin: 6px 44px 4px 0; font-size: 20px; line-height: 1.2; }
.sheet h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.sheet p { margin: 6px 0; font-size: 15px; line-height: 1.45; }

.photo {
  margin: 0 -16px 12px; height: 190px; position: relative; overflow: hidden;
  background: linear-gradient(160deg, #1fa3b0 0%, #0e6f9a 55%, #0b3f5c 100%);
  display: flex; align-items: flex-end; justify-content: flex-start; color: rgba(255, 255, 255, .92);
}
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-ph { padding: 12px 16px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.photo-ph svg { width: 18px; height: 18px; }

.cat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.tag { background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.stat { background: var(--paper-2); border-radius: 12px; padding: 10px 12px; }
.stat small { display: block; font-size: 12px; color: var(--ink-soft); }
.stat strong { font-size: 18px; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.primary-btn, .ghost-btn, .danger-btn {
  border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 750; font-size: 15px; text-decoration: none; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 1 1 auto;
}
.primary-btn { background: var(--brand); color: #fff; }
.ghost-btn { background: var(--paper-2); color: var(--ink); border: 1px solid var(--line); }
.danger-btn { background: var(--danger); color: #fff; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list button { width: 100%; border: 0; background: none; text-align: left; padding: 12px 2px; display: flex; align-items: center; gap: 12px; }
.list .li-icon { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; color: #fff; }
.list .li-main { flex: 1; min-width: 0; }
.list .li-title { font-weight: 700; font-size: 15px; }
.list .li-sub { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .li-right { font-size: 13px; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.filter-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin: 4px -16px 4px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filter-row button { flex: none; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; }
.filter-row button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.route-swatch { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--ink); }
.route-swatch span { width: 22px; height: 4px; border-radius: 2px; }
.stops { counter-reset: s; list-style: none; padding: 0; margin: 8px 0; }
.stops li { counter-increment: s; display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 15px; }
.stops li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }

/* SOS */
.sos-big { display: grid; gap: 10px; margin-top: 8px; }
.sos-big a { padding: 16px; font-size: 17px; }
.equip { margin: 0; padding-left: 20px; }
.equip li { margin: 6px 0; font-size: 15px; line-height: 1.4; }
.contact { line-height: 1.7; }
.contact a { color: var(--brand); font-weight: 600; text-decoration: none; }
.made-by { display: block; text-align: center; margin-top: 12px; font-size: 12px; color: var(--ink-soft); opacity: .75; text-decoration: none; }
.made-by-row { margin: 20px 0 0; }
.coords { font-family: ui-monospace, Menlo, monospace; background: var(--paper-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 10px; }

/* ---------- Briefing modal ---------- */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(11, 37, 51, .7); display: flex; align-items: flex-end; justify-content: center; padding: 12px; padding-bottom: calc(12px + var(--safe-b)); }
.modal[hidden] { display: none; }
.modal-card { background: var(--paper); border-radius: 22px; padding: 20px 18px 18px; width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; }
.modal-kicker { font-size: 13px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .06em; }
.modal h1 { font-size: 24px; margin: 4px 0 10px; }
.lang-row { display: flex; gap: 6px; margin-bottom: 8px; }
.lang-row button { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 6px 12px; font-weight: 700; font-size: 13px; }
.lang-row button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.rules { padding-left: 22px; margin: 8px 0 12px; }
.rules li { margin: 10px 0; font-size: 15px; line-height: 1.4; }
.fine { font-size: 12px; color: var(--ink-soft); line-height: 1.4; }
.modal .primary-btn { width: 100%; margin-top: 6px; }

/* ---------- Leaflet markers ---------- */
.pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 3px; transform: rotate(-45deg);
  display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}
.pin svg { transform: rotate(45deg); width: 14px; height: 14px; color: #fff; }
.pin.dot { width: 20px; height: 20px; border-radius: 50%; transform: none; border-width: 1.5px; }
.pin.dot svg { transform: none; width: 12px; height: 12px; }
.pin.sel { outline: 3px solid #ffb020; outline-offset: 2px; }
.boat-dot { width: 22px; height: 22px; border-radius: 50%; background: #1d8fe0; border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(29, 143, 224, .25), 0 2px 8px rgba(0, 0, 0, .4); }
.boat-dot.out { background: var(--danger); box-shadow: 0 0 0 10px rgba(220, 38, 38, .3), 0 2px 8px rgba(0, 0, 0, .4); }
.hz-label { background: rgba(255, 255, 255, .92); border: 0; border-radius: 8px; font-weight: 700; color: var(--ink); box-shadow: 0 2px 6px rgba(0, 0, 0, .2); }
.leaflet-control-attribution { font-size: 9px; }
.leaflet-top.leaflet-left { top: calc(64px + var(--safe-t)); }
.leaflet-control-zoom { display: none; }
