/* Splitwide Open — quiet. Near-monochrome, typography + space, hairlines not
   shadows, no accent colour, no cards. Two desaturated tones (clay/sage) only
   where money needs a sign. The aim is stillness: minimal, modern, a little
   liminal — restraint as the whole point. */

:root {
  --bg:      #f7f6fa;   /* neutral off-white, a whisper of blue-violet */
  --surface: #fdfdff;
  --ink:     #1d1c22;   /* soft near-black */
  --ink-2:   #56545d;   /* secondary */
  --muted:   #98969e;   /* captions */
  --line:    #e6e5ec;   /* hairline */
  --line-2:  #d7d5de;
  --owe:     #9a5d4b;   /* muted clay — you owe / debit */
  --owed:    #5d7a5f;   /* muted sage — you're owed / credit */
  --accent:  #7b6296;   /* muted violet — brand accent, same quiet register */
  --sans: "Helvetica Neue", Helvetica, Inter, system-ui, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --maxw: 640px;
  --shell: var(--maxw);   /* current content column width — masthead tracks it */

  /* ── motion — "the settle" ────────────────────────────────────────────────
     The Splitwide Open motion language: nothing fades or slides in flatly.
     Things arrive with a little weight and SETTLE — a quiet spring with a hair
     of overshoot — the same physicality as the mark's bounce and the hero's
     odometer roll. Calm, but alive. Three speeds, one signature curve. */
  --ease-settle: cubic-bezier(.21, 1.12, .3, 1); /* gentle overshoot — the signature */
  --ease-out:    cubic-bezier(.22, 1, .36, 1);   /* no overshoot, for exits/utility */
  --dur-1: 110ms;  /* taps & toggles */
  --dur-2: 200ms;  /* hovers & state */
  --dur-3: 340ms;  /* arrivals */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* no janky grey flash when tapping controls on iOS */
a, button, input, select, label, [role="button"] { -webkit-tap-highlight-color: transparent; }
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* dark palette — the same quiet language, dimmed. Applied when forced dark, or
   when the system is dark and the user hasn't forced light. */
:root[data-theme="dark"] {
  --bg:      #141319;
  --surface: #1d1c23;
  --ink:     #e7e5ed;
  --ink-2:   #aba9b4;
  --muted:   #7e7c88;
  --line:    #292830;
  --line-2:  #3a3843;
  --owe:     #cc8c73;
  --owed:    #93ae8b;
  --accent:  #9e88bb;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"], :root:not([data-theme]) {
    --bg:      #141319;
    --surface: #1d1c23;
    --ink:     #e7e5ed;
    --ink-2:   #aba9b4;
    --muted:   #7e7c88;
    --line:    #292830;
    --line-2:  #3a3843;
    --owe:     #cc8c73;
    --owed:    #93ae8b;
    --accent:  #9e88bb;
  }
}
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-2); }
a:hover { border-bottom-color: var(--ink); }

.amt, .bal, .feed__date, .feed__lent .amt, .hero__amount, .paircode, code,
input, select, .topbar__meta, .group-card__meta, .device code {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}

h1 { font: 500 22px/1.3 var(--sans); margin: 0; letter-spacing: -0.01em; }
/* section labels: small, quiet, tracked */
h2 { font: 500 11px/1 var(--sans); margin: 0 0 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.13em; }
h3 { font: 500 11px/1 var(--sans); margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); padding: 6px 0; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 max(22px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left)); }

/* ─── masthead: a quiet line, not a bar ─── */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  /* full-width blur, content aligned to the content column — no hairline.
     top padding clears the notch / status bar when installed as a PWA. */
  padding: max(16px, env(safe-area-inset-top)) max(22px, calc((100% - var(--shell)) / 2 + 22px)) 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(120%) blur(6px);
}
.appbar__brand { display: flex; align-items: center; gap: 9px; cursor: pointer; transition: opacity .15s; }
.appbar__brand:hover { opacity: 0.82; }
.appbar__brand .logo { width: 27px; height: 27px; }
/* header mark — inline so the ball + bar can animate. Colours track the theme
   (ink ball, violet bar) to match the static glyph elsewhere. */
.logo-mark { width: 100%; height: 100%; display: block; overflow: visible; }
.logo-ball { stroke: var(--ink); transform-box: fill-box; transform-origin: center bottom; }
.logo-bar { fill: var(--accent); transform-box: fill-box; transform-origin: center; }
/* click bounce: the ball falls, the bar flexes under the impact, the ball rebounds */
.appbar__brand.is-bouncing .logo-ball { animation: logo-ball 320ms cubic-bezier(.5, .05, .4, 1) both; }
.appbar__brand.is-bouncing .logo-bar  { animation: logo-bar  320ms cubic-bezier(.5, .05, .4, 1) both; }
@keyframes logo-ball {
  0%   { transform: translateY(0) scaleY(1); }
  38%  { transform: translateY(48px) scaleY(1.05); }  /* fall, a touch of stretch */
  48%  { transform: translateY(54px) scaleY(0.74); }  /* squash on contact */
  62%  { transform: translateY(34px) scaleY(1.05); }  /* push off */
  100% { transform: translateY(0) scaleY(1); }
}
@keyframes logo-bar {
  0%, 38% { transform: scaleY(1) translateY(0); }
  49%     { transform: scaleY(0.5) translateY(8px); }   /* bends under the ball */
  65%     { transform: scaleY(1.15) translateY(-2px); } /* springs back past flat */
  100%    { transform: scaleY(1) translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .appbar__brand.is-bouncing .logo-ball, .appbar__brand.is-bouncing .logo-bar { animation: none; }
}
/* ─── boot loader: a big, endlessly-bouncing logo while the first view loads ───
   Reuses the click-bounce motion, looped with a breath between hops. The
   translate values live in the 512-unit viewBox, so the bounce scales with the
   mark — same motion, just larger. */
.loader {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: var(--bg); text-align: center;
  transition: opacity var(--dur-3) var(--ease-out);
}
body:not(.booting) .loader { opacity: 0; pointer-events: none; } /* fade out once boot is done */
.loader__mark { width: 78px; height: 78px; }
.loader .logo-mark { width: 100%; height: 100%; }
.loader .logo-ball { animation: logo-ball-loop 1150ms cubic-bezier(.5, .05, .4, 1) infinite; }
.loader .logo-bar  { animation: logo-bar-loop  1150ms cubic-bezier(.5, .05, .4, 1) infinite; }
@keyframes logo-ball-loop {
  0%, 10%   { transform: translateY(0)    scaleY(1);    }  /* rest at the top */
  33%       { transform: translateY(48px) scaleY(1.05); }  /* fall */
  39%       { transform: translateY(54px) scaleY(0.74); }  /* squash on contact */
  47%       { transform: translateY(34px) scaleY(1.05); }  /* push off */
  70%, 100% { transform: translateY(0)    scaleY(1);    }  /* rebound, then rest */
}
@keyframes logo-bar-loop {
  0%, 33%   { transform: scaleY(1)    translateY(0);    }
  40%       { transform: scaleY(0.5)  translateY(8px);  }  /* bends under the ball */
  49%       { transform: scaleY(1.15) translateY(-2px); }  /* springs back */
  60%, 100% { transform: scaleY(1)    translateY(0);    }
}
@media (prefers-reduced-motion: reduce) {
  .loader .logo-ball, .loader .logo-bar { animation: none; }
}
/* while booting, the loader stands alone — no masthead, no footer. When boot
   finishes (the `booting` class is dropped), the chrome eases in. */
body.booting .appbar, body.booting .footer { display: none; }
body:not(.booting) .appbar, body:not(.booting) .footer { animation: chrome-in var(--dur-3) var(--ease-out); }
@keyframes chrome-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  body:not(.booting) .appbar, body:not(.booting) .footer { animation: none; }
}
/* brand glyph — the coin-split mark, swapped light/dark in lock-step with the
   palette. The art has baked-in colours (and a violet bar), so it rides as a
   background image rather than currentColor. */
.brand-glyph { display: inline-block; flex: none; background: url("/assets/icons/glyph-light.svg") center / contain no-repeat; }
:root[data-theme="dark"] .brand-glyph { background-image: url("/assets/icons/glyph-dark.svg"); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .brand-glyph,
  :root:not([data-theme]) .brand-glyph { background-image: url("/assets/icons/glyph-dark.svg"); }
}
.appbar__brand > span:last-child { font: 500 16.5px/1 var(--sans); letter-spacing: 0.04em; color: var(--ink); }
.brand-accent { color: var(--accent); } /* "Open" — in the masthead and the landing hero */
/* masthead profile button: the avatar + a small online/offline dot */
.profile-btn { position: relative; border: none; background: transparent; padding: 0; cursor: pointer; display: inline-flex; line-height: 0; }
.profile-btn[hidden] { display: none; }
.profile-btn .avatar { width: 34px; height: 34px; font-size: 12.5px; transition: border-color .15s; }
.profile-btn:hover .avatar { border-color: var(--ink); }
.profile-btn__dot { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: var(--owed); border: 2px solid var(--bg); }
body.is-offline .profile-btn__dot { background: var(--owe); }
.profile-head, .join-preview { display: flex; align-items: center; gap: 12px; }
.profile-name, .join-preview__name { font: 500 17px/1.2 var(--sans); color: var(--ink); }

/* pure blank background — no panels; zones held apart by air + labels */
main.container { padding-top: 28px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); display: grid; gap: 30px; }
.card { background: transparent; border: none; box-shadow: none; padding: 0; }

/* two columns on a wide screen: the feed left, balances right */
.cols { display: grid; gap: 30px; }
@media (min-width: 768px) {
  body.app-wide { --shell: 980px; }
  .container.wide { max-width: 980px; }
  .cols {
    grid-template-columns: 1.5fr 1fr;
    grid-template-areas: "act bal";
    gap: 30px 46px; align-items: start;
  }
  .zone-act { grid-area: act; }
  .zone-bal { grid-area: bal; }
}
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.row .grow { flex: 1 1 150px; }
.grid { display: grid; gap: 8px; }

/* ─── forms: underlines, not boxes ─── */
/* a field's label — whether a real <label> or a section heading (.field__label) */
label, .field__label { font: 500 11px/1.3 var(--sans); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
label { display: grid; gap: 6px; }
input, select {
  width: 100%; padding: 10px 2px; font-size: 16px; color: var(--ink);
  background: transparent; border: none; border-bottom: 1px solid var(--line-2); border-radius: 0;
}
input:focus, select:focus { outline: none; border-bottom-color: var(--ink); }
input::placeholder { color: var(--muted); }
/* drop the native number spinners — they clash with the flat underline fields */
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
/* selects get one consistent chevron instead of each browser's native arrow */
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a98a2' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right -1px center; background-size: 17px;
}

/* ─── buttons: flat, small, calm ─── */
.btn {
  appearance: none; cursor: pointer; font: 500 14px/1 var(--sans); letter-spacing: 0.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border: 1px solid var(--line-2); background: transparent; color: var(--ink);
  border-radius: 6px;
  transition: border-color var(--dur-2), background var(--dur-2), opacity var(--dur-2), transform var(--dur-1) var(--ease-out);
}
.btn .ico { width: 16px; height: 16px; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(0.96); } /* tactile press — part of "the settle" family */
.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn--primary:hover { opacity: 0.86; }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn--primary:disabled { opacity: 1; background: var(--line-2); border-color: var(--line-2); color: var(--muted); }
.btn:disabled:hover { border-color: var(--line-2); opacity: 0.5; } /* no hover lift when disabled */
.btn--primary:disabled:hover { opacity: 1; }
.btn--ghost { border-color: transparent; color: var(--muted); padding: 8px 6px; }
.btn--ghost:hover { color: var(--ink); }
/* compact icon-only topbar buttons: share (neutral) and delete (destructive) */
.btn--icon { padding: 10px; color: var(--muted); }
.btn--icon:hover { border-color: var(--ink); color: var(--ink); }
.btn--del { padding: 10px; color: var(--muted); }
.btn--del:hover { border-color: var(--owe); color: var(--owe); }
.btn--danger { border-color: var(--owe); color: var(--owe); }
.btn--danger:hover { background: var(--owe); border-color: var(--owe); color: var(--bg); }
.icon-btn { cursor: pointer; border: none; background: transparent; color: var(--line-2); padding: 8px; min-width: 38px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn .ico { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--ink-2); }

/* ─── initials: a quiet hairline ring ─── */
.avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center;
  font: 500 11px/1 var(--sans); color: var(--ink-2); background: transparent;
  border: 1px solid var(--line-2); letter-spacing: 0.02em;
}
.avatar--sm { width: 26px; height: 26px; font-size: 10px; }

/* ─── topbar inside a group ─── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar > div:first-child { min-width: 0; } /* title column shrinks so long names ellipsis instead of pushing the actions out */
.topbar h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__actions { display: flex; gap: 8px; flex: none; }
code.invite { cursor: pointer; color: var(--ink-2); letter-spacing: 0.04em; padding: 5px 2px; text-decoration: underline dotted var(--line-2); text-underline-offset: 3px; }
code.invite:hover { text-decoration-color: var(--ink); }
.device-key { cursor: pointer; color: var(--ink-2); text-decoration: underline dotted var(--line-2); text-underline-offset: 3px; }
.device-key:hover { text-decoration-color: var(--ink); }
.pill { font-size: 11px; }
.pill--ok { color: var(--owed); }            /* "verified" — just quiet text */
.pill--ok::before { content: "✓ "; }
.pill--warn { color: var(--owe); }
button.pill { border: none; background: transparent; cursor: pointer; font: inherit; font-size: 11px; padding: 5px 2px; color: var(--muted); }
button.pill:hover { color: var(--ink-2); }
button.pill.pill--ok { color: var(--owed); }

/* ─── the balance: a big quiet number, carried by space ─── */
.hero { text-align: center; padding: 26px 0 30px; }
.hero__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.13em; color: var(--muted); }
.hero__amount { font-size: 52px; font-weight: 400; letter-spacing: -0.02em; margin-top: 10px; line-height: 1; }
.hero--owed .hero__amount { color: var(--owed); }
.hero--owe .hero__amount { color: var(--owe); }
.hero--zero .hero__amount { color: var(--ink-2); font-size: 30px; }

/* ─── balances: hairline-separated lines ─── */
.balances { list-style: none; margin: 0; padding: 0; }
.balances li { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.balances li:first-child { border-top: none; }
.balances .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balances__settle { flex: none; padding: 6px 11px; font-size: 12.5px; gap: 5px; }
.balances__settle .ico { width: 14px; height: 14px; }
/* one person, possibly several currencies → stack the amounts, right-aligned */
.peo-amts { display: grid; gap: 3px; justify-items: end; }
.bal { font-weight: 500; text-align: right; white-space: nowrap; font-size: 14px; }
.bal small { display: block; font: 400 11px/1.4 var(--sans); color: var(--muted); letter-spacing: 0; margin-top: 1px; }
.bal--pos { color: var(--owed); }
.bal--neg { color: var(--owe); }
.bal--zero { color: var(--muted); }

/* ─── entries: spare rows ─── */
.feed { list-style: none; margin: 0; padding: 0; }
.feed__item {
  display: grid; grid-template-columns: 30px 1fr auto auto; align-items: center; gap: 13px;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.feed__item:first-child { border-top: none; }
.feed__date { display: none; } /* date lives in the subline; drop the column */
.feed__cat { display: flex; align-items: center; justify-content: center; color: var(--ink-2); opacity: 0.85; }
.feed__cat .ico { width: 20px; height: 20px; }
.feed__body { min-width: 0; }
.feed__title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed__sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.feed__lent { text-align: right; white-space: nowrap; }
.feed__lent .lbl { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.feed__lent .amt { display: block; font-weight: 500; font-size: 14px; margin-top: 1px; }
.feed__lent--pos .amt { color: var(--owed); }
.feed__lent--neg .amt { color: var(--owe); }
.feed__lent--neutral .amt { color: var(--muted); }
.feed__tools { display: flex; gap: 1px; opacity: 0; transition: opacity .15s; }
.feed__item:hover .feed__tools { opacity: 1; }

/* ─── integrity: a restrained notice, not a stamp ─── */
.tamper { border-left: 2px solid var(--owe); padding: 2px 0 2px 14px; }
.tamper strong { color: var(--owe); font-weight: 500; }
.device code { color: var(--ink-2); }
.device .row { margin-top: 12px; align-items: center; }

/* ─── auth ─── */
/* signed-out landing: hide the masthead title; show a hero above the form */
body.auth-view .appbar { display: none; }
.auth-hero { max-width: 440px; margin: 9vh auto 26px; text-align: center; }
.auth-hero__title { display: inline-flex; align-items: center; gap: 11px; font: 500 clamp(27px, 8vw, 34px)/1.1 var(--sans); letter-spacing: -0.02em; color: var(--ink); }
.auth-hero__title .auth-hero__mark { width: 40px; height: 40px; }
.auth-hero__sub { margin: 16px auto 0; max-width: 400px; color: var(--ink-2); font-size: 15.5px; line-height: 1.6; }
.auth { max-width: 360px; margin: 0 auto; }
.auth__tabs { display: flex; gap: 20px; margin-bottom: 22px; }
.auth__tabs button { cursor: pointer; border: none; background: transparent; color: var(--muted); padding: 0 0 6px; font: 500 13px/1 var(--sans); border-bottom: 1.5px solid transparent; }
.auth__tabs button.is-active { color: var(--ink); border-bottom-color: var(--ink); }

/* ─── group list ─── */
.group-card {
  flex: 1; min-width: 0; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 13px;
  padding: 15px 0; border: none; background: transparent; color: var(--ink); font: inherit;
}
/* each row = the (clickable) card + a quiet delete button, separated by a hairline */
.group-row { display: flex; align-items: center; border-top: 1px solid var(--line); }
.grid > .group-row:first-child { border-top: none; }
.group-card--new { border-top: 1px solid var(--line); }
.grid > .group-card--new:first-child { border-top: none; }
.group-del {
  flex: none; cursor: pointer; border: none; background: transparent; color: var(--line-2);
  padding: 11px 6px 11px 12px; display: inline-flex; align-items: center; transition: color .15s;
}
.group-row:hover .group-del { color: var(--muted); }
.group-del:hover { color: var(--owe); }
.group-del .ico { width: 18px; height: 18px; }
.group-card:hover .group-card__name { color: var(--ink); }
.group-card:hover { background: transparent; }
.group-card__name { font: 500 16.5px/1.3 var(--sans); }
.group-card__meta { color: var(--muted); font-size: 12px; }
.group-card .chev { color: var(--line-2); display: inline-flex; align-items: center; }
.group-card .chev .ico { width: 18px; height: 18px; }
.group-card:hover .chev { color: var(--ink-2); }
.group-card__main { flex: 1; min-width: 0; }
/* per-group balance overview, right-aligned before the chevron */
.gc-bal { font: 500 13.5px/1.2 var(--sans); white-space: nowrap; }
.gc-bal--pos { color: var(--owed); }
.gc-bal--neg { color: var(--owe); }
.gc-bal--zero { color: var(--muted); }
/* "New group" row */
.group-card--new { color: var(--muted); }
.group-card--new .group-card__name { color: inherit; }
.group-card--new:hover .group-card__name { color: var(--ink); }
.gc-new-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border: 1px dashed var(--line-2); border-radius: 50%; color: var(--muted); }
.group-card--new:hover .gc-new-icon { border-color: var(--ink-2); color: var(--ink-2); }
.gc-new-icon .ico { width: 16px; height: 16px; }
.groups-empty { margin: 4px 0 4px; }

/* ─── modal: a plain sheet ─── */
/* always centred, with a gutter on phones; dvh (not vh) so iOS's address bar /
   home indicator can't push the footer off-screen. */
.modal {
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); color: var(--ink);
  padding: 0; width: min(520px, calc(100vw - 24px)); margin: auto;
  max-height: 92vh; max-height: 90dvh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(17, 17, 24, 0.16);
  animation: modal-settle var(--dur-3) var(--ease-settle) both; /* arrive with weight */
}
@keyframes modal-settle {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal::backdrop { background: rgba(16, 16, 22, 0.36); backdrop-filter: blur(2px); animation: modal-veil var(--dur-2) var(--ease-out) both; }
@keyframes modal-veil { from { opacity: 0; } to { opacity: 1; } }
.modal__form { padding: 24px; }

/* ── modal shell — the baseline language: title header · scrollable body ·
      pinned footer. Other modals migrate onto this structure. ── */
.modal--sheet { overflow: hidden; }
.modal__sheet { display: flex; flex-direction: column; max-height: 92vh; max-height: 90dvh; }
.modal__head { flex: none; padding: 22px 24px 2px; }
.modal__head h2 { margin: 0; font: 600 20px/1.2 var(--sans); letter-spacing: -0.02em; color: var(--ink); text-transform: none; }
.modal__head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 24px 22px; display: grid; gap: 17px; align-content: start; }
.modal__foot { flex: none; display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); }
.modal__foot--split { justify-content: space-between; } /* wizard nav: back · count · next */
/* a labelled control built from parts rather than a single <label> */
.field { display: grid; gap: 8px; }
/* input with a leading symbol (currency, …) — shares the underline + focus ring */
.affix { display: flex; align-items: baseline; gap: 7px; border-bottom: 1px solid var(--line-2); transition: border-color .15s; }
.affix:focus-within { border-bottom-color: var(--ink); }
.affix__sym { color: var(--muted); font-size: 15px; }
.affix input { border: none; padding-left: 0; }

/* ─── popover: a dropdown anchored under a button (top/right set in JS) ─── */
.modal.modal--popover {
  position: fixed; margin: 0; inset: auto; /* clear the dialog UA left:0/top:0 so JS top/right win */
  width: min(264px, calc(100vw - 28px)); max-height: min(72vh, 440px);
  border-radius: 10px; box-shadow: 0 14px 38px rgba(17, 17, 24, 0.18);
}
.modal--popover::backdrop { background: transparent; backdrop-filter: none; }
.modal--popover .modal__form { padding: 16px; }
.profile-menu__actions { gap: 8px; }
.profile-menu__actions .btn { width: 100%; }
.theme-row { display: flex; flex-direction: column; gap: 6px; }
/* segmented controls — shared by the theme picker and the expense split-mode switch */
.theme-switch, .split-modes { display: flex; gap: 4px; }
.theme-opt, .split-mode {
  flex: 1; cursor: pointer; text-align: center; padding: 9px 8px;
  border: 1px solid var(--line-2); border-radius: 6px; background: transparent;
  font: 500 12.5px/1 var(--sans); color: var(--muted);
  transition: color .12s, border-color .12s, background .12s;
}
.theme-opt:hover, .split-mode:hover { color: var(--ink-2); }
.theme-opt.is-active, .split-mode.is-active { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.check { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); }
.check input { width: auto; }

.paircode { font: 500 26px/1.2 var(--mono); letter-spacing: 0.22em; text-align: center; color: var(--ink); padding: 18px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg); }
/* the 6-word recovery phrase is long — wrap it (at the underscores) instead of overflowing */
.paircode--phrase { font-size: 18px; letter-spacing: 0.04em; line-height: 1.55; overflow-wrap: anywhere; }

/* ─── toasts ─── */
.toasts { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(380px, calc(100vw - 36px)); }
.toast { padding: 11px 14px; background: var(--ink); color: var(--bg); border-radius: 7px; font-size: 13.5px; box-shadow: 0 6px 24px rgba(17,17,24,0.2); opacity: 0; transform: translateY(-10px); transition: opacity var(--dur-2), transform var(--dur-3) var(--ease-settle); }
.toast--in { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--owed); }
.toast--error { background: var(--owe); }

/* ─── how-it-works: a little presentation ─── */
.modal--wide { width: min(560px, 96vw); }
/* how-it-works rides the modal shell; only the slide content is bespoke */
.explain__body { min-height: min(340px, 64vh); }
.explain__tag { font: 400 11.5px/1 var(--mono); color: var(--muted); letter-spacing: 0.04em; text-transform: lowercase; margin-bottom: 12px; }
.explain__title { font: 500 22px/1.25 var(--sans); margin: 0 0 16px; letter-spacing: -0.01em; color: var(--ink); }
.explain__text { color: var(--ink-2); font-size: 16px; line-height: 1.65; max-width: 46ch; }
.explain__text p { margin: 0 0 14px; }
.explain__text b { color: var(--ink); font-weight: 500; }
.explain__text .ico { width: 17px; height: 17px; color: var(--ink-2); }

.footer { padding: 30px 22px 48px; text-align: center; font-size: 12.5px; color: var(--muted); }
.footer a { color: var(--ink-2); }

/* touch devices can't hover, so the per-entry edit/delete tools must be visible */
@media (hover: none) {
  .feed__tools { opacity: 1; }
}

/* ─── in-house line icons ─── */
.ico { width: 1.05em; height: 1.05em; display: inline-block; vertical-align: -0.16em; flex: none; }
.hero__amount .ico--hero { width: 0.82em; height: 0.82em; vertical-align: -0.02em; }

/* ─── odometer: the hero amount's digits roll up into place on entrance ─── */
.odo { display: inline-block; overflow: hidden; height: 1em; line-height: 1; vertical-align: bottom; }
.odo__track { display: block; transition: transform 1.05s cubic-bezier(.16, 1, .3, 1); will-change: transform; }
.odo__d { display: block; height: 1em; line-height: 1em; text-align: center; font-variant-numeric: tabular-nums; }
.odo__sep { display: inline-block; vertical-align: bottom; line-height: 1; }
@media (prefers-reduced-motion: reduce) {
  .odo__track { transition: none; }
  .modal, .modal::backdrop { animation: none; }
}

/* ─── export row under the activity feed ─── */
.export { margin-top: 18px; }
.export .pill { font-size: 12px; }

/* ─── receipts ─── */
.receipt-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.receipt-pick { cursor: pointer; } /* a .btn label wrapping a hidden file input */
.receipt-pick__txt { overflow: hidden; text-overflow: ellipsis; max-width: 180px; white-space: nowrap; }
.feed__receipt { cursor: pointer; border: none; background: transparent; color: var(--muted); padding: 0 1px; vertical-align: -0.16em; transition: color var(--dur-2); }
.feed__receipt:hover { color: var(--accent); }
.feed__receipt .ico { width: 15px; height: 15px; }
.receipt-view { justify-content: center; }
.receipt-img { max-width: 100%; max-height: 68vh; border-radius: 8px; display: block; }

/* ─── split editor (equal / exact / shares / percent) ─── */
/* split-mode shares the segmented-control base above; just its layout extras */
/* split editor — a clean .field section (no fieldset chrome). Equal mode hides
   the per-row inputs and the running total, so it reads as a simple checklist. */
.split-editor { gap: 11px; }
.split-modes { margin: 0; flex-wrap: wrap; }
.split-mode { min-width: 70px; }
.split-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.split-row:first-child { border-top: none; }
.split-row__who { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--ink); cursor: pointer; }
.split-row__who input[type="checkbox"] { flex: none; }
.split-row__val { display: flex; align-items: baseline; gap: 5px; color: var(--muted); font-size: 13px; }
.split-row__val input { width: 78px; text-align: right; padding: 3px 0; font-size: 14px; }
.split-row.is-off { opacity: 0.38; }
.split-editor[data-mode="equal"] .split-row__val,
.split-editor[data-mode="equal"] .split-sum { display: none; }
.split-sum { display: flex; justify-content: space-between; padding-top: 4px; font-size: 12.5px; color: var(--muted); }
.split-sum.is-bad { color: var(--owe); }
.split-sum.is-ok { color: var(--owed); }
