/* Boat Trip Planner — shared styles (trip.php, admin.php) */
:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-2: #f6f8fb;
  --ink: #0f1f33;
  --muted: #5d6d82;
  --line: #dde4ec;
  --navy: #0b2545;
  --sea: #1d5fa8;
  --sea-soft: #e3eefb;
  --accent: #f08a24;
  --accent-soft: #fdf0e2;
  --ok: #1f9d6b;
  --danger: #d64545;
  --danger-soft: #fbe9e9;
  --shadow: 0 1px 2px rgba(15,31,51,.06), 0 4px 16px rgba(15,31,51,.08);
  --radius: 12px;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
[data-theme="night"] {
  --bg: #070d16;
  --panel: #0f1824;
  --panel-2: #142030;
  --ink: #e6edf5;
  --muted: #8c9bb0;
  --line: #223247;
  --navy: #050b14;
  --sea: #5aa2ee;
  --sea-soft: #13263d;
  --accent: #ff9d45;
  --accent-soft: #33220f;
  --danger-soft: #3a1717;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, select { font: inherit; color: inherit; }

#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 380px;
  flex: 0 0 380px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--line);
  min-height: 0;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(135deg, #0b2545 0%, #13427a 100%);
  color: #fff;
}
.brand svg { flex: none; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.brand small { display: block; opacity: .7; font-size: 12px; font-weight: 500; }
.brand .spacer { flex: 1; }
.brand .icon-btn { color: #fff; border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.08); }
.brand .icon-btn:hover { background: rgba(255,255,255,.18); }

.scroll { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.card h2 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

/* ---------- Controls ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=number], input[type=search], input[type=datetime-local], select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}
input:focus, select:focus { border-color: var(--sea); box-shadow: 0 0 0 3px var(--sea-soft); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--sea); border-color: var(--sea); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
[data-theme="night"] .btn.primary { color: #06121f; }
.btn.danger { color: var(--danger); }
.btn.danger.confirm { background: var(--danger); border-color: var(--danger); color: #fff; }
.icon-btn {
  width: 30px; height: 30px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font-size: 15px; line-height: 1;
  color: var(--muted);
}
.icon-btn:hover { color: var(--ink); background: var(--panel-2); }
.icon-btn.small { width: 24px; height: 24px; font-size: 13px; border-radius: 6px; }

.pill {
  font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0;
  padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line);
}
.pill.dirty { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.saved { background: rgba(31,157,107,.12); color: var(--ok); border-color: transparent; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat {
  background: var(--panel-2); border-radius: 10px; padding: 10px 12px;
  border: 1px solid var(--line);
}
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .value small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 2px; }

/* ---------- Itinerary ---------- */
.itinerary { list-style: none; margin: 0; padding: 0; }
.wp-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 6px; border-radius: 8px;
}
.wp-row:hover { background: var(--panel-2); }
.wp-row.flash { animation: flash 1s ease; }
@keyframes flash { 0%,40% { background: var(--accent-soft); } 100% { background: transparent; } }
.wp-badge {
  width: 24px; height: 24px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--sea); color: #fff; font-size: 11.5px; font-weight: 700;
}
.wp-badge.start { background: var(--ok); }
.wp-badge.end { background: var(--accent); }
.wp-coords { flex: 1; font-family: var(--mono); font-size: 12.5px; cursor: pointer; min-width: 0; }
.wp-coords span { display: block; }
.wp-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wp-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.wp-wind { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.wp-wind b { color: var(--ink); font-weight: 700; }
.wp-wind small { font-size: 10.5px; }
.wp-wind.muted { font-style: italic; }
.wind-mini { width: 15px; height: 15px; flex: none; fill: var(--c, var(--sea)); stroke: rgba(0,0,0,.45); stroke-width: 1; }
.wind-hint { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 0 6px 8px; }
.wp-wind-badge {
  position: absolute; left: 24px; top: 3px; display: flex; align-items: center; gap: 2px;
  background: rgba(15,31,51,.85); color: #fff; font: 700 10.5px/1 Inter, sans-serif;
  padding: 2px 6px 2px 3px; border-radius: 10px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.wp-wind-badge .wind-mini { width: 13px; height: 13px; stroke: rgba(0,0,0,.6); }
.wp-row .icon-btn { opacity: 0; transition: opacity .15s; }
.wp-row:hover .icon-btn, .wp-row:focus-within .icon-btn { opacity: 1; }
@media (hover: none) { .wp-row .icon-btn { opacity: 1; } }

.leg-row {
  display: flex; align-items: center; gap: 10px;
  margin-left: 17px; padding: 6px 6px 6px 18px;
  border-left: 2px dashed var(--line);
  cursor: pointer; border-radius: 0 8px 8px 0;
  font-size: 12.5px; color: var(--muted);
}
.leg-row:hover { background: var(--panel-2); }
.leg-row.selected { background: var(--accent-soft); border-left-color: var(--accent); color: var(--ink); }
.leg-row .leg-data { flex: 1; display: flex; gap: 12px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.leg-row b { color: var(--ink); font-weight: 600; }
.leg-row .icon-btn { opacity: 0; }
.leg-row:hover .icon-btn, .leg-row.selected .icon-btn { opacity: 1; }
@media (hover: none) { .leg-row .icon-btn { opacity: 1; } }

.empty {
  text-align: center; color: var(--muted); padding: 18px 8px 8px;
}
.empty svg { opacity: .5; margin-bottom: 6px; }
.empty p { margin: 4px 0; }
.kbd { font-family: var(--mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel-2); }

/* ---------- Saved routes ---------- */
.routes { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.route-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line);
  cursor: pointer; background: var(--panel);
}
.route-item:hover { border-color: var(--sea); }
.route-item.active { border-color: var(--sea); background: var(--sea-soft); }
.route-item .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-item .meta { font-size: 11.5px; color: var(--muted); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

details.card summary {
  cursor: pointer; list-style: none;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600;
  display: flex; justify-content: space-between;
}
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: '▸'; transition: transform .15s; }
details.card[open] summary::after { transform: rotate(90deg); }
details.card[open] summary { margin-bottom: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

/* ---------- Map ---------- */
#map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #aad3df; }
[data-theme="night"] #map .leaflet-tile-pane { filter: brightness(.65) contrast(1.1) saturate(.8); }

.leaflet-container { font-family: inherit; }
.leaflet-bar a, .map-btn {
  width: 36px !important; height: 36px !important; line-height: 36px !important;
  font-size: 17px;
}
.map-btn { display: flex !important; align-items: center; justify-content: center; cursor: pointer; color: #0f1f33 !important; }
.map-btn.on { background: #e3eefb !important; color: #1d5fa8 !important; }
.leaflet-control-layers { border-radius: 10px !important; }
.leaflet-control-layers-toggle { width: 40px !important; height: 40px !important; }

.wp-icon { background: none; border: none; }
.wp-pin {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--sea); color: #fff; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  font: 700 11.5px/1 Inter, sans-serif;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  cursor: grab;
}
.wp-pin.start { background: var(--ok); }
.wp-pin.end { background: var(--accent); }

.leg-label { background: none; border: none; }
.leg-label div {
  display: inline-block; transform: translate(-50%, -50%);
  background: rgba(11,37,69,.85); color: #fff;
  font: 600 11px/1 Inter, sans-serif; padding: 4px 7px; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.leg-label.selected div { background: var(--accent); }

.cursor-pos {
  background: rgba(255,255,255,.9); padding: 4px 8px; border-radius: 6px;
  font: 500 11.5px/1.3 var(--mono); color: #0f1f33; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.leaflet-popup-content .btn { background: #fff; color: #0f1f33; border-color: #dde4ec; }
.leaflet-popup-content .btn:hover { background: #f6f8fb; }
.leg-popup { min-width: 180px; font-size: 13px; }
.leg-popup h3 { margin: 0 0 6px; font-size: 13px; }
.leg-popup table { border-collapse: collapse; width: 100%; margin-bottom: 8px; }
.leg-popup td { padding: 2px 0; }
.leg-popup td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Compass ---------- */
#compass {
  position: absolute; right: 16px; bottom: 48px;
  width: 170px; height: 170px; z-index: 900;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.92) 62%, rgba(255,255,255,.75) 72%);
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
  touch-action: none; user-select: none; cursor: grab;
}
#compass.dragging { cursor: grabbing; }
#compass img { width: 100%; height: 100%; pointer-events: none; display: block; }
#compass .needle {
  position: absolute; inset: 0; pointer-events: none;
  transition: transform .45s cubic-bezier(.3,1.4,.5,1), opacity .2s;
}
#compass .needle.idle { opacity: 0; }
#compass .readout {
  position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%);
  background: var(--navy); color: #fff; border-radius: 999px;
  padding: 3px 10px; font: 600 12px/1.2 var(--mono); white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
#compass[hidden] { display: none; }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 2000; pointer-events: none;
  padding-top: env(safe-area-inset-top);
}
.toast {
  background: #0f1f33; color: #fff; padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.3); font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  animation: toast-in .2s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  #app { flex-direction: column-reverse; }
  #map-wrap { flex: 0 0 56vh; flex: 0 0 56dvh; }
  #sidebar { width: 100%; flex: 1 1 auto; border-right: none; border-top: 1px solid var(--line); }
  .brand { padding-top: 10px; padding-bottom: 10px; }
  .scroll { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  #compass { width: 104px; height: 104px; right: 10px; bottom: 56px; }
  #compass .readout { font-size: 11px; padding: 2px 8px; }
  .leaflet-control-attribution { font-size: 9px; }
}

[hidden] { display: none !important; }
.brand h1, .brand small { white-space: nowrap; }
.brand > div:nth-child(2) { min-width: 0; overflow: hidden; }
.brand h1 { overflow: hidden; text-overflow: ellipsis; font-size: 15.5px; }
.account-btn .who { max-width: 80px; }
.wind-arrow small { font-weight: 600; opacity: .85; }
.account-btn { white-space: nowrap; flex: none; }

/* ---------- Accounts ---------- */
input[type=email], input[type=password] {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); outline: none; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.account-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px 0 4px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.1);
  color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; max-width: 150px;
}
.account-btn.anon { padding: 0 14px; background: var(--accent); border-color: var(--accent); }
.account-btn:hover { filter: brightness(1.1); }
.account-btn .avatar {
  width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
}
.account-btn .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { position: relative; }
#account-menu {
  position: absolute; right: 12px; top: calc(100% - 6px); z-index: 1500;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 12px; min-width: 220px;
}
#account-menu .email { color: var(--muted); font-size: 12px; margin-bottom: 10px; word-break: break-all; }
#account-menu .btn { width: 100%; margin-top: 6px; }

/* Locked (members-only) features */
.lockable { position: relative; }
.lockable.is-locked > :not(.unlock) { opacity: .35; pointer-events: none; filter: blur(.5px); user-select: none; }
.unlock { display: none; }
.lockable.is-locked > .unlock {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  position: absolute; inset: 0; width: 100%;
  background: transparent; border: none; cursor: pointer;
  color: var(--sea); font-weight: 700; font-size: 13px; text-align: center; padding: 8px;
}
.unlock span {
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 6px;
}
.unlock:hover span { border-color: var(--sea); }
.lock-badge { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(7,18,33,.55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  background: var(--panel); color: var(--ink); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%; max-width: 420px; max-height: 100%; overflow-y: auto; padding: 22px; position: relative;
  animation: toast-in .2s ease;
}
.modal-card h2 { margin: 0 0 4px; font-size: 20px; }
.modal-card .lead { color: var(--muted); margin: 0 0 16px; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.perks { list-style: none; padding: 12px 14px; margin: 0 0 16px; background: var(--sea-soft); border-radius: 10px; display: grid; gap: 4px; font-size: 13px; }
.perks li::before { content: '✓ '; color: var(--ok); font-weight: 700; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.tabs button { border: none; background: none; padding: 8px; border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
#auth-form { display: grid; gap: 12px; }
.pw-row { display: flex; gap: 6px; }
.pw-row input { flex: 1; font-family: var(--mono); }
.pw-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pw-tools .btn { padding: 6px 10px; font-size: 12px; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 8px 10px; margin: 0; font-size: 13px; }
.form-note { color: var(--muted); font-size: 12px; margin: 0; }
#auth-submit { width: 100%; padding: 11px; }

/* Boat settings */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.segmented label {
  display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-weight: 600; background: var(--panel-2);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:checked + span { color: var(--sea); }
.segmented label:has(input:checked) { border-color: var(--sea); background: var(--sea-soft); }
.segmented label:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--sea-soft); }
.stack { display: grid; gap: 10px; }
.home-pos { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ---------- Weather overlays ---------- */
.clouds-tiles { filter: grayscale(1) brightness(.5) contrast(1.5); }
.wind-icon { background: none; border: none; }
.wind-arrow { display: flex; flex-direction: column; align-items: center; transform: translate(-50%, -50%); pointer-events: none; }
.wind-arrow svg { width: 30px; height: 30px; fill: var(--c); stroke: rgba(0,0,0,.55); stroke-width: .8; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.wind-arrow span {
  font: 700 10.5px/1 Inter, sans-serif; color: #fff; background: rgba(15,31,51,.78);
  padding: 2px 4px; border-radius: 4px; margin-top: 1px; white-space: nowrap;
}
.wind-legend {
  background: rgba(255,255,255,.94); border-radius: 8px; padding: 6px 8px; box-shadow: 0 1px 4px rgba(0,0,0,.25);
  font: 600 11px/1.3 Inter, sans-serif; color: #0f1f33;
}
.wind-legend .chips { display: flex; gap: 3px; margin-top: 4px; }
.wind-legend .chips span { padding: 2px 5px; border-radius: 4px; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.4); }
