/* ===== Reset & Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Default = Dark Mode — palette from diedler.com (dark) */
:root {
  --bg-dark:    #0d1117;
  --bg-panel:   #161b22;
  --bg-panel2:  #1c232c;
  --accent:     #5aabff;   /* brighter brand blue for contrast on dark */
  --accent2:    #0c71c3;   /* diedler --blue */
  --green:      #2ecc71;
  --red:        #ff6b6b;
  --yellow:     #ff9000;   /* diedler --orange */
  --text:       #e6edf3;   /* diedler dark --text */
  --text-muted: #8d96a0;   /* diedler dark --text-muted */
  --border:     #283039;
  --inst-bg:    #10151c;
  --radius:     8px;
}

/* ===== Day Mode (light) — palette from diedler.com (deep blue + orange) ===== */
body.day {
  --bg-dark:    #f0f6fd;   /* diedler --bg-alt */
  --bg-panel:   #ffffff;   /* diedler --bg-card */
  --bg-panel2:  #e6f0fb;
  --accent:     #0c71c3;   /* diedler --blue (deep blue) */
  --accent2:    #0a5da8;   /* darker brand blue for edges/borders */
  --green:      #1b9e4b;
  --red:        #d6453c;
  --yellow:     #ff9000;   /* diedler --orange */
  --text:       #1a1a2e;   /* diedler --text */
  --text-muted: #5b6b7c;
  --border:     #d2e2f3;   /* from diedler --border #0c71c324 */
  --inst-bg:    #ffffff;
}

/* ===== Night Mode (red, night-vision) ===== */
body.night {
  --bg-dark:    #0d0000;
  --bg-panel:   #1a0000;
  --bg-panel2:  #220000;
  --accent:     #ff6b6b;
  --accent2:    #cc2222;
  --green:      #cc4444;
  --red:        #ff2222;
  --yellow:     #cc3300;
  --text:       #ffcccc;
  --text-muted: #994444;
  --border:     #440000;
  --inst-bg:    #0a0000;
}

html, body, #app {
  width: 100%; height: 100%;
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

/* ===== MOB Bar ===== */
#mob-bar {
  position: fixed;
  top: 50px;
  left: 0; right: 0;
  height: 32px;
  background: #c0392b;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 2000;
  letter-spacing: 0.5px;
}
#mob-bar.hidden { display: none; }
#mob-clear-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.5);
  color: white;
  border-radius: 4px;
  padding: 2px 10px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}
#mob-clear-btn:hover { background: rgba(255,255,255,0.35); }

/* ===== Header ===== */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 50px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 1000;
}

#logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
}

#gps-status {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--bg-panel2);
}
.status-off       { color: var(--text-muted); }
.status-searching { color: var(--yellow); animation: blink 1s infinite; }
.status-on        { color: var(--green); }

@keyframes blink { 50% { opacity: 0.4; } }

#header-right { display: flex; gap: 6px; }
#header-right button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  width: 34px; height: 34px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
#header-right button:hover { background: var(--bg-panel2); }
#btn-night.active { background: var(--bg-panel2); border-color: var(--accent); }

/* ===== Depth legend (vector chart) ===== */
.depth-legend { display: none; padding: 2px 4px 6px 22px; }
body.basemap-vector .depth-legend { display: block; }
.depth-legend-title { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.depth-legend-bar {
  height: 10px; border-radius: 5px; margin: 3px 0 2px;
  background: linear-gradient(90deg, #6fe3d8 0%, #25b5bf 22%, #1597b4 42%, #0d7399 64%, #0a567f 82%, #063a5e 100%);
  border: 1px solid var(--border);
}
.depth-legend-labels { display: flex; justify-content: space-between; font-size: 0.66rem; color: var(--text-muted); }

/* ===== Search bar ===== */
#search-bar {
  position: fixed;
  top: 56px; left: 50%; transform: translateX(-50%);
  width: min(440px, calc(100vw - 24px));
  z-index: 1200;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
#search-bar.hidden { display: none; }
#search-input {
  flex: 1; min-width: 0;
  background: var(--bg-panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.95rem;
}
#search-input::placeholder { color: var(--text-muted); }
#search-close {
  background: var(--bg-panel2); border: 1px solid var(--border); color: var(--text);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; flex-shrink: 0;
}
#search-results { flex-basis: 100%; display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
#search-results:empty { display: none; }
.search-result {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: transparent; border: none; border-radius: 8px;
  padding: 8px 10px; cursor: pointer; text-align: left; width: 100%;
}
.search-result:hover { background: var(--bg-panel2); }
.search-name { color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.search-addr { color: var(--text-muted); font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.search-hint { color: var(--text-muted); font-size: 0.82rem; padding: 8px 10px; }

/* ===== Map ===== */
#map {
  position: fixed;
  top: 50px;
  bottom: 112px;
  left: 0; right: 0;
  z-index: 1;
}
/* Night vision: dim the bright chart so it doesn't ruin dark adaptation. */
body.night #map { filter: brightness(0.62) contrast(1.05) sepia(0.25) hue-rotate(-10deg); }

/* Map shifts down when MOB bar is visible */
body.mob-active #map { top: 82px; }
body.mob-active #compass { bottom: 198px; }
body.mob-active #fab-group { bottom: 154px; }
body.mob-active #weather-widget { top: 90px; }

/* ===== Weather Widget ===== */
#weather-widget {
  position: fixed;
  top: 58px;
  left: 8px;
  z-index: 1001;
  background: rgba(10, 22, 40, 0.82);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.8rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
  white-space: nowrap;
  transition: opacity 0.3s;
}
#weather-widget.hidden { display: none; }

.weather-arrow {
  display: inline-block;
  font-size: 1rem;
  transition: transform 0.5s;
}

/* ===== Instruments: 2 rows × 4 ===== */
#instruments {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 112px;
  background: var(--inst-bg);
  border-top: 2px solid var(--accent2);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  padding: 3px 0;
  transition: transform 0.3s ease;
}

/* Collapse toggle tab */
#inst-toggle {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--inst-bg);
  border: 2px solid var(--accent2);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--text-muted);
  width: 52px;
  height: 20px;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
#inst-toggle:hover { color: var(--accent); }

/* Collapsed state */
body.inst-hidden #instruments    { transform: translateY(112px); }
body.inst-hidden #map            { bottom: 0; }
body.inst-hidden #compass        { bottom: 58px; }
body.inst-hidden #fab-group      { bottom: 10px; }
body.inst-hidden #inst-toggle    { border-bottom: 2px solid var(--accent2); border-radius: 8px 8px 0 0; }

/* MOB bar active adjustments for collapsed state */
body.mob-active.inst-hidden #map       { top: 82px; bottom: 0; }
body.mob-active.inst-hidden #compass   { bottom: 58px; }
body.mob-active.inst-hidden #fab-group { bottom: 10px; }

.inst-row {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-around;
}

.instrument {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  flex: 1;
  padding: 0 2px;
}

.inst-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.inst-value {
  font-size: 1.0rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: center;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

.inst-small {
  font-size: 0.72rem;
  max-width: 72px;
}

.inst-unit {
  font-size: 0.58rem;
  color: var(--text-muted);
}

/* ===== Destination Row (inside instrument panel) ===== */
#dest-row {
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 7px;
  height: 26px;
  font-size: 0.78rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#dest-row.hidden { display: none; }
#dest-row-icon { opacity: 0.7; color: var(--accent); }
#dest-row-name { font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest-spacer { flex: 1; }
#dest-row-dist { opacity: 0.9; }
#dest-row-brg  { opacity: 0.7; font-size: 0.72rem; }
#dest-row-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 0.68rem;
  cursor: pointer;
  transition: background 0.15s;
}
#dest-row-clear:hover { background: var(--bg-panel2); }

/* Expand panel height when destination row visible */
body.has-dest #instruments  { height: 140px; }
body.has-dest #map          { bottom: 140px; }
body.has-dest #compass      { bottom: 194px; }
body.has-dest #fab-group    { bottom: 150px; }
body.has-dest.inst-hidden #instruments { transform: translateY(140px); }
body.has-dest.inst-hidden #map         { bottom: 0; }
body.has-dest.inst-hidden #compass     { bottom: 58px; }
body.has-dest.inst-hidden #fab-group   { bottom: 10px; }
body.mob-active.has-dest #compass      { bottom: 226px; }
body.mob-active.has-dest #fab-group    { bottom: 182px; }

/* ===== FAB Group ===== */
#fab-group {
  position: fixed;
  right: 12px;
  bottom: 122px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 1001;
}

/* Collapsible action buttons wrapper. overflow stays visible so the label
   pills (positioned to the left of each button) are not clipped; the buttons
   themselves are hidden when closed via opacity + pointer-events. */
#fab-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  overflow: visible;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.35s ease, opacity 0.25s ease;
  padding-bottom: 0;
}

#fab-group.open #fab-actions {
  max-height: 320px;
  opacity: 1;
  pointer-events: auto;
  padding-bottom: 8px;
}

/* Label pill to the left of each tool, shown while the ✚ menu is open */
#fab-actions .fab { position: relative; }
#fab-actions .fab::after {
  content: attr(data-label);
  position: absolute; right: 52px; top: 50%; transform: translateY(-50%);
  background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 3px 9px; font-size: 0.72rem; font-weight: 600; white-space: nowrap;
  box-shadow: 0 1px 8px rgba(0,0,0,0.28);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#fab-group.open #fab-actions .fab::after { opacity: 1; }

/* Stagger individual buttons */
#fab-actions .fab { transition: background 0.2s, transform 0.2s, opacity 0.15s; }
#fab-actions .fab:nth-child(1) { transition-delay: 0.04s; }
#fab-actions .fab:nth-child(2) { transition-delay: 0.08s; }
#fab-actions .fab:nth-child(3) { transition-delay: 0.12s; }

.fab {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--accent2);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,180,216,0.3);
  transition: background 0.2s, transform 0.1s;
}
.fab:hover { background: var(--bg-panel2); }
.fab.active { background: var(--accent2); border-color: var(--accent); }
/* GPS FAB when active but follow is disabled (user panned away) */
.fab.active.follow-off { background: var(--bg-panel2); border-color: var(--yellow); box-shadow: 0 0 0 2px var(--yellow); }

/* Always-visible recenter/follow FAB sits just above the tools toggle */
#fab-gps { margin-bottom: 8px; }

/* MOB FAB – red, always visible, set apart from the routine tools (top-right).
   One tap drops the MOB marker; hidden while a MOB is active (the red bar takes
   over). Slightly larger than the tool FABs for emergency prominence. */
.fab-mob {
  border-color: #fff;
  background: #c0392b;
  color: #fff;
  box-shadow: 0 2px 14px rgba(231,76,60,0.55);
}
.fab-mob:hover { background: #e74c3c; }
#fab-mob {
  position: fixed;
  top: 60px; right: 12px;
  z-index: 1100;
  width: 48px; height: 48px;
}
#fab-mob::after {
  content: 'MOB';
  position: absolute;
  bottom: -13px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 800; letter-spacing: 0.5px;
  color: #c0392b;
  text-shadow: 0 1px 2px var(--bg-dark);
}
body.mob-active #fab-mob { display: none; }

/* Toggle FAB – always visible, rotates when open. Orange = primary action
   (brand CTA colour from diedler.com), set apart from the blue chrome. */
.fab-toggle {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 300;
  line-height: 1;
  box-shadow: 0 2px 12px rgba(255,144,0,0.45);
  transition: background 0.2s, transform 0.3s ease;
}
.fab-toggle:hover { background: var(--yellow); filter: brightness(1.08); }
#fab-group.open .fab-toggle { transform: rotate(45deg); }

/* ===== Bottom Sheet (feature info / pin actions, Navionics-style) ===== */
#feature-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1600;                 /* above instruments (1000), below MOB bar (2000) */
  background: var(--bg-panel);
  color: var(--text);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.35);
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  transform: translateY(110%);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
}
#feature-sheet.open { transform: translateY(0); }
.sheet-grip {
  width: 40px; height: 4px; flex-shrink: 0;
  margin: 8px auto 2px;
  border-radius: 2px;
  background: var(--text-muted);
  opacity: 0.45;
}
.sheet-head { display: flex; align-items: flex-start; gap: 10px; padding: 4px 16px 8px; }
.sheet-titles { flex: 1; min-width: 0; }
.sheet-title {
  font-size: 1.05rem; font-weight: 700; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sheet-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 1px; }
.sheet-close {
  background: var(--bg-panel2); border: 1px solid var(--border); color: var(--text);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 0.85rem; flex-shrink: 0;
}
.sheet-close:hover { background: var(--border); }
.sheet-body { padding: 0 16px; overflow-y: auto; font-size: 0.85rem; line-height: 1.65; }
.sheet-body:empty { display: none; }
.sheet-body b { color: var(--text-muted); font-weight: 600; }
.sheet-body a { color: var(--accent); }
.sheet-actions { display: flex; gap: 8px; padding: 12px 16px 4px; flex-wrap: wrap; }
.sheet-actions:empty { display: none; }
.sheet-btn {
  flex: 1; min-width: 104px;
  border: none; border-radius: 10px; padding: 11px 12px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer; color: #fff;
  transition: filter 0.15s;
}
.sheet-btn:hover { filter: brightness(1.08); }
.sheet-btn.primary { background: var(--accent2); }
.sheet-btn.cta { background: var(--yellow); }
.sheet-btn.ghost { background: var(--bg-panel2); color: var(--text); border: 1px solid var(--border); }

/* ===== Compass ===== */
#compass {
  position: fixed;
  left: 12px;
  bottom: 166px;
  z-index: 1001;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 50%;
  padding: 2px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
#compass-canvas {
  display: block;
  width: 64px;
  height: 64px;
}

/* ===== Nautical Scale Bar ===== */
.nm-scale {
  background: rgba(10,22,40,0.75);
  border: 1px solid var(--border, #1e3a5f);
  border-radius: 4px;
  padding: 3px 8px 4px;
  font-size: 0.72rem;
  color: #e0f0ff;
  pointer-events: none;
}
.nm-scale-bar {
  height: 4px;
  background: #e0f0ff;
  border: 1px solid rgba(255,255,255,0.5);
  border-top: none;
  margin-bottom: 2px;
}
.nm-scale-label {
  text-align: center;
  font-size: 0.68rem;
  color: #e0f0ff;
}

/* ===== Panels ===== */
.panel {
  position: fixed;
  right: 0; top: 50px;
  width: min(320px, 95vw);
  max-height: calc(100vh - 160px);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 0 var(--radius);
  z-index: 2000;
  overflow-y: auto;
  padding: 0;
  box-shadow: -4px 4px 20px rgba(0,0,0,0.5);
  transition: transform 0.25s ease;
}
.panel.hidden { display: none; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-panel2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  position: sticky;
  top: 0;
}

.panel-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.panel-close:hover { background: var(--border); color: var(--text); }

.layer-option {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.layer-option label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.layer-option input[type="checkbox"],
.layer-option input[type="radio"] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
}
.layer-option input[type="text"],
.ais-key-section input[type="text"] {
  width: 100%;
  margin-top: 6px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.menu-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.menu-item:hover { background: var(--bg-panel2); }
a.menu-item { display: block; color: var(--text); text-decoration: none; }

.menu-stats {
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.9;
}

.menu-info {
  padding: 12px 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.menu-legal {
  padding: 8px 16px 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}
.menu-legal a {
  color: var(--accent, #00b4d8);
  text-decoration: none;
}
.menu-legal a:hover {
  text-decoration: underline;
}

/* ===== Anchor Panel ===== */
.anchor-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.anchor-status {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
  background: var(--bg-panel2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.anchor-status.set { color: var(--yellow); border-color: var(--yellow); }
.anchor-slider-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.anchor-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}
.anchor-slider-header span {
  font-weight: 700;
  color: var(--accent);
  min-width: 52px;
  text-align: right;
}
#anchor-radius {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 6px;
}
.anchor-btns {
  display: flex;
  gap: 10px;
}
.btn-primary {
  flex: 1;
  padding: 9px 0;
  background: var(--accent2);
  border: none;
  color: white;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent); }
.btn-danger-sm {
  flex: 1;
  padding: 9px 0;
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.2s;
}
.btn-danger-sm:hover { background: rgba(231,76,60,0.15); }
.anchor-alarm-indicator {
  background: rgba(192,57,43,0.25);
  border: 1px solid #c0392b;
  border-radius: var(--radius);
  color: #ff6b6b;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 8px 12px;
  text-align: center;
  animation: blink 0.8s infinite;
}
.anchor-alarm-indicator.hidden { display: none; }

/* ===== Route Panel ===== */
.route-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.route-status {
  text-align: center;
  padding: 8px 12px;
  background: var(--bg-panel2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.route-status.active { color: #9b59b6; border-color: #9b59b6; background: rgba(155,89,182,0.08); }
.route-controls { display: flex; gap: 10px; }
.route-leg-item {
  display: flex;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  font-size: 0.85rem;
}
.route-leg-item.current {
  background: rgba(155, 89, 182, 0.1);
  border-radius: 6px;
  padding: 8px;
  border-bottom: none;
  margin-bottom: 1px;
}
.route-leg-item.passed { opacity: 0.4; }
.route-leg-num {
  width: 22px; height: 22px;
  background: var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-muted);
}
.route-leg-item.current .route-leg-num { background: #9b59b6; color: white; }
.route-leg-item.passed .route-leg-num { background: var(--green); color: white; }
.route-leg-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route-leg-dist { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.route-leg-move { display: flex; flex-direction: column; gap: 2px; }
.route-leg-move button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  width: 28px; height: 22px;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.route-leg-move button:hover { background: var(--bg-panel2); color: var(--text); }
.route-leg-move button:disabled { opacity: 0.25; cursor: default; }
.route-total {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: right;
}
.route-save-row {
  display: flex; gap: 8px; align-items: center;
}
.route-save-row input {
  flex: 1;
  background: var(--bg-dark); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px; padding: 7px 10px; font-size: 0.85rem;
}
.route-save-row input::placeholder { color: var(--text-muted); }
.saved-route-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.saved-route-info { flex: 1; }
.saved-route-name { font-weight: 600; color: var(--text); }
.saved-route-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.saved-route-load {
  background: var(--accent2); border: none; color: white;
  border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 0.78rem;
  white-space: nowrap;
}
.saved-route-load:hover { background: var(--accent); }
.saved-route-del {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; padding: 2px 6px;
}
.saved-route-del:hover { color: var(--red); }

/* ===== Waypoint List ===== */
#waypoint-list {
  max-height: 300px;
  overflow-y: auto;
}
.wp-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  font-size: 0.85rem;
}
.wp-item-name { flex: 1; color: var(--text); font-weight: 600; }
.wp-item-coords { font-size: 0.72rem; color: var(--text-muted); }
.wp-goto {
  background: var(--accent2);
  border: none;
  color: white;
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 0.78rem;
}
.wp-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
}
.wp-delete:hover { color: var(--red); }

.btn-danger {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.2s;
}
.btn-danger:hover { background: rgba(231,76,60,0.15); }

/* ===== Measure Bar ===== */
#measure-bar {
  position: fixed;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel2);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.85rem;
  color: var(--accent);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}
#measure-bar.hidden { display: none; }
#measure-stop {
  background: var(--accent2);
  border: none;
  color: white;
  border-radius: 12px;
  padding: 3px 12px;
  cursor: pointer;
  font-size: 0.8rem;
}

/* ===== AIS Ship Marker ===== */
.ais-ship {
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 16px solid #2ecc71;
  transform: rotate(var(--hdg, 0deg));
  transform-origin: 50% 75%;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.7));
}

/* Vessel inside the proximity-warning radius */
.ais-ship.ais-warn {
  border-bottom-color: #ff2b2b !important;
  animation: ais-warn-pulse 0.8s infinite;
}
@keyframes ais-warn-pulse {
  0%, 100% { filter: drop-shadow(0 0 3px #ff2b2b); }
  50%      { filter: drop-shadow(0 0 9px #ff2b2b); }
}

/* ===== Leaflet Overrides ===== */
.leaflet-control-attribution { display: none !important; }
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  background: var(--bg-panel) !important;
}
.leaflet-control-zoom a {
  background: var(--bg-panel) !important;
  color: var(--accent) !important;
  border-bottom: 1px solid var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-panel2) !important; }
.leaflet-bar { border: 1px solid var(--border) !important; }

/* Zoom controls below header, top-left */
.leaflet-top.leaflet-left { top: 58px; left: 8px; }

/* GPS dot */
.gps-dot {
  width: 16px; height: 16px;
  background: var(--accent);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(0,180,216,0.3);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(0,180,216,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(0,180,216,0.1); }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg-panel2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 0.85rem;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { border-color: var(--green); color: var(--green); }
.toast-error   { border-color: var(--red);   color: var(--red);   }

/* ===== Confirm Dialog ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  max-width: 280px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.confirm-msg {
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 18px;
  line-height: 1.5;
}
.confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.confirm-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 7px 16px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s;
}
.confirm-cancel:hover { background: var(--bg-panel2); }
.confirm-ok {
  background: var(--red);
  border: none;
  color: white;
  border-radius: var(--radius);
  padding: 7px 16px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s;
}
.confirm-ok:hover { background: #c0392b; }

/* ===== Offline Panel ===== */
.offline-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.offline-info { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }
.offline-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.88rem; }
.offline-row select {
  background: var(--bg-dark); border: 1px solid var(--border);
  color: var(--text); border-radius: 4px; padding: 5px 8px; font-size: 0.85rem;
}
.offline-estimate {
  background: var(--bg-panel2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  font-size: 0.82rem; color: var(--text-muted); line-height: 1.7;
}
.offline-progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.offline-progress-wrap.hidden { display: none; }
.offline-progress-bar-track {
  height: 8px; background: var(--bg-dark); border-radius: 4px; overflow: hidden;
  border: 1px solid var(--border);
}
.offline-progress-bar {
  height: 100%; width: 0%; background: var(--accent); border-radius: 4px;
  transition: width 0.3s ease;
}
.offline-progress-label { font-size: 0.78rem; color: var(--text-muted); text-align: center; }
.offline-cache-info { font-size: 0.78rem; color: var(--text-muted); line-height: 1.6; }
.offline-section-title {
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.mbtiles-status {
  font-size: 0.84rem; padding: 8px 10px;
  background: var(--bg-panel2); border: 1px solid var(--border);
  border-radius: var(--radius); line-height: 1.6; min-height: 36px;
}
.mbtiles-none { color: var(--text-muted); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .inst-value { font-size: 0.85rem; }
  .inst-small { font-size: 0.65rem; }
  .inst-label { font-size: 0.55rem; }
  #compass { display: none; }
  .fab { width: 40px; height: 40px; font-size: 1rem; }
}

/* ===== Update banner ===== */
#update-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 4000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-panel2);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
}
#update-banner button {
  background: var(--accent);
  color: #04141f;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 700;
  cursor: pointer;
}

/* ===== Big-view toggle button (instrument panel tab) ===== */
#inst-bigview {
  position: absolute;
  top: -20px;
  right: 14px;
  background: var(--inst-bg);
  border: 2px solid var(--accent2);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--text-muted);
  width: 40px;
  height: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}
#inst-bigview:hover,
body.bigview #inst-bigview { color: var(--accent); }

/* ===== Big-view: map small, instruments large ===== */
body.bigview #instruments { height: 62vh; transform: none; }
body.bigview #map         { bottom: 62vh; }
body.bigview #compass     { bottom: calc(62vh + 14px); }
body.bigview #fab-group   { bottom: calc(62vh + 14px); }
body.bigview .inst-value  { font-size: 2.6rem; max-width: none; }
body.bigview .inst-small  { font-size: 1.5rem; max-width: none; }
body.bigview .inst-label  { font-size: 1rem; }
body.bigview .inst-unit   { font-size: 0.95rem; }
body.bigview #dest-row    { height: 34px; font-size: 1rem; }
body.bigview #compass-canvas { width: 104px; height: 104px; }

/* ===== Menu version line ===== */
.menu-version {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ===== Changelog ===== */
#changelog-body { padding: 4px 14px 14px; overflow-y: auto; max-height: 70vh; }
.cl-entry { margin-bottom: 14px; }
.cl-ver { font-weight: 700; color: var(--accent); }
.cl-date { color: var(--text-muted); font-size: 0.75rem; margin-left: 6px; }
.cl-list { margin: 6px 0 0 18px; padding: 0; }
.cl-list li { font-size: 0.82rem; line-height: 1.5; margin-bottom: 3px; }

@media (max-width: 480px) {
  body.bigview .inst-value { font-size: 2rem; }
  body.bigview .inst-small { font-size: 1.2rem; }
}

/* ===== Short viewports (landscape phones): expand the FAB menu sideways =====
   A vertical stack of 6 buttons does not fit above the instrument panel on a
   short screen and used to overflow behind the header. Lay it out horizontally
   instead so every action stays on screen and tappable. */
@media (max-height: 560px) {
  #fab-group   { flex-direction: row-reverse; }
  #fab-actions {
    flex-direction: row-reverse;
    max-height: none;
    max-width: 0;
    padding-bottom: 0;
    transition: max-width 0.35s ease, opacity 0.25s ease;
  }
  #fab-group.open #fab-actions {
    max-width: 80vw;
    padding-bottom: 0;
    padding-right: 8px;
  }
}

/* === Big-View (ausgeklappte Instrumente) besser aufteilen + Vollbild === */
/* Im Big-View die Instrumenten-Reihen über die volle Höhe verteilen,
   statt oben zu kleben — gleichmäßiges, gut lesbares Raster. */
body.bigview #instruments {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 10px;
  padding: 14px 10px calc(env(safe-area-inset-bottom, 0px) + 12px);
}
body.bigview .inst-row {
  flex: 1 1 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  align-items: stretch;
}
body.bigview .instrument {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
/* Quer/Tablet/Desktop: alle 8 Werte in EINER Reihe, große Zahlen */
@media (min-width: 900px) and (orientation: landscape) {
  body.bigview #instruments { flex-direction: row; flex-wrap: wrap; }
  body.bigview .inst-row { grid-template-columns: repeat(8, 1fr); }
}
/* Vollbild-Button im Header wie die übrigen Header-Buttons */
#btn-fullscreen { font-size: 1rem; }
