/* tabby-api/public/app/app.css
   Tabby web app. Tokens match the site and the approved mock; light/dark follow the system unless Settings picks one.
   System fonts only (no external fonts). */
:root {
  --bg: #f6f5fb; --surface: #fff; --fg: #1b1a2b; --muted: #5f5d75; --line: #e3e1ef; --field-line: #85819e;
  --accent: #4b3fd6; --on-accent: #fff; --accent-soft: #ecebfc; --good: #1f7a51; --bad: #c2372f; --warn: #8f5500;
  --m0: #2462c8; --m1: #b84609; --m2: #0a795c; --m3: #8a3ec4; --m4: #c2275e; --m5: #0e7490; --m6: #896000; --m7: #526f13; --on-member: #fff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111019; --surface: #1a1926; --fg: #ecebf5; --muted: #a09eb8; --line: #2c2a3d; --field-line: #706d8f;
  --accent: #9d95ff; --on-accent: #16123a; --accent-soft: #25224a; --good: #4cc38a; --bad: #ff6b61; --warn: #f0a83a;
  --m0: #7eaaf5; --m1: #f59a5e; --m2: #4fd1a8; --m3: #c69bf1; --m4: #f586ad; --m5: #5cc7df; --m6: #e8bd4f; --m7: #a8cf5e; --on-member: #16123a;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #111019; --surface: #1a1926; --fg: #ecebf5; --muted: #a09eb8; --line: #2c2a3d; --field-line: #706d8f;
  --accent: #9d95ff; --on-accent: #16123a; --accent-soft: #25224a; --good: #4cc38a; --bad: #ff6b61; --warn: #f0a83a;
  --m0: #7eaaf5; --m1: #f59a5e; --m2: #4fd1a8; --m3: #c69bf1; --m4: #f586ad; --m5: #5cc7df; --m6: #e8bd4f; --m7: #a8cf5e; --on-member: #16123a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.15; overflow-wrap: anywhere; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1:focus, .main:focus { outline: none; }
.boot { padding: 24px; color: var(--muted); }
.muted { color: var(--muted); } .small, small { font-size: .85rem; }
.pos { color: var(--good); } .neg { color: var(--bad); } .warn { color: var(--warn); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed !important; top: 8px; left: 8px; width: auto; height: auto; clip: auto; z-index: 20; padding: 10px 16px; border-radius: 10px; background: var(--surface); color: var(--accent); font-weight: 650; }

/* Frame: sidebar on wide screens, a bottom tab bar on phones (like the app) */
.app { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 16px 10px 16px max(10px, env(safe-area-inset-left)); background: var(--surface); border-right: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px 8px; font-weight: 800; font-size: 1.15rem; color: var(--fg); text-decoration: none; }
.logo-mark { width: 22px; height: 22px; border-radius: 6px; display: inline-block; flex: none; }
.i { width: 22px; height: 22px; flex: none; }
.nav { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.main { padding: 24px clamp(16px, 4vw, 40px) 96px; min-width: 0; }
.page { max-width: 760px; margin: 0 auto; display: grid; gap: 16px; min-width: 0; }
.page.narrow { max-width: 480px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: -12px 0 -12px -4px; padding: 0 4px; justify-self: start; font-size: .94rem; font-weight: 600; text-decoration: none; }
.back span { font-size: 1.4em; line-height: 1; }
/* Shows after 250 ms of loading (main.js). Pinned to the top of the content column. */
.progress { position: fixed; top: 0; left: 200px; right: 0; height: 2px; overflow: hidden; z-index: 30; pointer-events: none; }
.progress i { position: absolute; top: 0; bottom: 0; width: 30%; background: var(--accent); animation: progress 1.2s ease-in-out infinite; }
.progress span { display: none; }
.progress.full { left: 0; } /* sign-in pages have no sidebar */
@keyframes progress { from { left: -30%; } to { left: 100%; } }
@media (max-width: 640px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; top: auto; left: 0; right: 0; bottom: 0; height: auto; z-index: 5; flex-direction: row; gap: 0;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: color-mix(in srgb, var(--surface) 85%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-right: 0; border-top: 1px solid var(--line); }
  .side .logo { display: none; } /* the page title carries identity on phones */
  .nav { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 2px; min-height: 56px; padding: 4px 0; border-radius: 0; font-size: 11px; font-weight: 600; }
  .nav.on { background: none; }
  .main { padding: 16px max(16px, env(safe-area-inset-right)) calc(96px + 56px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .progress { left: 0; }
  .side .nav:focus-visible { outline-offset: -3px; } /* full-bleed items: keep the ring on screen */
}
@media (prefers-reduced-transparency: reduce) { .side { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } }

/* Sync strip (main.js): above the page, only when something is wrong */
.sync-strip { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 12px; padding: 6px max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left)); background: var(--accent-soft); color: var(--fg); font-size: .9rem; text-align: center; }
.sync-strip:empty { display: none; }
.sync-strip[data-kind="undone"] { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); }
.sync-strip .btn { min-height: 44px; }

/* Lists and rows */
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.list { list-style: none; margin: 0; padding: 0 14px; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; min-height: 56px; min-width: 0; }
.row.link { color: inherit; text-decoration: none; }
button.row { width: 100%; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > span:last-child { display: grid; min-width: 0; }
.who b { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; } /* full text in a tooltip (main.js) */
.who.names b { display: block; } /* rows that name people wrap in full, never cut */
.who small { overflow-wrap: anywhere; } /* captions carry names and amounts: wrap, never cut */
.who small, .amt small { color: var(--muted); }
.amt { display: grid; justify-items: end; gap: 2px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amt small { white-space: normal; } /* "your share" wraps before the title is cut; money formats keep their own no-break spaces */
.avatar { flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--on-member); font-weight: 700; }
.avatar.sm { width: 28px; height: 28px; font-size: .8rem; }
.c0 { background: var(--m0); } .c1 { background: var(--m1); } .c2 { background: var(--m2); } .c3 { background: var(--m3); }
.c4 { background: var(--m4); } .c5 { background: var(--m5); } .c6 { background: var(--m6); } .c7 { background: var(--m7); }
/* Settle up (W2-7): the sentence at full width, the avatars inline before it, wrapping at spaces and hyphens;
   then the amount on the left and the buttons on the right */
.xfer { display: grid; gap: 4px; padding: 12px 0; }
.xfer-main { display: block; width: 100%; min-height: 44px; padding: 6px 0; background: none; border: 0; font: inherit; font-weight: 600; color: inherit; text-align: left; cursor: pointer; overflow-wrap: break-word; }
.xfer-main .pair { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; vertical-align: middle; }
.xfer-main .arrow { color: var(--muted); font-size: 14px; }
.xfer-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.xfer-foot .money { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.xfer-foot .btns { margin-left: auto; }
.paynote { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .9rem; color: var(--muted); }
.paynote > span { min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
@media (max-width: 359.98px) { .xfer-main .pair { display: none; } } /* the names are written out; room for them first */
/* Balances (R6): a member row opens how their balance adds up */
.bd > summary { list-style: none; cursor: pointer; }
.bd > summary::-webkit-details-marker { display: none; }
.bd > summary .chev { color: var(--muted); }
.bd[open] > summary .chev { transform: rotate(90deg); }
.bd-body { display: grid; gap: 10px; padding: 0 0 14px; }
.bd-body h3 { font-size: .85rem; font-weight: 650; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.bd-body ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.bd-body li { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; }
.bd-body li span:first-child { min-width: 0; overflow-wrap: anywhere; }
.bd-body li span:last-child, .bd-body h3 span:last-child, .bd-total span:last-child { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bd-total { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; }
.ic { flex: none; width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); display: inline-grid; place-items: center; }
.day { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 650; margin: 8px 0 6px; }
.feed { display: grid; gap: 4px; }
/* F6: new since your last visit */
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.new { color: var(--accent); font-weight: 650; white-space: nowrap; }
.new .dot { margin: 0 4px 0 0; }
.note-line { font-style: italic; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.ic .i { width: 18px; height: 18px; color: var(--accent); }
.empty { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 32px 16px; }
/* The group summary (W2-3): two lines in one card, "You owe €19.65" then "€99.10 spent · 6 people"; long amounts wrap, never cut */
.sum { display: grid; gap: 2px; min-width: 0; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.sum-main { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sum-main .btn { font-size: 1rem; }
.sum .small { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.seg { display: flex; gap: 4px; padding: 4px; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.seg a, .seg label { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; align-items: center; min-height: 44px; padding: 0 4px; border-radius: 9px; color: var(--muted); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.seg a > span, .seg label > span { overflow: hidden; text-overflow: ellipsis; }
.seg a.on, .seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
fieldset.seg { position: relative; } /* hidden radios stay inside */
.short { display: none; }
@media (max-width: 389.98px) { .seg a { font-size: .875rem; } } /* the bold active "Expenses" fits a quarter at 360–389 px */
@media (max-width: 359.98px) {
  .seg { gap: 2px; } .seg a, .seg label { padding: 0 2px; font-size: .8125rem; } /* four segments fit at 320 px (13 px, like iOS segmented controls) */
  .long { display: none; } .short { display: inline; } /* "Settle", "Equal"; the full name stays in aria-label */
}

/* Buttons and forms (44 px targets) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.btn.alt { background: transparent; color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 0 8px; }
.btn.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btns.end { justify-content: flex-end; } .btns.center { justify-content: center; }
.icon-btn { min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--muted); font-size: 1.1rem; border-radius: 10px; cursor: pointer; }
.stack { display: grid; gap: 12px; min-width: 0; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label, legend { font-size: .85rem; font-weight: 600; color: var(--muted); padding: 0; }
input, select, textarea { font: inherit; font-size: 16px; color: inherit; background: var(--bg); border: 1px solid var(--field-line); border-radius: 10px; min-height: 44px; padding: 8px 12px; width: 100%; min-width: 0; }
/* iOS Safari gives a date input its own width (past the sheet edge) and centred text (W2-11) */
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 22px; padding: 0; accent-color: var(--accent); margin: 0; flex: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.hint { font-size: .85rem; color: var(--muted); }
.msg { font-size: .9rem; } .msg:empty { display: none; } .msg.err { color: var(--bad); }
/* Field errors: red outline plus a ! icon, so color isn't the only signal (dom.js fieldError) */
.msg.err { display: flex; gap: 6px; align-items: baseline; }
.msg.err::before { content: "!"; content: "!" / ""; flex: none; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--bad); color: var(--surface); font-size: .7rem; font-weight: 800; line-height: 1; transform: translateY(2px); }
.msg.err:empty { display: none; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], .seg[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
::placeholder { color: var(--muted); opacity: 1; font-weight: 400; letter-spacing: normal; }
.counter { text-align: right; font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.disclosure { justify-self: start; padding-inline: 4px; }
.chev { display: inline-block; width: 1em; font-size: 1.3em; line-height: 1; transition: transform 150ms ease-out; }
.disclosure[aria-expanded="true"] .chev { transform: rotate(90deg); }
.note { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: .9rem; }
.otp { font: 600 1.5rem/1 var(--mono); letter-spacing: .5em; text-align: center; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .g2 { grid-template-columns: minmax(0, 1fr); } }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; cursor: pointer; }
input[role="switch"] { appearance: none; -webkit-appearance: none; position: relative; width: 51px; height: 31px; min-height: 31px; border: 0; border-radius: 999px; background: var(--field-line); cursor: pointer; transition: background-color 150ms; }
input[role="switch"]::before { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform 150ms ease-out; }
input[role="switch"]:checked { background: var(--accent); }
input[role="switch"]:checked::before { transform: translateX(20px); background: var(--on-accent); }
@media (forced-colors: active) {
  input[role="switch"] { border: 1px solid CanvasText; }
  input[role="switch"]::before { background: CanvasText; }
  input[role="switch"]:checked { background: Highlight; }
}

/* Sign-in pages */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth { width: 100%; max-width: 400px; padding: 24px; display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.tabs2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg); border-radius: 11px; }
.tabs2 a { display: flex; justify-content: center; align-items: center; min-height: 44px; border-radius: 9px; color: var(--muted); text-decoration: none; }
.tabs2 a.on { background: var(--surface); color: var(--fg); font-weight: 650; box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.or { text-align: center; color: var(--muted); font-size: .85rem; }

/* Dialogs: a centred dialog on wide screens, a bottom sheet up to 640 px. The header (Cancel · title · primary) stays on top while the body scrolls. */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--fg); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain; }
dialog::backdrop { background: rgb(10 8 30 / .45); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: grid; grid-template-columns: 1fr minmax(0, auto) 1fr; align-items: center; gap: 8px; min-height: 56px; padding: 6px 10px; background: var(--surface); border-bottom: 1px solid transparent; transition: border-color 120ms; }
.sheet-head.scrolled { border-bottom-color: var(--line); }
.sheet-head h2 { text-align: center; font-size: 1.0625rem; font-weight: 650; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.sheet-head > :first-child { justify-self: start; } .sheet-head > :nth-child(3) { justify-self: end; }
.sheet-err { grid-column: 1 / -1; padding: 0 10px 4px; } /* dlg.error(): in the sticky header, so it shows wherever the form is scrolled */
.sheet-head .btn:not(.ghost) { min-height: 36px; padding: 0 16px; border-radius: 999px; } /* 36 px pill; the header row keeps a 44 px+ target */
.sheet-head .btn { white-space: nowrap; }
.sheet-body { padding: 8px 20px 20px; }
dialog.alert { width: min(400px, calc(100vw - 24px)); padding: 20px; }
dialog.alert[open] { display: grid; gap: 12px; }
dialog.sheet[open] { animation: sheet-in 220ms cubic-bezier(.2, .8, .2, 1); }
dialog.sheet.closing { animation: sheet-out 180ms ease-in forwards; }
dialog.sheet[open]::backdrop { animation: fade-in 220ms ease-out; }
dialog.sheet.closing::backdrop { animation: fade-out 180ms ease-in forwards; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(16px); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@media (max-width: 640px) {
  dialog.sheet { inset: auto 0 var(--kb, 0px) 0; margin: 0; width: 100%; max-width: 100%; max-height: calc(var(--vvh, 100dvh) - 24px); border-radius: 16px 16px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom); }
  dialog.sheet[open] { animation-name: sheet-up; animation-duration: 300ms; }
  dialog.sheet.closing { animation-name: sheet-down; animation-duration: 220ms; }
  .sheet-head { padding-top: 14px; padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right)); border-radius: 16px 16px 0 0; }
  .sheet-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--line); } /* grab handle look */
  .sheet-body { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
}

/* Expense editor */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.split { display: grid; }
.split-row { display: flex; align-items: center; gap: 10px; min-height: 52px; border-bottom: 1px solid var(--line); min-width: 0; }
.split-row > label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 44px; cursor: pointer; }
.split-row > label > span:last-child { display: grid; min-width: 0; }
.split-row > label > span:last-child > span { overflow-wrap: anywhere; }
.split-row .val { width: 88px; text-align: right; flex: none; }
@media (max-width: 359.98px) { .split-row .val { width: 76px; } }
.pct { display: inline-flex; align-items: center; gap: 4px; }
.split-status { font-weight: 600; font-size: .9rem; }
/* Amount first, with the currency symbol inside the box */
.money-field { display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 0 12px; background: var(--bg); border: 1px solid var(--field-line); border-radius: 10px; }
.money-field:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.money-field:has([aria-invalid="true"]) { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.money-field > span { font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.amount-input { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; border: 0; padding: 0; background: none; }
.money-field .amount-input, .money-field .amount-input[aria-invalid="true"] { outline: none; border: 0; box-shadow: none; }
.receipt { justify-self: start; }
.money-field select.cur { flex: none; width: auto; min-height: 40px; padding: 0 6px; border: 0; background: none; font-size: 1.1rem; font-weight: 700; color: var(--muted); }
.money-field select.cur:focus-visible { outline: 3px solid var(--accent); }
.hint.center { text-align: center; }
.danger-zone { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); } /* Settings: Delete account well below Sign out */

/* Toast */
.toast-region { position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom)); display: grid; justify-items: center; padding: 0 16px; pointer-events: none; z-index: 10; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 4px 6px 4px 16px; border-radius: 999px; background: var(--fg); color: var(--bg); box-shadow: 0 10px 30px -10px rgb(0 0 0 / .4); max-width: 100%; }
.toast { position: relative; overflow: hidden; max-width: min(360px, 100%); }
.toast .btn.ghost { color: var(--bg); text-decoration: underline; }
.toast-time { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--bg); opacity: .6; transform-origin: left; animation: toast-time 8s linear forwards; }
.toast.paused .toast-time { animation-play-state: paused; }
@keyframes toast-time { to { transform: scaleX(0); } }
@media (max-width: 640px) { .toast-region { bottom: calc(56px + 12px + env(safe-area-inset-bottom)); } } /* 12 px above the tab bar */
/* The new row after Add: a soft highlight that fades (static under reduced motion) */
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from, 30% { background: var(--accent-soft); } }

/* Balances, invite, join */
.bar { position: relative; display: block; height: 6px; border-radius: 3px; background: var(--line); margin: 0 0 10px; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.bar i.pos { background: var(--good); } .bar i.neg { background: var(--bad); }
.invite { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.qr { width: 180px; height: 180px; border-radius: 12px; background: #fff; image-rendering: pixelated; flex: none; }
.link-text { font: .85rem var(--mono); word-break: break-all; }
.claim { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.claim .row { border: 1px solid var(--line); border-radius: 11px; padding: 8px 12px; }
pre.summary { white-space: pre-wrap; font: .85rem/1.5 var(--mono); background: var(--bg); padding: 12px; border-radius: 10px; margin: 0; overflow-wrap: anywhere; }

/* Hover and press feedback. Rows in a card get an inset so the highlight has rounded ends. */
a, button, label, input, select, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.btn, .chip, .row.link, button.row, .nav, .seg a, .seg label, .icon-btn { transition: transform 100ms ease-out, background-color 120ms, filter 120ms; }
.list .row.link, .list button.row { margin: 0 -8px; padding-inline: 8px; width: calc(100% + 16px); border-radius: 10px; }
.btn:active:not(:disabled), .chip:active, .row.link:active, button.row:active, .seg a:active, .seg label:active, .icon-btn:active { transform: scale(.98); }
@media (hover: hover) {
  .row.link:hover, button.row:hover, .nav:not(.on):hover, .icon-btn:hover, .seg a:not(.on):hover { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
  .btn:hover:not(:disabled) { filter: brightness(1.06); }
  .btn.alt:hover:not(:disabled), .btn.ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .progress { height: auto; } .progress i { position: static; display: block; width: 100%; height: 2px; }
  dialog.sheet[open], dialog.sheet[open]::backdrop { animation: fade-in 200ms ease-out !important; } /* fade instead of slide */
  dialog.sheet.closing, dialog.sheet.closing::backdrop { animation: fade-out 150ms ease-in forwards !important; }
  .toast-time { display: none; }
  .flash { background: var(--accent-soft); }
  .progress span { display: block; justify-self: end; margin: 6px 12px 0 auto; width: max-content; padding: 2px 10px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: .85rem; }
}
.get-app { display: block; padding: 12px 16px; background: var(--accent); color: var(--on-accent); text-align: center; font-weight: 650; text-decoration: none; }
.add-person { display: flex; align-items: flex-end; gap: 8px; } .add-person .field { flex: 1; }
select:disabled { opacity: .6; }

/* Group header: Invite, ••• menu (a popover in the top layer, placed by group.js); on phones "+ Add expense" is pinned above the tab bar */
.btn.more { padding: 0 12px; letter-spacing: .1em; }
.menu { position: fixed; inset: auto; margin: 0; width: 240px; max-width: calc(100vw - 16px); padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); box-shadow: 0 12px 32px -12px rgb(0 0 0 / .35); }
.menu:popover-open { display: grid; }
.menu button { min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.menu button.neg { color: var(--bad); }
.menu button:hover, .menu button:focus-visible { background: var(--accent-soft); }
.menu hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
@media (max-width: 640px) {
  .group-page { gap: 12px; }
  .group-title { font-size: 1.375rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; } /* full name in title= */
  /* A small pill on the right (W2-4): the amounts on the left stay readable beside it */
  #act-add { position: fixed; z-index: 4; right: max(16px, env(safe-area-inset-right)); bottom: calc(56px + 12px + env(safe-area-inset-bottom));
    padding: 0 20px; border-radius: 999px; box-shadow: 0 8px 24px -8px rgb(0 0 0 / .45); }
  #act-add .add-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* "+ Add", read as "Add expense" */
  body:has(#act-add) .toast-region { bottom: calc(56px + 12px + 44px + 12px + env(safe-area-inset-bottom)); } /* the toast never covers Add */
  body:has(#act-add) .main { padding-bottom: calc(96px + 56px + 56px + env(safe-area-inset-bottom)); } /* nor the end of the page */
}
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
/* Edit group: a person's buttons wrap under the name on narrow screens; the reason sits under the name */
.row.person { flex-wrap: wrap; }
.row.person .who { flex: 1 1 160px; }
.row.person .field small { color: var(--muted); }
/* Invite: the link in a field with Copy beside it; Reset at the bottom, away from Copy */
.invite > .stack { flex: 1 1 220px; } /* under the QR code on phones, beside it on wide screens */
.link-field { display: flex; gap: 8px; min-width: 0; }
.link-field .btn { flex: none; white-space: nowrap; }
dialog.alert ul { margin: 0; padding-left: 20px; }
.link-field input { font: .85rem var(--mono); text-overflow: ellipsis; }
.reset { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
details > summary { min-height: 44px; display: flex; align-items: center; gap: 4px; cursor: pointer; font-weight: 650; color: var(--accent); }
details[open] > summary { margin-bottom: 8px; }
/* Join: pick a name, then confirm */
.claim label.row { cursor: pointer; }
.claim label.row:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.claim label.row:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
/* 1.7 membership: the owner pill, Group info, people who left, Join's sticky button */
.owner-pill { display: inline-block; margin-left: 4px; padding: 0 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .75rem; font-weight: 600; line-height: 20px; vertical-align: 1px; white-space: nowrap; }
.linkish { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.info-owner { display: grid; gap: 10px; padding: 12px 14px; }
.small.strong { font-weight: 600; }
.powers { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.powers li { display: flex; align-items: center; gap: 10px; }
.powers .i { flex: none; width: 20px; height: 20px; color: var(--accent); }
.usage a { color: var(--accent); }
.menu .mi { display: grid; gap: 2px; padding: 8px 12px; text-align: left; }
.menu .mi small { color: var(--muted); font-size: .8rem; }
.menu button.mi { min-height: 52px; }
.menu button.mi:disabled { cursor: default; opacity: 1; }
.menu button.mi:disabled b { color: var(--muted); }
.claim .lab { margin: 6px 0 -2px; font-size: .85rem; color: var(--muted); }
.join-bar { position: sticky; bottom: 0; z-index: 1; display: grid; gap: 4px; margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
@media (max-width: 640px) { .join-bar { bottom: calc(56px + env(safe-area-inset-bottom)); padding-bottom: 10px; } } /* just above the tab bar */
