/* ==========================================================================
   Roamigo — visual system
   Mobile-first, max content width 430px, centred on larger screens with a
   fixed cream page background outside the app shell. Two themes (Pounamu
   default, Sunset) via CSS custom properties on html[data-theme="..."].
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,400;0,500;0,600;0,700;0,800;1,500&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ---------- Theme tokens ---------- */

:root,
html[data-theme="pounamu"] {
  --page-bg: oklch(0.94 0.02 85);
  --bg: oklch(0.97 0.015 85);
  --surface: #fff;
  --surface-2: oklch(0.94 0.02 165);
  --ink: oklch(0.24 0.03 150);
  --ink-2: oklch(0.45 0.02 150);
  --ink-3: oklch(0.55 0.02 150);
  --brand: oklch(0.34 0.06 165);
  --brand-2: oklch(0.52 0.1 165);
  --accent: oklch(0.62 0.13 45);
  --success: oklch(0.75 0.12 145);
  --line: oklch(0.88 0.02 85);
  --avatar-1: oklch(0.62 0.13 45);
  --avatar-2: oklch(0.52 0.1 165);
  --avatar-3: oklch(0.55 0.1 250);
  --avatar-4: oklch(0.42 0.03 150);
  --danger: oklch(0.55 0.18 25);
}

html[data-theme="sunset"] {
  --page-bg: oklch(0.93 0.025 70);
  --bg: oklch(0.97 0.02 70);
  --surface: #fff;
  --surface-2: oklch(0.94 0.02 200);
  --ink: oklch(0.24 0.04 40);
  --ink-2: oklch(0.45 0.03 40);
  --ink-3: oklch(0.55 0.03 40);
  --brand: oklch(0.5 0.13 35);
  --brand-2: oklch(0.55 0.08 200);
  --accent: oklch(0.72 0.14 65);
  --success: oklch(0.75 0.12 145);
  --line: oklch(0.88 0.02 70);
  --avatar-1: oklch(0.72 0.14 65);
  --avatar-2: oklch(0.55 0.08 200);
  --avatar-3: oklch(0.6 0.12 15);
  --avatar-4: oklch(0.4 0.05 40);
  --danger: oklch(0.55 0.18 25);
}

/* ---------- Reset / base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea { font-family: inherit; color: inherit; }

a { color: var(--brand-2); text-decoration: none; }
a:hover { color: var(--brand); }

::selection { background: var(--accent); color: #fff; }

/* ---------- App shell ---------- */

.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

@media (min-width: 431px) {
  .app {
    border-radius: 28px;
    border: 1px solid oklch(0.3 0.04 150 / 0.1);
    box-shadow: 0 0 0 1px oklch(0.97 0.015 85 / 0.6) inset, 0 40px 90px -30px oklch(0.3 0.04 150 / 0.45), 0 10px 30px -12px oklch(0.3 0.04 150 / 0.25);
    margin: 24px auto;
    min-height: calc(100vh - 48px);
  }
}

.screen {
  padding: 14px 20px calc(112px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
}

.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px 4px;
  gap: 12px;
}

.screen-title {
  font-family: 'Instrument Serif', serif;
  font-size: 30px;
  line-height: 1.1;
  color: var(--ink);
}

.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
/* The amber tint is reserved for a small set of badges: trip-day, activity
   date dividers, the setup step badge, and "Custom category" — not every
   field label. See design frames 1a/2a. */
.eyebrow.accent { color: var(--accent); }

.footer {
  font-size: 14px;
  color: var(--ink-3);
  text-align: center;
  padding: 18px 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.footer .heart-emoji {
  font-size: 15px; line-height: 1; display: inline-block;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.footer .heart-emoji.heart-grow { animation: kheartgrow 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes kheartgrow {
  0% { transform: scale(1); }
  60% { transform: scale(2.6); }
  84% { transform: scale(0.85); opacity: 1; }
  85% { transform: scale(0.85); opacity: 0; }
  86% { transform: scale(1); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.heart-piece {
  position: fixed;
  font-size: 13px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: kheartscatter 0.6s ease-out both;
}
@keyframes kheartscatter {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--hx)), calc(-50% + var(--hy))) scale(0.9); opacity: 0; }
}

/* ---------- Tab bar / FAB ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 430px;
  margin: 0 auto;
  height: 96px;
  /* Solid, not a fade-to-transparent gradient — the fade let scrolled
     content (a card's own "Settle" button, an Activity row, etc.) bleed
     through and visually collide with the tab labels as it passed behind
     the bar. A soft shadow gives the lifted-edge look instead. */
  background: var(--bg);
  box-shadow: 0 -8px 20px -10px color-mix(in oklch, var(--ink) 18%, transparent);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding: 16px 30px calc(env(safe-area-inset-bottom)) 30px;
  z-index: 80;
}

.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 700;
  background: none;
  border: none;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  padding: 2px;
}

.tabbar-item.active { color: var(--brand-2); }

.fab {
  width: 58px;
  height: 58px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 22px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -14px;
  box-shadow: 0 10px 22px -6px color-mix(in oklch, var(--accent) 70%, transparent);
  border: none;
  cursor: pointer;
}
.fab:active { transform: scale(0.96); }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 2px 0 oklch(0.3 0.04 150 / 0.05);
}

.card-dark {
  background: var(--brand);
  border-radius: 26px;
  padding: 22px 22px 20px;
  color: var(--bg);
  position: relative;
  overflow: hidden;
}
.card-dark::before {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--accent) 22%, transparent);
  pointer-events: none;
}

.hero-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.7;
  position: relative;
}

.hero-amount {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  position: relative;
}

.hero-sub {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
  position: relative;
}

.hero-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  opacity: 0.85;
  position: relative;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid oklch(0.96 0.02 85 / 0.18);
}

.payment-card {
  background: var(--surface);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 2px 0 oklch(0.3 0.04 150 / 0.05);
}

.payment-who { display: flex; align-items: center; gap: 10px; }

.payment-amount {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 14px;
  gap: 12px;
}

.activity-row {
  background: var(--surface);
  border-radius: 20px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 44px;
  cursor: pointer;
}

.activity-row.settlement { background: var(--surface-2); }

.activity-row-wrap.expanded .activity-row { border-radius: 20px 20px 0 0; }

.activity-caret { color: var(--ink-3); flex: none; display: flex; }

.activity-expand {
  background: color-mix(in oklch, var(--brand-2) 7%, var(--surface));
  border-radius: 0 0 20px 20px;
  padding: 14px 16px 16px;
  margin-top: -1px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.activity-expand-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.activity-expand-line .k { font-size: 12px; color: var(--ink-3); flex: none; }
.activity-expand-line .v { font-size: 13px; font-weight: 700; color: var(--ink); text-align: right; }

.activity-icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--brand-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.activity-row.settlement .activity-icon { background: var(--brand-2); color: var(--surface); }

.activity-main { flex: 1; min-width: 0; }
.activity-main .title { font-size: 15px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-main .sub { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.activity-amt { text-align: right; }
.activity-amt .amt { font-size: 16px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.activity-amt .approx { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--ink-3); }

.day-header { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.day-header .eyebrow { white-space: nowrap; }
.day-header .total { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-3); white-space: nowrap; }

.strip { flex: 1; height: 1px; background: var(--line); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 13px;
  border-radius: 999px;
}
.pill-green { background: color-mix(in oklch, var(--success) 30%, var(--surface)); color: var(--brand); }
.pill-warn { background: color-mix(in oklch, var(--accent) 22%, var(--surface)); color: var(--brand); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 10px 10px 18px;
  border-radius: 999px;
  box-shadow: 0 12px 28px -12px oklch(0.2 0.02 150 / 0.35), 0 2px 0 oklch(0.3 0.04 150 / 0.05);
  z-index: 950;
  animation: ktoastCentered 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 48px);
}
.toast .btn-ghost {
  background: var(--brand);
  color: var(--bg);
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  flex: none;
}
.toast .btn-ghost:active { filter: brightness(0.92); }

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-2);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 999px;
}
.sync-pill.offline { color: var(--ink-3); }

.changelog { display: flex; flex-direction: column; gap: 12px; font-size: 13px; color: var(--ink-2); }
.changelog-card {
  background: color-mix(in oklch, var(--accent) 14%, var(--surface));
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.changelog-card .glyph { color: var(--brand); flex: none; }
.changelog-card .text { font-size: 12px; color: var(--ink-2); }

.detail-card { display: flex; flex-direction: column; }
.detail-line { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.detail-line .k { font-size: 13px; color: var(--ink-3); }
.detail-line .v { font-size: 14px; font-weight: 700; color: var(--ink); }
.detail-divider { height: 1px; background: var(--line); }

/* ---------- Avatars ---------- */

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--bg);
  flex: none;
  background: var(--ink-3);
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.xl { width: 64px; height: 64px; font-size: 23px; }

.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -9px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

.avatar[data-color="1"] { background: var(--avatar-1); }
.avatar[data-color="2"] { background: var(--avatar-2); }
.avatar[data-color="3"] { background: var(--avatar-3); }
.avatar[data-color="4"] { background: var(--avatar-4); }

/* A left member's avatar everywhere in the app — dimmed + desaturated, never
 * removed, so their history stays visually attributable without reading as
 * "still an active amigo". */
.avatar.left { opacity: 0.45; filter: grayscale(0.75); }
.chip.left, .member-card.left { opacity: 0.55; }

/* ---------- Forms ---------- */

.amount-field {
  background: var(--surface);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 2px 0 oklch(0.3 0.04 150 / 0.05);
}

.amount-currency-symbol {
  font-size: 30px;
  font-weight: 600;
  color: var(--ink-3);
}

.amount-input {
  font-family: 'Figtree', sans-serif;
  font-size: 54px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  border: none;
  background: transparent;
  outline: none;
  caret-color: var(--accent);
  width: 100%;
  padding: 0;
  min-width: 0;
}
.amount-input::placeholder { color: var(--ink-3); opacity: 0.6; }

.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  color: var(--brand-2);
  padding: 9px 13px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  min-height: 40px;
}

/* A pastel stripe shown under an amount field when what's typed is
 * ambiguous (e.g. "1.500") — same color language as .pill-warn, but a
 * full-width tap target rather than a small pill. */
.amount-hint {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: color-mix(in oklch, var(--accent) 22%, var(--surface));
  color: var(--brand);
  border: none;
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.amount-hint-cta { text-decoration: underline; }

.field {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: 20px;
  padding: 15px 18px;
  box-shadow: 0 2px 0 oklch(0.3 0.04 150 / 0.05);
  min-height: 44px;
}

.field-icon { color: var(--ink-3); flex: none; display: flex; }

.input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  width: 100%;
  min-width: 0;
}
.input::placeholder { color: var(--ink-3); font-weight: 400; opacity: 0.6; text-transform: none; }

.cat-sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
  min-height: 32px;
}
.cat-sort-toggle:active { color: var(--brand-2); }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.cat-tile {
  background: var(--surface);
  border-radius: 16px;
  padding: 10px 4px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-align: center;
}
.cat-tile.selected {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 18px -8px color-mix(in oklch, var(--accent) 90%, transparent);
}
.cat-tile.custom { border: 2px dashed var(--line); }

.card-accent { border: 2px solid var(--accent); }

.member-cards { display: flex; gap: 10px; }

.member-card {
  flex: 1;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 12px 4px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  cursor: pointer;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.member-card .avatar { width: 38px; height: 38px; font-size: 14px; }
.member-card span {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
/* Selected state is ONE signal, not two: a filled brand background (same
 * language as .chip.selected elsewhere) with an inline check next to the
 * name — not a bordered card PLUS a separate floating checkmark badge,
 * which read as a checkbox drawn on top of another checkbox. */
.member-card.selected {
  background: var(--brand-2);
  border-color: var(--brand-2);
}
.member-card.selected span { color: #fff; }
.member-card.selected span svg { color: #fff; flex: none; }
.member-card.off { opacity: 0.5; background: var(--surface-2); border-color: var(--surface-2); }

.toggle {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
  min-height: 44px;
  align-items: center;
}
.toggle-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  padding: 6px 13px;
  min-height: 38px;
  border-radius: 999px;
  cursor: pointer;
  border: none;
  background: transparent;
}
.toggle-opt.active { color: #fff; background: var(--brand-2); }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: 20px;
  padding: 14px 18px;
  box-shadow: 0 2px 0 oklch(0.3 0.04 150 / 0.05);
  min-height: 44px;
  gap: 10px;
}
.row-label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.row-value { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--ink); }

.card-divider { height: 1px; background: var(--line); margin: 14px 0; }

.link-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--brand-2);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  padding: 6px 2px;
  min-height: 32px;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  min-height: 40px;
}
.chip.selected { background: var(--brand-2); color: #fff; }

.reaction-tally { display: flex; flex-wrap: wrap; gap: 6px; }
.reaction-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 999px;
  padding: 5px 10px; font-size: 14px; cursor: pointer;
}
.reaction-chip.mine { border-color: var(--accent); background: color-mix(in oklch, var(--accent) 12%, var(--surface-2)); }
.reaction-picker { display: flex; gap: 8px; }
.reaction-pick {
  background: none; border: 1px solid var(--border, var(--surface-2)); border-radius: 999px;
  width: 38px; height: 38px; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.reaction-pick:active { transform: scale(0.88); }
.reaction-pick.active { background: color-mix(in oklch, var(--accent) 14%, transparent); border-color: var(--accent); }
/* Collapsed Activity row only — presence, not a tap target. */
.reaction-mini { font-size: 13px; flex: none; margin-right: 2px; letter-spacing: -1px; }

.method-chips { display: flex; gap: 8px; }
.method-chip {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 700;
  padding: 12px 0;
  min-height: 44px;
  border-radius: 999px;
  text-align: center;
  border: none;
  cursor: pointer;
}
.method-chip.active { background: var(--brand); color: var(--bg); }

.code-boxes { display: flex; gap: 8px; align-items: center; }
.code-box {
  flex: 1;
  min-width: 0;
  height: 56px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  padding: 0;
}
.code-box:focus { background: var(--surface); border-color: var(--brand-2); outline: none; }
.code-box.filled { background: var(--surface); border-color: var(--brand-2); }
.code-dash {
  width: 10px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-weight: 700;
}

.theme-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-card {
  border-radius: 18px;
  padding: 12px 14px;
  position: relative;
  border: 2px solid var(--line);
  cursor: pointer;
  min-height: 44px;
  text-align: left;
}
.theme-card.selected { border-color: var(--accent); }
/* These preview a FIXED palette, independent of the phone's live theme, so
 * their own text uses currentColor rather than the --ink-* variables (which
 * track whichever theme is currently active and would be unreadable against
 * a dark preview card, or invisible against a light one). */
.theme-card[data-theme-preview="pounamu"] { background: oklch(0.34 0.06 165); color: oklch(0.96 0.02 85); }
.theme-card[data-theme-preview="sunset"] { background: oklch(0.97 0.02 70); color: oklch(0.3 0.06 40); }

.theme-swatches { display: flex; gap: 6px; }
.theme-swatch { width: 16px; height: 16px; border-radius: 50%; flex: none; }

.theme-card-title {
  font-family: 'Instrument Serif', serif;
  font-size: 20px;
  margin-top: 10px;
  color: inherit;
}
.theme-card-sub { font-size: 11px; margin-top: 1px; color: inherit; opacity: 0.75; }

.theme-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  padding: 16px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  min-height: 44px;
  font-family: inherit;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: var(--bg); }
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 26px -10px color-mix(in oklch, var(--accent) 80%, transparent);
}
.btn-secondary { background: var(--surface-2); color: var(--brand-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  flex: none;
}
.btn-icon:active { transform: scale(0.94); }
@keyframes roamigo-spin { to { transform: rotate(360deg); } }
.btn-icon.is-refreshing svg { animation: roamigo-spin 0.9s linear infinite; }
.btn-block { width: 100%; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger-icon {
  width: 56px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}
.btn-danger-icon:active { transform: scale(0.97); }

/* ---------- Sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.15 0.02 150 / 0.45);
  z-index: 900;
  animation: kfadeIn 0.2s ease both;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  padding: 14px 24px calc(28px + env(safe-area-inset-bottom));
  z-index: 901;
  animation: kslideUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
  max-height: 88vh;
  overflow-y: auto;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  margin: 0 auto 22px;
}

.sheet-title {
  font-family: 'Instrument Serif', serif;
  font-size: 30px;
  color: var(--ink);
  text-align: center;
}

.sheet-divider { height: 1px; background: var(--line); margin: 18px 0 14px; }

.logo-mark { flex: none; }

/* ---------- Celebrate ---------- */

.screen-celebrate {
  min-height: 100vh;
  background: var(--brand);
  color: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 34px;
  position: relative;
  overflow: hidden;
}
.screen-celebrate::before {
  content: "";
  position: absolute;
  right: -70px;
  top: 120px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--accent) 18%, transparent);
  pointer-events: none;
  animation: kdriftA 9s ease-in-out infinite;
}
.screen-celebrate::after {
  content: "";
  position: absolute;
  left: -90px;
  bottom: 60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--success) 14%, transparent);
  pointer-events: none;
  animation: kdriftB 11s ease-in-out infinite;
}

.welcome-mark { width: 64px; height: 64px; margin: 0 auto; animation: kpop 0.6s cubic-bezier(0.34, 1.4, 0.64, 1) both; }
.welcome-pop { opacity: 0; animation: kwelcomeIn 0.5s ease 0.25s both; }

/* Intro screen lockup — matches the design handoff's "H3d locked in" I2
 * variant exactly (Figtree 800, lowercase, tight negative tracking; the
 * designer's own caption: "the most presence of the four — splash
 * screens, app store, merch"). brandStrip() (below) uses the same
 * typeface/tracking at header scale, not a separate treatment anymore. */
.intro-mark, .header-mark, .brand-strip {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}
.intro-mark { margin: 0 auto; }
/* brandStrip() is a flex row (mark + wordmark/tagline column + beta pill);
 * without this the mark itself is a flex ITEM and can get squeezed narrower
 * than its own SVG viewBox on a tight width, visibly squashing the planes
 * (Gandalf audit catch, 2026-10-15, measured down to 2px wide at 320px on
 * screenSettled() before its own wrapper-width fix — harmless to apply
 * everywhere brandStrip() appears, not just there). */
.header-mark { flex: none; }
.intro-wordmark {
  margin-top: 18px;
  font-weight: 800;
  font-size: 52px;
  line-height: 0.95;
  letter-spacing: -0.045em;
  color: var(--bg);
}
.intro-tagline {
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

/* A short tagline-style line on a celebrate screen (Welcome's "Have a great
 * trip.") — thicker/bolder than the default .celebrate-sub so it reads as a
 * line worth a moment, not just supporting copy. */
.celebrate-sub.welcome-tagline {
  font-weight: 700;
  opacity: 1;
}

/* Word-by-word entrance for a tagline: each word pops slightly oversized
 * then settles back to its own size, staggered left to right via inline
 * animation-delay — plays out BEFORE the plane swoop fires (the swoop's
 * own start is delayed in JS to match), so the words land first and the
 * planes are the second beat, not two things happening at once. */
@keyframes kwordzoom {
  0% { opacity: 0; transform: scale(0.5); }
  55% { opacity: 1; transform: scale(1.22); }
  75% { transform: scale(0.94); }
  100% { transform: scale(1); }
}
.word-zoom {
  display: inline-block;
  animation: kwordzoom 0.46s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* brandStrip()'s per-screen header lockup — same Figtree-800 lowercase
 * treatment as the intro splash, just at header scale and on the light
 * (--bg) background every other screen uses, instead of screen-celebrate's
 * dark green. */
.header-wordmark {
  font-weight: 800;
  font-size: 36px;
  line-height: 1.15;
  letter-spacing: -0.04em;
  color: var(--brand);
}

/* The full stop after "roamigo" in every wordmark lockup (header, intro,
   loading) — always the accent orange, even on dark backgrounds where the
   rest of the wordmark switches to --bg via inline style. */
.wordmark-dot {
  color: var(--accent);
}

/* App-wide "this is still beta" marker — a quiet grey outlined pill pushed
 * to the far right of brandStrip()'s own row (its own flex child, margin-
 * left:auto takes up whatever space brand-strip has to give — on a normal
 * top-level screen that's the full screen width, so it lands at the actual
 * right edge; in the few centred "onDark" celebrate contexts brand-strip
 * shrinks to its own content width, so it just trails the tagline column
 * instead — never broken, just not pushed as far in that one layout). */
.beta-pill {
  display: inline-block;
  flex: none;
  align-self: flex-start;
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid oklch(0.55 0.02 150 / 0.3);
  color: var(--ink-3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.beta-pill-ondark {
  border-color: color-mix(in oklch, var(--bg) 35%, transparent);
  color: color-mix(in oklch, var(--bg) 65%, transparent);
}

/* The "Roam · Eat · Split · Repeat" slogan, repeated under the wordmark
 * everywhere brandStrip() appears (every screen) — small and quiet so it
 * doesn't compete with the screen's own heading just below it. */
.header-tagline {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  /* The wordmark's lowercase "r" (Figtree) has real left-side-bearing that
     JetBrains Mono's flush-left "R" doesn't, so the boxes align but the
     ink visibly doesn't — nudge to compensate. */
  margin-left: 2px;
  transition: opacity 0.15s ease;
}
/* Tapping the brand strip briefly swaps the tagline to "Roam with your
 * amigos!" (swapTaglineOnce() in app.js). Both phrases live in the DOM at
 * once, stacked in the same grid cell (`grid-template-areas`/`grid-area`
 * below), each `white-space:nowrap` — so the cell is permanently sized for
 * whichever phrase is wider (the default; "Roam with your amigos!" measures
 * ~32px narrower), and the "swap" is purely an opacity cross-fade between
 * two already-laid-out elements. Fixes a real bug (user report + Gandalf
 * audit, 2026-10-15): the old version replaced one element's own text,
 * which is a different width each way, so the swap AND the revert visibly
 * resized and re-centred the whole brand strip (and on centred celebrate
 * screens, shifted everything below it too) every single tap. */
.header-tagline-slot {
  display: grid;
  grid-template-areas: "tagline";
}
.header-tagline-slot > .header-tagline {
  grid-area: tagline;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.header-tagline-slot [data-tagline-default] { opacity: 1; }
.header-tagline-slot.tagline-alt-active [data-tagline-default] { opacity: 0; }
.header-tagline-slot.tagline-alt-active [data-tagline-alt] { opacity: 1; }

/* Intro / Welcome: the mark's four planes scatter out across the open
 * screen on curved loops, then glide back and dock exactly on the static
 * mark (which is hidden for the duration) — see planeSwoopShow() in
 * animations.js. `offset-path` (the actual curve, per-plane, is set inline
 * in JS from SWOOP_PATHS) carries the plane along a bezier with ONE
 * continuous easing over the whole flight, and `offset-rotate: auto 90deg`
 * keeps the nose tangent to the direction of travel throughout — no dead
 * stops, no hand-picked rotation fighting the actual heading. */
.plane-swoop {
  position: fixed;
  pointer-events: none;
  offset-rotate: auto 90deg;
  animation: kswoop 1.5s cubic-bezier(0.55, 0.05, 0.25, 1) both;
}

.ring-check {
  position: relative;
  width: 112px;
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ring-check .icon-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  animation: kpop 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
.ring-check .icon-wrap.success { background: var(--success); color: var(--brand); }
.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid color-mix(in oklch, var(--success) 60%, transparent);
  animation: kring 2.6s ease-out infinite;
}
.ring:nth-child(2) { animation-delay: 1.3s; }

.celebrate-title {
  font-family: 'Instrument Serif', serif;
  font-size: 44px;
  line-height: 1.05;
  margin-top: 30px;
}
.celebrate-sub { font-size: 16px; opacity: 0.78; margin-top: 12px; text-wrap: pretty; }

/* "Nobody else here yet" invite nudge on the empty-trip celebrate screen —
 * only shown when the trip has no spends AND no other active member (see
 * screenAllSettled()'s soloBanner comment). Reuses the same translucent
 * light-on-dark pill look as .celebrate-card, but a single tappable row
 * rather than a stat block. */
.solo-invite-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-top: 24px;
  padding: 12px 16px;
  border-radius: 16px;
  background: oklch(0.96 0.02 85 / 0.1);
  cursor: pointer;
  text-align: left;
  border: none;
  font-family: inherit;
  color: inherit;
}
.solo-invite-banner .solo-invite-label { font-size: 13px; opacity: 0.85; }
.solo-invite-banner .solo-invite-cta { display: flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 700; color: var(--accent); flex: none; }
.celebrate-card {
  background: oklch(0.96 0.02 85 / 0.1);
  border-radius: 22px;
  padding: 18px 20px;
  margin-top: 30px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.celebrate-card .line { display: flex; align-items: center; justify-content: space-between; }
.celebrate-card .divider { height: 1px; background: oklch(0.96 0.02 85 / 0.16); }

/* ---------- Vignette (per-category "added" moment) ---------- */

.vignette-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(0.2 0.02 150 / 0.45);
  padding: 24px;
  opacity: 1;
  transition: opacity 0.25s ease;
  cursor: pointer;
}
.vignette-overlay.leaving { opacity: 0; }

.vignette {
  width: min(280px, 82vw);
  height: min(300px, 58vh);
  border-radius: 28px;
  background: var(--bg);
  box-shadow: 0 18px 40px -18px oklch(0.3 0.04 150 / 0.5);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: default;
}
.vignette.dark { background: var(--brand); color: var(--bg); }

.vignette-eyebrow {
  padding: 14px 18px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.vignette.dark .vignette-eyebrow { color: color-mix(in oklch, var(--accent) 70%, var(--bg)); }

.vignette-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.vignette-toast {
  margin: 0 14px 14px;
  background: var(--brand);
  color: var(--bg);
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: ktoast 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  cursor: pointer;
}
.vignette.dark .vignette-toast { background: var(--surface-2); color: var(--brand); }
.vignette-toast .vt-icon { color: var(--success); flex: none; display: flex; }
.vignette-toast .vt-title { flex: 1; font-size: 13px; font-weight: 600; }
.vignette-toast .vt-amt { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }

.confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  animation-name: kfall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  pointer-events: none;
}

.money-fly {
  position: fixed;
  left: 50%;
  bottom: 140px;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 20px;
  color: var(--success);
  z-index: 997;
  pointer-events: none;
  animation: kmoneyfly 0.9s ease-out both;
}

/* originEl's own position (set inline via left/top in reactionPop()), not
 * fixed to a screen edge like .money-fly — a reaction has to visibly come
 * FROM the chip that was tapped. */
.reaction-pop {
  position: fixed;
  transform: translate(-50%, -50%);
  font-size: 28px;
  z-index: 997;
  pointer-events: none;
  animation: kreactionpop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ribbon-piece {
  position: absolute;
  top: -34px;
  border-radius: 3px;
  animation-name: kribbonfall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
  pointer-events: none;
}

/* ---------- Utilities ---------- */

.hidden, [hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.mono { font-family: 'JetBrains Mono', monospace; }
.serif { font-family: 'Instrument Serif', serif; }
.tabular { font-variant-numeric: tabular-nums; }
.mt-14 { margin-top: 14px; }
.is-pending { border-left: 3px dashed var(--accent); opacity: 0.6; padding-left: 10px; }

/* ---------- Allocation editor (paid-by / split-with) ---------- */

.alloc {
  background: var(--surface);
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 2px 0 oklch(0.3 0.04 150 / 0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alloc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.alloc-modes {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
  align-items: center;
}
.alloc-mode {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
  border: none;
  background: transparent;
  min-height: 38px;
}
.alloc-mode.active { color: #fff; background: var(--brand-2); }

.alloc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 6px 2px;
  border-radius: 14px;
  transition: opacity 0.15s ease;
}
.alloc-row.off { opacity: 0.5; }

.alloc-check {
  width: 26px;
  height: 26px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-2);
  cursor: pointer;
  /* This is a <button> with no reset — without these it keeps the
     browser's native beveled border + grey background, which sat right
     behind the green check-square icon and looked like a checkbox drawn
     inside another checkbox. That, not the icon's own colours, was the
     actual bug the icon-colour fix above never touched. */
  background: none;
  border: none;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}
.alloc-row.off .alloc-check { color: var(--ink-3); }

/* The "checked" icon draws an outline square plus a checkmark, both as
 * unfilled strokes in the same colour — at 22px that reads as a smaller
 * shape nested inside a bigger one, not a checkmark. Give it real contrast:
 * a filled square with a white tick, like every other checkmark badge in
 * the app (.theme-check). CSS wins over the SVG's own
 * fill="none"/stroke="currentColor" attributes, so no markup change needed. */
.alloc-row:not(.off) .alloc-check svg rect {
  fill: var(--brand-2);
  stroke: var(--brand-2);
}
.alloc-row:not(.off) .alloc-check svg path {
  stroke: #fff;
}

.alloc-name {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alloc-input {
  width: 76px;
  text-align: right;
  border: none;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  outline: none;
}
.alloc-input:disabled { opacity: 0.6; }
/* A box the editor auto-filled (vs. one the person actually typed into) —
 * lighter weight and a muted colour so it visibly reads as "not yours to
 * double-check", same reasoning .pill-warn already uses for a different
 * kind of "look at this" state. */
.alloc-input.auto { font-weight: 500; color: var(--ink-3); }
.alloc-input::-webkit-outer-spin-button,
.alloc-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.alloc-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.alloc-suffix {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
  width: 20px;
  flex: none;
}

.alloc-remaining {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  padding-top: 2px;
}
.alloc-remaining.ok { color: var(--brand); }
.alloc-remaining.over { color: var(--danger); }
.alloc-remaining.mismatch { color: var(--danger); text-align: left; }
.alloc-hint {
  font-family: inherit;
  font-weight: 500;
  font-size: 11px;
  color: var(--ink-3);
  text-align: left;
  margin-top: 2px;
}

/* ---------- Settle-up direction context (#/settle-new) ---------- */

.settle-context {
  font-size: 13px;
  font-weight: 600;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.settle-context.ok { color: var(--brand); }
.settle-context.warn {
  background: color-mix(in oklch, var(--accent) 22%, var(--surface));
  color: var(--brand);
}
.settle-context.muted { color: var(--ink-3); font-weight: 500; }
.link-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  color: inherit;
  cursor: pointer;
}

/* ---------- Totals panel (Balances) ---------- */

.totals-card {
  background: var(--surface);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 2px 0 oklch(0.3 0.04 150 / 0.05);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Collapsed state echoes the design's amber "Trip spend so far" strip. */
.spend-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in oklch, var(--accent) 14%, var(--bg));
  border-radius: 18px;
  padding: 13px 16px;
  border: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
}
.spend-strip .glyph { color: var(--accent); flex: none; }
.spend-strip .text { flex: 1; font-size: 13px; color: var(--ink-2); }
.spend-strip .care { color: var(--ink-3); flex: none; }

.totals-total {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.totals-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 2px;
  min-height: 44px;
}

.person-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 6px 0;
}

.person-name {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-nums {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
}

.person-net {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 72px;
}
.person-net.positive { color: var(--brand); }
.person-net.negative { color: var(--accent); }

/* ---------- Per-currency sections ---------- */

.currency-section { display: flex; flex-direction: column; gap: 10px; }

.currency-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 2px;
}

/* ---------- Add-to-home-screen banner ---------- */

.a2hs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 96px;
  max-width: 430px;
  margin: 0 auto;
  padding: 0 16px;
  z-index: 85;
  animation: kslideUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}

.a2hs-inner {
  background: var(--brand);
  color: var(--bg);
  border-radius: 20px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 14px 30px -14px oklch(0.2 0.02 150 / 0.45);
}
/* Descendant, not child: the subtitle sits inside a wrapper div. */
.a2hs-inner .muted { color: color-mix(in oklch, var(--bg) 72%, transparent); }
.a2hs-share { color: color-mix(in oklch, var(--bg) 85%, transparent); flex: none; }

/* The banner floats above the tab bar, so the screen needs room for both or it
   covers the last control (the summary button, the save button). */
.screen:has(.a2hs), .screen:has(.update-banner) { padding-bottom: calc(196px + env(safe-area-inset-bottom)); }

.a2hs-close {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--bg) 18%, transparent);
  color: var(--bg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}

/* ---------- Update-available banner ---------- */
/* Same floating slot as .a2hs (never shown at the same time — app.js hides
   the install banner while this one is up, see render()) and the same
   .a2hs-inner visuals (brand pill, white text, rounded), but its own class:
   a separate .screen:has() padding rule and flows.test.html's element
   counts both depend on the two being distinguishable, not reused wholesale. */
.update-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 96px;
  max-width: 430px;
  margin: 0 auto;
  padding: 0 16px;
  z-index: 85;
  animation: kslideUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
.update-banner .a2hs-inner { background: var(--ink); }

/* ---------- Confirm dialog ---------- */

.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.15 0.02 150 / 0.45);
  z-index: 920;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: kfadeIn 0.2s ease both;
}

.confirm-box {
  width: min(340px, 100%);
  background: var(--bg);
  border-radius: 24px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: kpop 0.25s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.confirm-title {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  color: var(--ink);
  text-align: center;
}

.confirm-actions {
  display: flex;
  gap: 10px;
}
.confirm-actions .btn { flex: 1; }

/* ---------- Accessibility ---------- */

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

button, [role="button"] { touch-action: manipulation; }

/* ==========================================================================
   Keyframes — copied from the design vignette library (support all category
   "added" animations, sheet slide-up, toast, celebration rings, confetti).
   ========================================================================== */

@keyframes kfall { 0%{transform:translateY(-40px) rotate(0deg);opacity:0} 12%{opacity:1} 100%{transform:translateY(420px) rotate(540deg);opacity:0} }
@keyframes kpop { 0%{transform:scale(0.6);opacity:0} 60%{transform:scale(1.08)} 100%{transform:scale(1);opacity:1} }
@keyframes ksteam { 0%{transform:translateY(0) scaleX(1);opacity:0} 20%{opacity:0.9} 100%{transform:translateY(-46px) scaleX(1.6);opacity:0} }
@keyframes kclinkL { 0%,100%{transform:rotate(0)} 45%{transform:rotate(16deg) translateX(8px)} 55%{transform:rotate(16deg) translateX(8px)} }
@keyframes kclinkR { 0%,100%{transform:rotate(0)} 45%{transform:rotate(-16deg) translateX(-8px)} 55%{transform:rotate(-16deg) translateX(-8px)} }
@keyframes kspark { 0%,40%{transform:scale(0);opacity:0} 50%{transform:scale(1.2);opacity:1} 75%,100%{transform:scale(0.2) translateY(-18px);opacity:0} }
@keyframes kneedle { 0%{transform:rotate(-78deg)} 60%{transform:rotate(84deg)} 75%{transform:rotate(70deg)} 100%{transform:rotate(76deg)} }
@keyframes kfill { 0%{stroke-dashoffset:190} 60%,100%{stroke-dashoffset:0} }
@keyframes kdrive { 0%{transform:translateX(-90px)} 100%{transform:translateX(400px)} }
@keyframes kbob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-2px)} }
@keyframes kpuff { 0%{transform:scale(0.3);opacity:0.5} 100%{transform:scale(1.8) translateX(-14px);opacity:0} }
@keyframes khop { 0%{transform:translate(0,0)} 12%{transform:translate(0,-14px)} 25%{transform:translate(44px,-26px)} 37%{transform:translate(44px,-40px)} 50%{transform:translate(88px,-52px)} 62%{transform:translate(88px,-66px)} 75%,88%{transform:translate(132px,-78px)} 100%{transform:translate(132px,-78px)} }
@keyframes kflag { 0%,75%{transform:scaleY(0);opacity:0} 85%{transform:scaleY(1.15);opacity:1} 100%{transform:scaleY(1);opacity:1} }
@keyframes ktearL { 0%,35%{transform:translateX(0) rotate(0)} 60%,100%{transform:translateX(-22px) rotate(-9deg)} }
@keyframes ktearR { 0%,35%{transform:translateX(0) rotate(0)} 60%,100%{transform:translateX(22px) rotate(9deg)} }
@keyframes kzz { 0%{transform:translate(0,0) scale(0.6);opacity:0} 25%{opacity:1} 100%{transform:translate(26px,-44px) scale(1.2);opacity:0} }
@keyframes kslideL { 0%{transform:translateX(-70px) rotate(-30deg);opacity:0} 60%,100%{transform:translateX(0) rotate(0);opacity:1} }
@keyframes kslideR { 0%{transform:translateX(70px) rotate(30deg);opacity:0} 60%,100%{transform:translateX(0) rotate(0);opacity:1} }
@keyframes kdrop { 0%{transform:translateY(-50px);opacity:0} 40%{opacity:1} 60%{transform:translateY(0)} 75%{transform:translateY(-6px)} 100%{transform:translateY(0)} }
@keyframes kripple { 0%{transform:scale(0.4);opacity:0.7} 100%{transform:scale(2.2);opacity:0} }
@keyframes ktoast { 0%{transform:translateY(60px);opacity:0} 100%{transform:translateY(0);opacity:1} }
@keyframes kring { 0%{transform:scale(0.8);opacity:0.55} 100%{transform:scale(1.9);opacity:0} }

/* Extra, non-vignette keyframes used by the shell chrome. */
@keyframes kslideUp { 0%{transform:translateY(30px);opacity:0} 100%{transform:translateY(0);opacity:1} }
/* .toast is horizontally centred with left:50%/translateX(-50%); the shared
   ktoast keyframes replace `transform` entirely for the animation's duration,
   so the centring has to be baked into its own keyframes or the toast sits
   with its left edge at 50% instead of centred, hanging off the right edge. */
@keyframes ktoastCentered { 0%{transform:translateX(-50%) translateY(60px);opacity:0} 100%{transform:translateX(-50%) translateY(0);opacity:1} }
@keyframes kfadeIn { 0%{opacity:0} 100%{opacity:1} }
@keyframes kwelcomeIn { 0%{transform:translateY(14px);opacity:0} 100%{transform:translateY(0);opacity:1} }
@keyframes kribbonfall { 0%{transform:translate(0,0) rotate(0deg);opacity:0} 10%{opacity:1} 50%{transform:translate(var(--sway),220px) rotate(180deg)} 100%{transform:translate(calc(var(--sway) * -1),460px) rotate(360deg);opacity:0} }
@keyframes kmoneyfly { 0%{transform:translate(-50%,0) scale(0.8);opacity:0} 20%{opacity:1;transform:translate(-50%,-14px) scale(1.15)} 100%{transform:translate(-50%,-170px) scale(0.85);opacity:0} }
@keyframes kreactionpop { 0%{transform:translate(-50%,-50%) scale(0.4);opacity:0} 55%{transform:translate(-50%,-68%) scale(1.35);opacity:1} 100%{transform:translate(-50%,-85%) scale(1);opacity:0} }
@keyframes kdriftA { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(-14px,16px) scale(1.07)} }
@keyframes kdriftB { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(12px,-14px) scale(1.05)} }
/* One continuous flight along whichever offset-path the element was given
 * (see SWOOP_PATHS in animations.js) — the scale dip at the midpoint is a
 * depth cue ("further from the dock, further from camera"), nothing else
 * needs to change per-plane since offset-rotate already tracks heading. */
@keyframes kswoop {
  0% { offset-distance: 0%; transform: scale(1); opacity: 1; }
  45% { transform: scale(0.92); }
  100% { offset-distance: 100%; transform: scale(1); opacity: 1; }
}
@keyframes kplanetransfer {
  0% { transform: translate(-50%,-50%) translate(0,0) rotate(var(--ang)) scale(0.8); opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(-50%,-50%) translate(var(--tx),var(--ty)) rotate(var(--ang)) scale(0.8); opacity: 0; }
}
.plane-transfer {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  animation: kplanetransfer 0.85s cubic-bezier(0.45, 0.05, 0.15, 1) both;
}
/* launchPlane and departingPlanes both use offset-path (the actual curve is
 * set inline per element in JS from LAUNCH_PATHS / DEPART_PATHS) with
 * offset-rotate:auto so the nose tracks the curve's own tangent — same
 * language as .plane-swoop, no hand-computed rotation to keep in sync. */
@keyframes kplanelaunch {
  0% { offset-distance: 0%; transform: scale(0.9); opacity: 1; }
  65% { opacity: 1; }
  100% { offset-distance: 100%; transform: scale(0.55); opacity: 0; }
}
.plane-launch {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  offset-rotate: auto 90deg;
  /* Ease-out only — a thrown object leaves fast and slows gently; the old
     ease-in-out decelerated it to a dead stop mid-air while fading. */
  animation: kplanelaunch 1s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
@keyframes kplanedepart {
  0% { offset-distance: 0%; transform: scale(0.9); opacity: 1; }
  100% { offset-distance: 100%; transform: scale(0.5); opacity: 0; }
}
.plane-depart {
  position: fixed;
  pointer-events: none;
  offset-rotate: auto 90deg;
  animation: kplanedepart 1.1s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* Celebrate screens sit on the brand colour, so the primary button flips to cream. */
.screen-celebrate .btn-primary {
  background: var(--bg);
  color: var(--brand);
  box-shadow: none;
}
.screen-celebrate .btn-primary:active { filter: brightness(0.95); }

/* ---------- Trip route (triproute.js) ----------
 * A horizontally-scrolling strip of boarding-pass-style stubs, one per
 * unique spend location — v2, replacing an animated SVG snake-and-plane
 * (live feedback: the plane's parked heading regularly faced backwards,
 * and the snake grew taller with every stop, crowding Home). A stub is a
 * real <button>, so it's natively tappable/keyboard-reachable — no SVG
 * click-delegation workaround needed — and it's the tap target for
 * "add a spend at this location" (see the troute-stop case in app.js).
 * Every colour is a theme token, so it follows Pounamu/Sunset automatically;
 * the deal-in stagger is skipped outright in Calm mode (isCalm() check in
 * triproute.js), and the [data-calm] kill-switch below zeroes it too. */
.troute { padding: 16px 0 14px; overflow: hidden; }
.troute-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 18px;
}
.troute-count { font-size: 11px; color: var(--ink-3); }

.troute-strip {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding: 4px 18px 6px;
  overflow-x: auto;
  overflow-y: visible;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  /* The strip already scroll-snaps and is swipeable — the browser's own
     scrollbar underneath it was just visual noise on a card this short. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.troute-strip::-webkit-scrollbar { display: none; }

/* The boarding-pass stub: a dashed "tear" edge on the left with two
   punched-hole notches (::before/::after, painted in the card's own
   background so they read as cutouts against it, not the page). Kept
   compact deliberately — an earlier, roomier size (118×92, 17px name)
   read as mostly blank space per direct feedback. */
.troute-stub {
  flex: none;
  scroll-snap-align: start;
  width: 98px;
  min-height: 60px;
  position: relative;
  background: var(--surface-2);
  border: none;
  border-left: 2px dashed var(--line);
  border-radius: 4px 12px 12px 4px;
  padding: 8px 10px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  cursor: pointer;
}
.troute-stub::before, .troute-stub::after {
  content: "";
  position: absolute;
  left: -6px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  /* Cuts through to the card's OWN background (var(--surface), pure
     white), not var(--bg) — the two are close but not equal in either
     theme, so the notch used to sit as a faint mismatched cream dot on
     the white card instead of reading as a clean punched-out hole. */
  background: var(--surface);
}
.troute-stub::before { top: -6px; }
.troute-stub::after { bottom: -6px; }

.troute-stub-seq {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}
.troute-stub-name {
  /* Instrument Serif's thin strokes disappear below ~16px — 14px (the
     first compact pass) read as "not readable" per direct feedback. */
  font-size: 16px;
  line-height: 1.2;
  color: var(--ink);
}
.troute-stub-add {
  margin-top: auto;
  display: flex;
  color: var(--brand-2);
}
.troute-stub-add svg { display: block; }
.troute-stub:active { transform: scale(0.97); }

/* Deal-in entrance: stubs land left-to-right on the same overshoot spring
   used elsewhere in the app (kwordzoom), each offset by its
   own animation-delay (set inline per stub in triproute.js). */
.troute-stub.troute-deal {
  animation: ktroutedeal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes ktroutedeal {
  0% { opacity: 0; transform: translateX(18px) rotate(-2deg); }
  100% { opacity: 1; transform: translateX(0) rotate(0); }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Calm mode (Settings toggle, isCalm() in animations.js) is a separate,
 * in-app flag on top of the OS-level query above — CSS can't see it on its
 * own, so app.js's applyCalmAttr() mirrors it onto [data-calm]. Without
 * this, purely CSS-driven animations (welcome-mark's kpop, all-settled's
 * ring/kring) ignored Calm mode entirely; only JS-triggered ones
 * (confetti, ribbons, vignettes — gated inside animations.js itself) did. */
html[data-calm] *, html[data-calm] *::before, html[data-calm] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ---------- Trip switcher (tap the trip name in the header) ---------- */
.trip-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin-top: 2px;
  padding: 0;
  background: none;
  border: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.trip-switch-btn .screen-title { min-width: 0; overflow-wrap: anywhere; }
.trip-switch-caret { color: var(--brand-2); flex: none; display: flex; }
.trip-switch-btn:active .trip-switch-caret { transform: translateY(1px); }

.switcher-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.switcher-row.current { border-color: var(--brand-2); }
.switcher-main { display: flex; flex-direction: column; min-width: 0; }
.switcher-name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.switcher-dates { font-size: 12px; margin-top: 2px; }
.switcher-empty { font-size: 13px; text-align: center; padding: 14px 8px 4px; }

/* "Start a new trip" shortcut next to the "Your trips" sheet title — same
 * ask-new-trip confirm flow Settings already uses (askStartNewTrip()), just
 * reachable without a trip through Settings first. */
.switcher-new-trip-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: color-mix(in oklch, var(--accent) 18%, var(--surface));
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  flex: none;
}
.switcher-new-trip-btn:active { transform: scale(0.94); }
