/* ============================================================================
   Coshare — app.css
   Theme: LIGHT by default (standard). Dark is an explicit choice via the toggle.
   The user override lives on <html data-theme="dark|light"> and is written by
   js/theme.js (localStorage key mcs.theme).

   Every colour is a token. No literal colours below this header, so adding a
   third theme means adding one block, not hunting through 90 rules.
   ========================================================================= */

/* ---------- brand fonts: self-hosted (offline-first, nothing fetched) ----------
   Figtree + Bricolage Grotesque, SIL OFL 1.1 (see fonts/OFL-*.txt).
   Latin variable subsets only (~60 KB total). */
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("../fonts/figtree-latin-wght.woff2") format("woff2");
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/bricolage-grotesque-latin-wght.woff2") format("woff2");
}

/* ============================================================================
   Brand: "Shared Horizon"
   Sunset Coral #F0643C · Saffron #FFB627 · Dusk Indigo #2B2350
   Sand #FFF4E8 (light ground) · Night Sky #17122B (dark ground)
   Coral is deepened for light-mode text/buttons and lifted to #FF7A55 on dark
   so every text pair clears WCAG AA (tests/contrast.js checks them all).
   ========================================================================= */
:root {
  /* LIGHT is the standard theme (2026-10-22). Dark is opt-in via the toggle. */
  color-scheme: light;

  /* surfaces — warm, derived from Sand */
  --bg: #FFF4E8;
  --surface: #FFFCF8;
  --card: #FFFFFF;
  --card-2: #FFF8F0;
  --card-3: #F8E9D8;
  --border: #EBDCCB;
  --border-soft: #F2E6D8;
  --border-strong: #968779; /* form controls: >= 3:1 on every surface */
  --hairline: rgba(150, 95, 45, .08);

  /* brand */
  --primary: #B83F1E;          /* deep coral: 5.6:1 white-on-coral, 4.7:1+ on every surface */
  --primary-alt: #FFB627;      /* saffron */
  --primary-deep: #9A3517;
  --primary-grad: linear-gradient(135deg, #B83F1E 0%, #C94A24 100%);
  --on-primary: #FFFFFF;
  --primary-soft: rgba(240, 100, 60, .12);
  --primary-ring: rgba(240, 100, 60, .38);
  --accent: #FFB627;           /* saffron: fills only, text on it is indigo */
  --on-accent: #2B2350;
  --accent-soft: rgba(255, 182, 39, .22);

  /* logo parts (the horizon bar flips to Sand on dark) */
  --logo-sun: #F0643C;
  --logo-sea: #FFB627;
  --logo-bar: #2B2350;
  --wordmark: #2B2350;

  /* semantic — each has a soft fill and a text colour that stays readable
     on its own surface in either theme. Positive is green, danger is a
     raspberry red, so neither is confused with the coral primary. */
  --ok: #1E7A52;
  --ok-text: #17704A;
  --ok-soft: rgba(30, 122, 82, .11);
  --ok-ring: rgba(30, 122, 82, .30);
  --danger: #B4234A;
  --danger-soft: rgba(180, 35, 74, .10);
  --danger-text: #A41F44;
  --danger-ring: rgba(180, 35, 74, .30);
  --warn: #C98A00;
  --warn-soft: rgba(255, 182, 39, .20);
  --warn-text: #7F4E00;
  --info: #4A44B5;
  --info-soft: rgba(74, 68, 181, .10);
  --info-text: #3F3A9E;
  --neutral-soft: rgba(150, 95, 45, .10);

  /* text — Dusk Indigo ink */
  --text: #2B2350;
  --text-grad: linear-gradient(180deg, #2B2350, #4A4170);
  --muted: #5C5470;
  --dim: #675F7B;

  /* type */
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  --display: "Bricolage Grotesque", "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* shape + depth (shadows tinted indigo, never pure black) */
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --shadow: 0 10px 28px rgba(43, 35, 80, .10);
  --shadow-sm: 0 1px 4px rgba(43, 35, 80, .07);
  --shadow-primary: 0 6px 16px rgba(240, 100, 60, .24);

  /* glass + chrome */
  --hdr-bg: rgba(255, 244, 232, .86);
  --nav-bg: rgba(255, 252, 248, .90);
  --hover: rgba(43, 35, 80, .05);
  --scrim: rgba(23, 18, 43, .45);
  --ring: 0 0 0 3px var(--primary-ring);

  /* decorative background glows */
  --glow-1: rgba(240, 100, 60, .12);
  --glow-2: rgba(255, 182, 39, .14);
  --accent-line: linear-gradient(90deg, var(--primary), var(--accent) 60%, transparent);
}

/* ---------- dark theme: explicit choice via the toggle ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  /* surfaces — Night Sky ground, Dusk Indigo cards */
  --bg: #17122B;
  --surface: #1E1836;
  --card: #221B3E;
  --card-2: #2B2350;
  --card-3: #362C63;
  --border: #3E3470;
  --border-soft: #2E2754;
  --border-strong: #8178B0;
  --hairline: rgba(255, 244, 232, .07);

  /* brand: coral lifted for the dark ground */
  --primary: #FF7A55;
  --primary-alt: #FFC24D;
  --primary-deep: #E85A33;
  --primary-grad: linear-gradient(135deg, #FF7A55 0%, #FF9466 100%);
  --on-primary: #17122B;       /* Night Sky ink on coral: 7:1 */
  --primary-soft: rgba(255, 122, 85, .16);
  --primary-ring: rgba(255, 122, 85, .45);
  --accent: #FFC24D;
  --on-accent: #17122B;
  --accent-soft: rgba(255, 194, 77, .16);

  --logo-sun: #FF7A55;
  --logo-sea: #FFC24D;
  --logo-bar: #FFF4E8;
  --wordmark: #FFF4E8;

  --ok: #4FD18F;
  --ok-text: #7FE0AE;
  --ok-soft: rgba(79, 209, 143, .14);
  --ok-ring: rgba(79, 209, 143, .34);
  --danger: #FF5C80;
  --danger-soft: rgba(255, 92, 128, .15);
  --danger-text: #FF9AB0;
  --danger-ring: rgba(255, 92, 128, .36);
  --warn: #FFC24D;
  --warn-soft: rgba(255, 194, 77, .15);
  --warn-text: #FFD27A;
  --info: #9C97FF;
  --info-soft: rgba(156, 151, 255, .15);
  --info-text: #C3C0FF;
  --neutral-soft: rgba(196, 187, 218, .12);

  --text: #FFF4E8;
  --text-grad: linear-gradient(180deg, #FFF4E8, #D9CFEA);
  --muted: #C4BBDA;
  --dim: #ABA2C8;

  --shadow: 0 10px 30px rgba(8, 5, 18, .50);
  --shadow-sm: 0 2px 8px rgba(8, 5, 18, .35);
  --shadow-primary: 0 6px 18px rgba(255, 122, 85, .26);

  --hdr-bg: rgba(23, 18, 43, .86);
  --nav-bg: rgba(30, 24, 54, .90);
  --hover: rgba(255, 244, 232, .06);
  --scrim: rgba(10, 7, 20, .72);

  --glow-1: rgba(255, 122, 85, .14);
  --glow-2: rgba(255, 194, 77, .08);
}

/* ============================================================================
   base
   ========================================================================= */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  padding: 0 0 100px;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* two soft glows behind everything, fixed so the page never scrolls them */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(58rem 30rem at 12% -6%, var(--glow-1), transparent 62%),
    radial-gradient(46rem 26rem at 92% 4%, var(--glow-2), transparent 60%);
}

::selection { background: var(--primary); color: var(--on-primary); }

/* theme changes are a colour fade, not a layout change */
body, .card, .app-header, .bottom-nav, .modal, .modal-backdrop,
.pill, .chip, .key, .stat, .member, .list-row, .bal, .settle,
.picker-item, .trip-banner, .share-row, .toast, .brand-mark {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease, box-shadow .3s ease;
}

.wrap { max-width: 520px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 12px; }

/* custom scrollbars, only where a scrollbar is actually visible */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--card-3);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 20px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border); background-clip: content-box; }

/* ============================================================================
   header
   ========================================================================= */

.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--hdr-bg);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border-soft);
  padding: 13px 0 11px;
}
/* a hairline of brand colour under the glass */
.app-header::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--accent-line);
  opacity: .55;
}
.app-header .wrap { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: grid; place-items: center;
}
.brand-mark svg, .logo-mark { display: block; width: 100%; height: 100%; overflow: visible; }
.logo-mark .lm-sun { fill: var(--logo-sun); }
.logo-mark .lm-sea { fill: var(--logo-sea); }
.logo-mark .lm-bar { fill: var(--logo-bar); }
.brand-text { min-width: 0; }
.brand-name {
  font-family: var(--display); font-size: 21px; font-weight: 800; line-height: 1;
  letter-spacing: -.6px; color: var(--wordmark); text-transform: lowercase;
}
.brand-sub {
  font-size: 11px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.header-right { margin-left: auto; display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }

/* ---------- theme toggle ---------- */
.theme-toggle {
  width: 32px; height: 32px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--card-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; padding: 0; font-size: 15px; line-height: 1;
  transition: background-color .15s, color .15s, border-color .15s, transform .12s;
}
.theme-toggle:hover { color: var(--text); background: var(--card-3); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--primary); }
.theme-toggle .ic { display: none; }
:root:not([data-theme="dark"]) .theme-toggle .ic-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: block; }

/* ---------- offline / fx status pill ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .2px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill .dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 0 3px rgba(127, 127, 127, .18);
}
.pill-offline { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-ring); }
.pill-online { background: var(--ok-soft); color: var(--ok-text); border-color: var(--ok-ring); }

/* ============================================================================
   step bar
   ========================================================================= */

.steps { display: flex; gap: 5px; padding: 13px 0 4px; }
.steps .seg {
  flex: 1; height: 4px; border-radius: 2px;
  background: var(--card-3);
  transition: background .25s, box-shadow .25s;
}
.steps .seg.done { background: var(--primary-deep); }
.steps .seg.active { background: var(--primary-grad); box-shadow: 0 0 12px var(--primary-ring); }

/* ============================================================================
   typography
   ========================================================================= */

/* --text-grad is defined per theme from plain tokens: color-mix() would leave
   the gradient invalid (and the heading invisible) on engines that lack it. */
h1 {
  font-size: 22px; font-weight: 800; letter-spacing: -.5px;
  background: var(--text-grad);
  -webkit-background-clip: text; background-clip: text;
  color: var(--text); /* fallback if background-clip:text is unsupported */
  -webkit-text-fill-color: transparent;
}
@supports not ((background-clip: text) or (-webkit-background-clip: text)) {
  h1 { background: none; -webkit-text-fill-color: currentColor; }
}
h2 { font-size: 17px; font-weight: 800; letter-spacing: -.2px; }
h1, h2 { font-family: var(--display); }
h3 { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
p { color: var(--muted); font-size: 13.5px; }
.hint { font-size: 12px; color: var(--dim); line-height: 1.55; }
.mono { font-family: var(--mono); }

.section-head { display: flex; align-items: baseline; gap: 8px; margin: 22px 0 12px; }
.section-head .count { font-size: 11px; color: var(--dim); margin-left: auto; }

/* ============================================================================
   cards
   ========================================================================= */

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 15px; border-bottom: 1px solid var(--border-soft);
  background: var(--hairline);
}
.card-head h3 { margin: 0; }
.card-body { padding: 15px; }

.stat-row { display: flex; gap: 10px; }
.stat {
  flex: 1; min-width: 0;
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 11px 12px;
  box-shadow: var(--shadow-sm);
}
.stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: .7px; color: var(--dim); font-weight: 700; }
.stat .v {
  font-size: 16px; font-weight: 800; margin-top: 3px; letter-spacing: -.3px;
  word-break: break-all; font-variant-numeric: tabular-nums;
}
.stat .v.pos { color: var(--ok-text); }
.stat .v.neg { color: var(--danger-text); }
.stat .v.neutral { color: var(--muted); }

/* ============================================================================
   forms
   ========================================================================= */

label.field { display: block; margin-bottom: 12px; }
label.field:last-child { margin-bottom: 0; }
label.field > span {
  display: block; font-size: 10.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 6px;
}
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 12px 13px;
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background-color .3s;
}
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--dim); }
input:disabled, select:disabled { opacity: .5; }
input.invalid, select.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
textarea { resize: vertical; min-height: 62px; }
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' stroke='%237b8798' stroke-width='2' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }

.inline-note { font-size: 11.5px; color: var(--dim); margin-top: 6px; }
.inline-note.warn { color: var(--warn-text); }
.inline-note.error { color: var(--danger-text); }
.inline-note.ok { color: var(--ok-text); }

/* ---------- by-shares stepper ----------
   One row per person: name, - [shares] +, resulting amount.
   Not .field-row/.field — those are display:block and would stack the
   controls vertically instead of laying them out side by side. */
.share-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
}
.share-row:last-of-type { border-bottom: none; }
.share-name {
  flex: 1; min-width: 0; margin: 0;
  font-size: 13.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.shares-input {
  flex: 0 0 46px; width: 46px;
  text-align: center; padding: 7px 2px;
  font-variant-numeric: tabular-nums;
}
.step-btn {
  flex: 0 0 32px; width: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; margin: 0;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text); font-size: 16px; line-height: 1; cursor: pointer;
  transition: background-color .12s, transform .06s;
}
.step-btn:hover { background: var(--card-3); }
.step-btn:active { transform: translateY(1px); }
.share-amount {
  flex: 0 0 auto; min-width: 86px; text-align: right;
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--text);
}

/* ============================================================================
   buttons
   ========================================================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; padding: 14px 16px;
  background: var(--primary-grad); color: var(--on-primary);
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 800; font-family: inherit;
  cursor: pointer; letter-spacing: .1px;
  box-shadow: var(--shadow-primary);
  transition: transform .08s, opacity .15s, box-shadow .15s, background-color .3s;
}
.btn:hover { opacity: .94; box-shadow: 0 8px 22px var(--primary-ring); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary { background: var(--card-2); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--card-3); opacity: 1; box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); box-shadow: none; }
.btn-ghost:hover { color: var(--text); background: var(--hover); opacity: 1; }
.btn-danger { background: var(--danger-soft); color: var(--danger-text); border: 1px solid var(--danger-soft); box-shadow: none; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); opacity: 1; }
.btn-sm { padding: 9px 13px; font-size: 13px; width: auto; border-radius: 9px; }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }

/* ============================================================================
   chips
   ========================================================================= */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 13px; border-radius: 20px;
  background: var(--card-2); color: var(--muted);
  border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 700; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: background-color .14s, color .14s, border-color .14s, transform .1s;
}
.chip:hover { color: var(--text); background: var(--card-3); }
.chip:active { transform: scale(.96); }
.chip:focus-visible { outline: none; box-shadow: var(--ring); }
.chip.active {
  background: var(--primary-grad); color: var(--on-primary);
  border-color: transparent; font-weight: 800; box-shadow: var(--shadow-primary);
}
.chip.excluded { opacity: .42; text-decoration: line-through; }
.chip .x { margin-left: 4px; font-size: 10px; }

/* ============================================================================
   member list
   ========================================================================= */

.member {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; margin-bottom: 6px;
  background: var(--card-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.member:last-child { margin-bottom: 0; }
.member input {
  flex: 1; padding: 6px 8px; font-size: 14px;
  background: transparent; border-color: transparent;
}
.member input:hover { border-color: var(--border); }
.member .idx {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.icon-btn {
  width: 30px; height: 30px; flex: 0 0 auto;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-size: 13px; display: grid; place-items: center;
  transition: color .15s, border-color .15s, background-color .15s;
}
.icon-btn:hover { color: var(--danger-text); border-color: var(--danger); background: var(--danger-soft); }
.icon-btn.ok:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

/* ============================================================================
   keypad + amount display
   ========================================================================= */

.amount-display {
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1.5px solid var(--primary);
  border-radius: var(--radius); padding: 13px 15px; margin-bottom: 10px;
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.amount-display .expr {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  min-height: 17px; word-break: break-all;
}
.amount-display .total {
  font-size: 31px; font-weight: 800; color: var(--primary);
  letter-spacing: -1.1px; margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.amount-display.err { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.amount-display.err .total { color: var(--danger-text); font-size: 15px; }

.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.key {
  padding: 16px 0;
  background: linear-gradient(180deg, var(--card-3), var(--card-2));
  color: var(--text);
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  font-size: 19px; font-weight: 700; font-family: inherit;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .06s, background-color .12s, color .12s, box-shadow .12s;
}
.key:hover { border-color: var(--border); }
.key:active {
  transform: scale(.95);
  background: var(--primary-grad); color: var(--on-primary);
  box-shadow: var(--shadow-primary);
}
.key.op { background: transparent; color: var(--muted); font-size: 17px; box-shadow: none; border-color: transparent; }
.key.op:hover { color: var(--primary); background: var(--primary-soft); }
.key.fn { background: transparent; color: var(--muted); font-size: 14px; font-weight: 800; box-shadow: none; border-color: transparent; }
.key.fn:hover { color: var(--primary); background: var(--primary-soft); }

/* ============================================================================
   badges
   ========================================================================= */

.badge {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .3px;
  text-transform: uppercase; white-space: nowrap;
}
.badge-pos { background: var(--ok-soft); color: var(--ok-text); }
.badge-neg { background: var(--danger-soft); color: var(--danger-text); }
.badge-zero { background: var(--neutral-soft); color: var(--muted); }
.badge-fx { background: var(--info-soft); color: var(--info-text); }
.badge-manual { background: var(--warn-soft); color: var(--warn-text); }
.badge-cat { background: var(--card-2); color: var(--muted); border: 1px solid var(--border-soft); }

/* ============================================================================
   list rows
   ========================================================================= */

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px; border-bottom: 1px solid var(--border-soft);
  transition: background-color .14s;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--hover); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-size: 14px; font-weight: 600; }
.list-row .meta { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.list-row .amount {
  font-size: 14.5px; font-weight: 800; white-space: nowrap; letter-spacing: -.2px;
  font-variant-numeric: tabular-nums;
}
.list-row .actions { display: flex; gap: 5px; flex: 0 0 auto; }

.empty { padding: 28px 16px; text-align: center; color: var(--dim); font-size: 13px; }
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .5; }

/* ============================================================================
   balances
   ========================================================================= */

.bal {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 15px; border-bottom: 1px solid var(--border-soft);
}
.bal:last-child { border-bottom: none; }
.bal .who { flex: 1; font-size: 14px; font-weight: 600; min-width: 0; }
.bal .val { font-size: 15px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }

.settle {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 15px; border-bottom: 1px solid var(--border-soft);
}
.settle:last-child { border-bottom: none; }
.settle .flow { flex: 1; font-size: 13.5px; min-width: 0; }
.settle .flow b { font-weight: 700; }
.settle .amt { font-size: 14.5px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ============================================================================
   filters
   ========================================================================= */

.filter-bar { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar .chip { flex: 0 0 auto; }

/* ============================================================================
   toast
   ========================================================================= */

.toast-host {
  position: fixed; left: 0; right: 0; bottom: 88px; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
/* keep toasts clear of the bottom nav and of tappable content */
.toast {
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); padding: 12px 17px; border-radius: 22px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
  animation: toast-in .22s cubic-bezier(.2, .9, .3, 1.2);
  max-width: 100%; text-align: center;
  pointer-events: auto;
}
.toast.ok { border-color: var(--ok-ring); color: var(--ok-text); }
.toast.err { border-color: var(--danger-ring); color: var(--danger-text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: none; } }

/* ============================================================================
   modal
   ========================================================================= */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: var(--scrim);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in .16s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow);
  padding: 19px 16px calc(19px + env(safe-area-inset-bottom));
  animation: slide-up .24s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: none; } }
.modal h2 { margin-bottom: 4px; }
.modal .modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal .modal-actions .btn { flex: 1; }

/* ============================================================================
   bottom nav — a floating glass bar rather than a full-bleed strip
   ========================================================================= */

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border-soft);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  display: flex;
}
.bottom-nav button {
  flex: 1; background: transparent; border: none;
  padding: 8px 2px 7px; color: var(--dim);
  font-size: 10px; font-weight: 700; font-family: inherit;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border-radius: 11px; position: relative;
  transition: color .18s, background-color .18s;
}
.bottom-nav button .ic {
  font-size: 19px; line-height: 1;
  transition: transform .22s cubic-bezier(.2, .9, .3, 1.3);
}
.bottom-nav button:hover { color: var(--muted); }
.bottom-nav button.active { color: var(--primary); background: var(--primary-soft); }
.bottom-nav button.active .ic { transform: translateY(-1px) scale(1.08); }
.bottom-nav button:focus-visible { outline: none; box-shadow: var(--ring); }
.bottom-nav button .pip {
  position: absolute; top: 5px; right: 50%; margin-right: -16px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--warn);
}

/* ============================================================================
   pre / code
   ========================================================================= */

pre.block {
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow-y: auto; margin: 0;
  color: var(--muted);
}
pre.block.tall { max-height: 340px; }

/* ============================================================================
   canvas / camera
   NOTE: a QR code and a shareable summary image are both read by other
   devices and scanners, so these stay white in every theme on purpose.
   ========================================================================= */

.qr-wrap {
  background: #fff; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 12px; display: grid; place-items: center; margin: 0 auto;
  width: fit-content; max-width: 100%;
  box-shadow: var(--shadow-sm);
}
.qr-wrap canvas { display: block; image-rendering: pixelated; max-width: 100%; height: auto; }
.qr-meta { text-align: center; margin-top: 10px; font-size: 11.5px; color: var(--dim); }

video { width: 100%; border-radius: var(--radius-sm); background: #000; display: block; }
.scan-frame {
  position: relative; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border);
}

/* ============================================================================
   misc utilities
   ========================================================================= */

.divider { height: 1px; background: var(--border-soft); margin: 15px 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack > * + * { margin-top: 10px; }
.nowrap { white-space: nowrap; }
.text-dim { color: var(--dim); }
.text-muted { color: var(--muted); }
.fs-11 { font-size: 11px; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.center { text-align: center; }

.screen { display: none; animation: screen-in .22s ease; }
.screen.active { display: block; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.trip-banner {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, var(--card-2), var(--card));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.trip-banner .nm { font-size: 14.5px; font-weight: 700; }
.trip-banner .sub { font-size: 11.5px; color: var(--dim); }

.picker-list { max-height: 46vh; overflow-y: auto; margin: 0 -16px; }
.picker-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 14px 16px; background: transparent; border: none;
  border-bottom: 1px solid var(--border-soft); color: var(--text);
  font-family: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
  transition: background-color .14s;
}
.picker-item:hover { background: var(--card-2); }
.picker-item.active { background: var(--primary-soft); }
.picker-item .grow { flex: 1; min-width: 0; }
.picker-item .sub { font-size: 11.5px; color: var(--dim); }

/* ============================================================================
   responsive + motion
   ========================================================================= */

@media (max-width: 380px) {
  .wrap { padding: 0 13px; }
  .keypad { gap: 5px; }
  .key { font-size: 17px; padding: 14px 0; }
  .amount-display .total { font-size: 27px; }
  .stat .v { font-size: 15px; }
  .share-amount { min-width: 72px; font-size: 12.5px; }
}

/* tablets: the app is a phone-first column, so just let it breathe */
@media (min-width: 600px) and (max-width: 1023.98px) {
  body { padding-bottom: 108px; }
  .bottom-nav {
    left: 50%; right: auto; bottom: 14px; transform: translateX(-50%);
    width: min(560px, calc(100vw - 40px));
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    box-shadow: var(--shadow);
  }
}

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

/* ============================================================================
   CLEAN UI v2 (2026-10-22)
   Flat, calm surfaces: no background glows, no gradient buttons or headings,
   lighter shadows, SVG line icons instead of emoji. Tokens only — both themes.
   ========================================================================= */
:root, :root[data-theme="dark"] {
  --glow-1: transparent;
  --glow-2: transparent;
  --primary-grad: var(--primary);
  --text-grad: linear-gradient(var(--text), var(--text));
  --shadow-primary: none;
}
:root { --shadow: 0 1px 3px rgba(43,35,80,.07), 0 1px 2px rgba(43,35,80,.05); }
.app-header::after { display: none; }
.app-header { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
.brand-mark { background: none; box-shadow: none; }
.btn { font-weight: 700; box-shadow: none; }
.btn:hover { box-shadow: none; opacity: .92; }
.chip.active { box-shadow: none; }
.card { box-shadow: var(--shadow); }
.bottom-nav { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); border-top: 1px solid var(--border); }
.bottom-nav button .ic { display: grid; place-items: center; height: 22px; }
.bottom-nav button .ic svg { width: 22px; height: 22px; }
.bottom-nav button.active .ic { transform: none; }
.theme-toggle .ic svg { width: 16px; height: 16px; }
.filter-bar { padding: 2px 2px 8px; }
.import-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ============================================================================
   RESPONSIVE v3 (2026-10-22) — phone, tablet and computer
   Phone (<600px): one column, menu at the bottom.
   Tablet (600–1023px): wider single column, floating menu bar.
   Computer (>=1024px): menu becomes a left sidebar, screens use two columns.
   ========================================================================= */

/* header: guide button */
.help-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 10px; border-radius: 10px;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.help-btn svg { width: 17px; height: 17px; }
.help-btn:hover { color: var(--text); background: var(--hover); }
.help-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.header-right { display: flex; align-items: center; gap: 8px; }
@media (max-width: 420px) { .help-label { display: none; } .help-btn { width: 34px; padding: 0; justify-content: center; } }

/* the sidebar-only Guide entry stays out of the phone bar (header button covers it) */
.bottom-nav .nav-help { display: none; }

/* columns collapse to a single stack on phones and tablets */
.cols { display: block; }
.col { min-width: 0; }
.cta-row { margin-top: 4px; }
.kbd-tip { display: none; }
.key.pressed { background: var(--primary-soft); border-color: var(--primary); }

/* guide content */
.steps { padding-left: 20px; display: grid; gap: 7px; font-size: 14px; }
.steps li::marker { color: var(--primary); font-weight: 700; }
.bullets { padding-left: 18px; display: grid; gap: 7px; font-size: 14px; }
.help-dl { display: grid; gap: 4px; font-size: 14px; }
.help-dl dt { font-weight: 700; margin-top: 6px; }
.help-dl dd { color: var(--muted); }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }
.help-toc a {
  font-size: 12.5px; font-weight: 600; color: var(--primary); text-decoration: none;
  padding: 6px 10px; border-radius: 999px; background: var(--primary-soft);
}
.help-toc a:hover { text-decoration: underline; }
.help .card { scroll-margin-top: 76px; }

/* trip rates */
.rate-status { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rate-status .hint { flex: 1 1 220px; }
.trip-rate-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--border-soft);
}
.trip-rate-row:last-child { border-bottom: none; }
.trip-rate-row .grow { flex: 1 1 180px; min-width: 0; }
.trip-rate-add { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 8px; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px;
  background: var(--neutral-soft); color: var(--muted); vertical-align: 1px; }

/* modal: a centred dialog on wider screens rather than a bottom sheet */
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: var(--radius-lg); max-width: 480px; padding: 22px 22px; }
  .wrap { max-width: 680px; }
}

@media (min-width: 1024px) {
  :root { --side-w: 232px; --main-w: 1120px; }
  body { padding-bottom: 40px; }
  .app-header { z-index: 120; }
  .app-header .wrap { max-width: none; padding: 0 24px; }
  .brand { width: calc(var(--side-w) - 24px); }

  /* menu → left sidebar */
  .bottom-nav, .bottom-nav[class] {
    top: 0; bottom: 0; left: 0; right: auto; transform: none;
    width: var(--side-w); flex-direction: column; gap: 2px;
    padding: 76px 12px 16px;
    border: none; border-right: 1px solid var(--border); border-radius: 0; box-shadow: none;
    background: var(--surface);
  }
  .bottom-nav button {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px;
    font-size: 14px; font-weight: 600; padding: 10px 12px; color: var(--muted);
  }
  .bottom-nav button:hover { background: var(--hover); color: var(--text); }
  .bottom-nav button.active { color: var(--primary); }
  .bottom-nav button .ic, .bottom-nav button .ic svg { width: 20px; height: 20px; }
  .bottom-nav .nav-help { display: flex; margin-top: auto; }
  .help-btn { display: none; }

  /* main area sits to the right of the sidebar, centred in what is left */
  main.wrap {
    max-width: var(--main-w); padding: 22px 32px 0;
    margin-left: calc(var(--side-w) + max(0px, (100vw - var(--side-w) - var(--main-w)) / 2));
    margin-right: auto;
  }
  .section-head h1 { font-size: 24px; }

  /* two-column screens */
  .cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 20px; align-items: start; }
  .col-first { margin-top: 0; }
  .cols-log { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .col-sticky { position: sticky; top: 80px; }
  .cols-ledger { grid-template-columns: 280px minmax(0, 1fr); }
  .cols-ledger.no-filter { grid-template-columns: minmax(0, 1fr); }
  .cols-ledger #filter-card { position: sticky; top: 80px; }
  .cols-ledger .filter-bar { flex-wrap: wrap; overflow: visible; }
  .cta-row { display: flex; justify-content: flex-end; }
  .cta-row .btn { width: auto; padding-left: 28px; padding-right: 28px; }
  .kbd-tip { display: block; }
  #screen-ledger .stat-row .stat .v { font-size: 20px; }

  /* card grids that just need to flow (share, guide) */
  .masonry { column-count: 2; column-gap: 20px; }
  .masonry > .card { break-inside: avoid; display: inline-block; width: 100%; }

  /* trip banner: compact strip above each screen */
  .trip-banner { margin-bottom: 18px; }
  .toast-host { left: calc(var(--side-w) + 16px); }
}

@media (min-width: 1440px) {
  :root { --main-w: 1200px; }
}

/* ============================================================================
   BRAND v3 "Shared Horizon" (2026-10-25)
   Horizon Split mark + lowercase Bricolage wordmark. Logo parts are tokens,
   so the indigo horizon bar turns Sand on the Night Sky ground.
   ========================================================================= */
.brand-text { display: flex; flex-direction: column; gap: 3px; }
.h-brand { display: flex; align-items: center; gap: 10px; }
.h-brand-mark { width: 30px; height: 30px; flex: 0 0 auto; }
.empty .big.brand-empty { width: 56px; height: 56px; margin: 0 auto 12px; opacity: 1; }
.amount-display, .bal .val, .settle .amt, .stat .v { font-variant-numeric: tabular-nums; }

/* ============================================================================
   site footer + simple pages (privacy, 404) — 2026-10-25
   Uses only existing tokens: muted / primary on bg (covered by tests/contrast.js).
   ========================================================================= */
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 4px 10px; margin: 28px 0 8px; padding: 14px 0 0;
  border-top: 1px solid var(--border-soft);
  font-size: 13px; color: var(--muted);
}
.site-footer a { color: var(--primary); font-weight: 600; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer a:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
.site-footer-tag { font-family: var(--display); font-weight: 600; }

.page-header .wrap { justify-content: space-between; }
.page-header .brand { text-decoration: none; color: inherit; }
.back-link { color: var(--primary); font-weight: 600; font-size: 14px; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.page-main { max-width: 720px; margin: 0 auto; padding: 20px 16px 0; }
body.simple-page { padding-bottom: 32px; }
.legal h1 { font-family: var(--display); font-size: 28px; margin: 8px 0 4px; color: var(--text); }
.legal h2 { font-family: var(--display); font-size: 18px; margin: 26px 0 8px; color: var(--text); }
.legal p, .legal li { font-size: 15px; line-height: 1.6; color: var(--text); }
.legal p { margin: 0 0 10px; }
.legal ul { margin: 0 0 10px 20px; }
.legal li { margin: 4px 0; }
.legal a { color: var(--primary); font-weight: 600; }
.legal code { font-family: var(--mono); font-size: 13px; }
.legal .updated { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.legal .lead { font-size: 17px; }
.notfound { text-align: center; padding-top: 48px; }
.notfound .big { font-family: var(--display); font-size: 64px; font-weight: 700; color: var(--primary); line-height: 1; }
.notfound .btn { display: inline-flex; width: auto; padding-left: 28px; padding-right: 28px; text-decoration: none; margin-top: 18px; }
