* { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: 'Segoe UI', Arial, sans-serif; font-size: 13px; overflow: hidden; }

#map { position: absolute; inset: 0; }

#wind-canvas {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 2;
  display: none;
}

/* ── Vertical icon toolbar ─────────────────────────────────────────────────── */

#toolbar {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  z-index: 10;
  width: 62px;
}

.tb-btn {
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 6px;
  background: none;
  color: #444;
  cursor: pointer;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.tb-btn:hover  { background: #e8eef4; color: #1a5276; }
.tb-btn.active { background: #1a5276; color: #fff; }

.tb-divider {
  width: 26px;
  height: 1px;
  background: #e0e0e0;
  margin: 3px 0;
  flex-shrink: 0;
}

/* ── Toolbar popups ────────────────────────────────────────────────────────── */

.tb-popup {
  position: absolute;
  right: 78px;   /* toolbar width (62) + gap (6) + right offset (10) */
  top: 10px;
  width: 260px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  z-index: 20;
}
.tb-popup.hidden { display: none; }

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #1a5276;
  color: #fff;
  border-radius: 8px 8px 0 0;
  font-weight: bold;
  font-size: 13px;
}

.popup-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}

.popup-body {
  padding: 10px 12px;
}

.popup-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #666;
  margin: 10px 0 6px;
  letter-spacing: 0.5px;
}

.popup-body label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: #333;
}

.popup-body input[type=number] {
  width: 70px;
  padding: 3px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
}

#required-depth-display { font-size: 12px; color: #555; margin-top: 4px; }

select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 6px;
}

#current-level { font-size: 12px; color: #555; }

#time-display {
  font-size: 12px;
  color: #1a5276;
  font-weight: bold;
  margin-bottom: 4px;
}

#tide-level-display { font-size: 12px; color: #555; margin-top: 4px; }

/* ── Tool info overlay (route / passer feedback) ───────────────────────────── */

#tool-info {
  position: absolute;
  left: 10px;
  top: 10px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  padding: 8px 12px;
  z-index: 15;
  font-size: 13px;
  min-width: 160px;
}
#tool-info.hidden { display: none; }

.tool-info-row { font-size: 1em; font-weight: bold; color: #1a5276; margin-bottom: 2px; }
.tool-info-row.hidden { display: none; }
.tool-info-actions { margin-top: 6px; display: flex; gap: 6px; }

/* ── Legend ────────────────────────────────────────────────────────────────── */

.legend { display: flex; flex-direction: column; gap: 4px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.swatch { display: inline-block; width: 16px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.15); flex-shrink: 0; }

/* ── Layer toggles ─────────────────────────────────────────────────────────── */

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  justify-content: flex-start !important;
}
.toggle input { cursor: pointer; }
.toggle-indent { padding-left: 20px; font-size: 11px; color: #666; }
.toggle-sub { margin-bottom: 2px; }

/* ── Hover popup ───────────────────────────────────────────────────────────── */

#feature-popup {
  position: absolute;
  background: rgba(255,255,255,0.97);
  border: 1px solid #aac;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  max-width: 220px;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  line-height: 1.5;
}
#feature-popup.hidden { display: none; }
#feature-popup strong { display: block; margin-bottom: 3px; font-size: 13px; color: #1a5276; }

/* ── Bottom tide bar ───────────────────────────────────────────────────────── */

#tide-control-bar {
  position: absolute;
  top: calc(100vh - 240px);
  left: 0;
  width: 100vw;
  height: 40px;
  background: #0d1720;
  border-top: 2px solid #1e3a55;
  z-index: 50;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  color: #c8d8e8;
  font-size: 12px;
}

.tcb-left {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.tcb-left select {
  background: #1a2d42;
  color: #c8d8e8;
  border: 1px solid #2a4a6a;
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 11px;
  max-width: 150px;
}
#station-auto {
  background: #1e3a55;
  color: #a0c0e0;
  border: 1px solid #2a5a7a;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
#station-auto:hover { background: #2a4a6a; }

.tcb-center {
  flex: 1;
  text-align: center;
  line-height: 1.25;
}
#tcb-time {
  font-size: 13px;
  font-weight: bold;
  color: #00cc66;
}
#tcb-level {
  font-size: 13px;
  font-weight: bold;
  color: #8ab0d0;
}

.tcb-right {
  flex-shrink: 0;
  text-align: right;
  font-size: 11px;
  color: #6a8aaa;
  white-space: nowrap;
}

#tide-bar {
  position: absolute;
  top: calc(100vh - 200px);
  left: 0;
  width: 100vw;
  height: 200px;
  background: #111e2b;
  z-index: 50;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  display: block;
}

.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right {
  margin-bottom: 240px;
}

/* ── Tool buttons ──────────────────────────────────────────────────────────── */

.tool-btn {
  padding: 3px 10px;
  font-size: 11px;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
}
.tool-btn:hover { background: #e0e0e0; }
.tool-btn.active { background: #1a5276; color: #fff; border-color: #1a5276; }

/* ── All-layers modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 8px; width: 320px; max-width: 92vw;
  max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.modal-body { overflow-y: auto; padding: 4px 10px 10px; }
.modal-body label { display: flex; align-items: center; gap: 7px; padding: 3px 0; font-size: 13px; }
.modal-body .lyr-count { color: #999; font-size: 11px; margin-left: auto; }

/* ── Auto-route overview ── */
#route-auto-block { font-weight: normal; max-width: 320px; }
.route-auto-controls { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 4px 0; }
.route-day { font-size: 12px; padding: 2px 4px; }
#route-start-sel, #route-end-sel { font-size: 11px; padding: 2px 3px; max-width: 130px; }
#route-overview { margin-top: 4px; }
.route-sum { font-size: 12px; color: #555; margin-bottom: 3px; }
.route-rec { font-size: 12px; color: #1a5276; margin: 3px 0; }
.route-msg { font-size: 12px; color: #777; margin: 4px 0; }
.route-err { color: #c0392b; }
.route-gototime { font-size: 11px; padding: 1px 5px; }
table.route-cp { border-collapse: collapse; width: 100%; font-size: 11px; font-weight: normal; }
table.route-cp th { text-align: left; color: #888; font-weight: 600; border-bottom: 1px solid #ddd; padding: 2px 4px; }
table.route-cp td { padding: 3px 4px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
table.route-cp .cp-sub { color: #999; font-size: 10px; }
table.route-cp .cp-block { color: #c0392b; font-weight: 600; }
table.route-cp .keel-ok { color: #16a34a; font-weight: 600; }
table.route-cp .cp-warn { color: #d68910; font-weight: 600; }
.dep-opts { display: flex; flex-direction: column; gap: 3px; margin: 4px 0; }
.dep-opt { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; }
.dep-opt .dep-sub { color: #888; font-size: 10px; font-weight: normal; }
.dep-opt.best { border-color: #16a34a; }
.dep-opt.sel { background: #1a5276; color: #fff; border-color: #1a5276; }
.dep-opt.sel .dep-sub { color: #cfe2f3; }
.route-speed-lbl { font-size: 11px; color: #555; display: inline-flex; align-items: center; gap: 2px; }
.route-speed-lbl input { width: 42px; font-size: 12px; padding: 2px 3px; }
table.route-cp tr.cp-row { cursor: pointer; }
table.route-cp tr.cp-row:hover td { background: #eef4fa; }
