/* Flight Watch — phone-first styles. Colours are tokens; dark mode has its own steps. */
:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f0f1f3;
  --border: #e2e3e6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7d7c77;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e6f0fc;
  --on-accent: #ffffff;
  --series: #2a78d6;
  --spark: #a9a8a2;
  --good: #0ca30c;
  --good-ink: #006300;
  --good-soft: #e5f5e5;
  --bad: #d03b3b;
  --bad-ink: #a82626;
  --bad-soft: #fbe9e9;
  --warn-soft: #fff4dc;
  --warn-ink: #7a5200;
  --band: rgba(42, 120, 214, 0.08);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 16px;
  --tabbar-h: 58px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #2f2f2c;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: #1b2a3d;
    --on-accent: #ffffff;
    --series: #3987e5;
    --spark: #6b6a64;
    --good: #0ca30c;
    --good-ink: #5fd35f;
    --good-soft: #15291a;
    --bad: #e66767;
    --bad-ink: #f19a9a;
    --bad-soft: #331b1b;
    --warn-soft: #33290f;
    --warn-ink: #f3c768;
    --band: rgba(57, 135, 229, 0.12);
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #242422; --border: #2f2f2c;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: #1b2a3d; --on-accent: #ffffff;
  --series: #3987e5; --spark: #6b6a64;
  --good: #0ca30c; --good-ink: #5fd35f; --good-soft: #15291a;
  --bad: #e66767; --bad-ink: #f19a9a; --bad-soft: #331b1b;
  --warn-soft: #33290f; --warn-ink: #f3c768;
  --band: rgba(57, 135, 229, 0.12); --shadow: none;
}

* { box-sizing: border-box; }
/* App shell: the page itself never scrolls (so iPhone Safari can't slide the tab bar around when its toolbar
   shrinks or the page bounces); only .scroll does, and the tab bar is a normal row at the bottom. */
html { -webkit-text-size-adjust: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  height: 100%; overflow: hidden; overscroll-behavior: none;
  display: flex; flex-direction: column;
}
.scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; padding-bottom: 16px; }
a { color: var(--accent-ink); }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
}
.top-inner, main, .banner-wrap { max-width: 560px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; }
.top p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.back[hidden] { display: none; }
.back { display: inline-flex; align-items: center; gap: 2px; font-size: 16px; text-decoration: none; margin: 0 0 4px -4px; color: var(--accent-ink); }

main { padding: 4px 16px 0; }
.banner-wrap { padding: 0 16px; }
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warn-soft); color: var(--warn-ink);
  border-radius: 12px; padding: 10px 12px; font-size: 13px; margin: 4px 0 8px;
}
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 20px 4px 8px; }

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 14px 16px; margin-bottom: 12px;
}
a.card { display: block; color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
a.card:active { transform: scale(0.99); }
.card.paused { opacity: 0.62; }

.w-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.w-route { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.w-route .arrow { color: var(--muted); font-weight: 500; margin: 0 4px; }
.w-name { color: var(--text-2); font-size: 14px; margin-top: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 12px; background: var(--surface-2); color: var(--text-2); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.w-price-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 12px; }
.w-price { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.w-target { font-size: 13px; margin-top: 6px; }
.w-mode { font-size: 24px; margin-right: 6px; vertical-align: 4px; }
.modes-line { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--text-2); margin-top: 6px; }
.w-foot { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.tip { font-size: 13px; color: var(--text-2); margin-top: 8px; display: flex; gap: 6px; }
.good-text { color: var(--good-ink); }
.bad-text { color: var(--bad-ink); }
.muted { color: var(--muted); }

/* Status badge: icon + label, never colour alone */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.badge svg { width: 12px; height: 12px; }
.badge.low { background: var(--good-soft); color: var(--good-ink); }
.badge.typical { background: var(--surface-2); color: var(--text-2); }
.badge.high { background: var(--bad-soft); color: var(--bad-ink); }
.badge.paused { background: var(--surface-2); color: var(--muted); }
.badge.new { background: var(--accent-soft); color: var(--accent-ink); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Chart */
.chart-card { padding: 14px 8px 10px; }
.chart-card h3 { margin: 0 8px 2px; font-size: 16px; }
.chart-card .sub { margin: 0 8px 8px; font-size: 13px; color: var(--muted); }
.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .target { stroke: var(--text-2); stroke-width: 1.25; stroke-dasharray: 4 4; }
.chart .target-label { fill: var(--text-2); font-size: 11px; font-weight: 600; }
.chart .target-label, .chart .band-label { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart .band { fill: var(--band); }
.chart .band-label { fill: var(--muted); font-size: 11px; }
.chart .cross { stroke: var(--text-2); stroke-width: 1; }
.tooltip {
  position: absolute; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 10px; box-shadow: 0 4px 14px rgba(0,0,0,0.12); font-size: 12px; white-space: nowrap;
  transform: translateX(-50%); display: none;
}
.tooltip strong { display: block; font-size: 15px; }
.tooltip span { color: var(--muted); }
.spark { display: block; }
.spark path { fill: none; stroke: var(--spark); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--series); stroke: var(--surface); stroke-width: 2; }

/* Lists / tables */
.rows { padding: 4px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--border); text-decoration: none; color: inherit; }
.row:first-child { border-top: 0; }
.row .main { min-width: 0; }
.row .t1 { font-weight: 600; }
.row .t2 { font-size: 13px; color: var(--muted); margin-top: 1px; }
.row .end { text-align: right; flex-shrink: 0; }
.row .price { font-weight: 700; font-size: 17px; }
table.checks { width: 100%; border-collapse: collapse; font-size: 14px; }
table.checks th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 16px 6px; }
table.checks td { padding: 8px 16px; border-top: 1px solid var(--border); white-space: nowrap; }
table.checks td, table.checks th { padding-left: 12px; padding-right: 12px; }
table.checks { font-size: 13px; }
table.checks td:last-child, table.checks th:last-child { text-align: right; }
dl.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; text-align: right; }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 13px 16px; border-radius: 12px; border: 0; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: default; }
/* "Continue with Google", in Google's own button colours (light and dark). */
.btn.google { background: #ffffff; color: #1f1f1f; border: 1px solid #747775; font-weight: 500; gap: 10px; }
@media (prefers-color-scheme: dark) { .btn.google { background: #131314; color: #e3e3e3; border-color: #8e918f; } }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.legal { text-align: center; font-size: 13px; margin: 14px 0 0; }
.legal a { color: var(--muted); }
.btn.danger { color: var(--bad-ink); margin-top: 2px; }
.btn.small { width: auto; padding: 7px 14px; font-size: 14px; flex-shrink: 0; }
.between { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.between > :first-child { min-width: 0; flex: 1; }
.btn-row { display: grid; gap: 10px; margin: 12px 0; }

/* Form */
.field { margin-bottom: 16px; }
.field > label, .field > .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .hint, .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.field .error { font-size: 12px; color: var(--bad-ink); margin-top: 6px; }
.input { width: 100%; padding: 12px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 16px; min-height: 46px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.pair > *, .swap > .field { min-width: 0; flex: 1; }
input[type="date"].input { -webkit-appearance: none; appearance: none; min-width: 0; display: block; }
.swap { display: flex; align-items: end; gap: 8px; }
.swap .input { text-transform: uppercase; }
.swap-btn { border: 0; background: var(--surface-2); border-radius: 10px; width: 44px; height: 46px; flex-shrink: 0; cursor: pointer; color: var(--text-2); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 3px; border-radius: 11px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 9px 6px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { border: 1px solid var(--border); background: var(--surface); padding: 7px 12px; border-radius: 999px; font-size: 14px; cursor: pointer; color: var(--text-2); }
.pick button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.prefix { position: relative; }
.prefix span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.prefix .input { padding-left: 30px; }
pre.code { background: var(--surface-2); border-radius: 10px; padding: 12px; font-size: 12px; overflow-x: auto; white-space: pre; margin: 8px 0; }

/* Meter */
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.meter > div { height: 100%; background: var(--accent); border-radius: 99px; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.steps { margin: 0; padding-left: 20px; font-size: 14px; color: var(--text-2); }
.steps li { margin: 6px 0; }

/* Tab bar */
.tabs {
  flex: none; position: relative; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; -webkit-tap-highlight-color: transparent; }
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--accent); }
.tabs a .dot-count { position: absolute; }

/* Airport picker */
.ap-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ap-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 4px 4px 4px 10px; font-size: 14px; }
.ap-chip button { border: 0; background: transparent; color: inherit; font-size: 18px; line-height: 1; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }
.ap-results { margin-top: 6px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.ap-result { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--border); background: transparent; padding: 10px 12px; cursor: pointer; }
.ap-result:first-child { border-top: 0; }
.ap-result:active, .ap-result:hover { background: var(--surface-2); }
.ap-code { font-weight: 700; width: 40px; flex-shrink: 0; }
.ap-text { display: flex; flex-direction: column; min-width: 0; }
.ap-city { font-size: 15px; }
.ap-name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-near { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.ap-near .hint { margin: 0 2px 0 0; }
.ap-add { display: inline-flex; align-items: center; gap: 4px; border: 1px dashed var(--border); background: transparent; color: var(--text-2); border-radius: 999px; padding: 5px 10px; font-size: 13px; cursor: pointer; }

/* ± days summary */
.flex-summary { background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: -4px 0 12px; }
.flex-summary b { color: var(--accent-ink); }
.flex-summary .hint { margin-top: 4px; }

/* Stepper (travellers) */
.stepper { display: flex; align-items: center; justify-content: space-between; background: var(--surface-2); border-radius: 10px; padding: 3px; min-height: 46px; }
.stepper button { width: 40px; height: 40px; border: 0; border-radius: 8px; background: var(--surface); font-size: 20px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.stepper button:disabled { opacity: 0.35; cursor: default; }
.stepper span { font-weight: 600; font-size: 17px; }

/* Collapsible "more filters" */
details.more { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; }
details.more summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent-ink); margin-bottom: 12px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: '+ '; }
details.more[open] summary::before { content: '− '; }

/* Buy or wait hint: icon + words, colour only supports them */
.advice { display: flex; gap: 10px; align-items: flex-start; border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; border: 1px solid var(--border); background: var(--surface); }
.advice svg { flex-shrink: 0; margin-top: 1px; }
.advice b { display: block; font-size: 15px; }
.advice.good { background: var(--good-soft); color: var(--good-ink); border-color: transparent; }
.advice.wait { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.advice.either { color: var(--text-2); }

/* Cheapest-days calendar */
.cal { margin-top: 8px; }
.cal-month { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 6px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-head { font-size: 11px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cal-cell { min-height: 42px; border-radius: 8px; padding: 3px 2px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; background: transparent; }
.cal-cell.has { background: var(--surface-2); }
.cal-cell.best { background: var(--good-soft); outline: 2px solid var(--good); outline-offset: -2px; }
.cal-day { font-size: 11px; color: var(--muted); }
.cal-price { font-size: 12px; font-weight: 600; }
.cal-cell.best .cal-price { color: var(--good-ink); }

@media (min-width: 600px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}

/* Netlify's free plan adds a "Powered by Netlify" badge (an iframe, normally bottom right) that can't be removed.
   Owner's choice: the badge gets its own strip at the very top, centred, and the app starts below it, so it never
   covers the tab bar or the content. (Its visible pill is 186 × 48 px inside a 202 × 64 px frame.) */
#nl-badge-frame { top: calc(env(safe-area-inset-top) + 2px) !important; bottom: auto !important; left: calc(50% - 96px) !important; right: auto !important; }
body:has(#nl-badge-frame) { padding-top: calc(env(safe-area-inset-top) + 54px); }
body:has(#nl-badge-frame) .top { padding-top: 6px; }
