/*
 * Amelia — the Chart direction.
 *
 * Chart paper, aviation green, chart magenta, caution ochre. Barlow Semi
 * Condensed for labels, IBM Plex Mono for anything that is a value.
 *
 * The signature carries straight over from the design: every figure shows where
 * it came from. On the settings page that is the precedence chain — a value set
 * here, a value from .env, or the built-in default — printed in mono next to
 * the value itself, the same way a fare carries the time it was fetched.
 *
 * Single-theme on purpose: a chart is paper. Every colour is painted explicitly
 * so the page never borrows a host background.
 */

:root {
  --paper: #E6ECF0;
  --panel: #F7FAFB;
  --panel-2: #FFFFFF;
  --ink: #0A1E29;
  --mute: #54707E;
  --faint: #7D949F;
  --mag: #C60A68;
  --grn: #0E7355;
  --ochre: #A96F00;
  --grid: #B7C6D0;

  --sans: "Barlow Semi Condensed", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--mag); outline-offset: 2px; }
[hidden] { display: none !important; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
}
main { padding-bottom: 24px; }

/* ---------- shared chart components ---------- */

.lbl {
  display: block;
  font-size: 9.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 600;
}
.val {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.val-sm { font-size: 12px; }

.strip {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 11px;
  border-bottom: 1.5px solid var(--ink);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 5;
}
.strip-r { text-align: right; }

.plate {
  background: var(--panel);
  border-bottom: 1px solid var(--grid);
  padding: 13px 16px 15px;
}
.plate-hd {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 11px;
}
.plate-t {
  font-size: 9.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 600;
}

.sec {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  padding: 20px 16px 8px;
  font-size: 9.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 600;
}
.sec-m {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .02em;
  color: var(--faint);
  font-weight: 400;
  text-transform: none;
}

.note {
  margin: 18px 16px 0;
  padding: 11px 13px;
  background: var(--panel);
  border: 1px solid var(--grid);
  border-left: 3px solid var(--mag);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--mute);
}

.link {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mag);
  cursor: pointer;
}
.link--block {
  display: block;
  width: calc(100% - 32px);
  margin: 26px 16px 0;
  padding: 11px;
  text-align: center;
  border: 1px solid var(--grid);
  color: var(--mute);
}

/* ---------- connection checks ---------- */

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.check {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.check::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 4px;
  background: var(--grid);
}
.check--ok::before { background: var(--grn); }
.check--bad::before { background: var(--ochre); }
.check--wait::before { background: var(--grid); }

.check-n { font-size: 13.5px; font-weight: 500; }
.check-d {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.55;
  color: var(--mute);
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.check--bad .check-d { color: var(--ochre); }

/* ---------- a setting ---------- */

.setting {
  padding: 14px 16px;
  border-bottom: 1px solid var(--grid);
  background: var(--panel);
}
.setting-hd {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.setting-n { font-size: 16px; font-weight: 600; letter-spacing: .01em; }
.setting-src {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
  text-align: right;
}
.setting-src[data-source="set here"] { color: var(--mag); }
.setting-d {
  font-size: 12.5px;
  color: var(--mute);
  margin: 3px 0 10px;
  line-height: 1.5;
}

.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--grid);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.input:focus { border-color: var(--mag); }
.input--search { margin: 0 0 10px; }

/* value + action on one line, wrapping on a narrow phone */
.setting-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.setting-row .input { flex: 1 1 140px; min-width: 0; }

.btn {
  padding: 10px 14px;
  border: 1.5px solid var(--mag);
  background: var(--mag);
  color: #fff;
  border-radius: 2px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--grid); }

.model-current {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--grid);
  border-radius: 2px;
}
.model-current-id {
  display: block;
  font-family: var(--mono);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}
.model-current-m {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--faint);
  margin-top: 3px;
}

/* segmented choice */
.choice { display: flex; border: 1px solid var(--grid); border-radius: 2px; overflow: hidden; }
.choice-opt {
  flex: 1;
  padding: 9px 4px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--mute);
  background: var(--panel-2);
  border-right: 1px solid var(--grid);
}
.choice-opt:last-child { border-right: none; }
.choice-opt[aria-pressed="true"] { background: var(--mag); color: #fff; }

.field-error {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ochre);
}
.field-label {
  display: block;
  font-size: 9.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 600;
  margin-bottom: 6px;
}

/* ---------- tabs ---------- */

.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 560px;
  margin: 0 auto;
  background: var(--panel);
  border-top: 1.5px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  padding: 14px 0 18px;
  text-align: center;
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--mute);
}
.tab.is-on { color: var(--mag); box-shadow: inset 0 2.5px 0 var(--mag); }

/* ---------- sheets ---------- */

.sheet {
  width: min(560px, 100%);
  max-height: 86vh;
  margin: auto auto 0;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  border: none;
  border-top: 1.5px solid var(--ink);
  border-radius: 3px 3px 0 0;
  background: var(--paper);
  color: var(--ink);
  overflow-y: auto;
}
.sheet::backdrop { background: rgba(10, 30, 41, .45); }
.sheet--short { max-height: 40vh; }
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 11px;
  margin-bottom: 12px;
  border-bottom: 1.5px solid var(--ink);
}
.sheet-sub {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  margin-top: 3px;
}
.stub-body { font-size: 13.5px; line-height: 1.6; color: var(--mute); margin: 0; }

.models { list-style: none; margin: 0; padding: 0; }
.model {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 0;
  border-bottom: 1px solid var(--grid);
}
.model[aria-current="true"] .model-id { color: var(--mag); }
.model-id { display: block; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.model-meta {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--faint);
  margin-top: 3px;
}
.models-empty { padding: 16px 0; font-size: 13px; color: var(--mute); }

/* ---------- gate ---------- */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.gate-card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--grid);
  border-top: 1.5px solid var(--ink);
  padding: 22px 20px;
}
.gate-h { font-size: 30px; font-weight: 600; letter-spacing: -.01em; margin: 4px 0 20px; }
.gate-card .btn { width: 100%; margin-top: 14px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 20;
  padding: 9px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 11px;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast[data-kind="bad"] { background: var(--ochre); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================
   Sections added with the rest of the app: chart, trip, plan, cost.
   Same tokens throughout — nothing below introduces a new colour.
   ============================================================ */

.loading { padding: 28px 16px; font-size: 13px; color: var(--mute); }
.empty-line { margin: 0; padding: 14px 16px; font-size: 13px; color: var(--mute); }

.src {
  display: block;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .02em;
  color: var(--faint);
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.src.stale { color: var(--ochre); }

.strip--soft { border-bottom-color: var(--grid); border-bottom-width: 1px; }
.val--big {
  font-family: var(--sans);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  line-height: 1.05;
}
.val--sm { font-size: 12px; }

.plate--hard { border-bottom: 1.5px solid var(--ink); }
.plate-m {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
  letter-spacing: .02em;
}
.svg { display: block; width: 100%; height: auto; }

.next { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.next-n { font-size: 21px; font-weight: 600; letter-spacing: .03em; line-height: 1.05; }

/* rows ------------------------------------------------------ */

.rows { padding: 0 16px; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--grid);
  color: inherit;
  text-decoration: none;
}
a.row { transition: background .14s ease, padding .14s ease; }
a.row:hover { background: var(--panel-2); padding-left: 7px; padding-right: 7px; }
.row-main { color: inherit; text-decoration: none; min-width: 0; }
.row-n {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.row-n--sm { font-size: 15px; letter-spacing: .01em; text-transform: none; font-weight: 500; }
.row-s {
  font-size: 11.5px;
  color: var(--mute);
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-top: 3px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.row-r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

.num { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.num--big { font-size: 19px; font-weight: 500; display: block; margin-top: 3px; }
.num--soft { color: var(--faint); }

.flag {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  white-space: nowrap;
}
.flag.mag { color: var(--mag); }
.flag.grn { color: var(--grn); }
.flag.och { color: var(--ochre); }
.flag.mut { color: var(--faint); }

.back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 11px;
  border-bottom: 1.5px solid var(--ink);
  color: inherit;
  text-decoration: none;
}
.back-t { font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--mute); font-weight: 600; }
.back-r {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.budget-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 18px 16px 0;
  padding: 12px 13px;
  background: var(--panel);
  border: 1px solid var(--grid);
  color: inherit;
  text-decoration: none;
}

.chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 16px; }
.chip {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .05em;
  padding: 4px 7px;
  border: 1px solid var(--grid);
  background: var(--panel-2);
  color: var(--mute);
  border-radius: 2px;
}
.chip.on { border-color: var(--mag); color: var(--mag); }

.acts { display: grid; gap: 8px; padding: 16px; }
.acts .btn { width: 100%; text-align: center; text-decoration: none; display: block; }
.btn-sub {
  margin: 0;
  padding: 0 16px 8px;
  text-align: center;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
  line-height: 1.6;
}
.btn--danger { border-color: var(--ochre); color: var(--ochre); }

.note--warn { border-left-color: var(--ochre); }
.note .link { display: block; margin-top: 8px; }

.blank { padding: 26px 16px; text-align: center; }
.blank-t { font-size: 22px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; margin: 0 0 10px; }
.blank-p { font-size: 13.5px; line-height: 1.6; color: var(--mute); margin: 0 auto; max-width: 34ch; }

.link--quiet { color: var(--mute); }

/* sheets: forms --------------------------------------------- */

.field { margin-bottom: 14px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-hint { margin: 6px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--mute); }
.sheet-note {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: var(--panel);
  border-left: 3px solid var(--mag);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--mute);
}
textarea.input { resize: vertical; font-family: var(--sans); font-size: 14px; }
select.input { appearance: none; }

.tabs a.tab { text-decoration: none; display: block; }

.seg-link {
  display: inline-block;
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .06em;
  color: var(--mag);
  text-decoration: none;
}
.seg-link:hover { text-decoration: underline; }

/* ============================================================
   Ask — the chat, shared with Telegram.
   ============================================================ */

.ask { padding-bottom: 8px; }

.thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 8px;
}

.msg {
  background: var(--panel);
  border: 1px solid var(--grid);
  padding: 10px 13px;
  max-width: 88%;
}
.msg--her { border-left: 3px solid var(--mag); align-self: flex-start; }
.msg--you { background: var(--panel-2); align-self: flex-end; }
.msg-who {
  display: block;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 5px;
}
.msg-text {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* what she actually did — provenance, not decoration */
.tool-line {
  margin: 0;
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .04em;
  color: var(--faint);
  padding-left: 3px;
}
.tool-line--bad { color: var(--ochre); }

.msg--working .working-text { color: var(--mute); font-style: italic; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px 0;
}
.composer-input {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--grid);
  border-radius: 2px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
}
.composer-input:focus { border-color: var(--mag); }
.composer-input:disabled { opacity: .6; }

.composer-mic,
.composer-send {
  flex: 0 0 auto;
  padding: 10px 12px;
  border: 1.5px solid var(--grid);
  border-radius: 2px;
  background: var(--panel-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink);
}
.composer-send { background: var(--mag); border-color: var(--mag); color: #fff; }
.composer-send:disabled { opacity: .45; }
.composer-mic.is-recording {
  background: var(--ochre);
  border-color: var(--ochre);
  color: #fff;
}

.composer-status {
  margin: 7px 16px 0;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
  color: var(--mute);
}

.speaker {
  margin-top: 3px;
  padding: 3px 9px;
  border: 1px solid var(--grid);
  border-radius: 2px;
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mute);
}
.speaker.is-on { background: var(--mag); border-color: var(--mag); color: #fff; }

/* five tabs now, not four */
.tabs { grid-template-columns: repeat(5, 1fr); }
.tab { font-size: 9.5px; letter-spacing: .1em; }
