:root {
  --bg: #0b1220;
  --panel: #0f1729;
  --raised: #1c2842;
  --border: #22304d;
  --line: #1a2540;
  --text: #e6edf7;
  --muted: #8b9ab0;
  --accent: #22d3ee;
  --accent-ink: #042029;
  --ok: #a3e635;
  --adv: #a78bfa;
  --warn: #fbbf24;
  --danger: #f87171;
  --pad-ink: #22d3ee;
  --pad-grid: rgba(148, 163, 184, .1);
  --pad-hint: #64748b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
header.top {
  display: flex; align-items: center; gap: 16px;
  height: 52px; padding: 0 20px; flex: none;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
header.top h1 { font-size: 18px; margin: 0; letter-spacing: .2px; flex: none; }
header.top h1 span { color: var(--accent); }
header.top p { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Layout */
main { flex: 1; display: grid; grid-template-columns: 380px 1fr; min-height: 0; }
aside { overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 0 20px 20px; }
.map-wrap { position: relative; min-height: 0; }
#map { height: 100%; min-height: 420px; background: #0a0f1a; }

/* Steps */
section.step { padding: 20px 0; border-bottom: 1px solid var(--line); }
section.step h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 15px; font-weight: 600; }
section.step h2 .n {
  display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 600;
}
.sub { margin: 8px 0 14px; font-size: 13px; color: var(--muted); }
#placeRef:not(:empty) { color: var(--text); }
#placeRef:not(:empty)::after { content: ' · '; color: var(--muted); }

/* Airport search */
.airport-search { position: relative; }
.airport-search input[type=search] { padding-left: 32px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b9ab0' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6'/%3E%3Cpath d='M20 20l-4.5-4.5'/%3E%3C/svg%3E") no-repeat 10px 50% / 15px; }
.airport-search input[type=search]::-webkit-search-cancel-button { filter: invert(.6); }
.results {
  position: absolute; z-index: 1000; left: 0; right: 0; top: calc(100% + 4px); max-height: 300px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
}
.results li { display: grid; grid-template-columns: 56px 1fr; column-gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.results li b { font-variant-numeric: tabular-nums; }
.results li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results li small { grid-column: 2; color: var(--muted); font-size: 12px; }
.results li[aria-selected="true"], .results li:hover { background: var(--raised); }
.results li.note { display: block; color: var(--muted); cursor: default; }
.results li.note:hover { background: none; }

/* Each step's collapsed "Advanced" section */
details.more { margin-top: 14px; }
details.more > summary {
  display: inline-flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; user-select: none;
  font-size: 12px; color: var(--muted);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before {
  content: ''; width: 5px; height: 5px; margin: 0 2px 0 1px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s;
}
details.more[open] > summary::before { transform: rotate(45deg); margin-top: -3px; }
details.more > summary:hover, details.more[open] > summary { color: var(--text); }
.changed { padding: 0 6px; border-radius: 9px; font-size: 11px; color: var(--adv); background: rgba(167, 139, 250, .12); }
.more-body { margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--adv); }
.more-body > * + * { margin-top: 10px; }
.more-body > :first-child { margin-top: 0; }
.more-body .reset { font-size: 12px; }

/* Controls */
.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin-bottom: 12px;
  padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.tabs button {
  background: none; border: 0; border-radius: 7px; padding: 6px 0;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--raised); color: var(--text); font-weight: 600; }
.tabpanel { display: none; }
.tabpanel.active { display: block; }
.tabpanel > * + * { margin-top: 8px; }

label.field { display: block; margin: 0; font-size: 12px; color: var(--muted); }
label.field > span { display: flex; justify-content: space-between; margin-bottom: 4px; }
label.field output { color: var(--text); font-variant-numeric: tabular-nums; }
label.field.inline { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
label.field.inline > span { margin: 0; }
.unit-input { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.unit-input input { width: 76px; text-align: right; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }

input[type=text], input[type=search], input[type=number], textarea, select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { display: block; resize: vertical; min-height: 56px; font-size: 17px; }
input[type=range] { width: 100%; margin: 4px 0 0; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); margin: 0; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 10px; }
.split label.check { margin: 0; }

button.btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 8px 12px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
button.btn:hover { filter: brightness(1.08); }
button.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); font-weight: 500; }
button.btn.secondary:hover { filter: none; border-color: var(--muted); }
button.btn.wide { display: block; width: 100%; padding: 12px 14px; border-radius: 10px; font-size: 15px; }
button.btn small { font-weight: 500; opacity: .65; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

canvas#pad {
  width: 100%; height: 220px; display: block; touch-action: none; cursor: crosshair;
  background: var(--bg); border: 1px dashed var(--border); border-radius: 8px;
}

.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.presets button {
  display: grid; justify-items: center; gap: 4px; padding: 8px 4px; cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 11px;
}
.presets button:hover { border-color: var(--border); color: var(--text); }
.presets button.active { border-color: var(--accent); color: var(--text); }
.presets svg { width: 40px; height: 40px; stroke: var(--accent); fill: none; stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; }

.drop {
  display: block; cursor: pointer; padding: 18px; text-align: center; color: var(--muted); font-size: 13px;
  border: 1px dashed var(--border); border-radius: 8px;
}
.drop.over { border-color: var(--accent); color: var(--text); }
.drop input { display: none; }

/* Check the flight */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; margin-top: 14px; }
.stat .k { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--muted); }

.checks { list-style: none; margin: 14px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.checks li { display: flex; gap: 10px; margin-top: 6px; }
.checks li::before { content: ''; flex: none; width: 7px; height: 7px; margin-top: 7px; border-radius: 50%; background: var(--muted); }
.checks li.ok::before { background: var(--ok); }
.checks li.warn { color: var(--text); }
.checks li.warn::before { background: var(--warn); }
.checks li.bad { color: var(--text); }
.checks li.bad::before { background: var(--danger); }

/* Load it into your GPS */
#exports { margin-top: 12px; }
.plan + .plan { margin-top: 10px; }
.plan .title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.plan .title b { color: var(--text); font-weight: 600; }
.formats { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.formats button { padding: 5px 9px; }
.formats .plan-label { font-size: 12px; color: var(--muted); min-width: 44px; }
.howto { margin: 12px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.howto li + li { margin-top: 4px; }
.howto b { color: var(--text); font-weight: 600; }
.safety { margin: 14px 0 0; padding-left: 10px; border-left: 2px solid var(--warn); font-size: 12px; color: var(--muted); }
.safety b { color: var(--text); font-weight: 600; }

details.tips { margin-top: 16px; font-size: 13px; color: var(--muted); }
details.tips summary { cursor: pointer; color: var(--text); }
details.tips ul { margin: 8px 0 0; padding-left: 18px; }
details.tips li + li { margin-top: 6px; }
details.tips b { color: var(--text); font-weight: 600; }
.credits { margin: 16px 0 0; font-size: 11px; color: var(--muted); }
.credits a { color: inherit; }

.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* Map */
.map-legend {
  position: absolute; z-index: 800; top: 10px; right: 10px; max-width: calc(100% - 70px);
  display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 10px; border-radius: 8px; pointer-events: none;
  background: rgba(15, 23, 41, .9); border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.legend-items { display: contents; }
.swatch { display: inline-block; width: 16px; height: 0; vertical-align: middle; margin-right: 6px; }
.swatch.draw { border-top: 3px solid var(--accent); }
.swatch.hop { border-top: 2px dashed var(--warn); }

.leaflet-container { font: inherit; }
.leaflet-bar, .leaflet-touch .leaflet-bar { border: 1px solid var(--border); box-shadow: none; border-radius: 8px; overflow: hidden; }
.leaflet-bar a, .leaflet-touch .leaflet-bar a { background: var(--panel); color: var(--text); border-bottom: 1px solid var(--line); }
.leaflet-bar a:hover { background: var(--raised); color: var(--text); }
.leaflet-bar a:last-child { border-bottom: 0; }
.map-actions a { display: flex; align-items: center; justify-content: center; }
.leaflet-container .leaflet-control-attribution { background: rgba(15, 23, 41, .8); color: var(--muted); }
.leaflet-container .leaflet-control-attribution a { color: var(--muted); }
.leaflet-control-scale-line { background: rgba(15, 23, 41, .8); color: var(--muted); border-color: var(--muted); }
.leaflet-tooltip.wp { background: rgba(11, 18, 32, .9); color: var(--text); border: 1px solid var(--border); font-size: 11px; padding: 2px 5px; box-shadow: none; }
.leaflet-tooltip.wp::before { display: none; }
.leaflet-tooltip.apt { background: rgba(15, 23, 41, .9); color: var(--text); border: 1px solid var(--border); font-size: 11px; font-weight: 600; padding: 1px 5px; box-shadow: none; }
.leaflet-tooltip.apt::before { display: none; }

/* Phones and small tablets: map on top so every change is visible straight
   away, then the steps; the page scrolls as a whole. */
@media (max-width: 900px) {
  html, body { height: auto; }
  main { display: flex; flex-direction: column; }
  .map-wrap { order: -1; height: 45vh; min-height: 280px; }
  #map { min-height: 0; }
  aside { border-right: 0; overflow: visible; padding: 0 16px 20px; }
  header.top { padding: 0 16px; }
  header.top p { display: none; }
}
