:root {
  --bg: #f6f4ee; --fg: #1d2430; --muted: #6b7280; --card: #fff; --line: #d9d5cb;
  --ocean: #cfe3ee; --land: #e9e2cf; --border: #b9b2a0;
  --route: #d1495b; --sun: #f6b400; --accent: #2a6f97;
  /* window-state ordinal ramp (one hue; validated light vs #fff, dark vs #1b2029) */
  --win-twilight: #f2a373; --win-high: #e0662a; --win-view: #a33c0c;
  --series-1: #2a78d6; --grid: rgba(0,0,0,.08); --band: rgba(0,0,0,.045);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --fg: #e6e8ec; --muted: #9aa3af; --card: #1b2029; --line: #2c3340;
    --ocean: #1d3344; --land: #4a4a42; --border: #6c6a5f;
    --route: #ff6b7d; --accent: #6fb7e0;
    --win-twilight: #8a3f16; --win-high: #d4631f; --win-view: #f7ae7c;
    --series-1: #3987e5; --grid: rgba(255,255,255,.09); --band: rgba(255,255,255,.05);
  }
}
* { box-sizing: border-box; }
body { margin: 0; padding: 0 16px 32px; background: var(--bg); color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; max-width: 1100px; margin-inline: auto; }
header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 18px 0 8px; }
h1 { margin: 0; font-size: 26px; display: flex; align-items: center; gap: 8px; }
h2 { font-size: 16px; margin: 20px 0 6px; }
.tag { margin: 0; color: var(--muted); }
a { color: var(--accent); }

form { display: grid; grid-template-columns: 1fr 1fr 1.4fr 1fr auto; gap: 10px; align-items: end;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
@media (max-width: 760px) {
  form { grid-template-columns: 1fr 1fr; }
  form > label:not(.ap), form button { grid-column: span 2; }
  form button { padding: 12px 16px; }
}
label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; position: relative; }
input { font: inherit; font-size: 15px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; width: 100%; }
@media (max-width: 760px) { input { font-size: 16px; } } /* 16px+ stops iOS zooming in on focus */
/* Same box for every field: date pickers otherwise add a couple of px of native padding,
   and iOS Safari draws datetime-local as a centered pill. */
form input { height: 38px; line-height: normal; }
@media (max-width: 760px) { form input { height: 42px; } }
#dep { -webkit-appearance: none; appearance: none; min-width: 0; text-align: left; }
#dep::-webkit-date-and-time-value { text-align: left; }
#dep::-webkit-datetime-edit { padding: 0; }
.ap input { text-transform: uppercase; font-weight: 600; letter-spacing: .04em; }
.dur { display: flex; align-items: center; gap: 4px; color: var(--fg); }
.dur input { width: 4.2em; }
.hint { position: absolute; top: 100%; left: 0; margin-top: 3px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; text-decoration: underline; }
form { padding-bottom: 26px; }
@media (max-width: 760px) { form label:has(.hint) { margin-bottom: 16px; } form { padding-bottom: 12px; } }
button { font: inherit; font-weight: 600; border: 0; border-radius: 6px; padding: 8px 16px; background: var(--accent); color: #fff; cursor: pointer; }

.suggest { position: absolute; top: 100%; left: 0; z-index: 10; width: max-content; min-width: min(280px, calc(100vw - 32px)); max-width: calc(100vw - 32px); margin: 2px 0 0; padding: 0; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.15); }
.suggest:empty { display: none; }
.ap + .ap .suggest { left: auto; right: 0; }
.suggest li { padding: 8px 10px; cursor: pointer; color: var(--fg); font-size: 13px; }
.suggest li b { display: inline-block; width: 3.2em; }
.suggest li:hover, .suggest li.active { background: var(--bg); }

.status { color: var(--muted); min-height: 1.4em; }
.status.err { color: var(--route); }

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; margin-bottom: 10px; }
.summary .big { grid-column: span 2; font-size: 18px; font-weight: 600; }
.summary .verdict { grid-column: span 2; font-size: 16px; padding: 8px 10px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); }
@media (max-width: 600px) { .summary { grid-template-columns: 1fr; } .summary .big, .summary .verdict { grid-column: auto; } }

.mapwrap { background: var(--ocean); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#map { display: block; width: 100%; height: auto; }
.land { fill: var(--land); stroke: var(--border); stroke-width: .4; }
.grat { fill: none; stroke: var(--fg); stroke-opacity: .08; }
.night { fill: #0a1020; fill-opacity: .16; }
.route { fill: none; stroke: var(--route); stroke-width: 2.2; stroke-dasharray: 5 4; }
.flown { fill: none; stroke: var(--route); stroke-width: 2.6; }
.apt { fill: var(--route); stroke: #fff; stroke-width: 1.2; }
.aptlabel { font: 700 12px system-ui, sans-serif; fill: var(--fg); paint-order: stroke; stroke: var(--bg); stroke-width: 3; }
.sun { fill: var(--sun); stroke: #fff; stroke-width: 1.5; }
.sunray { stroke: var(--sun); stroke-width: 1.5; }
.plane { font-size: 20px; }
.evt { fill: var(--sun); stroke: var(--fg); stroke-width: 1; }

.controls { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.controls button { width: 44px; height: 40px; padding: 0; flex: none; }
.controls input { flex: 1; min-width: 0; height: 32px; padding: 0; border: 0; background: none; accent-color: var(--accent); }
.now { margin-top: 6px; font-variant-numeric: tabular-nums; color: var(--muted); }
.now b { color: var(--fg); }

.wincard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; margin: 0 0 8px; font-size: 13px; }
.legend li { display: block; }
.legend i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }
.legend span { color: var(--muted); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; cursor: crosshair; touch-action: pan-y; }
.chart h3 { font-size: 13px; font-weight: 600; margin: 10px 0 2px; color: var(--fg); }
.axis text, .lanelabel, .bandlabel { font: 11px system-ui, sans-serif; fill: var(--muted); }
.lanelabel { font-size: 12px; fill: var(--fg); font-weight: 600; }
.bandlabel { paint-order: stroke; stroke: var(--card); stroke-width: 3px; stroke-linejoin: round; }
.axis line, .axis path, .gridline { stroke: var(--grid); }
.lanebg { fill: var(--band); }
.aheadmark { fill: var(--muted); fill-opacity: .55; }
.legend i.aheadkey { background: var(--muted); opacity: .55; height: 6px; vertical-align: 1px; }
.band { fill: var(--band); }
.horizon { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.elevline { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
.cursor { stroke: var(--fg); stroke-width: 1.5; }
.hoverline { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 2; }
.dot { fill: var(--series-1); stroke: var(--card); stroke-width: 2; }
.tip { position: absolute; top: 0; pointer-events: none; z-index: 5; background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 12px; line-height: 1.45;
  box-shadow: 0 6px 18px rgba(0,0,0,.18); white-space: nowrap; }
.k { color: var(--muted); }
.wintable { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.wintable th, .wintable td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.wintable th { color: var(--muted); font-weight: 600; font-size: 12px; }
.wintable td.num { white-space: nowrap; }
.note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
@media (max-width: 600px) {
  .wintable .hide-sm { display: none; }
  .wintable th, .wintable td { padding: 6px 4px; }
  .wincard { padding: 10px; }
  .tip { white-space: normal; width: max-content; max-width: 230px; }
}

.events { padding-left: 18px; margin: 0; }
.events li { margin: 3px 0; }
footer { margin-top: 28px; color: var(--muted); font-size: 12px; }
