/* Kitty Bill: light brand theme (docs/brand/brand-guidelines.md). Mobile-first (390px),
   centered column up to 640px on larger screens. */
:root {
  --bg: #f8f5fc;
  --surface: #ffffff;
  --surface-lav: #efe7ff;
  --blob: rgba(233, 222, 253, .75);
  --primary: #6538d8;
  --primary-strong: #5426c9;
  --primary-soft: #e2d0fd;
  --ink: #1e1428;
  --text: #2a2238;
  --muted: #6f6787;
  --border: #ebe4f5;
  --pos: #16a34a;
  --pos-ink: #12803b;
  --pos-bg: #e9f8ee;
  --neg: #e5484d;
  --neg-ink: #c9343a;
  --neg-bg: #fdecee;
  --shadow: 0 8px 24px rgba(60, 30, 120, .08);
  --shadow-lg: 0 16px 40px rgba(60, 30, 120, .16);
  --r-card: 20px;
  --r-tile: 16px;
  --r-pill: 100px;
  --tabbar-h: 68px;
  --gutter: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}
h1, h2, h3 { color: var(--ink); margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.pos { color: var(--pos-ink); }
.neg { color: var(--neg-ink); }
.center { text-align: center; display: block; margin-inline: auto; }
.accent { color: var(--primary); }
.noscript { padding: 24px; text-align: center; }

/* ---------- layout ---------- */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 8px) var(--gutter) calc(32px + var(--safe-b));
  min-height: 100dvh;
}
body.has-tabbar .app { padding-bottom: calc(var(--tabbar-h) + 40px + var(--safe-b)); }
.app:focus { outline: none; }

.page-head { display: flex; align-items: center; gap: 8px; min-height: 52px; margin: 4px 0 12px; }
.page-head.big { margin: 12px 0 16px; }
.page-title { font-size: 22px; font-weight: 800; flex: 1; }
.page-head.big .page-title { font-size: 28px; }
.page-title:focus, h1:focus { outline: none; }
.page-actions { display: flex; gap: 8px; }
.page-head-spacer { flex: 1; }

.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; flex: none;
  border: 0; background: transparent; color: var(--ink); border-radius: 50%;
}
.icon-btn:hover { background: var(--surface-lav); }
.icon-btn.small { width: 36px; height: 36px; font-size: 14px; color: var(--muted); }
.back { margin-left: -10px; }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(101, 56, 216, .35);
}
.round-btn:hover { background: var(--primary-strong); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: var(--r-pill);
  border: 1.5px solid transparent; font-weight: 700; font-size: 16px; text-align: center;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .6; cursor: default; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-primary { background: var(--primary); color: #fff; min-height: 52px; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary-soft); background: #fbf9ff; }
.btn-ghost.danger, .btn-text.danger { color: var(--neg-ink); }
.btn-danger { background: var(--neg); color: #fff; min-height: 52px; }
.btn-text { background: transparent; color: var(--primary); border: 0; }
.btn-block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 16px; font-size: 14px; }
.link-btn { background: none; border: 0; padding: 6px 0; color: var(--primary); font-weight: 700; }
.link-btn.center { margin: 16px auto; }
.btn-row { display: flex; gap: 10px; margin: 16px 0; }
.btn-row .btn { flex: 1; }
.btn-col { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 16px; }

/* ---------- cards & lists ---------- */
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); }
.card.pad { padding: 16px; margin: 16px 0; }
.list { list-style: none; margin: 0 0 8px; padding: 4px 0; }
.list > li + li { border-top: 1px solid var(--border); }
.list-head { font-size: 14px; font-weight: 700; color: var(--muted); margin: 20px 4px 8px; letter-spacing: 0; text-transform: none; }
.section-title { font-size: 18px; font-weight: 800; margin: 20px 4px 8px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px;
  background: none; border: 0; text-align: left; color: inherit; min-height: 64px;
}
button.row:hover, a.row:hover { background: #fbf9ff; }
.list > li:first-child .row { border-radius: var(--r-card) var(--r-card) 0 0; }
.list > li:last-child .row { border-radius: 0 0 var(--r-card) var(--r-card); }
.list > li:only-child .row { border-radius: var(--r-card); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.row-sub { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.row-quote { font-size: 14px; color: var(--text); font-style: italic; overflow-wrap: anywhere; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.row-amount { font-weight: 800; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.impact { font-size: 13px; font-weight: 600; white-space: nowrap; }
.impact.pos { color: var(--pos-ink); }
.impact.neg { color: var(--neg-ink); }
.impact.muted { color: var(--muted); font-weight: 500; }
.chev { color: #b9b0cc; display: grid; }
.cat-icon {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--primary-soft); font-size: 21px;
}
.cat-icon.pay { background: var(--pos-bg); }
.cat-icon.big { width: 64px; height: 64px; font-size: 30px; }
.is-deleted .row-title { text-decoration: line-through; color: var(--muted); }
.is-pending { opacity: .75; }
.pending-tag, .deleted-tag { font-weight: 600; color: var(--primary); }
.deleted-tag { color: var(--neg-ink); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: var(--r-pill); width: fit-content;
}
.badge.angry { background: var(--neg-bg); color: var(--neg-ink); }
.banner { padding: 10px 14px; border-radius: 14px; background: var(--surface-lav); color: var(--ink); margin: 0 0 12px; font-size: 14px; }
.banner.neg { background: var(--neg-bg); color: var(--neg-ink); }
.hint { font-size: 13px; color: var(--muted); }
.hint.center { margin: 12px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; }

/* ---------- avatars & tiles ---------- */
.avatar {
  width: var(--s, 40px); height: var(--s, 40px); border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; background: var(--abg, #e2d0fd); color: var(--afg, #4b2aa8);
  font-weight: 800; font-size: calc(var(--s, 40px) * .38); letter-spacing: 0;
  box-shadow: 0 0 0 2px var(--surface);
}
.avatar.more { background: var(--primary-soft); color: var(--primary); font-size: calc(var(--s, 40px) * .4); }
.avatar.new { --s: 32px; background: var(--surface-lav); color: var(--primary); }
.avatar-stack { display: inline-flex; padding-left: 6px; }
.avatar-stack .avatar { margin-left: -6px; }
.tile {
  width: var(--s, 56px); height: var(--s, 56px); border-radius: var(--r-tile); flex: none;
  display: grid; place-items: center; background: var(--tbg, var(--surface-lav)); font-size: calc(var(--s, 56px) * .5);
}

/* ---------- mascot ---------- */
.mascot { display: block; height: auto; object-fit: contain; pointer-events: none; user-select: none; }
.mascot-hero { width: min(260px, 70vw); }
.mascot-lg { width: 180px; }
.mascot-md { width: 140px; }
.mascot-card { width: 92px; flex: none; align-self: flex-end; margin: -8px -6px -14px 0; }
.mascot-sheet { width: 64px; flex: none; margin: -18px 0 -6px -4px; }
.mascot-toast { width: 52px; flex: none; margin: -14px 0 -10px -6px; }
.blob-wrap { position: relative; display: grid; place-items: center; padding: 8px 0; isolation: isolate; }
.blob-wrap::before {
  content: ""; position: absolute; z-index: -1; width: 78%; aspect-ratio: 1.15; max-width: 240px;
  background: var(--blob); border-radius: 58% 42% 55% 45% / 52% 48% 52% 48%; bottom: 4px;
}
.hero-blob::before { max-width: 320px; width: 95%; }
/* Reserve the blob's full height so it never paints over the subtitle (3-line LT copy). */
.hero-blob { min-height: 290px; align-content: end; padding-bottom: 36px; }
@media (prefers-reduced-motion: no-preference) {
  .mascot { animation: pop .2s ease-out both; }
  @keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
}

/* ---------- welcome / auth ---------- */
.welcome, .auth-page {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  min-height: calc(100dvh - 40px); padding-top: 8px;
}
.welcome-top, .auth-top { width: 100%; display: flex; justify-content: space-between; align-items: center; min-height: 48px; }
.welcome-top { justify-content: flex-end; }
.logo-lockup { width: 180px; height: auto; margin: 8px 0 20px; }
.hero-title { font-size: clamp(30px, 8.5vw, 40px); font-weight: 800; line-height: 1.1; max-width: 12ch; }
.hero-sub { color: var(--muted); margin: 12px auto 4px; max-width: 30ch; }
.hero-blob { margin: 8px 0 12px; }
.welcome-actions { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.tagline { font-weight: 700; color: var(--muted); margin-top: 18px; text-align: center; }
.credit { color: var(--muted); font-size: 13px; margin: 6px 0 8px; display: flex; gap: 4px; align-items: center; justify-content: center; }
.credit strong { color: var(--ink); }
.credit-arrow { color: var(--primary); display: inline-grid; }
.auth-title { font-size: 28px; font-weight: 800; margin-top: 8px; }
.auth-sub { color: var(--muted); margin: 8px auto 20px; max-width: 32ch; }
.auth-switch { margin-top: 20px; color: var(--muted); }
.auth-switch a { font-weight: 700; }
.auth-page .form { width: 100%; max-width: 420px; text-align: left; }
.lang-switch { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 3px; }
.lang-switch button { border: 0; background: none; padding: 6px 12px; min-height: 34px; border-radius: var(--r-pill); font-weight: 700; font-size: 13px; color: var(--muted); }
.lang-switch button.on { background: var(--primary); color: #fff; }

/* ---------- cat states ---------- */
.cat-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px 8px; gap: 6px; }
.cat-title { font-size: 22px; font-weight: 800; margin-top: 8px; }
.cat-line { color: var(--muted); max-width: 32ch; }
.cat-state .stack, .cat-state > .btn { max-width: 360px; margin-top: 16px; }
.loading .skeleton { height: 72px; border-radius: var(--r-card); margin: 10px 0; background: linear-gradient(90deg, #f1ebfa, #faf7ff, #f1ebfa); background-size: 200% 100%; }
.loading .skeleton.short { width: 60%; }
@media (prefers-reduced-motion: no-preference) {
  .loading .skeleton { animation: shimmer 1.4s linear infinite; }
  @keyframes shimmer { to { background-position: -200% 0; } }
}

/* ---------- groups home ---------- */
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.summary-cell { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 12px 16px; display: grid; gap: 2px; }
.summary-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.summary-amount { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.group-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.group-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 12px; color: inherit;
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow);
}
.group-card:hover { box-shadow: var(--shadow-lg); }
.group-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.group-card-name { font-weight: 800; color: var(--ink); font-size: 17px; overflow-wrap: anywhere; }
.group-card-meta { font-size: 13px; color: var(--muted); }
.group-card-bal { font-size: 13px; font-weight: 700; }
.lav-card {
  display: flex; align-items: center; gap: 14px; margin: 16px 0; padding: 18px 16px;
  background: var(--surface-lav); border-radius: var(--r-card); color: var(--ink);
}
.lav-logo { width: 56px; height: auto; flex: none; }
.lav-title { display: block; font-weight: 700; }
.lav-link { display: block; color: var(--primary); font-weight: 700; margin-top: 4px; }

/* ---------- group screen ---------- */
.group-hero { display: flex; align-items: center; gap: 16px; margin: 0 0 16px; }
.group-hero .avatar-stack { margin-top: 8px; }
.group-name { font-size: 26px; font-weight: 800; overflow-wrap: anywhere; }
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a {
  flex: 1; text-align: center; padding: 12px 4px; color: var(--muted); font-weight: 700;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
.add-btn { margin-bottom: 8px; }
.sticky-card { position: sticky; bottom: calc(var(--tabbar-h) + 12px + var(--safe-b)); margin-top: 20px; z-index: 2; }
.balance-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; overflow: hidden;
  padding: 16px 16px 16px 18px; border-radius: var(--r-card); box-shadow: var(--shadow-lg); background: var(--pos-bg); margin: 0 0 16px;
}
.balance-card.neg { background: var(--neg-bg); }
.balance-card.settled { background: var(--surface-lav); }
.bc-label { font-size: 14px; font-weight: 600; color: var(--ink); }
.bc-amount { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.bc-line { font-weight: 700; color: var(--ink); }
.bc-note { font-size: 13px; color: var(--neg-ink); font-weight: 600; margin-top: 2px; }
.balance-card .link-btn { margin-top: 4px; }
.callout {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--r-card);
  background: var(--surface-lav); margin: 0 0 16px; overflow: hidden;
}
.callout .mascot { order: 2; margin-left: auto; }
.callout-neg, .angry-callout { background: var(--neg-bg); }
.callout-pos { background: var(--pos-bg); }
.callout-title { font-weight: 800; color: var(--ink); margin-bottom: 2px; }
.callout .btn { margin-top: 10px; }
.bal-section + .bal-section { margin-top: 12px; }
.transfer-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.transfer { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 12px 14px; }
.transfer-who { display: flex; align-items: center; gap: 6px; }
.transfer-arrow { color: var(--muted); font-weight: 800; }
.transfer-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; margin-left: 6px; }
.transfer-amount { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.transfer-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.friend-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; margin-bottom: 16px; }
.friend-status { font-weight: 700; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-size: 14px; font-weight: 700; color: var(--ink); padding: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
input, select, textarea {
  width: 100%; font-size: 16px; padding: 12px 14px; min-height: 48px; border-radius: 14px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; min-height: 48px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(101, 56, 216, .15); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--primary); flex: none; }
.form-error { color: var(--neg-ink); font-weight: 600; font-size: 14px; }
.inline-field { display: flex; gap: 8px; align-items: center; }
.inline-field input { flex: 1; }
.switch-field { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--bg); border-radius: 14px; cursor: pointer; }
.switch-field input { margin-top: 2px; }
.switch-field small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.switch-field strong { font-size: 14px; color: var(--ink); }
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.type-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: var(--r-tile); border: 1.5px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.type-opt input { position: absolute; opacity: 0; pointer-events: none; }
.type-opt:has(input:checked) { border-color: var(--primary); background: var(--surface-lav); }
.type-opt:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  border-radius: var(--r-pill); border: 1.5px solid var(--border); background: var(--surface);
  font-weight: 600; font-size: 14px; color: var(--ink);
}
.chip.on, .chip[aria-pressed="true"] { border-color: var(--primary); background: var(--surface-lav); color: var(--primary-strong); }
.person-chip { padding-left: 6px; }
.radio-chip input { width: 18px; height: 18px; }
.radio-chip:has(input:checked) { border-color: var(--primary); background: var(--surface-lav); }
.new-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.person-line { display: flex; align-items: center; gap: 10px; }
.person-line > span:not(.avatar) { flex: 1; min-width: 0; }
.add-person { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-person .btn { grid-column: 1 / -1; justify-self: start; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.seg { display: flex; background: var(--bg); border-radius: var(--r-pill); padding: 4px; gap: 2px; border: 1px solid var(--border); }
.seg button { flex: 1; border: 0; background: none; min-height: 38px; border-radius: var(--r-pill); font-weight: 700; font-size: 14px; color: var(--muted); padding: 0 6px; }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.copy-field { margin-top: 12px; }

/* ---------- expense sheet ---------- */
.ctx-chip { align-self: flex-start; }
.amount-row { display: flex; align-items: center; gap: 10px; background: var(--surface-lav); border-radius: var(--r-card); padding: 10px 12px; }
.cur-select { width: auto; min-width: 84px; min-height: 44px; border-radius: var(--r-pill); font-weight: 700; padding: 8px 10px; background: var(--surface); }
.amount-input { border: 0; background: transparent; font-size: 34px; font-weight: 800; padding: 4px 0; min-height: 56px; font-variant-numeric: tabular-nums; }
.amount-input:focus { box-shadow: none; }
.desc-row { display: flex; gap: 10px; align-items: center; }
.cat-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--primary-soft); font-size: 22px; flex: none; }
.defaults .chip { background: var(--surface-lav); border-color: transparent; color: var(--primary-strong); }
.preview { min-height: 8px; }
.preview-line { font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.preview-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.preview-list li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; background: var(--bg); border-radius: var(--r-pill); font-size: 13px; }
.preview-list strong { font-variant-numeric: tabular-nums; }
.preview-error { color: var(--neg-ink); font-weight: 600; font-size: 14px; }
.adv-section { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.adv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.adv-head h3 { font-size: 16px; font-weight: 800; }
.pp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pp-row { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 0; cursor: default; }
label.pp-row { cursor: pointer; }
.pp-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.pp-out { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-input { width: 104px; flex: none; text-align: right; min-height: 44px; padding: 8px 10px; }
.suffix-wrap { position: relative; display: inline-flex; align-items: center; flex: none; }
.suffix-wrap .pp-input { padding-right: 26px; width: 92px; }
.suffix { position: absolute; right: 10px; color: var(--muted); font-weight: 700; pointer-events: none; }
.remainder { font-size: 14px; font-weight: 700; color: var(--primary); min-height: 1.2em; }

/* ---------- detail / comments ---------- */
.detail-hero { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.detail-desc { font-weight: 800; color: var(--ink); font-size: 18px; overflow-wrap: anywhere; }
.detail-amount { font-size: 30px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.2; }
.detail-block h3 { font-size: 14px; color: var(--muted); font-weight: 700; margin: 14px 4px 6px; letter-spacing: 0; }
.detail-block .list { box-shadow: none; border: 1px solid var(--border); }
.row.static { min-height: 56px; }
.notes { background: var(--bg); padding: 12px 14px; border-radius: 14px; margin: 12px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-actions { display: flex; gap: 10px; margin: 16px 0 8px; }
.detail-actions .btn { flex: 1; }
.comments { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 14px; }
.comments h3 { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.comment-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.comment { display: flex; gap: 8px; align-items: flex-start; }
.comment-bubble { flex: 1; min-width: 0; background: var(--bg); border-radius: 4px 16px 16px 16px; padding: 8px 12px; }
.comment-meta { font-size: 12px; color: var(--muted); }
.comment-meta strong { color: var(--ink); }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.comment-form textarea { flex: 1; min-height: 48px; max-height: 160px; }
.comment-form .btn { min-height: 48px; }

/* ---------- settle ---------- */
.settle-pair { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 4px 0; }
.settle-arrow { font-size: 24px; font-weight: 800; color: var(--primary); }
.settled-wrap { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 8px 0 16px; }
.settled-line { font-size: 22px; font-weight: 800; color: var(--ink); }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .9; } }

/* ---------- activity ---------- */
.activity-row { align-items: flex-start; }
.activity-row .avatar { margin-top: 2px; }
.activity-row.unread { background: #faf6ff; }
.activity-row .row-title { font-weight: 600; }
.activity-row.unread .row-title { font-weight: 800; }

/* ---------- profile ---------- */
.profile-hero { display: flex; align-items: center; gap: 14px; padding: 16px; margin-bottom: 14px; }
.profile-name { font-size: 20px; font-weight: 800; color: var(--ink); overflow-wrap: anywhere; }
.profile-form { padding: 16px; margin-bottom: 16px; }

/* ---------- invite ---------- */
.invite-group { display: flex; align-items: center; gap: 14px; text-align: left; margin: 8px 0 20px; }
.invite-group .auth-title { margin: 0; }
.claim-list { display: grid; gap: 8px; }
.claim-opt { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; }
.claim-opt:has(input:checked) { border-color: var(--primary); background: var(--surface-lav); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 max(8px, calc((100vw - 640px) / 2)) var(--safe-b);
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); box-shadow: 0 -6px 24px rgba(60, 30, 120, .06);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; padding: 6px 0; min-width: 56px; }
.tab.on { color: var(--primary); }
.tab-icon { position: relative; display: grid; }
.tab-dot { position: absolute; top: -1px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--neg); box-shadow: 0 0 0 2px #fff; }
.tab-add {
  width: 58px; height: 58px; border-radius: 50%; border: 0; flex: none; margin: -26px 6px 0;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 22px rgba(101, 56, 216, .4);
}
.tab-add:hover { background: var(--primary-strong); }
.tab-add svg { width: 28px; height: 28px; }

/* ---------- pill & toasts ---------- */
.net-pill {
  position: fixed; top: calc(var(--safe-t) + 8px); left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; padding: 6px 14px; border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
}
.net-pill:not(.offline) { background: var(--primary); }
.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 18px + var(--safe-b)); z-index: 40;
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 var(--gutter); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; width: fit-content;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 18px; box-shadow: var(--shadow-lg);
  font-weight: 600; font-size: 15px;
}
.toast-success { background: #2b1d4a; }
.toast-error { background: #4a1a22; }
.toast-action { background: none; border: 0; color: #cdb6ff; font-weight: 800; padding: 4px 6px; }
.toast.leaving { opacity: 0; transition: opacity .2s; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in .2s ease-out; }
  @keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
}

/* ---------- sheets (native <dialog>) ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: 92dvh;
  background: transparent; color: var(--text); overflow: visible;
}
dialog.sheet::backdrop { background: rgba(30, 20, 40, .42); }
.sheet-inner {
  background: var(--surface); border-radius: 26px 26px 0 0; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px var(--gutter) calc(20px + var(--safe-b)); box-shadow: var(--shadow-lg);
}
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: 2px auto 8px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; position: sticky; top: -8px; background: var(--surface); z-index: 1; padding-top: 4px; }
.sheet-title { flex: 1; font-size: 20px; font-weight: 800; }
.sheet-title:focus { outline: none; }
.sheet-close { margin-right: -8px; }
.sheet-text { color: var(--text); margin-bottom: 12px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
dialog.sheet-tall .sheet-inner { min-height: 60dvh; }
dialog.sheet-full { max-height: 100dvh; height: 100dvh; margin: 0 auto; }
dialog.sheet-full .sheet-inner { border-radius: 0; height: 100dvh; max-height: 100dvh; display: flex; flex-direction: column; justify-content: center; background: var(--bg); }
dialog.sheet-full .sheet-head { background: transparent; justify-content: center; text-align: center; }
dialog.sheet-full .sheet-title { font-size: 30px; }
dialog.sheet-full .sheet-grip { display: none; }
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] .sheet-inner { animation: sheet-up .22s ease-out; }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } }
}
@media (min-width: 700px) {
  dialog.sheet:not(.sheet-full) { margin: auto; }
  dialog.sheet:not(.sheet-full) .sheet-inner { border-radius: 26px; }
}
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 10px 8px;
  background: none; border: 0; border-radius: 14px; text-align: left; font-weight: 600; color: var(--ink);
}
.menu-item:hover { background: var(--surface-lav); }
.menu-item.danger { color: var(--neg-ink); }
.menu-icon { width: 36px; height: 36px; display: grid; place-items: center; background: var(--bg); border-radius: 50%; font-size: 18px; flex: none; }
.menu-label { flex: 1; display: flex; flex-direction: column; }
.menu-label small { color: var(--muted); font-weight: 500; font-size: 13px; }
.menu-check { color: var(--primary); font-weight: 800; }

@media (max-width: 360px) {
  .field-row { grid-template-columns: 1fr; }
  .add-person { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Invite QR */
.btn-pair { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-pair .btn svg { vertical-align: -3px; }
.qr-card { background: #fff; border-radius: 24px; padding: 16px; box-shadow: var(--shadow, 0 8px 24px rgba(60, 30, 120, .08)); width: min(280px, 100%); margin: 4px auto 0; border: 1px solid var(--border, #ebe4f5); }
.qr-svg { display: block; width: 100%; height: auto; }
.qr-hint { text-align: center; }
.qr-warn { background: var(--neg-bg, #fdecee); border-radius: 14px; padding: 10px 12px; color: var(--text, #2a2238); }

/* Receipt photos (expense sheet + detail) */
.receipt-field { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.receipts { margin: 14px 0; }
.receipt-field h3 { font-size: 16px; font-weight: 800; }
.receipts h3 { font-size: 14px; font-weight: 700; color: var(--muted); letter-spacing: 0; margin: 0 4px 8px; }
.receipt-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.receipt-buttons .btn { flex: 1 1 150px; min-height: 48px; padding: 8px 12px; font-size: 15px; line-height: 1.2; }
.receipt-thumbs { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.receipt-field .receipt-thumbs { margin: 0; }
.receipt-field .receipt-thumbs:empty { display: none; }
.receipt-thumb { position: relative; display: grid; place-items: center; width: 84px; height: 84px; padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--bg); }
button.receipt-thumb:hover { border-color: var(--primary-soft); }
.receipt-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 13px; display: block; }
.receipt-fail { font-size: 28px; opacity: .55; }
.receipt-x {
  position: absolute; top: -6px; right: -6px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface);
  background: var(--ink); color: #fff; font-size: 12px; line-height: 1; display: grid; place-items: center; padding: 0;
}
.receipt-x::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; } /* 44px touch target */
.receipt-spin { width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--primary-soft); border-top-color: var(--primary); display: inline-block; }
.receipt-spin.big { width: 40px; height: 40px; border-width: 4px; }
@media (prefers-reduced-motion: no-preference) {
  .receipt-spin { animation: receipt-spin .8s linear infinite; }
  @keyframes receipt-spin { to { transform: rotate(360deg); } }
}
.receipt-note:empty { display: none; }
.receipt-empty { display: flex; align-items: center; gap: 12px; background: var(--bg); border-radius: 16px; padding: 10px 14px; margin-bottom: 10px; }
.receipt-empty .mascot { width: 56px; margin: 0; flex: none; }
.receipt-empty p { color: var(--muted); font-weight: 600; }
.receipt-stage { display: grid; place-items: center; background: var(--bg); border-radius: 16px; min-height: 40dvh; overflow: auto; touch-action: pan-x pan-y pinch-zoom; }
.receipt-stage img { max-width: 100%; max-height: 62dvh; object-fit: contain; display: block; }
.receipt-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; }
.receipt-nav .icon-btn { font-size: 28px; line-height: 1; }
.receipt-nav .icon-btn[disabled] { opacity: .3; }
.receipt-tag { font-size: 13px; }

/* name hints in member forms; privacy link */
.name-hint { margin: 6px 2px 0; color: var(--primary); font-weight: 700; }
.name-hint.warn { color: var(--muted); font-weight: 600; }
.privacy-link { text-align: center; font-size: 13px; margin: 4px 0; }
.privacy-link a { color: var(--primary); font-weight: 700; }
.claim-failed { margin-top: 12px; }
