/* Chart Planner — Harmonized Ali Sailing Tools UI */

.chart-page main { padding-bottom: 28px; }
.chart-layout {
  display: grid;
  grid-template-columns: clamp(255px, 21vw, 295px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.settings .section {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.settings .card-head { border: 0; }
.settings label,
.replay label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 6px;
  gap: 8px;
}
.settings label:not(:first-child) { margin-top: 14px; }
.chart-page output {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}
.chart-page input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 4px 0;
  cursor: pointer;
}
.settings .section p,
.replay,
.chart-page #coverage {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.settings .section p { margin: 6px 0 11px; }

.settings button,
.chart-page #mapError button,
.remove-point {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.settings button:hover:not(:disabled),
.chart-page #mapError button:hover,
.remove-point:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
  color: var(--accent);
}
.settings button.action {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 700;
  width: 100%;
  padding: 9px 12px;
}
.settings button.action:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}
.tools { display: flex; gap: 6px; margin: 8px 0; }
.tools button { flex: 1; white-space: nowrap; }
.settings .text-action {
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  padding: 4px 0;
  display: block;
  margin: 6px 0 8px;
  text-align: left;
}
.settings .text-action:hover { background: transparent; color: var(--accent-hover); }
.settings button:disabled { opacity: 0.45; cursor: not-allowed; }
#resetPlan { width: 100%; }

/* Arrivals Summary Bar */
.arrivals {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr 1fr;
  padding: 13px 18px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}
.arrivals > div { padding: 0 14px; border-left: 1px solid var(--border); }
.arrivals > div:first-child { border: 0; padding-left: 0; }
.eta-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.arrivals strong {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  display: block;
  margin-top: 4px;
  color: var(--ink);
}
.model-swatch, .tide-swatch {
  width: 9px;
  height: 9px;
  border: 2px solid #0d9488;
  display: inline-block;
  border-radius: 50%;
  background: #0d9488;
  flex-shrink: 0;
}
.tide-swatch { border-color: #c2410c; background: #ffffff; }

/* Map & Current Bar */
.current-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
}
.current-bar > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.current-bar .segmented button { white-space: nowrap; padding: 5px 11px; }
.current-bar #tideArrows[aria-pressed="true"] { background: #c2410c; color: #ffffff; }
.current-bar small {
  margin-left: auto;
  color: var(--faint);
  font-size: 11.5px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

#map {
  height: clamp(380px, 52vh, 620px);
  background: #dbeafe;
  isolation: isolate;
  cursor: crosshair;
}
.chart-page .leaflet-container { font-family: var(--font-sans); }
.wp-marker {
  background: #0f172a;
  border: 2px solid #ffffff;
  border-radius: 50%;
  color: #ffffff;
  text-align: center;
  font: 700 11px/18px var(--font-sans);
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.35);
}

.current-arrow { pointer-events: none !important; text-align: center; color: #0f766e; }
.current-arrow.tide { color: #b45309; }
.vector-symbol { display: block; }
.vector-symbol svg {
  width: 44px;
  height: 36px;
  display: block;
  margin: auto;
  overflow: visible;
  filter: drop-shadow(0 0 2px #ffffff) drop-shadow(0 0 1px #ffffff);
}
.vector-symbol path, .vector-symbol circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vector-symbol b {
  display: inline-block;
  vertical-align: top;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.94);
  font: 800 11px/14px var(--font-mono);
}

.path-key {
  display: flex;
  align-items: center;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 8px 18px;
  border-block: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 11.5px;
  color: var(--muted);
}
.path-key strong { color: var(--ink); }
.path-key i {
  display: inline-block;
  width: 20px;
  border-top: 3px solid #146651;
  margin-right: 5px;
  vertical-align: middle;
}
.path-key .fallback-line { border-top: 3px dashed #b14d20; }

.replay { padding: 12px 18px; }
.replay label { color: var(--ink); }
.replay #positions { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; }

.chart-page #coverage:not(:empty),
#mapError {
  border-top: 1px solid var(--border);
  padding: 10px 18px;
  background: var(--warn-bg);
  color: var(--warn-fg);
  margin: 0;
}
#coverage button { margin-left: 8px; }
#fallbackDetails {
  padding: 9px 18px;
  background: var(--warn-bg);
  color: var(--warn-fg);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
#fallbackDetails summary { cursor: pointer; font-weight: 600; }
#fallbackNotes > div { padding-top: 7px; }
#fallbackNotes button { margin-left: 6px; background: none; border: 0; text-decoration: underline; color: var(--accent); }

/* Leg Inspector */
.chart-page .log-head { padding: 13px 18px; }
.chart-page th, .chart-page td { padding: 9px 14px; }
.chart-page td:nth-child(1) { white-space: normal; }
.remove-point { padding: 3px 8px; }

.inspect-controls {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto minmax(140px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px 18px 2px;
}
.inspect-controls label { margin: 0; }
.inspect-controls output { display: block; font-size: 11px; color: var(--faint); }
#inspectTransit { margin: 10px 18px 0; font-size: 13px; font-weight: 700; color: var(--ink); }
#inspectCourse { margin: 5px 18px 12px; color: var(--muted); font-size: 12px; }
#legRows td:last-child { white-space: normal; min-width: 180px; }

/* Departure Optimizer */
#optimizer .log-head { flex-wrap: wrap; }
#optimizer .log-head p { margin: 4px 0 0; font-size: 12px; color: var(--faint); }
#optSummary {
  padding: 10px 18px;
  font-size: 12.5px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}
.opt-scroll { max-height: 360px; overflow: auto; }
.opt-scroll thead th { position: sticky; top: 0; z-index: 1; }
.opt-scroll tbody th { background: transparent; text-transform: none; letter-spacing: 0; color: var(--ink); }
.opt-scroll button,
#coverage button {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
}
.opt-scroll button:hover { border-color: var(--accent); color: var(--accent); }
.opt-scroll td small { display: inline-block; margin-left: 5px; font-size: 10.5px; font-weight: 600; opacity: 0.85; }

.duration-band-0 { background: #bbf7d0; color: #14532d; }
.duration-band-1 { background: #dcfce7; color: #166534; }
.duration-band-2 { background: #fef3c7; color: #78350f; }
.duration-band-3 { background: #fed7aa; color: #7c2d12; }
.duration-band-4 { background: #fecaca; color: #7f1d1d; }

html[data-theme="dark"] .duration-band-0 { background: rgba(16, 185, 129, 0.28); color: #a7f3d0; }
html[data-theme="dark"] .duration-band-1 { background: rgba(34, 197, 94, 0.18); color: #bbf7d0; }
html[data-theme="dark"] .duration-band-2 { background: rgba(245, 158, 11, 0.22); color: #fde68a; }
html[data-theme="dark"] .duration-band-3 { background: rgba(249, 115, 22, 0.24); color: #fed7aa; }
html[data-theme="dark"] .duration-band-4 { background: rgba(239, 68, 68, 0.28); color: #fecaca; }

.duration-key { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--faint); font-weight: 600; }
.duration-key i {
  width: 76px;
  height: 9px;
  border-radius: 99px;
  background: linear-gradient(to right, #86efac, #fde68a, #fca5a5);
}
.selected-departure { background: var(--accent-soft) !important; }
.selected-departure button { background: var(--accent); border-color: var(--accent); color: #ffffff; }

.gap-marker {
  color: #b45309;
  border: 2px solid currentColor;
  box-shadow: 0 0 0 2px #ffffff;
  background: #fef3c7;
  border-radius: 50%;
  font: 700 13px/16px var(--font-sans);
  text-align: center;
}

#chartGribFiles { width: 100%; font-size: 12px; }
#legAction { margin-bottom: 10px; }

/* Method Details Card */
#method { padding: 14px 18px; }
#method summary { cursor: pointer; font-weight: 700; color: var(--ink); }
#method p, #method details, #runs {
  line-height: 1.55;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 0;
}
#stationSources { padding: 6px 0; column-width: 265px; }
#stationSources a { display: block; margin-bottom: 2px; }

/* Responsive */
@media (max-width: 900px) {
  .chart-layout { grid-template-columns: 1fr; }
  .map-card { grid-row: 1; }
  .settings { display: grid; grid-template-columns: 1fr 1fr; }
  .settings .card-head { grid-column: 1 / -1; }
  .arrivals strong { font-size: 16px; }
}
@media (max-width: 720px) {
  .inspect-controls { grid-template-columns: auto 1fr; }
}
@media (max-width: 560px) {
  .chart-page .arrivals { padding: 10px 12px; grid-template-columns: 1fr 1fr; row-gap: 10px; }
  .arrivals > div { padding: 0 8px; }
  .arrivals > div:nth-child(3) { border: 0; padding-left: 0; }
  .arrivals strong { font-size: 15px; }
  .eta-label { font-size: 10px; }
  .settings { display: block; }
  #map { height: 360px; }
}
