:root {
  --bg: #08131b;
  --bg-2: #05121a;
  --surface: #0e1d28;
  --surface-2: #132634;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #e4edf2;
  --muted: #8ea3b0;
  --faint: #5d7280;
  --accent: #5cc0de;
  --accent-ink: #08131b;
  --accent-soft: rgba(92, 192, 222, 0.14);
  --good: #4fd18b;
  --warn: #f2b84b;
  --bad: #f27979;
  --radius: 6px;
  --panel-w: 480px;
  --top-h: 56px;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- top bar ---- */
.topbar {
  height: var(--top-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 24px; height: 24px; }
.topsearch { position: relative; flex: 0 1 340px; display: flex; align-items: center; }
.topsearch > svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.topsearch input {
  width: 100%; height: 34px; padding: 0 12px 0 32px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid transparent; border-radius: var(--radius);
  color: #fff; font: inherit; font-size: 14px;
}
.topsearch input:focus { border-color: var(--line-2); outline: none; background: rgba(255, 255, 255, 0.09); }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--text); font-size: 14px; padding: 6px 10px; border-radius: var(--radius); white-space: nowrap; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav a.active { color: var(--accent); }
.account { margin-left: auto; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.menu-btn { display: none; background: none; border: 0; width: 36px; height: 36px; padding: 6px; margin-left: 4px; }
.menu-btn svg { width: 24px; height: 24px; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px;
  border-radius: 9px; background: var(--good); color: var(--accent-ink);
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---- suggest dropdown ---- */
.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); overflow: hidden; display: none;
}
.suggest.open { display: block; }
.suggest button {
  display: flex; width: 100%; gap: 10px; align-items: baseline; text-align: left;
  padding: 8px 12px; background: none; border: 0; cursor: pointer;
}
.suggest button:hover, .suggest button.hl { background: var(--accent-soft); }
.suggest .code { font-family: var(--mono); color: var(--accent); width: 34px; flex: none; }
.suggest .sub { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }

/* ---- layout ---- */
.layout { display: flex; height: calc(100dvh - var(--top-h)); }
.panel {
  width: var(--panel-w); flex: none; overflow-y: auto; overscroll-behavior: contain;
  padding: 28px 24px 40px; border-right: 1px solid var(--line); background: var(--bg);
  outline: none;
}
.globe-wrap { position: relative; flex: 1; min-width: 0; background: radial-gradient(ellipse at center, #0c2231 0%, var(--bg) 70%); overflow: hidden; }
#globe { position: absolute; inset: 0; }
.globe-hint { position: absolute; bottom: 12px; right: 16px; font-size: 12px; color: var(--faint); pointer-events: none; }
.globe-legend { position: absolute; top: 14px; right: 16px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); pointer-events: none; }
.globe-legend span { display: flex; align-items: center; gap: 6px; }
.globe-legend i { display: inline-block; width: 18px; height: 2px; border-radius: 1px; }

/* ---- type ---- */
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
h1 { font-size: 40px; line-height: 1.1; font-weight: 600; margin: 0 0 14px; letter-spacing: -0.01em; }
h1 .accent { color: var(--accent); display: block; }
h2 { font-size: 22px; font-weight: 600; margin: 0 0 6px; }
h3 { font-size: 14px; font-weight: 600; margin: 28px 0 10px; color: var(--text); }
.lede { color: var(--muted); margin: 0 0 22px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.disclaimer { color: var(--faint); font-size: 12px; margin-top: 24px; }

/* ---- forms ---- */
.search-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 4px; position: relative; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select {
  height: 38px; padding: 0 10px; width: 100%;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: 14px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field .hint { font-size: 12px; color: var(--faint); }
.swap {
  position: absolute; right: -17px; top: 27px; z-index: 2; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line-2); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.swap svg { width: 14px; height: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line-2);
  background: transparent; color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; }
.btn.big { height: 40px; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.error { color: var(--bad); font-size: 13px; margin: 0; }

/* ---- cards & lists ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-2);
  background: transparent; cursor: pointer; color: var(--text);
}
.chip:hover { border-color: var(--accent); }
.deal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.deal {
  display: grid; gap: 2px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; text-align: left;
}
.deal:hover { border-color: var(--accent); text-decoration: none; }
.deal .city { font-weight: 500; }
.deal .meta { font-size: 12px; color: var(--muted); }
.deal .price { font-family: var(--mono); color: var(--accent); font-size: 15px; }

.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 4px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.fact b { display: block; font-family: var(--mono); font-size: 15px; font-weight: 500; }
.fact span { font-size: 11px; color: var(--muted); }

.fare-list { display: grid; gap: 6px; }
.fare {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; width: 100%;
}
.fare:hover, .fare.sel { border-color: var(--accent); }
.fare .al { font-weight: 500; }
.fare .info { font-size: 12px; color: var(--muted); grid-column: 1; }
.fare .price { font-family: var(--mono); font-size: 17px; grid-row: 1 / span 2; grid-column: 2; text-align: right; }
.fare .tag { font-size: 11px; color: var(--good); display: block; }

.route-head { display: flex; align-items: center; gap: 10px; }
.route-head .codes { font-family: var(--mono); font-size: 30px; font-weight: 500; letter-spacing: 0.02em; }
.route-head .arrow { color: var(--accent); }

.watch-box { margin-top: 18px; padding: 12px; border-radius: 10px; border: 1px dashed var(--line-2); display: grid; gap: 10px; }

.watch {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); margin-bottom: 8px;
}
.watch.hit { border-color: var(--good); }
.watch .title { font-weight: 500; }
.watch .title a { color: var(--text); }
.watch .sub { font-size: 12px; color: var(--muted); }
.watch .now { font-family: var(--mono); font-size: 18px; text-align: right; }
.watch .delta { font-size: 12px; text-align: right; }
.watch .actions { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; }
.status.good { color: var(--good); }
.status.warn { color: var(--warn); }
.down { color: var(--good); }
.up { color: var(--bad); }

/* ---- charts ---- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .bar { fill: var(--accent); opacity: 0.55; }
.chart .bar.min { opacity: 1; }
.chart .bar.sel { fill: #fff; opacity: 1; }
.chart .hit:hover + .bar, .chart g:hover .bar { opacity: 1; }
.chart .axis { fill: var(--faint); font-size: 10px; font-family: var(--mono); }
.chart .grid { stroke: var(--line); }
.tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, -100%);
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 8px;
  font-size: 12px; white-space: nowrap; display: none; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
.tip b { font-family: var(--mono); font-weight: 500; }
.spark { width: 120px; height: 32px; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark path.target { stroke: var(--good); stroke-width: 1; stroke-dasharray: 3 3; }
.spark circle { fill: var(--accent); }

/* ---- agent ---- */
.chat { display: grid; gap: 10px; margin: 16px 0; }
.msg { padding: 10px 12px; border-radius: 10px; max-width: 92%; white-space: pre-wrap; }
.msg.user { background: var(--accent-soft); justify-self: end; }
.msg.assistant { background: var(--surface); border: 1px solid var(--line); }
.msg .steps { font-size: 11px; color: var(--faint); margin-top: 6px; font-family: var(--mono); white-space: normal; }
.proposal { border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; background: var(--surface); }
.proposal .kv { font-size: 13px; }
.proposal .kv span { color: var(--muted); }
.chat-input { display: flex; gap: 8px; position: sticky; bottom: -40px; padding: 10px 0 0; background: var(--bg); }
.chat-input textarea {
  flex: 1; min-height: 40px; max-height: 140px; resize: vertical; padding: 9px 10px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--text); font: inherit; font-size: 14px;
}
.typing { color: var(--muted); font-size: 13px; }
.typing::after { content: '…'; animation: blink 1s steps(3) infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

/* ---- dialog / toast ---- */
.dialog {
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--text);
  padding: 22px; width: min(380px, calc(100vw - 32px));
}
.dialog::backdrop { background: rgba(2, 8, 12, 0.7); }
.dialog form { display: grid; gap: 12px; }
.dialog h2 { margin: 0; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 14px; font-size: 14px;
  transition: 0.2s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
details.table-view summary { cursor: pointer; font-size: 12px; color: var(--muted); margin-top: 8px; }

.empty { padding: 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 10px; }

/* ---- onboarding, toggles, compare ---- */
.progress { height: 4px; border-radius: 2px; background: var(--line); margin: 0 0 16px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width 0.25s; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: block; padding: 12px; border-radius: 8px; border: 1px solid var(--line-2); font-size: 14px; height: 100%; }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 4px 0; }
.toggle input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.toggle b { font-weight: 500; display: block; font-size: 14px; }
.toggle small { color: var(--muted); font-size: 12px; }
.compare { display: grid; gap: 4px; }
.cmp-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.cmp-row b { font-family: var(--mono); font-weight: 500; }
.cmp-row.best { border-color: var(--good); }
.cmp-row.best b::after { content: ' best'; font-family: inherit; font-size: 11px; color: var(--good); }
.topbar, .layout { max-width: 100vw; }
.topsearch { min-width: 0; }

/* ---- round trips ---- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line-2); justify-self: start; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span, .seg a { display: block; padding: 5px 12px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg input:checked + span, .seg a.on { background: var(--accent-soft); color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg.sm span, .seg.sm a { padding: 3px 10px; font-size: 12px; }
.field.off { opacity: 0.4; }
h4.sub { font-size: 12px; font-weight: 500; color: var(--muted); margin: 12px 0 6px; }
.trip-total { margin-top: 14px; padding: 12px; border-radius: 10px; border: 1px solid var(--accent); background: var(--surface); display: grid; gap: 4px; }
.trip-total:empty { display: none; }
.trip-total b { display: block; font-family: var(--mono); font-size: 22px; font-weight: 500; }

/* ---- frequent flyer + booking ---- */
.ff-badge { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 500; color: var(--accent); background: var(--accent-soft); vertical-align: 1px; }
.fare { cursor: pointer; }
.fare:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fare .fare-book { grid-column: 1 / -1; display: none; padding-top: 6px; }
.fare.sel .fare-book { display: block; }
.fare .book { font-size: 13px; font-weight: 500; }
.ff-pick { display: grid; gap: 8px; }
.trip-total .btn { margin-top: 4px; }

/* ---- live fares ---- */
.live-box { margin-top: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--good); background: var(--surface); display: grid; gap: 8px; }
.live-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(79, 209, 139, 0.2); }
.live-box .fare { background: var(--bg); }
.insight { margin: 0; }
.insight.low { color: var(--good); }
.insight.high { color: var(--warn); }
.live-none { margin: 12px 0 0; }
.live-tag { font-size: 10px; font-family: inherit; color: var(--good); border: 1px solid var(--good); border-radius: 4px; padding: 0 4px; vertical-align: 2px; }
.fare .fare-book .book + .book { margin-left: 12px; }

/* ---- phone pieces (hidden on desktop) ---- */
.tabbar, .bookbar, .globe-toggle { display: none; }
.hint-touch { display: none; }
@media (hover: none) { .hint-mouse { display: none; } .hint-touch { display: inline; } }
.suggest { max-height: min(50vh, 360px); overflow-y: auto; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .topsearch { flex-basis: 220px; }
  .nav a { padding: 6px 7px; }
}
@media (max-width: 900px) {
  :root { --tab-h: 58px; --safe-b: env(safe-area-inset-bottom, 0px); }
  body { overflow: auto; }
  .topbar { position: sticky; top: 0; gap: 10px; padding-top: env(safe-area-inset-top, 0px); height: calc(var(--top-h) + env(safe-area-inset-top, 0px)); }
  .nav { display: none; }
  .topsearch { flex: 1; }
  .brand { font-size: 0; gap: 0; }
  .brand svg { width: 30px; height: 30px; }
  .account { margin-left: 0; }
  .account .btn { padding: 0 10px; }
  .account .btn svg + * { display: none; }

  /* globe: a compact band you can expand */
  .layout { flex-direction: column-reverse; height: auto; }
  .globe-wrap { height: clamp(190px, 30vh, 290px); flex: none; transition: height 0.25s; }
  body.map-open .globe-wrap { height: calc(100dvh - var(--top-h) - var(--tab-h) - var(--safe-b)); }
  .globe-toggle {
    display: inline-flex; align-items: center; gap: 6px; position: absolute; left: 12px; bottom: 10px; z-index: 3;
    height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line-2);
    background: rgba(8, 19, 27, 0.8); color: var(--text); font-size: 13px; cursor: pointer;
  }
  .globe-toggle svg { width: 16px; height: 16px; }
  .globe-hint { bottom: 18px; }
  .globe-legend { top: 10px; right: 12px; }

  .panel { width: 100%; border-right: 0; padding: 18px 16px calc(var(--tab-h) + var(--safe-b) + 28px); overflow: visible; }
  body.has-bookbar .panel { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 96px); }
  h1 { font-size: 30px; margin-bottom: 16px; }
  .lede { display: none; }
  h2 { font-size: 20px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .route-head { flex-wrap: wrap; row-gap: 8px; }
  .route-head .codes { font-size: 26px; }

  /* comfortable tap targets; 16px text stops iPhones zooming into fields */
  .field input, .field select, .chat-input textarea, .topsearch input { font-size: 16px; }
  .field input, .field select { height: 46px; }
  .topsearch input { height: 38px; }
  .btn { height: 42px; }
  .btn.sm { height: 36px; }
  .btn.big { height: 48px; font-size: 16px; }
  .chip { padding: 8px 12px; font-size: 14px; }
  .seg span, .seg a { padding: 8px 14px; font-size: 14px; }
  .fare { padding: 12px; }
  .fare .book { display: inline-block; padding: 6px 0; }
  .toggle { padding: 8px 0; }
  .toggle input { width: 22px; height: 22px; }

  /* From / To stack with the swap button between them */
  .pair { grid-template-columns: 1fr; }
  .pair .swap { display: grid; right: 12px; top: auto; bottom: -22px; width: 34px; height: 34px; }
  .pair .swap svg { transform: rotate(90deg); width: 16px; height: 16px; }

  /* bottom navigation */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--bg-2); border-top: 1px solid var(--line);
  }
  .tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 500; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .badge { position: absolute; top: 5px; left: calc(50% + 6px); }

  /* selected flight + booking, pinned above the tab bar */
  .bookbar {
    position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 39;
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    background: var(--surface-2); border-top: 1px solid var(--line-2); box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  }
  .bookbar[hidden] { display: none; }
  .bookbar .bb-info { flex: 1; min-width: 0; display: grid; }
  .bookbar .bb-info b { font-family: var(--mono); font-size: 18px; font-weight: 500; }
  .bookbar .bb-info span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bookbar .btn { height: 40px; }

  .chat-input { bottom: calc(var(--tab-h) + var(--safe-b)); padding-bottom: 10px; }
  .toast { bottom: calc(var(--tab-h) + var(--safe-b) + 16px); }
  body.has-bookbar .toast { bottom: calc(var(--tab-h) + var(--safe-b) + 84px); }
  .trip-total .row .btn { flex: 1; }
}
@media (max-width: 360px) {
  .deal-grid { grid-template-columns: 1fr; }
  .facts b { font-size: 14px; }
}

/* ---- settings groups ---- */
.settings { display: grid; gap: 12px; }
.settings .group { margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); display: grid; gap: 10px; min-width: 0; }
.settings legend { padding: 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.save-row { display: flex; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; padding: 10px 0; background: var(--bg); }
@media (max-width: 900px) {
  .save-row { bottom: calc(var(--tab-h) + var(--safe-b)); }
  .save-row .btn { flex: 1; }
}

/* ---- phone fixes ---- */
.field input[type=date] { min-width: 0; }
@media (max-width: 900px) {
  .topsearch { flex: 1 1 0; min-width: 0; }
  .account { flex: none; }
  .field input[type=date] { padding: 0 8px; }
  .grid2 { gap: 8px; }
}

/* ---- pick airports on the globe ---- */
.field.map-target input { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.map-target > span::after { content: ' · map fills this'; color: var(--accent); font-size: 11px; }
.field.flash input { animation: flash 0.7s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: var(--bg); } }
.map-hint { margin: 0; font-size: 12px; color: var(--faint); }
#globe canvas { cursor: crosshair; }

.suggest-head { margin: 14px 0 6px; }

/* ---- multi-city ---- */
.multi { display: grid; gap: 10px; }
.legs { display: grid; gap: 10px; }
.leg { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--bg); display: grid; gap: 8px; }
.leg-head { display: flex; align-items: center; justify-content: space-between; }
.leg-n { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.leg-grid { display: grid; grid-template-columns: 1fr 1fr 130px; gap: 8px; }
.add-leg { justify-self: start; }
.multi-codes { font-size: 22px; line-height: 1.3; }
.leg-card { margin-top: 18px; }
.leg-card h3 { margin: 0 0 4px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.leg-src { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.gap-note { margin: 8px 0 0; padding-left: 10px; border-left: 2px dashed var(--line-2); }
@media (max-width: 900px) {
  .leg-grid { grid-template-columns: 1fr 1fr; }
  .leg-grid .field:last-child { grid-column: 1 / -1; }
  .multi-codes { font-size: 18px; }
}
/* ---- share ---- */
.share { display: grid; gap: 12px; }
.share h2 { margin: 0; }
.share-text { margin: 0; white-space: pre-wrap; font: 13px/1.5 var(--mono); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 40vh; overflow: auto; }
.share-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#shareRoute { margin-left: 4px; }

/* ---- AI analysis ---- */
.ai-box { margin-top: 12px; padding: 12px; border-radius: 10px; border: 1px solid rgba(199, 166, 255, 0.45); background: var(--surface); display: grid; gap: 6px; }
.ai-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: #08131b; background: #c7a6ff; border-radius: 4px; padding: 1px 5px; }
.verdict { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.verdict.good { color: var(--good); }
.verdict.neutral { color: var(--accent); }
.verdict.warn { color: var(--warn); }
.ai-headline { margin: 0; font-weight: 500; }
.ai-reasons { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.ai-line { flex-basis: 100%; order: 5; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ai-line:empty { display: none; }

/* ---- admin ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 2px; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi b { font-family: var(--mono); font-size: 22px; font-weight: 500; }
.kpi small { font-size: 11px; color: var(--faint); }
.admin-chart { margin-top: 10px; }
.admin-chart .bar-v { fill: var(--accent); opacity: 0.35; }
.admin-chart .bar-a { fill: var(--accent); }
.admin-chart .legend { display: flex; gap: 14px; color: var(--muted); margin-top: 4px; }
.admin-chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.sw-v { background: rgba(92, 192, 222, 0.35); } .sw-a { background: var(--accent); }
.filter { flex: 1; min-width: 160px; height: 34px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--text); font: inherit; font-size: 14px; }
.table-scroll { overflow-x: auto; }
table.users td { vertical-align: middle; white-space: nowrap; }
table.users .who { display: flex; gap: 8px; align-items: center; }
table.users .who img, .sm-av { width: 28px; height: 28px; border-radius: 50%; }
table.users .actions { display: flex; gap: 4px; }
.btn.danger { color: var(--bad); }
body:has(#view .kpis) { --panel-w: 760px; }
@media (max-width: 900px) { .kpi b { font-size: 18px; } }

/* ---- my travels ---- */
.travel-kpis { margin-top: 14px; }
.cand-list, .trip-list { display: grid; gap: 6px; }
.cand { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px dashed #f2b84b; border-radius: 8px; background: var(--surface); }
.trip-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 900px) { .trip-row { grid-template-columns: 1fr auto; } .trip-row .small.muted { grid-column: 1; } }
.travel-kpis .kpi b { font-size: 18px; white-space: nowrap; }

/* ---- trip import ---- */
.import-box { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.imp { display: grid; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); cursor: pointer; font: inherit; }
.imp:hover { border-color: var(--accent); }
.imp span { font-size: 12px; color: var(--muted); }
#impStatus:empty { display: none; }
@media (max-width: 420px) { .import-grid { grid-template-columns: 1fr; } }

/* ---- account menu ---- */
.account { position: relative; }
button.avatar { border: 0; padding: 0; cursor: pointer; }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 230px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 6px; display: grid;
}
.account-menu[hidden] { display: none; }
.account-menu a, .account-menu button { display: block; text-align: left; padding: 10px 12px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; }
.account-menu a:hover, .account-menu button:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.am-who { display: flex; gap: 10px; align-items: center; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.am-who div, .account-card div { display: grid; min-width: 0; }
.am-who span:not(.avatar), .account-card div span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.am-signout { color: var(--bad) !important; border-top: 1px solid var(--line) !important; margin-top: 4px; border-radius: 0 0 6px 6px !important; }
.account-card { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.account-card div { flex: 1; }
.account-card .avatar img, .am-who .avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---- time machine ---- */
.tm-start { margin: 6px 0 4px; }
.tm {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6; width: min(460px, calc(100% - 24px));
  background: rgba(8, 19, 27, 0.88); backdrop-filter: blur(6px); border: 1px solid rgba(242, 184, 75, 0.5); border-radius: 12px;
  padding: 12px 14px; display: grid; gap: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.tm[hidden] { display: none; }
.tm-top { display: flex; align-items: center; }
.tm-badge { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #f2b84b; }
.tm-x { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 2px 6px; }
.tm-date { font-size: 22px; font-weight: 600; }
.tm-trip { font-size: 14px; }
.tm-trip b { font-family: var(--mono); font-weight: 500; color: #f2b84b; }
.tm-stats { font-size: 12px; color: var(--muted); }
.tm input[type=range] { width: 100%; accent-color: #f2b84b; }
.tm-years { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); font-family: var(--mono); }
.tm-years:empty { display: none; }
.tm-ctrl { display: flex; gap: 8px; align-items: center; justify-content: center; }
.tm-ctrl button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-size: 15px; cursor: pointer; }
.tm-ctrl .tm-play { width: 48px; height: 48px; background: #f2b84b; color: #08131b; border-color: #f2b84b; font-size: 18px; }
.tm-ctrl select { height: 34px; background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 6px; }
@media (max-width: 900px) { .tm { bottom: 54px; } .tm-date { font-size: 18px; } }

/* ======================================================================
   Readability pass: contrast, type scale, spacing, tap targets.
   Kept last so it wins over earlier component rules.
   ====================================================================== */
:root {
  --muted: #a3b5c1;   /* ~8:1 on the background */
  --faint: #8396a4;   /* ~5:1, passes WCAG AA for small text */
}
body { line-height: 1.55; }
.small, .meta, .info, .hint, .map-hint, .disclaimer, .sub, .fare .info, .deal .meta, .cmp-row .small,
.toggle small, .field > span, h4.sub, .tm-stats, .kpi small, .legend, .ai-reasons, table.data { font-size: 13px; }
.disclaimer { line-height: 1.5; }
.tag, .ff-badge, .verdict, .live-tag, .ai-badge, .tm-badge { font-size: 11.5px; }
.eyebrow { font-size: 12.5px; }
.fare .al { font-size: 15px; }
.fare .price { font-size: 18px; }
.fare .info { margin-top: 2px; line-height: 1.45; }
.fare-list { gap: 8px; }
h3 { font-size: 15px; margin: 30px 0 10px; }
.panel > h2, #view > h2 { line-height: 1.25; }
.lede, .muted { line-height: 1.6; }
.fare-list:not(.expanded) .fare.extra { display: none; }
.show-more {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px dashed var(--line-2); background: none;
  color: var(--accent); font: inherit; font-size: 14px; cursor: pointer;
}
.show-more:hover { border-color: var(--accent); }
.linkbtn { padding: 4px 0; }
.seg span, .seg a { padding: 6px 12px; }

@media (max-width: 900px) {
  body { font-size: 16px; }
  .small, .meta, .info, .hint, .map-hint, .disclaimer, .sub, .fare .info, .deal .meta, .cmp-row .small,
  .toggle small, .field > span, h4.sub, .tm-stats, .kpi small, .legend, .ai-reasons, table.data { font-size: 14px; }
  .muted { font-size: inherit; }
  .lede { font-size: 16px; }
  h1 { font-size: 30px; line-height: 1.15; }
  h2 { font-size: 22px; }
  h3 { font-size: 16px; margin-top: 28px; }
  .eyebrow { font-size: 13px; }
  .tabbar a { font-size: 12px; }
  .fare .al { font-size: 16px; }
  .fare .price { font-size: 19px; }
  .deal .city { font-size: 16px; }
  .deal .price { font-size: 17px; }
  .deal { padding: 12px; }
  /* every tappable thing at least ~40px tall */
  .linkbtn { min-height: 40px; padding: 8px 0; display: inline-flex; align-items: center; }
  .seg span, .seg a, .seg.sm span, .seg.sm a { min-height: 40px; display: flex; align-items: center; padding: 0 14px; font-size: 14px; }
  .route-head .btn.sm { height: 40px; }
  .fare .book { min-height: 40px; display: inline-flex; align-items: center; font-size: 14px; }
  .fare .fare-book .book + .book { margin-left: 16px; }
  .chip { min-height: 40px; display: inline-flex; align-items: center; }
  .trip-row .linkbtn { justify-self: end; }
  .tm { bottom: calc(var(--tab-h) + var(--safe-b) + 10px); }
  .tm-ctrl button { width: 44px; height: 44px; }
  .tm-ctrl .tm-play { width: 52px; height: 52px; }
  .tm-trip { font-size: 15px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .facts .fact span { font-size: 12.5px; }
  .cand { flex-direction: column; align-items: stretch; }
  .cand .row { justify-content: flex-end; }
  .import-grid .imp { min-height: 64px; }
  .imp span { font-size: 13px; }
  .ai-box, .live-box { padding: 14px; }
}
/* chart labels are in SVG units; the chart is ~0.8x on phones, so start larger */
.chart .axis { font-size: 13px; }
details.table-view summary, details summary { font-size: 13px; padding: 6px 0; }
.status { font-size: 13px; }
@media (max-width: 900px) {
  .chart .axis { font-size: 15px; }
  details summary { font-size: 14px; min-height: 40px; display: flex; align-items: center; }
  .status { font-size: 14px; }
  .tag { font-size: 12px; }
}
/* chart labels stay legible over bars */
.chart .axis { paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
@media (max-width: 900px) {
  /* the pinned booking bar already has these buttons */
  .trip-total .row, .trip-total .row + .small, #oneBook .row { display: none; }
  #oneBook:has(.row) { display: none; }
}
.fare.sel .fare-book { display: flex; flex-wrap: wrap; column-gap: 18px; }
.fare .fare-book .book + .book { margin-left: 0 !important; }
/* route header: codes on their own line, controls underneath */
:root { --panel-w: 520px; }
.route-head { flex-wrap: wrap; row-gap: 10px; }
.route-head .codes { flex-basis: 100%; white-space: nowrap; }
.route-head .spacer { display: none; }

/* ---- installable app ---- */
.install-banner { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 18px; border-radius: 12px; border: 1px solid var(--accent); background: var(--surface); }
.install-banner img { border-radius: 10px; flex: none; }
.install-banner div { flex: 1; display: grid; min-width: 0; }
.install-banner span { font-size: 13px; color: var(--muted); }
.install-x { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 6px; }
.install-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; line-height: 1.5; }
/* installed: respect the notch / home indicator */
body.standalone .topbar { padding-top: env(safe-area-inset-top, 0px); }

.danger-btn { color: var(--bad); border-color: rgba(242, 121, 121, 0.5); }
/* small phones (360px): keep the route controls on one line */
@media (max-width: 380px) {
  .route-head { column-gap: 6px; }
  .route-head .seg span, .route-head .seg a { padding: 0 10px; }
  .route-head .btn.sm { padding: 0 10px; }
  .seg span, .seg a { padding: 0 11px; }
}
