:root {
  --bg: #f5f6f8; --card: #fff; --ink: #14181f; --muted: #667085; --line: #e3e6eb;
  --accent: #1f5fd6; --accent-ink: #fff; --good: #137a43; --warn: #a15c00; --err: #b42318;
  --radius: 12px; --accent-light: #eef3fc;
  /* Native controls (select popups, date pickers, calendar icons, scrollbars) follow the theme;
     without this they stay light on the dark page and their text/icons become unreadable. */
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --card: #171b21; --ink: #e8eaed; --muted: #98a2b3; --line: #2a2f37;
          --accent: #5b8cff; --good: #4cc38a; --warn: #f0a94a; --err: #f97066; --accent-light: #1e2a3f; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
header { padding: 28px 20px 8px; max-width: 980px; margin: auto; }
header h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
header p { margin: 4px 0 0; color: var(--muted); }
main { max-width: 980px; margin: auto; padding: 12px 20px 60px; }

form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }


.airport-row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 6px; }
[hidden] { display: none !important; }
.label-note { font-weight: 400; text-transform: none; letter-spacing: 0; }
.hint { margin: 4px 0 8px; }
.hint:empty { display: none; }
.airport-row .field { flex: 1; min-width: 140px; }

.grid-dates { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 6px; }

.alt-list { display: flex; gap: 8px; flex-wrap: wrap; }
.alt-row { display: flex; gap: 4px; align-items: end; margin-bottom: 6px; }
.alt-row .field { min-width: 0; width: 220px; }
.alt-row .remove-alt { background: none; border: none; color: var(--err); cursor: pointer; font-size: 20px; width: 36px; height: 42px; padding: 0; border-radius: 8px; }

.add-btn { margin: 4px 0; display: inline-block; background: none; border: 1px dashed var(--line); border-radius: 8px; padding: 6px 14px; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; }
.add-btn:hover { border-color: var(--accent); background: var(--accent-light); }

.grid-pax { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); max-width: 520px; align-items: end; }
.grid-currency { max-width: 200px; }
@media (max-width: 760px) { .swap { display: none; } .airport-row .field { min-width: 100px; } }

.field { min-width: 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.code { font-weight: 600; }
option { background-color: var(--card); color: var(--ink); }
input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
/* Consistent select look across browsers (iOS Safari otherwise draws glossy pills) */
select { -webkit-appearance: none; appearance: none; padding-right: 30px; background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23667085' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* Autocomplete dropdown */
.ac-wrap { position: relative; }
.ac-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 100; max-height: 220px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin-top: 2px; display: none; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.ac-list.show { display: block; }
.ac-item { padding: 8px 12px; cursor: pointer; font-size: 14px; }
.ac-item:hover, .ac-item.active { background: var(--accent-light); }
.ac-item .ac-code { font-weight: 700; margin-right: 8px; }
.ac-item .ac-detail { color: var(--muted); font-size: 12px; }

.swap { height: 42px; width: 42px; border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--ink); cursor: pointer; font-size: 18px; flex-shrink: 0; }
button.go { height: 42px; padding: 0 22px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
button.go:disabled { opacity: .6; cursor: not-allowed; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Segmented radio controls (radios stay focusable for keyboard users) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--muted); background: var(--card); white-space: nowrap; position: relative; }
.seg label + label { border-left: 1px solid var(--line); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -3px; box-shadow: inset 0 0 0 4px var(--card); }
.check-row { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font-size: 13px; cursor: pointer; }
.check-row input { width: 22px; height: 22px; min-height: 0; padding: 0; margin: 0; flex: none; accent-color: var(--accent); }
.check-row input:focus { outline: none; }
.check-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none; }

/* Stops section */
.stops-section { margin-top: 12px; }
.stop-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; flex-wrap: wrap; background: var(--bg); }
.stop-num { font-weight: 700; color: var(--accent); font-size: 14px; min-width: 24px; }
.stop-num::before { content: "Stop "; }
.stop-fields { display: flex; gap: 8px; align-items: end; flex: 1 1 100%; order: 1; min-width: 200px; flex-wrap: wrap; }
.stop-fields .field { flex: 1; min-width: 100px; }
.stop-fields .stop-continent { flex: 0 0 220px; }
.itin-note { color: var(--accent); }
.stop-suggest-label { color: var(--muted); font-size: 13px; padding: 10px 0; flex: 1 1 240px; }
.remove-stop { margin-left: auto; background: none; border: none; color: var(--err); cursor: pointer; font-size: 20px; padding: 4px 8px; }

/* Places to avoid */
.avoid-row { display: flex; gap: 8px; align-items: stretch; }
.avoid-row .field { flex: 1; min-width: 0; max-width: 420px; }
.avoid-row .ghost-btn { flex: 0 0 auto; }
.field-error { color: var(--err); margin-top: 4px; }
.field-error:empty { display: none; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 12px; border: 1px solid var(--err); color: var(--err); border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--card); }
.chip-remove { background: none; border: 0; color: inherit; cursor: pointer; font-size: 18px; line-height: 1; width: 28px; height: 28px; border-radius: 50%; padding: 0; }
.chip-remove:hover { background: var(--bg); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Results */
.banner { padding: 10px 14px; border-radius: 8px; margin: 14px 0 0; border: 1px solid var(--line); background: var(--card); }
.banner.err { color: var(--err); border-color: currentColor; }
.banner.info { color: var(--warn); border-color: currentColor; }
.banner + .banner { margin-top: 8px; }
.ghost-btn { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.ghost-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.ghost-btn:disabled { color: var(--good); border-color: var(--good); cursor: default; }
#results:focus { outline: none; }
.bar { display: flex; justify-content: space-between; align-items: center; margin: 20px 2px 10px; gap: 10px; flex-wrap: wrap; }
.bar .meta { color: var(--muted); }

/* Itinerary result cards */
.itin-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.itin-card.best-card { border-color: var(--good); border-width: 2px; }
.itin-header { padding: 14px 16px; display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: 8px; }
.itin-route { font-weight: 700; font-size: 17px; margin: 0 0 2px; line-height: 1.35; }
.itin-total-cost { font-size: 20px; font-weight: 700; color: var(--good); }
.sub { color: var(--muted); font-size: 13px; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid currentColor; margin-left: 6px; }
.tag.suggested { color: var(--accent); background: var(--accent-light); }
.tag.best { color: var(--good); }
.tag.cheapest { color: var(--good); background: rgba(19, 122, 67, 0.1); border-color: var(--good); }

.bar-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sort-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sort-field select { width: auto; padding: 6px 30px 6px 8px; font-size: 13px; }
.same-day { color: var(--warn); margin: 6px 0; }
.itin-details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; border-top: 1px solid var(--line); min-height: 44px; box-sizing: border-box; }
.itin-details > summary::-webkit-details-marker { display: none; }
.itin-details > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg); transition: transform .15s; flex: none; margin-right: 2px; }
.itin-details[open] > summary::before { transform: rotate(45deg); }
.itin-details > summary:hover { background: var(--accent-light); }
.itin-details > summary:focus-visible { outline-offset: -2px; }
.itin-details-title { color: var(--accent); font-weight: 600; font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .itin-details > summary::before { transition: none; } }
.itin-leg-airports { margin: 8px 0 0; display: grid; gap: 4px; font-size: 13px; }
.itin-leg-airports > div { display: flex; gap: 8px; min-width: 0; }
.itin-leg-airports dt { color: var(--muted); font-weight: 600; flex: 0 0 40px; }
.itin-leg-airports dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.itin-leg-airports .ap-place { color: var(--muted); }
.itin-leg-airports .ap-place::before { content: "— "; }
.itin-leg { padding: 12px 16px; border-top: 1px solid var(--line); }
.itin-leg-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.itin-leg-label .suggested-tag { color: var(--accent); font-style: italic; text-transform: none; letter-spacing: 0; }
.itin-leg-route { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.itin-leg-date { color: var(--muted); font-size: 13px; }
.itin-leg-cost { font-size: 15px; font-weight: 600; color: var(--good); margin: 4px 0 10px; }

.book-links { display: flex; flex-wrap: wrap; gap: 8px; }
.book-link { display: inline-flex; align-items: center; gap: 5px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; transition: background .15s, border-color .15s; }
.book-link:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.book-link svg { width: 14px; height: 14px; }
.book-link.gf, .book-link.cheap { border-color: var(--accent); background: var(--accent-light); }

.more-airlines { margin-top: 8px; }
.more-airlines summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; padding: 6px 0; width: max-content; }
.more-airlines .book-links { margin-top: 6px; }
.itin-footer { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--bg); }
.itin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
a { color: var(--accent); }
footer { color: var(--muted); font-size: 12px; margin-top: 24px; }

/* ---------- Phone layout ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, label, input, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* iOS Safari gives date inputs a wide intrinsic width that overflows grid/flex cells,
   and collapses them when empty — pin the width and height. */
input[type="date"] { min-height: 42px; display: block; -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; }
input[type="date"]::-webkit-date-and-time-value { min-height: 1.45em; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

@media (max-width: 600px) {
  header { padding: max(18px, env(safe-area-inset-top)) 16px 4px; }
  header h1 { font-size: 22px; }
  header p { font-size: 14px; }
  main { padding: 10px 12px max(40px, env(safe-area-inset-bottom)); }
  form { padding: 14px; }

  /* 16px inputs stop iOS Safari from zooming in on focus */
  input, select { font-size: 16px; padding: 11px 10px; min-height: 46px; }
  .field label { font-size: 13px; }

  .airport-row .field { min-width: 0; flex: 1 1 0; }
  .grid-dates { gap: 8px; }

  .alt-list { display: block; }
  .alt-row .field { flex: 1 1 auto; width: auto; }
  .alt-row .remove-alt, .remove-stop { width: 44px; height: 44px; padding: 0; margin: 0 0 1px; font-size: 22px; flex-shrink: 0; }

  .check-row { min-height: 44px; font-size: 14px; margin: 6px 0 4px; }
  .check-row input { min-height: 0; padding: 0; }
  .add-btn:not([hidden]) { display: block; width: 100%; padding: 12px 14px; font-size: 14px; text-align: center; }

  /* Stop cards: stack controls, full-width segmented toggles */
  .stop-row { position: relative; flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; }
  .stop-num { min-width: 0; padding-right: 48px; }
  .remove-stop { position: absolute; top: 2px; right: 2px; }
  .seg { display: flex; width: 100%; align-self: stretch; }
  .seg label { flex: 1 1 0; text-align: center; padding: 10px 4px; min-height: 44px; font-size: 13px; white-space: normal; line-height: 1.2; display: flex; align-items: center; justify-content: center; }
  .stop-fields { min-width: 0; }
  .stop-fields .field { min-width: 0; flex: 1 1 0; }
  .stop-suggest-label { padding: 2px 0; }
  .stop-fields .stop-continent { flex: 1 1 100%; }

  .grid-pax { gap: 8px; max-width: none; }
  .grid-currency { max-width: none; }
  .step { padding: 14px 0; }
  .step legend { font-size: 16px; }
  .perks li { font-size: 12px; }
  .ghost-btn { min-height: 44px; flex: 1 1 auto; }
  .bar .ghost-btn { flex: 0 1 auto; }
  .more-airlines summary { min-height: 44px; display: flex; align-items: center; }
  button.go { width: 100%; height: 50px; font-size: 16px; }

  .avoid-row .field { max-width: none; }
  .avoid-row .ghost-btn { flex: 0 0 auto; min-width: 72px; }
  .chip { min-height: 44px; font-size: 14px; padding: 0 2px 0 14px; }
  .chip-remove { width: 44px; height: 44px; font-size: 22px; }

  .ac-list { max-height: 50vh; }
  .ac-item { padding: 12px; font-size: 15px; }

  /* Results */
  .itin-header { padding: 12px 14px; }
  .itin-route { font-size: 16px; }
  .itin-leg { padding: 12px 14px; }
  .itin-details > summary { padding: 10px 14px; }
  .bar-actions { width: 100%; }
  .sort-field { flex: 1 1 100%; font-size: 14px; }
  .sort-field select { flex: 1; font-size: 16px; min-height: 44px; }
  .itin-leg-airports .ap-place { display: block; }
  .itin-leg-airports .ap-place::before { content: none; }
  .itin-leg-route { font-size: 15px; }
  .book-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .book-link { justify-content: center; text-align: center; min-height: 44px; padding: 8px 10px; }
  .book-link.gf, .book-link.cheap { grid-column: 1 / -1; font-size: 14px; }
  .itin-footer { padding: 10px 14px; }
}

@media (max-width: 360px) {
  .grid-dates { grid-template-columns: 1fr; }
  .grid-pax { grid-template-columns: 1fr; }
  .stop-fields { flex-direction: column; align-items: stretch; }
}

.about { margin-top: 32px; }
.about h2 { font-size: 18px; margin: 0 0 8px; }
.about p { margin: 0 0 10px; color: var(--muted); }
.about details { border-top: 1px solid var(--line); padding: 4px 0; }
.about summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.about details p { margin-top: 4px; }

.not-found { text-align: center; padding: 60px 0; }
.not-found a { color: var(--accent); }

/* Static guide pages (routes/) */
.site-name { margin: 0; font-size: 20px; font-weight: 700; }
.site-name a { color: var(--ink); text-decoration: none; }
.guide { line-height: 1.6; }
.guide a { color: var(--accent); }
.guide h1 { font-size: 28px; line-height: 1.2; margin: 8px 0 12px; letter-spacing: -0.01em; }
.guide h2 { font-size: 20px; margin: 28px 0 8px; }
.guide .lead { font-size: 16px; }
.guide th .sub { display: block; font-weight: 400; }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: 4px; }
.cta-row { margin: 18px 0; }
.guide .cta { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 18px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.guide .cta:hover { filter: brightness(1.08); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.guide table { border-collapse: collapse; width: 100%; font-size: 14px; }
.guide th, .guide td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.guide thead th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.guide tbody tr:last-child > * { border-bottom: none; }
.guide td a { display: inline-block; padding: 2px 0; white-space: nowrap; }
.link-list { padding-left: 20px; }
.link-list li { margin: 6px 0; }
.link-list a { display: inline-block; min-height: 24px; }
.about .more { margin-top: 12px; }
.about a { color: var(--accent); }
@media (max-width: 600px) {
  .guide h1 { font-size: 24px; }
  .guide table, .guide thead, .guide tbody, .guide tr, .guide th, .guide td { display: block; }
  .guide thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .guide tbody tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .guide tbody tr:last-child { border-bottom: none; }
  .guide tbody th, .guide tbody td { padding: 2px 0; border: none; }
  .guide tbody td:nth-of-type(1)::before { content: "Extra distance: "; color: var(--muted); }
  .guide tbody td:nth-of-type(2)::before { content: "Flying time: "; color: var(--muted); }
  .guide tbody td:nth-of-type(3)::before { content: "Est. fare from: "; color: var(--muted); }
  .guide td a { min-height: 44px; display: inline-flex; align-items: center; }
}

/* Form steps */
.hero .tagline { font-size: 16px; color: var(--muted); margin: 6px 0 10px; max-width: 640px; }
.perks { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.perks li { font-size: 13px; color: var(--good); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.perks li::before { content: "✓ "; }
.step { border: 0; margin: 0; padding: 16px 0; min-width: 0; border-bottom: 1px solid var(--line); }
.step:first-of-type { padding-top: 0; }
.step legend { float: left; width: 100%; display: flex; align-items: center; gap: 10px; padding: 0; margin-bottom: 10px; font-size: 17px; font-weight: 650; color: var(--ink); }
.step legend .label-note { font-size: 13px; color: var(--muted); font-weight: 400; }
.step-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 700; flex: none; }
.step legend + * { clear: both; }
.step-hint { margin-top: 0; }
.sub-heading { font-size: 14px; font-weight: 600; margin: 16px 0 4px; }
.sub-heading:first-child { margin-top: 4px; }
.more-options { border-bottom: 1px solid var(--line); }
.more-options > summary { cursor: pointer; min-height: 52px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 8px 0; list-style: none; }
.more-options > summary::-webkit-details-marker { display: none; }
.more-options > summary::before { content: "›"; display: inline-block; width: 26px; text-align: center; font-size: 22px; line-height: 1; color: var(--accent); transition: transform .15s; }
.more-options[open] > summary::before { transform: rotate(90deg); }
.more-title { font-weight: 650; font-size: 16px; }
.more-options.in-use #more-summary { color: var(--accent); font-weight: 600; }
.more-body { padding: 0 0 16px 36px; }
.go-row { margin-top: 18px; display: flex; justify-content: flex-end; }
button.go { min-width: 200px; height: 48px; font-size: 16px; }
.results-note { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
@media (max-width: 600px) {
  .more-body { padding-left: 0; }
  .go-row { position: sticky; bottom: 0; margin: 12px -14px -14px; padding: 12px 14px max(12px, env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); z-index: 5; }
  button.go { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .more-options > summary::before { transition: none; } }
