/* Skyroutes. Layout: one fixed app frame. Header (title, blurb, tabs) over a 372px trip panel beside a full-height map; nothing but the result list scrolls.
   Brand: logo navy ink, an orange-to-coral route gradient, rounded Nunito type. Prices use a teal scale so they never read as the brand accent. */
:root {
  --bg: #F3F4F7;
  --surface: #FFFFFF;
  --surface-2: #F5F6F9;
  --ink: #262D3F;             /* logo navy */
  --muted: #5E6577;
  --line: #DDE0E8;
  --accent: #F27A3A;          /* route orange */
  --accent-2: #F0605A;        /* route coral */
  --accent-soft: #FDEBDD;
  --accent-ink: #1F2433;
  --brand-grad: linear-gradient(90deg, #FA953C, #F0605A);
  --sea: #D6E2EB;
  --land: #F8FAFB;
  --land-line: #C5D1DA;
  --arc: rgba(38, 45, 63, .24);
  --dim: #AEB4C2;
  --p1: #0A6560; --p2: #16958A; --p3: #4DBBAE; --p4: #93D3C8; --p5: #C9D9D6;
  --o1: #2C6BD6; --o2: #C93A86; --o3: #7B4BC4; --o4: #1C9A57;
  --good: #1D8148; --bad: #C2361C;
  --font-ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-data: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --h: 32px;
  --r: 9px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10141D; --surface: #171C27; --surface-2: #1E2431; --ink: #E8EBF2; --muted: #9AA2B4; --line: #2A3140;
    --accent: #FF8C45; --accent-2: #FF6B62; --accent-soft: #3A2418; --accent-ink: #1A1205;
    --sea: #0A1117; --land: #1A2630; --land-line: #2A3A46; --arc: rgba(232, 235, 242, .2); --dim: #363D4D;
    --p1: #46D6C6; --p2: #2DAE9F; --p3: #258478; --p4: #285F59; --p5: #33474A;
    --o1: #5C93F0; --o2: #EE6BB0; --o3: #A07BE6; --o4: #3FC27C;
    --good: #4CC07D; --bad: #F06A4E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10141D; --surface: #171C27; --surface-2: #1E2431; --ink: #E8EBF2; --muted: #9AA2B4; --line: #2A3140;
  --accent: #FF8C45; --accent-2: #FF6B62; --accent-soft: #3A2418; --accent-ink: #1A1205;
  --sea: #0A1117; --land: #1A2630; --land-line: #2A3A46; --arc: rgba(232, 235, 242, .2); --dim: #363D4D;
  --p1: #46D6C6; --p2: #2DAE9F; --p3: #258478; --p4: #285F59; --p5: #33474A;
  --o1: #5C93F0; --o2: #EE6BB0; --o3: #A07BE6; --o4: #3FC27C;
  --good: #4CC07D; --bad: #F06A4E;
  color-scheme: dark;
}

html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 14px; overflow: hidden; }
* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--accent) 45%, transparent) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 8px; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; }

.app { height: 100%; display: flex; flex-direction: column; }

/* Header: a full-width bar; the map and panel below run edge to edge */
.ph { flex: none; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.ph-top { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 7px; flex: none; }
.brand img { width: 30px; height: 30px; display: block; }
.wordmark { font-weight: 800; font-size: 21px; letter-spacing: -.01em; color: var(--ink); line-height: 1; padding-bottom: 2px; }
.ph h1 { flex: 1; min-width: 0; margin: 0; font-size: 22px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 16px; border-left: 1px solid var(--line); }
.ph-actions { flex: none; display: flex; align-items: center; gap: 8px; }
.blurb { margin: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; margin-bottom: -1px; }
.tab { height: 36px; padding: 0 14px; border: 0; background: none; cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; position: relative; }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand-grad); }
.tab .count { font-family: var(--font-data); font-size: 12px; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); position: absolute; top: 7px; right: 6px; }

.btn { height: var(--h); padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand-grad); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.badge { height: 24px; padding: 0 8px; border-radius: 6px; display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--ink); border: 1px dashed var(--accent); }

/* Body */
.page-body { flex: 1; min-height: 0; overflow: hidden; display: grid; grid-template-columns: 372px minmax(0, 1fr); }
.page-body.single { grid-template-columns: minmax(0, 1fr); }
.card { background: var(--surface); min-width: 0; min-height: 0; }

.panel { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line); padding-left: env(safe-area-inset-left, 0px); }
.saved { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.controls { flex: none; padding: 14px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > .lab { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.field > .lab b { font-family: var(--font-data); font-size: 12px; letter-spacing: 0; text-transform: none; color: var(--ink); font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select.sel { height: var(--h); border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); padding: 0 8px; width: 100%; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: var(--h); padding: 0 11px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .sw { width: 9px; height: 9px; border-radius: 50%; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; height: var(--h); }
.seg button { flex: 1; border: 0; background: var(--surface); cursor: pointer; font-weight: 500; padding: 0 6px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 20px; margin: 0; }
.dates { font-family: var(--font-data); font-size: 12px; color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 8px; height: var(--h); cursor: pointer; font-weight: 500; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

.list-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.list-head .n { font-weight: 600; }
.list-head select.sel { width: auto; }
.list { flex: 1; min-height: 0; overflow: auto; }
.res { width: 100%; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.res:hover { background: var(--surface-2); }
.res[aria-current="true"] { background: var(--accent-soft); }
.res .code { grid-row: span 2; font-family: var(--font-data); font-weight: 600; font-size: 16px; letter-spacing: .04em; display: flex; align-items: center; gap: 6px; }
.res .code i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.res .city { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res .meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res .price { grid-row: span 2; text-align: right; }
.res .price b { display: block; font-family: var(--font-data); font-size: 16px; font-weight: 600; }
.res .price span { font-size: 11px; color: var(--muted); }
.res .pills { display: flex; gap: 4px; flex-wrap: wrap; }
.opill { font-family: var(--font-data); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid; }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; line-height: 1.5; }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; }

/* Map */
.mapcard { position: relative; overflow: hidden; background: var(--sea); }
#map { position: absolute; inset: 0; }

.mapctl { position: absolute; top: 12px; right: calc(12px + env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 6px; }
.mapctl .btn { width: var(--h); padding: 0; justify-content: center; }
.legend { position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--r); background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); font-size: 12px; }
.legend .k { display: flex; align-items: center; gap: 5px; font-family: var(--font-data); }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.maphint { position: absolute; left: 12px; top: 12px; padding: 6px 10px; border-radius: var(--r); background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.maplibregl-popup.tip { pointer-events: none; }
.maplibregl-popup.tip .maplibregl-popup-content { background: var(--ink); color: var(--surface); padding: 6px 9px; border-radius: 6px; font: 12px var(--font-ui); white-space: nowrap; box-shadow: none; }
.maplibregl-popup.tip .maplibregl-popup-tip { border-top-color: var(--ink); }
.tip b { font-family: var(--font-data); }
.orig { padding: 2px 7px; border-radius: 5px; background: var(--ink); color: var(--surface); border: 2px solid var(--surface); font: 600 11px var(--font-data); letter-spacing: .03em; box-shadow: 0 2px 6px rgba(5, 10, 15, .3); pointer-events: none; }
.orig.o0 { background: var(--o1); } .orig.o1 { background: var(--o2); } .orig.o2 { background: var(--o3); } .orig.o3 { background: var(--o4); }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib.maplibregl-compact { background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted); }
.maplibregl-ctrl-attrib-button { filter: var(--attrib-filter, none); }

/* Ticket (selected trip) */
.ticket { position: absolute; right: calc(12px + env(safe-area-inset-right, 0px)); bottom: 40px; width: min(400px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(10, 20, 30, .18); }
.t-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 14px 10px; }
.t-route { font-family: var(--font-data); font-size: 22px; font-weight: 600; letter-spacing: .03em; }
.t-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.t-x { width: var(--h); height: var(--h); border-radius: var(--r); border: 1px solid var(--line); background: none; cursor: pointer; flex: none; }
.t-legs { border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.leg { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; font-size: 13px; }
.leg .tag { font-family: var(--font-data); font-size: 11px; color: var(--muted); letter-spacing: .06em; }
.leg .when { font-family: var(--font-data); }
.leg .who { color: var(--muted); font-size: 12px; text-align: right; }
.t-sum { padding: 10px 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.t-sum .bk { color: var(--muted); font-size: 12px; font-family: var(--font-data); }
.t-sum .tot { font-family: var(--font-data); font-size: 22px; font-weight: 600; }
.partners { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.partner { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 40px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; }
.partner:hover { border-color: var(--accent); }
.partner.best { background: var(--brand-grad); border-color: transparent; color: var(--accent-ink); }
.partner .pp { font-family: var(--font-data); }
.t-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 14px 14px; }
.t-note { font-size: 11px; color: var(--muted); line-height: 1.4; }
.grouprows { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; border-top: 1px dashed var(--line); }
.grow { display: grid; grid-template-columns: 12px 76px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; font-size: 13px; }
.grow i { width: 10px; height: 10px; border-radius: 50%; }
.grow .gm { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow b { font-family: var(--font-data); }
.grow a { font-size: 12px; color: var(--ink); }

/* Saved */
.saved { display: flex; flex-direction: column; overflow: hidden; }
.saved .list-head { padding: 12px 16px; }
.tablewrap { flex: 1; min-height: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 9px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.num, th.num { text-align: right; font-family: var(--font-data); }
td .r { font-family: var(--font-data); font-weight: 600; }
.up { color: var(--bad); } .down { color: var(--good); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: var(--r); font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 20; }

.m-only { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(5, 10, 15, .45); z-index: 24; }
.summary { flex: none; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.summary span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--muted); }
.summary span b { color: var(--ink); font-weight: 600; }
.sheet-head { justify-content: space-between; align-items: center; gap: 8px; }
.sheet-head b { font-size: 17px; }
.sheet-head div { display: flex; gap: 8px; }
.sheet-foot { position: sticky; bottom: 0; background: var(--surface); padding-top: 4px; }
.sheet-foot .btn { width: 100%; justify-content: center; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto; }

@media (max-width: 820px) {
  :root { --h: 38px; }
  .m-only { display: flex; }
  .ph { gap: 4px; }
  .ph h1 { font-size: 17px; padding-left: 10px; }
  .wordmark, .ph-actions, .blurb { display: none; }
  .tab { height: 40px; padding: 0 10px; }
  .page-body { display: flex; flex-direction: column; }
  .mapcard { flex: 0 0 42%; order: -1; }
  .panel { flex: 1; border-right: 0; border-top: 1px solid var(--line); padding-right: env(safe-area-inset-right, 0px); }
  .res { padding: 12px 14px; }
  .maphint, .legend, #zin, #zout { display: none; }
  .controls { display: none; }
  .controls.open { display: flex; position: fixed; left: 0; right: 0; bottom: 0; max-height: 88%; overflow: auto; z-index: 30;
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(5, 10, 15, .25);
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .ticket { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 78%; z-index: 26;
    border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); box-shadow: 0 -10px 30px rgba(5, 10, 15, .25); }
  .ticket .t-head { padding-top: 10px; }
  .partner { height: 46px; }
  .saved td, .saved th { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Live data states */
.badge.live { background: color-mix(in srgb, var(--good) 14%, transparent); border: 1px solid var(--good); }
.badge.est { background: var(--accent-soft); border: 1px dashed var(--accent); }
.subhead { padding: 10px 14px 6px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.res.nofare .city, .res.nofare .price b { color: var(--muted); }
.res.nofare .price b { font-family: var(--font-ui); font-size: 14px; }
select.sel.addsel { width: auto; }
.toggle input:disabled + * , .toggle:has(input:disabled) { opacity: .55; cursor: not-allowed; }
