/* FareScope — instrument-cluster dark. No framework; this file is the whole system.
   Every price is a live Google Flights price — the UI's job is to make provenance
   and state (live / cached / quota / down) legible at a glance.

   Tokens: ink · panel · line · txt · muted | green = action/live · amber = caution
           crimson = alert/destructive · indigo = interactive-secondary
   Type:   Archivo (display) · Spline Sans Mono (numbers, codes, provenance) */

@import url("/fonts/fonts.css");

:root {
  --ink: #0a0e14;
  --panel: #121821;
  --panel2: #0e141c;
  --line: #1f2a37;
  --line2: #2a3a4d;
  --txt: #e6eaf0;
  --muted: #8b97a7;
  --green: #34d399;
  --green-ink: #06210f;
  --amber: #fbbf24;
  --crimson: #f43f5e;
  --indigo: #818cf8;
  --indigo-soft: #c7ccf8;
  --r: 12px;
  --r-sm: 8px;
  --font-d: "Archivo", system-ui, sans-serif;
  --font-m: "Spline Sans Mono", ui-monospace, SFMono-Regular, monospace;
}

/* ---- reset-ish ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body {
  background: var(--ink);
  color: var(--txt);
  font-family: var(--font-d);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; }
a { color: inherit; }
img { max-width: 100%; }
ul { list-style: none; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--font-m); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* chrome isn't selectable; prices/codes are (long-press copy) */
header, .chip, .btn, .badge, .seg, .ex-chip, .link-btn { -webkit-user-select: none; user-select: none; }
.mono, .price, .code { -webkit-user-select: text; user-select: text; }

/* ---- safe areas (iOS standalone) ---- */
.safe-top { padding-top: env(safe-area-inset-top); }
.safe-bottom { padding-bottom: calc(env(safe-area-inset-bottom) + 1.5rem); }
.safe-x { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* ---- shell ---- */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-row { max-width: 720px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.brand { font-family: var(--font-m); font-weight: 600; font-size: 17px; color: var(--green); letter-spacing: -0.02em; }
.brand .mark { margin-right: 2px; }
.tagline { font-size: 11px; color: var(--muted); }
@media (max-width: 480px) { .tagline { display: none; } }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line); color: var(--muted); font-size: 16px;
  position: relative; transition: border-color .15s, color .15s;
}
.icon-btn:hover { color: var(--txt); border-color: var(--line2); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 999px;
  background: var(--green); box-shadow: 0 0 6px var(--green);
}

main { max-width: 720px; margin: 0 auto; padding-top: 16px; }

/* ---- status chip (mode + quota fused) ---- */
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-m); font-size: 11px;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; color: var(--muted);
}
.status-chip .live { color: var(--green); }
.status-chip .mock { color: var(--amber); }
.qbar { width: 40px; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.qbar i { display: block; height: 100%; background: var(--green); transition: width .3s; }
.qbar.warn i { background: var(--amber); }
.qbar.hot i { background: var(--crimson); }

/* ---- panels ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.search-panel { padding: 16px; margin-bottom: 16px; }
/* minmax(0,1fr): a bare 1fr has a min-content floor — date inputs would force overflow */
.fld-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.fld-label { display: block; font-size: 11px; color: var(--muted); letter-spacing: .01em; }
.fld-label .soft { opacity: .6; }
.fld {
  width: 100%; margin-top: 4px; min-height: 46px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; color: var(--txt);
  font-family: var(--font-m); font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fld:focus { border-color: var(--green); box-shadow: 0 0 0 1px color-mix(in srgb, var(--green) 25%, transparent); }
input[type="date"].fld { min-width: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); }
select.fld { -webkit-appearance: none; appearance: none; }

.search-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  border-radius: 10px; padding: 13px 16px; font-size: 14px; font-weight: 600; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .15s, transform .08s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: var(--green-ink); flex: 1; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--panel2); border: 1px solid var(--line); color: var(--txt); }
.btn-ghost:hover { border-color: var(--indigo); }
.btn-danger-ghost { background: var(--panel2); border: 1px solid var(--line); color: var(--crimson); }
.btn-danger-ghost:hover { border-color: var(--crimson); }
.hint { font-family: var(--font-m); font-size: 11px; color: var(--muted); margin-top: 10px; min-height: 14px; }

/* ---- combobox ---- */
.combo { position: relative; }
.combo-sub { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); min-height: 14px; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm);
  max-height: 40vh; overflow-y: auto; box-shadow: 0 10px 28px rgba(0,0,0,.5);
}
.combo-list.up { top: auto; bottom: calc(100% + 4px); }
.combo-opt {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px; cursor: pointer;
  min-height: 46px; border-left: 2px solid transparent;
}
.combo-opt:hover, .combo-opt.active { background: color-mix(in srgb, var(--indigo) 10%, transparent); border-left-color: var(--indigo); }
.combo-opt .ic { width: 18px; text-align: center; flex: none; }
.combo-opt .lbl { font-size: 13px; }
.combo-opt .sub { color: var(--muted); font-size: 11px; }
.combo-opt .code { margin-left: auto; color: var(--muted); font-family: var(--font-m); font-size: 12px; flex: none; }
.combo-opt mark { color: var(--green); background: transparent; font-weight: 600; }
.combo-opt.special .lbl { color: var(--indigo); }

/* ---- provenance + summary bar ---- */
.summary-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px 14px; margin-bottom: 12px;
}
.summary-bar .verdict { font-size: 13px; }
.summary-right { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.provenance {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-m); font-size: 10.5px; color: var(--muted);
  padding: 0 2px; margin: 0 0 10px;
}
.provenance .src { color: var(--txt); }
.provenance .live-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--green); box-shadow: 0 0 5px var(--green); }
.provenance .cached-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); }
.provenance .mock-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--amber); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { padding: 7px 11px; font-size: 11px; color: var(--muted); min-height: 36px; }
.seg button.on { background: color-mix(in srgb, var(--indigo) 10%, transparent); color: var(--indigo-soft); }

.watch-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px;
  font-size: 12px; font-family: var(--font-m); color: var(--muted);
  transition: border-color .15s, color .15s;
}
.watch-btn:hover { border-color: var(--amber); color: var(--amber); }
.watch-btn.on { border-color: color-mix(in srgb, var(--amber) 45%, transparent); color: var(--amber); background: color-mix(in srgb, var(--amber) 8%, transparent); }

/* ---- result cards ---- */
.results { display: flex; flex-direction: column; gap: 12px; }
.result-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.result-card.top { box-shadow: 0 0 0 1px color-mix(in srgb, var(--green) 40%, transparent); }
.result-card:hover { border-color: var(--line2); }
.rc-head { display: flex; align-items: flex-start; gap: 12px; }
.rc-main { flex: 1; min-width: 0; }
.rc-airline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rc-airline img { width: 20px; height: 20px; border-radius: 5px; }
.rc-airline .name { font-weight: 600; }
.rc-airline .meta { font-size: 12px; color: var(--muted); }
.rc-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.route-line { font-family: var(--font-m); font-size: 12px; color: var(--muted); margin-top: 9px; }
.route-line b { color: var(--txt); font-weight: 600; }
.rc-price { text-align: right; flex: none; }
.price { font-family: var(--font-m); font-size: 24px; font-weight: 600; }
.price.best { color: var(--green); }
.rc-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: var(--font-m); }
.rc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 13px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 12px;
  font-size: 13px; text-decoration: none; min-height: 40px;
  transition: border-color .15s;
}
.link-btn:hover { border-color: var(--green); }
.link-btn.quiet { color: var(--muted); font-size: 12px; }
.link-btn.quiet:hover { border-color: var(--line2); color: var(--txt); }
.segs { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 11px; font-size: 12px; color: var(--muted); display: grid; gap: 5px; }
.segs .mono { font-size: 11.5px; }

.badge {
  font-family: var(--font-m); font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  padding: 2.5px 7px; border-radius: 6px; border: 1px solid;
}
.badge-green { color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); background: color-mix(in srgb, var(--green) 7%, transparent); }
.badge-amber { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, transparent); background: color-mix(in srgb, var(--amber) 7%, transparent); }
.badge-indigo { color: var(--indigo); border-color: color-mix(in srgb, var(--indigo) 35%, transparent); background: color-mix(in srgb, var(--indigo) 7%, transparent); }
.badge-crimson { color: var(--crimson); border-color: color-mix(in srgb, var(--crimson) 35%, transparent); background: color-mix(in srgb, var(--crimson) 7%, transparent); }

/* ---- state panels ---- */
.state-panel { text-align: center; padding: 34px 18px; color: var(--muted); }
.state-panel .ic { font-size: 28px; }
.state-panel .hd { color: var(--txt); font-weight: 600; margin-top: 8px; font-size: 15px; }
.state-panel .bd { font-size: 13px; margin-top: 5px; max-width: 42ch; margin-left: auto; margin-right: auto; }
.state-panel .actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.state-banner {
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); color: var(--amber);
  background: color-mix(in srgb, var(--amber) 5%, transparent);
  border-radius: var(--r-sm); padding: 9px 12px; font-size: 12px; margin-bottom: 10px;
}

/* ---- skeletons ---- */
.skel-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.skel { background: #1a2433; border-radius: 6px; }
.searching { font-family: var(--font-m); font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dot-pulse { display: inline-block; width: 8px; height: 8px; border-radius: 999px; background: var(--green); }

/* ---- anywhere grid ---- */
.dest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .dest-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.dest-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 13px; background: var(--panel);
  cursor: pointer; text-align: left; transition: border-color .15s;
}
.dest-card:hover { border-color: var(--green); }
.dest-card .city { font-weight: 600; font-size: 13.5px; }
.dest-card .sub { font-size: 11px; color: var(--muted); font-family: var(--font-m); margin-top: 1px; }
.dest-card .price { font-size: 17px; color: var(--green); margin-top: 8px; }
.dest-card .when { font-size: 10.5px; color: var(--muted); font-family: var(--font-m); margin-top: 1px; }
.dest-note { font-size: 11px; color: var(--muted); font-family: var(--font-m); margin: 10px 2px 0; }

/* ---- watches ---- */
.section-head { display: flex; align-items: center; gap: 8px; margin: 26px 0 10px; }
.section-head .t { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.section-head .right { margin-left: auto; font-size: 11px; color: var(--muted); font-family: var(--font-m); }
.watch-grid { display: grid; gap: 10px; }
@media (min-width: 560px) { .watch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.watch-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px; }
.watch-card .route { font-family: var(--font-m); font-weight: 600; font-size: 14px; }
.watch-card .route .arrow { color: var(--muted); font-weight: 400; }
.watch-card .when { font-size: 11px; color: var(--muted); font-family: var(--font-m); margin-top: 2px; }
.watch-row { display: flex; align-items: center; gap: 10px; }
.watch-row .x { margin-left: auto; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); flex: none; display: inline-flex; align-items: center; justify-content: center; }
.watch-row .x:hover { color: var(--crimson); }
.watch-stats { display: flex; align-items: baseline; gap: 10px; margin-top: 10px; }
.watch-stats .last { font-family: var(--font-m); font-size: 18px; font-weight: 600; }
.watch-stats .last.down { color: var(--green); }
.watch-stats .thr { font-size: 10.5px; color: var(--amber); font-family: var(--font-m); }
.watch-stats .checked { font-size: 10.5px; color: var(--muted); font-family: var(--font-m); margin-left: auto; }
.spark { display: block; margin-top: 8px; width: 100%; height: 26px; }
.spark polyline { fill: none; stroke: var(--indigo); stroke-width: 1.5; opacity: .9; }
.spark .fill { fill: color-mix(in srgb, var(--indigo) 12%, transparent); stroke: none; }
.watch-empty { font-size: 12.5px; color: var(--muted); padding: 4px 2px; }

/* threshold mini-form */
.watch-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 12px; }
.watch-form .fld { margin-top: 0; max-width: 130px; min-height: 42px; }
.watch-form .lbl { font-size: 12.5px; }

/* ---- saved chips ---- */
.saved-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.saved-card {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 6px 6px 12px; font-size: 12px;
  font-family: var(--font-m); color: var(--muted);
}
.saved-card .go { cursor: pointer; color: var(--indigo-soft); background: none; font: inherit; }
.saved-card .x { cursor: pointer; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; }
.saved-card .x:hover { color: var(--crimson); }

/* ---- hero ---- */
.hero { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; margin-bottom: 16px; }
.hero .h { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.hero .sub { color: var(--muted); font-size: 13px; margin-top: 6px; max-width: 52ch; }
.hero-points { display: grid; gap: 8px; margin-top: 14px; }
@media (min-width: 560px) { .hero-points { grid-template-columns: 1fr 1fr; } }
.hero-point { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel2); font-size: 12.5px; color: var(--muted); }
.hero-point .t { font-weight: 600; font-size: 13px; color: var(--txt); margin-bottom: 3px; }
.hero-point .t.green { color: var(--green); }
.hero-point .t.amber { color: var(--amber); }
.ex-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ex-chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; font-size: 13px;
  font-family: var(--font-m); color: var(--indigo-soft);
  background: color-mix(in srgb, var(--indigo) 7%, transparent);
  cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; gap: 6px;
}
.ex-chip:hover { border-color: var(--indigo); }
.ex-chip .to { color: var(--muted); font-size: 11px; }

/* ---- install sheet ---- */
.sheet-veil { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,.6); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 22px 20px;
  padding-bottom: calc(env(safe-area-inset-bottom) + 22px);
  max-width: 720px; margin: 0 auto;
}
.sheet .grab { width: 36px; height: 4px; border-radius: 999px; background: var(--line2); margin: 0 auto 16px; }
.sheet h2 { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.sheet .why { color: var(--muted); font-size: 13px; margin-top: 6px; }
.steps { display: grid; gap: 10px; margin-top: 16px; }
.step { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; }
.step .n {
  flex: none; width: 24px; height: 24px; border-radius: 999px; background: var(--panel2);
  border: 1px solid var(--line); color: var(--green); font-family: var(--font-m); font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.step .k { color: var(--txt); font-weight: 600; }
.sheet .actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 60;
  background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px;
  padding: 11px 16px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
  max-width: min(90vw, 420px); text-align: center;
}
.toast.good { border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.toast.bad { border-color: color-mix(in srgb, var(--crimson) 40%, transparent); }

/* ---- settings drawer ---- */
.drawer-veil { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.6); }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 31; width: min(100vw, 400px);
  background: var(--panel); border-left: 1px solid var(--line);
  padding: 20px; padding-top: calc(env(safe-area-inset-top) + 20px); overflow-y: auto;
}
.drawer h2 { font-size: 17px; font-weight: 800; }
.drawer .close { margin-left: auto; }
.drawer-head { display: flex; align-items: center; margin-bottom: 16px; }
.drawer section { border-top: 1px solid var(--line); padding: 16px 0; }
.drawer section:first-of-type { border-top: none; padding-top: 0; }
.drawer .st { font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.drawer p { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.drawer p b { color: var(--txt); }
.kv { display: flex; justify-content: space-between; font-family: var(--font-m); font-size: 12px; padding: 4px 0; color: var(--muted); }
.kv b { color: var(--txt); font-weight: 500; }
.notif-status { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-m); font-size: 12px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; margin-bottom: 10px; }
.notif-status .on { color: var(--green); }
.notif-status .off { color: var(--muted); }
.notif-status .blocked { color: var(--crimson); }

/* ---- motion ---- */
@media (prefers-reduced-motion: no-preference) {
  .skel {
    background: linear-gradient(90deg, #121821, #1f2a37, #121821);
    background-size: 200% 100%; animation: skel 1.2s ease-in-out infinite;
  }
  @keyframes skel { to { background-position: -200% 0; } }
  .result-card, .dest-card, .watch-card { animation: rise .28s ease both; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  .dot-pulse { animation: pulse 1s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .3; } }
  .drawer { transition: transform .28s ease; }
  .sheet { transition: transform .3s cubic-bezier(.32,.72,0,1); }
  .toast { animation: toast-in .25s ease both; }
  @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
}
.drawer-wrap.closed .drawer { transform: translateX(100%); }
.drawer-wrap.closed .drawer-veil { display: none; }
.sheet-wrap.closed .sheet { transform: translateY(105%); }
.sheet-wrap.closed .sheet-veil { display: none; }
