:root {
  --sky: #EEF3FF;
  --ink: #12204A;
  --ink-2: #4A5785;
  --ink-3: #56638F; /* 5.4:1 on white; the old #6B78A3 failed 4.5:1 for the 11px tab labels */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --line: #C9D3F0;
  --line-2: #DCE3F7;
  --white: #FFFFFF;
  --mango: #FFB020;
  --mango-soft: #FFF1D1;
  --grape: #7B5CFF;
  --grape-ink: #3B2BD9;
  --mint: #2BD9A5;
  --coral: #FF7A59;
  --coral-soft: #FFE3DB;
  --warn-ink: #B4330B;
  --display: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  --text: -apple-system, system-ui, "Segoe UI", Helvetica, sans-serif;
  --top: max(env(safe-area-inset-top), 16px);
  --bottom: env(safe-area-inset-bottom);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--sky); color: var(--ink); font-family: var(--text); -webkit-text-size-adjust: 100%; }
/* Native feel: no grey tap flash, no rubber-band page bounce behind the app */
html { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body { min-height: 100dvh; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { caret-color: var(--grape-ink); }
::selection { background: #FFD98A; color: var(--ink); }
a { color: var(--grape-ink); }
:focus-visible { outline: 3px solid var(--grape); outline-offset: 2px; }
h1, .wcard .name, .result b, .best .display, .bigticket h1 { overflow-wrap: anywhere; }
.big-num, .miles, .stub, .result .display, .best .display, .stamp, .bar + div, .between b.small { font-variant-numeric: tabular-nums; }

/* Everything you tap: fire instantly, don't select the label on long-press, and answer the press */
.btn, .chip, .pick, .ticket, .wcard, .icon-btn, .alert, a.note, nav.tabs a {
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  transition: transform 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
.btn:active:not(:disabled), .chip:active, .pick:active, .ticket:active, .wcard:active, .icon-btn:active, .alert:active, a.note:active { transform: scale(0.97); }
nav.tabs a:active { transform: scale(0.92); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; padding: calc(var(--top) + 12px) 20px calc(96px + var(--bottom)) 20px; display: flex; flex-direction: column; gap: 18px; }
.screen.no-nav { padding-bottom: calc(24px + var(--bottom)); }
.screen.grape { background: var(--grape); }

h1, h2, .display { font-family: var(--display); margin: 0; letter-spacing: -0.3px; }
h1 { font-size: 30px; font-weight: 800; }
h1.huge { font-size: 40px; line-height: 1.02; }
h2 { font-size: 19px; font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px; border-radius: 18px; border: 0; background: var(--ink); color: var(--white); font-weight: 700; font-size: 17px; text-decoration: none; cursor: pointer; }
.btn.block { width: 100%; }
.btn.light { background: var(--white); color: var(--ink); }
.panel .btn.light { background: var(--sky); }
.btn.ghost { background: transparent; color: var(--grape-ink); font-weight: 600; font-size: 15px; min-height: 44px; }
.btn.outline { background: transparent; border: 2px solid currentColor; }
.btn.danger { background: var(--coral-soft); color: var(--warn-ink); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 20px; }
.btn:disabled { opacity: 0.45; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--white); display: inline-flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 18px; border: 0; background: var(--white); font-weight: 600; font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line-2); background: var(--white); color: var(--ink); font-size: 17px; }
.input:focus { border-color: var(--ink); outline: none; }
textarea.input { min-height: 120px; resize: vertical; font-size: 16px; line-height: 1.4; } /* under 16px, iOS zooms the page on focus */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.search { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 16px; border-radius: 18px; background: var(--white); border: 2px solid var(--ink); }
.search input { flex: 1; border: 0; outline: none; background: transparent; font-size: 17px; min-width: 0; }

/* Cards & panels */
.panel { background: var(--white); border-radius: 18px; padding: 16px; }
.hero { border-radius: 24px; background: var(--mango); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.big-num { font-family: var(--display); font-weight: 800; font-size: clamp(40px, 15vw, 60px); line-height: 0.9; letter-spacing: -0.025em; }
.hero .row { flex-wrap: wrap; row-gap: 6px; }
.bar { height: 10px; border-radius: 5px; background: rgba(18, 32, 74, 0.15); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 5px; background: var(--ink); }
.bar.light { background: #E2E8F8; }
.alert { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 18px; background: var(--white); border: 2px solid var(--coral); color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.35; }
.alert .dot { width: 36px; height: 36px; border-radius: 18px; background: var(--coral-soft); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--warn-ink); }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--white); font-size: 14px; line-height: 1.4; }

/* Ticket rows */
.ticket { display: flex; border-radius: 16px; background: var(--white); color: var(--ink); text-decoration: none; overflow: hidden; }
.ticket .main { flex: 1; min-width: 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; }
.ticket .main b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket .perf { width: 0; border-left: 2px dashed var(--line); margin: 10px 0; }
.ticket .main .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket .stub { min-width: 104px; flex-shrink: 0; padding: 14px 14px 14px 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; white-space: nowrap; }
.miles { font-family: var(--display); font-weight: 800; font-size: 18px; color: var(--grape-ink); }
.miles.zero { color: var(--ink-3); }

/* Big ticket (transaction) */
.bigticket { border-radius: 24px; background: var(--white); display: flex; flex-direction: column; }
.bigticket .top { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 4px; }
.bigticket .tear { position: relative; height: 24px; display: flex; align-items: center; }
.bigticket .tear::before, .bigticket .tear::after { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 12px; background: var(--grape); }
.bigticket .tear::before { left: -12px; } .bigticket .tear::after { right: -12px; }
.bigticket .tear span { flex: 1; margin: 0 22px; border-top: 2px dashed var(--line); }
.bigticket .bottom { padding: 18px 22px 22px; display: flex; flex-direction: column; gap: 16px; }
.stamp { padding: 8px 12px; border-radius: 12px; background: var(--mango-soft); font-weight: 700; font-size: 14px; transform: rotate(-4deg); white-space: nowrap; flex-shrink: 0; }
.bigticket .between { flex-wrap: wrap; row-gap: 10px; }
.split { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 16px; background: var(--sky); }
.splitbar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; display: flex; }
.splitbar i:first-child { background: var(--grape-ink); } .splitbar i:last-child { background: #9C88FF; }

/* Wallet */
.wallet { display: flex; flex-direction: column; }
.wcard { display: flex; justify-content: space-between; gap: 12px; min-height: 104px; padding: 18px 20px 30px; border-radius: 20px 20px 0 0; color: var(--ink); text-decoration: none; }
.wcard + .wcard { margin-top: -24px; }
.wcard:last-child { border-radius: 20px; padding-bottom: 18px; }
.wcard .name { font-weight: 700; font-size: 17px; }
.wcard > .stack { min-width: 0; }
.wcard .rate { font-size: 14px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.wcard .sub { font-size: 14px; font-weight: 600; }
.wcard.dark { color: var(--white); }
.ring { width: 52px; height: 52px; border-radius: 26px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ring > span { width: 38px; height: 38px; border-radius: 19px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; }

/* Picker list */
.pick { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 16px; background: var(--white); border: 0; text-align: left; cursor: pointer; text-decoration: none; color: var(--ink); }
.swatch { width: 28px; height: 20px; border-radius: 5px; flex-shrink: 0; }

/* Results */
.best { border-radius: 24px; background: var(--mango); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.result { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--white); }
.result.dim { color: var(--ink-3); }

/* Nav */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 8px calc(6px + var(--bottom)); background: rgba(255,255,255,0.96); border-top: 1px solid var(--line-2); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); z-index: 10; }
nav.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; min-height: 48px; font-size: 11px; font-weight: 600; color: var(--ink-3); text-decoration: none; }
nav.tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; }
nav.tabs a.add span.plus { width: 44px; height: 44px; margin-top: -4px; border-radius: 22px; background: var(--ink); color: var(--white); display: flex; align-items: center; justify-content: center; }
@media (min-width: 560px) { nav.tabs { left: 50%; transform: translateX(-50%); max-width: 520px; border-radius: 20px 20px 0 0; } }

/* Onboarding */
.dots { display: flex; gap: 6px; align-items: center; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: #B9C6EA; }
.dots i.on { width: 28px; background: var(--ink); }
.promise { position: relative; height: 190px; }
.promise .card { position: absolute; left: 0; top: 18px; width: 290px; max-width: 78%; height: 146px; border-radius: 20px; background: var(--mango); transform: rotate(-6deg); padding: 18px 20px; display: flex; flex-direction: column; justify-content: space-between; }
.promise .card b { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: 3px; }
.promise .badge { position: absolute; right: 4px; top: 0; width: 112px; height: 112px; border-radius: 56px; background: var(--grape); color: var(--white); display: flex; flex-direction: column; align-items: center; justify-content: center; transform: rotate(10deg); text-align: center; }
.promise .badge b { font-family: var(--display); font-weight: 800; font-size: 25px; line-height: 1; }
.tick { width: 44px; height: 44px; border-radius: 14px; background: var(--white); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
ol.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; line-height: 1.45; }
code { background: var(--mango-soft); padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }

/* Toast: a transition (interruptible), enters from where it sits, leaves faster than it came */
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--bottom)); transform: translate(-50%, 0); background: var(--ink); color: var(--white); padding: 12px 18px; border-radius: 16px; font-weight: 600; font-size: 15px; z-index: 20; width: max-content; max-width: min(90vw, 420px); text-align: center;
  box-shadow: 0 8px 24px rgba(18, 32, 74, 0.22); opacity: 1; transition: opacity 220ms var(--ease-out), transform 260ms var(--ease-out); }
@starting-style { .toast { opacity: 0; transform: translate(-50%, 10px) scale(0.96); } }
.toast.leaving { opacity: 0; transform: translate(-50%, 6px) scale(0.98); transition-duration: 150ms; }
.toast.low { bottom: calc(24px + var(--bottom)); }
/* The one celebration: miles earned on a purchase you just logged */
.confetti { animation: pop 420ms cubic-bezier(0.16, 1, 0.3, 1) both; transform-origin: left center; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .confetti { animation: fade 200ms ease both; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .toast, .toast.leaving { transform: translate(-50%, 0); }
  .btn, .chip, .pick, .ticket, .wcard, .icon-btn, .alert, a.note, nav.tabs a { transition: none; }
}
.empty { text-align: center; padding: 28px 16px; border-radius: 18px; background: var(--white); display: flex; flex-direction: column; gap: 10px; align-items: center; }
hr.sep { border: 0; border-top: 1px solid var(--line-2); margin: 4px 0; width: 100%; }
