/* ───────── Design tokens (swap these to re-theme) ───────── */
:root {
  --bg: #f6f6f6;
  --card: #ffffff;
  --ink: #111111;
  --muted: #6c6c74;
  --line: #ececee;
  --chip: #f1f1f2;
  --field: #f3f4f3;
  --hero-a: #f2edfc;
  --hero-b: #fbfaff;
  --accent: #c86de0;
  --track: #e3e3e6;
  --good: #1f7a2e;
  --bad: #b3201d;
  --badge-soon: #f7eded;
  --badge-later: #ebebee;
  --backdrop: #b3b4b9;

  --r-xl: 32px;
  --r-lg: 26px;
  --r-md: 18px;
  --r-pill: 999px;

  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ───────── Base ───────── */
* { box-sizing: border-box; margin: 0; }
html { background: var(--backdrop); }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--backdrop);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app {
  position: relative;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow-x: hidden;
}
@media (min-width: 520px) {
  body { padding: 32px 0; }
  .app { min-height: calc(100dvh - 64px); border-radius: 48px; box-shadow: 0 24px 70px rgba(0, 0, 0, .14); }
  .nav { bottom: 56px !important; }
}

.screen { padding: calc(env(safe-area-inset-top) + 28px) 20px 150px; }
.screen.sheet-screen { padding-bottom: 40px; }

/* ───────── Type helpers ───────── */
.h1 { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.h2 { font-size: 26px; font-weight: 700; letter-spacing: -.015em; margin: 30px 0 14px; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ───────── Top bar (home) ───────── */
.topbar { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 12px; }
.topbar .greet { text-align: center; }
.topbar .greet b { display: block; font-size: 18px; font-weight: 600; }
.topbar .greet span { font-size: 15px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 22px; color: #fff;
}
.avatar.andre { background: #1f8f8a; }
.avatar.karensa { background: #d1498d; }
.avatar.sm { width: 44px; height: 44px; font-size: 18px; }
.icon-btn { width: 56px; height: 56px; border-radius: 50%; background: var(--card); display: grid; place-items: center; }
.tagline { margin: 22px 0 14px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.tagline svg { width: 18px; height: 18px; fill: var(--ink); stroke: none; }

/* ───────── Hero card ───────── */
.hero {
  position: relative;
  background: linear-gradient(180deg, var(--hero-a), var(--hero-b));
  border-radius: var(--r-xl);
  padding: 22px 24px 24px;
}
.hero-label { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.hero-label button { display: grid; place-items: center; }
.hero-label svg { width: 24px; height: 24px; }
.amount { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.amount small { font-size: 22px; color: var(--muted); font-weight: 500; }
.amount b { font-size: clamp(34px, 11vw, 48px); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.hero-emoji {
  position: absolute; top: 24px; right: 24px;
  width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center; font-size: 32px;
  background: #d9eef0;
}
.hero-progress { margin-top: 22px; }
.hero.compact .amount b { font-size: clamp(30px, 9.5vw, 40px); }
.hero-progress .row-between { align-items: baseline; margin-bottom: 8px; }
.hero-progress .pct { color: var(--good); font-size: 18px; font-weight: 500; }
.hero-progress .tot { font-size: 22px; font-weight: 700; }
.hero-foot { margin-top: 14px; font-size: 17px; }

.bar { height: 6px; border-radius: 9px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 9px; background: var(--accent); }

/* ───────── Countdown timeline ───────── */
.cd-title { margin-top: 22px; font-size: 20px; font-weight: 600; }
.cd { position: relative; margin-top: 14px; }
.cd-dots, .cd-labels { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.cd-dots { position: relative; align-items: center; }
.cd-line { position: absolute; left: 15px; right: 15px; top: 50%; height: 2px; background: var(--track); transform: translateY(-50%); }
.cd-line i { display: block; height: 100%; background: var(--ink); }
.dot { position: relative; width: 30px; height: 30px; border-radius: 50%; background: #d6d6da; display: grid; place-items: center; }
.dot.done { background: var(--ink); color: #fff; }
.dot svg { width: 16px; height: 16px; stroke-width: 2.6; }
.cd-dots .dot:nth-child(3) { justify-self: center; }
.cd-dots .dot:nth-child(4) { justify-self: end; }
.cd-labels { margin-top: 8px; }
.cd-labels > div { font-size: 19px; }
.cd-labels > div:nth-child(2) { text-align: center; }
.cd-labels > div:nth-child(3) { text-align: right; }
.cd-labels b { font-weight: 600; font-size: 21px; }
.cd-labels span { color: var(--muted); font-size: 19px; }

/* ───────── Payment tracker (person cards) ───────── */
.people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.person { background: var(--card); border-radius: var(--r-xl); padding: 16px 14px 14px; }
.person-head { display: flex; align-items: center; gap: 10px; }
.person-head b { font-size: 16px; line-height: 1.15; font-weight: 600; }
.person p { margin: 16px 0 12px 4px; font-size: 15px; line-height: 1.3; min-height: 42px; }
.person-foot { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 6px; }
.person-total { background: var(--chip); border-radius: var(--r-pill); padding: 8px 10px; text-align: center; }
.person-total b { display: block; font-size: 18px; font-weight: 700; }
.person-total span { font-size: 13px; }
.round-btn { background: var(--chip); border-radius: 50%; width: 44px; height: 44px; display: grid; place-items: center; align-self: center; }

/* ───────── Where it went ───────── */
.went { display: grid; gap: 18px; }
.went-row { display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center; }
.emoji-dot {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px;
}
.tint-0 { background: #d9eef0; }
.tint-1 { background: #ece6ec; }
.tint-2 { background: #f1e7ee; }
.tint-3 { background: #e8ecd8; }
.went-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.went-top span { font-size: 19px; }
.went-top b { font-size: 22px; font-weight: 700; }

/* ───────── Search / filter ───────── */
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--r-pill);
  padding: 0 22px; height: 64px; margin-top: 18px;
}
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 19px; }
.search input::placeholder { color: #a5a5ad; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--r-pill);
  height: 52px; padding: 0 28px 0 22px; font-size: 19px; margin-top: 14px;
}
.pill-btn svg { width: 18px; height: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.fchip { background: var(--card); border-radius: var(--r-pill); padding: 9px 16px; font-size: 16px; }
.fchip.on { background: var(--ink); color: #fff; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 26px 0 12px; font-size: 19px; }
.section-head a, .section-head button { font-weight: 600; }
.section-head .bad { font-weight: 700; font-size: 19px; }

/* ───────── Event carousel ───────── */
.carousel { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-left: 20px; margin: 0 -20px; padding: 0 20px 4px; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.ev-card { flex: 0 0 min(76%, 300px); scroll-snap-align: start; background: var(--card); border-radius: var(--r-xl); padding: 18px; display: block; }
.ev-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.ev-card .emoji-dot { width: 52px; height: 52px; }
.ev-card h3 { margin-top: 14px; font-size: 25px; font-weight: 700; letter-spacing: -.01em; }
.ev-card .tot { margin-top: 4px; display: flex; align-items: baseline; gap: 8px; }
.ev-card .tot small { color: var(--muted); font-size: 16px; }
.ev-card .tot b { font-size: 25px; font-weight: 700; }
.ev-card .pct { margin-top: 6px; color: var(--good); font-size: 17px; }

/* ───────── List rows ───────── */
.list { background: var(--card); border-radius: var(--r-xl); padding: 6px 18px; }
.row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 0; }
.row + .row { border-top: 1px solid var(--line); }
.badge { width: 48px; height: 48px; border-radius: 50%; background: var(--badge-later); display: grid; place-content: center; text-align: center; line-height: 1.05; }
.badge.soon { background: var(--badge-soon); }
.badge b { font-size: 20px; font-weight: 600; display: block; }
.badge span { font-size: 14px; font-weight: 600; }
.row-title { font-size: 17px; font-weight: 700; line-height: 1.2; }
.row-sub { font-size: 15px; color: #2b2b30; margin-top: 2px; }
.row-side { text-align: center; }
.row-amt { font-size: 19px; font-weight: 700; }
.chip { display: inline-block; margin-top: 4px; background: var(--chip); border-radius: var(--r-pill); padding: 2px 14px; font-size: 15px; }
.chip.paid { background: #e5f3e7; color: var(--good); font-weight: 600; }
.row.is-paid .row-title, .row.is-paid .row-sub { opacity: .55; }
.empty { padding: 22px 0; text-align: center; color: var(--muted); }

/* ───────── Event detail ───────── */
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 20px; }
.back svg { width: 18px; height: 18px; stroke-width: 2.2; }
.ev-title { margin: 14px 0 18px; }
.ev-title .h1 { font-size: 28px; }
.days-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--card); border-radius: var(--r-pill); padding: 12px 18px; font-size: 16px; white-space: nowrap; }
.days-pill svg { width: 24px; height: 24px; fill: var(--bad); stroke: none; }
.cat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 22px 10px 8px; font-size: 17px; }
.cat-head span { min-width: 0; }
.cat-head b { white-space: nowrap; font-size: 16px; font-weight: 700; }
.cat-head b.good { color: var(--good); }
.cat-head b.bad { color: var(--bad); }

/* ───────── Add sheet ───────── */
.sheet { margin: 22px -20px -40px; background: var(--card); border-radius: 44px 44px 0 0; padding: 30px 26px 40px; min-height: 70dvh; }
.sheet h2 { font-size: 30px; font-weight: 700; padding-left: 6px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #f1f1f2; border-radius: var(--r-pill); padding: 4px; box-shadow: 0 6px 16px rgba(0, 0, 0, .08); }
.seg button { height: 52px; border-radius: var(--r-pill); font-size: 17px; white-space: nowrap; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 6px rgba(0, 0, 0, .08); }
.seg button svg { width: 20px; height: 20px; stroke-width: 2.2; }
.sheet .seg:first-of-type { margin-top: 24px; }

.amt-display { display: flex; align-items: baseline; gap: 14px; margin: 24px 0 18px 8px; color: var(--ink); }
.amt-display small { font-size: 26px; font-weight: 700; color: #a8a8ad; }
.amt-display b { font-size: 68px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.amt-display.zero b { color: #a8a8ad; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key { height: 72px; border-radius: 22px; background: #f3f4f2; font-size: 30px; font-weight: 500; display: grid; place-items: center; transition: transform .06s, background .12s; }
.key:active { transform: scale(.96); background: #e8e9e6; }
.key svg { width: 30px; height: 30px; }

.field { margin-top: 20px; }
.field label { display: block; font-size: 17px; font-weight: 500; margin: 0 0 8px 2px; }
.input {
  width: 100%; height: 64px; border-radius: 22px; border: 0; outline: 0;
  background: var(--field); padding: 0 22px; font-size: 19px;
}
.input:focus { box-shadow: 0 0 0 2px var(--accent) inset; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; pointer-events: none; }
.input-wrap > svg.chev { left: auto; right: 20px; }
.input-wrap.has-icon .input { padding-left: 54px; }
.input::placeholder { color: #8c8c94; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 54px; }
.two { display: block; }
.save {
  width: 100%; height: 66px; margin-top: 28px; border-radius: var(--r-pill);
  background: var(--ink); color: #fff; font-size: 21px; font-weight: 600;
}
.save:active { transform: scale(.985); }

/* ───────── Event emoji picker ───────── */
.emoji-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.emoji-pick button { width: 56px; height: 56px; border-radius: 50%; background: var(--field); font-size: 26px; }
.emoji-pick button.on { background: #e9dcf7; box-shadow: 0 0 0 2px var(--accent); }

/* ───────── Floating nav ───────── */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 4px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(14px);
  border: 1px solid #d9d9dd; border-radius: var(--r-pill);
  padding: 6px; z-index: 10;
}
.nav[hidden] { display: none; }
.nav-item { display: grid; justify-items: center; gap: 2px; width: 76px; height: 64px; border-radius: 30px; align-content: center; font-size: 13px; }
.nav-item svg { width: 28px; height: 28px; stroke-width: 1.5; }
.nav-item.on { background: #e9e9eb; }
.fab { width: 64px; height: 64px; border-radius: 50%; background: #000; color: #fff; display: grid; place-items: center; margin-left: 6px; }
.fab svg { width: 30px; height: 30px; stroke-width: 1.4; }

/* ───────── Toast ───────── */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--r-pill);
  font-size: 16px; opacity: 0; pointer-events: none; transition: .25s; z-index: 70; max-width: 86%;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ───────── Item detail ───────── */
.topnav { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; }
.topnav h1 { text-align: center; font-size: 20px; font-weight: 700; }
.circle-btn { width: 48px; height: 48px; border-radius: 50%; background: var(--card); display: grid; place-items: center; }
.circle-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 56px; background: #fff; border-radius: 20px; padding: 6px; box-shadow: 0 12px 40px rgba(0, 0, 0, .16); min-width: 184px; z-index: 20; }
.menu button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 12px 14px; border-radius: 14px; font-size: 16px; text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--chip); }
.menu .danger { color: var(--bad); }
.menu svg { width: 20px; height: 20px; }

.meta { display: flex; align-items: center; gap: 10px; margin-top: 26px; color: var(--muted); font-size: 16px; flex-wrap: wrap; }
.status { padding: 2px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; border: 1px solid; }
.status.paid { background: #e8f6ea; color: var(--good); border-color: #bfe3c5; }
.status.partial { background: #fff3d6; color: #8a5a00; border-color: #f0d9a0; }
.status.unpaid { background: var(--chip); color: var(--muted); border-color: var(--line); }
.status.overdue { background: #fbe7e6; color: var(--bad); border-color: #f0c4c2; }
.item-name { font-size: 20px; font-weight: 600; margin-top: 12px; }
.item-amt { font-size: clamp(34px, 10vw, 42px); font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.facts span { display: block; color: var(--muted); font-size: 15px; }
.facts b { display: block; margin-top: 6px; font-size: 17px; font-weight: 600; }
.facts small { display: block; margin-top: 2px; color: var(--muted); font-size: 14px; }
.facts small.bad { color: var(--bad); }
.dashed { border: 0; border-top: 1.5px dashed #cfcfd4; margin: 22px 0 8px; }

.card { background: var(--card); border-radius: var(--r-lg); padding: 20px 22px; margin-top: 14px; }
.card h3 { font-size: 20px; font-weight: 700; }
.link { font-weight: 600; font-size: 16px; color: #6b3fa0; }
.vendor { display: flex; gap: 14px; align-items: center; margin-top: 14px; }
.vendor .avatar { width: 52px; height: 52px; font-size: 20px; background: #ece0f8; color: #6b3fa0; flex: none; }
.vendor b { display: block; font-size: 17px; }
.vendor span:not(.avatar) { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 15px; margin-top: 2px; }
.vendor span svg { width: 18px; height: 18px; }
.note-text { margin-top: 10px; font-size: 16px; line-height: 1.5; white-space: pre-wrap; color: #2b2b30; overflow-wrap: anywhere; }
.note-empty { margin-top: 10px; color: var(--muted); font-size: 16px; }

.pay-table { margin-top: 12px; }
.pay-head, .pay-row { display: grid; grid-template-columns: 1.15fr 1fr auto 16px; gap: 10px; align-items: center; }
.pay-head { color: var(--muted); font-size: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.pay-head span:last-child, .pay-row .amt { text-align: right; }
.pay-row { padding: 14px 0; font-size: 16px; }
.pay-row + .pay-row { border-top: 1px solid var(--line); }
.pay-row .amt { font-weight: 600; }
.pay-who { display: flex; align-items: center; gap: 8px; }
.pay-who .avatar { width: 24px; height: 24px; font-size: 12px; }
.sum { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); font-size: 16px; }
.sum.total { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 16px; color: var(--ink); font-weight: 700; font-size: 18px; }

.btn { height: 60px; border-radius: 999px; font-size: 18px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn svg { width: 22px; height: 22px; }
.btn.ghost { background: var(--chip); }
.btn.ghost.danger { color: var(--bad); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.soft { height: 52px; background: #f2edfc; color: #5b2d86; font-size: 17px; }
.btn.danger-solid { background: var(--bad); color: #fff; }
.actionbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(430px, 100%);
  display: grid; grid-template-columns: 1fr 1.5fr; gap: 12px;
  padding: 26px 20px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(246, 246, 246, 0), var(--bg) 40%); z-index: 10;
}
@media (min-width: 520px) { .actionbar { bottom: 32px; border-radius: 0 0 48px 48px; } }

/* ───────── Confirm dialog ───────── */
.scrim { position: fixed; inset: 0; background: rgba(17, 17, 20, .42); display: flex; align-items: flex-end; justify-content: center; z-index: 60; animation: fade .18s; }
.dialog { width: min(430px, 100%); background: #fff; border-radius: 32px 32px 0 0; padding: 28px 24px calc(24px + env(safe-area-inset-bottom)); animation: rise .22s ease-out; }
.dialog h3 { font-size: 22px; font-weight: 700; }
.dialog p { color: var(--muted); line-height: 1.5; margin: 10px 0 22px; font-size: 16px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.toast.has-action { pointer-events: auto; }
.toast button { margin-left: 16px; font-weight: 700; color: #d9b8f0; }

/* ───────── Edit / note field ───────── */
.textarea { height: auto; min-height: 104px; padding: 16px 22px; resize: vertical; line-height: 1.4; display: block; }
.hint { margin: 10px 0 0 8px; min-height: 0; }
.hint:empty { display: none; }
.hint button { background: #f2edfc; color: #5b2d86; border-radius: var(--r-pill); padding: 8px 16px; font-size: 15px; font-weight: 600; }
.hint span { color: var(--muted); font-size: 15px; }

/* ───────── Add / Edit overlay sheet ───────── */
body.sheet-open { overflow: hidden; }
.sheet-overlay { position: fixed; inset: 0; background: rgba(17, 17, 20, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .2s; }
.sheet-panel {
  width: min(430px, 100%); max-height: calc(100dvh - 44px - env(safe-area-inset-top));
  display: flex; flex-direction: column; background: #fff; border-radius: 34px 34px 0 0;
  overflow: hidden; outline: 0; animation: slideup .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet-overlay.closing { animation: fadeout .18s forwards; }
.sheet-overlay.closing .sheet-panel { animation: slidedown .18s forwards; }
@keyframes slideup { from { transform: translateY(100%); } }
@keyframes slidedown { to { transform: translateY(100%); } }
@keyframes fadeout { to { opacity: 0; } }
@media (min-width: 520px) { .sheet-panel { border-radius: 34px; margin-bottom: 32px; } }

.sheet-grab { width: 44px; height: 5px; border-radius: 9px; background: #d9d9de; margin: 10px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 20px 4px 26px; flex: none; }
.sheet-head h2 { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.circle-btn.sm { width: 40px; height: 40px; background: var(--chip); }
.circle-btn.sm svg { width: 20px; height: 20px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 10px 26px 24px; }
.sheet-foot { flex: none; display: grid; grid-template-columns: 1fr 1.6fr; gap: 12px; padding: 14px 22px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
.sheet-foot .btn { height: 56px; }
.sheet-body .field:first-of-type { margin-top: 20px; }

/* Amount (tap to toggle keypad) */
.amt-display { display: flex; align-items: baseline; gap: 12px; width: 100%; margin: 14px 0 4px; padding: 6px 4px; text-align: left; border-radius: 18px; }
.amt-display b { font-size: 52px; min-width: 0; }
.amt-display[data-long] b { font-size: 34px; }
.amt-display small { font-size: 24px; }
.amt-caret { margin-left: auto; align-self: center; color: var(--muted); display: grid; transition: transform .2s; }
.amt-display[aria-expanded="true"] .amt-caret { transform: rotate(180deg); }
.amt-display:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Collapsible keypad */
.kp-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .26s ease; }
.kp-wrap.open { grid-template-rows: 1fr; }
.kp-inner { min-height: 0; overflow: hidden; }
.kp-wrap:not(.open) .kp-inner { visibility: hidden; transition: visibility 0s .26s; }
.sheet-panel .keypad { margin-top: 10px; }
.sheet-panel .key { height: 62px; font-size: 28px; border-radius: 20px; }
.kp-done { width: 100%; height: 50px; margin-top: 12px; border-radius: var(--r-pill); background: #f2edfc; color: #5b2d86; font-size: 17px; font-weight: 600; }
.kp-done:active { transform: scale(.985); }

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

/* Small pill button (Edit event) */
.pill-btn.sm { height: 40px; padding: 0 16px 0 14px; font-size: 15px; margin-top: 0; gap: 8px; font-weight: 600; }
.pill-btn.sm svg { width: 18px; height: 18px; }

/* Tappable payment rows */
button.pay-row { width: 100%; text-align: left; background: none; border-radius: 12px; }
button.pay-row:active { background: var(--chip); }
button.pay-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pay-row .chev { color: #a5a5ad; display: grid; }
.pay-row .chev svg { width: 16px; height: 16px; }
.actionbar.single { grid-template-columns: 1fr; }
.ctx { background: var(--chip); border-radius: 20px; padding: 14px 18px; margin-top: 12px; }
.ctx b { display: block; font-size: 17px; }
.ctx span { color: var(--muted); font-size: 15px; }

/* ───────── Checklist ───────── */
.task-card { margin-top: 14px; }
.task-card h3 { font-size: 20px; font-weight: 700; }
.task-count { margin-top: 10px; margin-bottom: 10px; font-size: 16px; color: var(--muted); }
.task-count b { font-size: 30px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; margin-right: 2px; }
.task-next { margin: 16px 0 2px; font-size: 14px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.task-list .trow:last-child { padding-bottom: 0; }
.task-add { width: 100%; margin-top: 14px; }
.task-done-all { display: flex; align-items: center; gap: 14px; margin: 12px 0 16px; }
.task-done-all b { display: block; font-size: 18px; }
.task-done-all > div > span { color: var(--muted); font-size: 15px; }
.progress-card { margin-top: 18px; }

.trow { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; }
.trow + .trow { border-top: 1px solid var(--line); }
.tick { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.tick > span { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #8e8e96; background: var(--card); display: grid; place-items: center; color: #fff; }
.tick > span svg { width: 16px; height: 16px; stroke-width: 2.6; opacity: 0; }
.tick.on > span { background: var(--ink); border-color: var(--ink); }
.tick.on > span svg { opacity: 1; }
.tick:active > span { transform: scale(.92); }
.tick:focus-visible, .t-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 12px; }
.t-main { display: block; min-width: 0; text-align: left; padding: 6px 0; }
.t-main .row-title, .t-main .row-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-link { display: inline-grid; vertical-align: -2px; margin-left: 2px; color: var(--muted); }
.t-link svg { width: 15px; height: 15px; }
.trow .status { white-space: nowrap; }
.trow.is-done .row-title { text-decoration: line-through; }
.trow.is-done .row-title, .trow.is-done .row-sub { opacity: .55; }

.done-toggle { width: 100%; text-align: left; align-items: center; }
.done-count { display: inline-flex; align-items: center; gap: 6px; }
.done-count svg { width: 18px; height: 18px; }
.empty-state { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 48px 12px 0; }
.empty-state .emoji-dot { width: 72px; height: 72px; font-size: 32px; }
.empty-state h3 { font-size: 22px; font-weight: 700; margin-top: 6px; }
.empty-state p { color: var(--muted); line-height: 1.5; max-width: 280px; }
.empty-state .btn { margin-top: 10px; padding: 0 28px; }

/* Task sheets */
.head-actions { display: flex; align-items: center; gap: 8px; }
.task-title { margin-top: 12px; font-size: 26px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; overflow-wrap: anywhere; }
.sheet-card { background: var(--chip); border-radius: var(--r-lg); padding: 18px 20px; margin-top: 14px; }
.sheet-card h3 { font-size: 20px; font-weight: 700; }
.vendor-btn { width: 100%; text-align: left; }
.vendor-btn > div { flex: 1; min-width: 0; }
.vendor-chev { display: grid; color: var(--muted); }
.vendor-chev svg { width: 18px; height: 18px; }
.sheet-body .muted { font-weight: 400; }
.t-main .row-title { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
.t-main .row-sub { white-space: normal; overflow: visible; }

/* Tasks heading on Home, filter card on Checklist, three-up tabs on the + sheet */
.h2-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.h2-row .link { font-size: 17px; }
.h2-row + .task-card { margin-top: 0; }
.filter-card { padding: 18px 20px 16px; }
.fgroup + .fgroup { margin-top: 16px; }
.flabel { display: block; font-size: 15px; color: var(--muted); font-weight: 500; }
.filter-card .filters { margin-top: 8px; }
.filter-card .fchip { background: var(--chip); }
.filter-card .fchip.on { background: var(--ink); color: #fff; }
.filter-clear { margin-top: 16px; }
.fcount { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; display: inline-grid; place-items: center; }
.seg.three button { flex-direction: column; height: 64px; gap: 3px; font-size: 13.5px; line-height: 1.1; padding: 0 4px; }
.seg.three button svg { width: 20px; height: 20px; }

/* sync status line under the tagline */
.sync { display: block; margin: -4px auto 10px; padding: 4px 12px; border: 0; background: none; font: inherit; font-size: 13px; color: #777; text-align: center; }
.sync[data-state="synced"] { color: #1f8f8a; }
.sync[data-state="offline"], .sync[data-state="signin"], .sync[data-state="error"] { color: #c0392b; font-weight: 600; }
.sync[hidden] { display: none; }
