/* Layout: one phone-width column, sticky top bar, thumb-reach action bar at the bottom,
   everything else opens as bottom sheets. */
:root {
  --bg: #F3F4EF;
  --surface: #FFFFFF;
  --surface-2: #EAEDE5;
  --ink: #131915;
  --muted: #646E67;
  --line: #DFE3DA;
  --accent: #FFB21E;
  --accent-ink: #231700;
  --accent-soft: #FFF1CF;
  --pos: #0F7F53;
  --pos-soft: #DDF3E8;
  --neg: #C93A32;
  --neg-soft: #FBE3E0;
  --scrim: rgba(12, 16, 14, .42);
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 8px 24px rgba(20, 30, 25, .07);

  --font-display: 'Unbounded', 'Onest', system-ui, sans-serif;
  --font-body: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --tap: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101412; --surface: #181D1A; --surface-2: #222924; --ink: #EDF1EC; --muted: #9AA59D; --line: #2B332E;
    --accent: #FFB83A; --accent-ink: #231700; --accent-soft: #3A2E12;
    --pos: #4CCB92; --pos-soft: #16312A; --neg: #FF7A6E; --neg-soft: #3A1E1C;
    --scrim: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101412; --surface: #181D1A; --surface-2: #222924; --ink: #EDF1EC; --muted: #9AA59D; --line: #2B332E;
  --accent: #FFB83A; --accent-ink: #231700; --accent-soft: #3A2E12;
  --pos: #4CCB92; --pos-soft: #16312A; --neg: #FF7A6E; --neg-soft: #3A1E1C;
  --scrim: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.app {
  max-width: 560px; margin: 0 auto; min-height: 100dvh;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 0 10px;
  margin: 0 -4px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar h1 {
  flex: 1; min-width: 0; margin: 0; font: 600 18px/1.2 var(--font-display);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand { font: 700 20px/1 var(--font-display); letter-spacing: -.01em; }
.brand b { color: var(--accent); font-weight: 700; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: var(--ink);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; }

/* ---------- type ---------- */
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 2px 10px; }
.section-title h2 { margin: 0; font: 600 15px/1.2 var(--font-display); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.list { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 16px; min-height: 64px; position: relative;
}
.row + .row::before { content: ''; position: absolute; top: 0; left: 68px; right: 0; border-top: 1px solid var(--line); }
button.row:active, a.row:active { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { text-align: right; flex: none; max-width: 46%; }
.row-end .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.row-end .row-sub { white-space: normal; }

.tile {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); font-size: 20px;
}
.tile.big { width: 52px; height: 52px; border-radius: 16px; font-size: 26px; }

.avatar {
  --c: #888; width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff;
  background: var(--c); text-transform: uppercase; user-select: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatars { display: flex; }
.avatars .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatars .avatar + .avatar { margin-left: -8px; }

/* ---------- pills & chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pill.pos { background: var(--pos-soft); color: var(--pos); }
.pill.neg { background: var(--neg-soft); color: var(--neg); }
.pill.zero { background: var(--surface-2); color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line); font-size: 15px; font-weight: 500;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .avatar { margin-left: -8px; }

.person-chip {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 68px; flex: none;
  padding: 6px 0; border-radius: var(--r-md); font-size: 13px; text-align: center;
}
.person-chip .avatar { width: 46px; height: 46px; font-size: 18px; transition: transform .15s, box-shadow .15s; }
.person-chip[aria-pressed="false"] .avatar { filter: grayscale(1); opacity: .35; }
.person-chip[aria-pressed="true"] .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.person-chip span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- segmented ---------- */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px;
  padding: 3px; border-radius: 14px; background: var(--surface-2);
}
.segmented button {
  min-height: 38px; border-radius: 11px; font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 0 6px; white-space: nowrap;
}
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 16px; font-weight: 600; font-size: 16px;
  background: var(--surface-2); color: var(--ink); width: 100%;
  transition: transform .1s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--ink); color: var(--bg); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--neg-soft); color: var(--neg); }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; width: auto; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }
.link { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

/* bottom action bar */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  pointer-events: none;
}
.actionbar-inner { max-width: 528px; margin: 0 auto; display: flex; gap: 10px; pointer-events: auto; }
.actionbar .btn { box-shadow: 0 6px 20px rgba(0,0,0,.14); }
.actionbar .btn.square { width: 56px; padding: 0; flex: none; background: var(--surface); }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input {
  width: 100%; min-height: 52px; padding: 12px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1.5px solid var(--line); font-size: 17px;
  outline: none; -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--ink); }
textarea.input { min-height: 80px; resize: vertical; }
.input.center { text-align: center; }
.input.code { font: 600 26px/1 var(--font-display); letter-spacing: .2em; text-transform: uppercase; text-align: center; }

.amount-box { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 0 4px; }
.amount-input {
  width: 100%; min-width: 0; max-width: 260px; border: 0; background: transparent; outline: none;
  font: 600 44px/1.1 var(--font-display); text-align: center; letter-spacing: -.02em; padding: 0;
  font-variant-numeric: tabular-nums;
}
.amount-input::placeholder { color: var(--line); }
.cur-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px; border-radius: 12px;
  background: var(--surface-2); font-weight: 700; flex: none;
}
.mini-input {
  width: 96px; min-height: 40px; padding: 6px 10px; border-radius: 10px; text-align: right;
  border: 1.5px solid var(--line); background: var(--surface); font-variant-numeric: tabular-nums; font-size: 16px;
  outline: none;
}
.mini-input:focus { border-color: var(--ink); }
.mini-input.wide { width: 100%; text-align: left; }

.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--pos); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* ---------- home ---------- */
.hello { margin: 8px 2px 18px; }
.hello h2 { margin: 0 0 4px; font: 600 26px/1.15 var(--font-display); letter-spacing: -.01em; text-wrap: balance; }
.summary-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary-strip .card { padding: 14px 16px; }
.summary-strip .val { font: 600 20px/1.2 var(--font-display); margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- group hero ---------- */
.hero { padding: 20px; margin-top: 4px; }
.hero .status { font: 600 30px/1.1 var(--font-display); letter-spacing: -.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.hero-meta div { min-width: 0; }
.hero-meta b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.tabs-wrap { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 64px); z-index: 4; padding: 14px 0 6px; background: var(--bg); }

.day { margin: 18px 4px 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.transfer-tile { background: var(--pos-soft); color: var(--pos); }
.receipt-dot { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-left: 4px; color: var(--muted); }

/* debts */
.debt { display: flex; align-items: center; gap: 10px; padding: 14px 16px; position: relative; }
.debt + .debt::before { content: ''; position: absolute; top: 0; left: 16px; right: 16px; border-top: 1px solid var(--line); }
.debt .flow { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.debt .flow .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.debt .arrow { color: var(--muted); flex: none; width: 18px; height: 18px; }
.debt.me { background: var(--accent-soft); }
.debt-amt { font: 600 16px/1.2 var(--font-body); font-variant-numeric: tabular-nums; white-space: nowrap; }
.debt-actions { display: flex; gap: 8px; align-items: center; flex: none; }

.bal { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 4px 12px; padding: 12px 16px; position: relative; }
.bal + .bal::before { content: ''; position: absolute; top: 0; left: 64px; right: 0; border-top: 1px solid var(--line); }
.bal .bar { grid-column: 2 / 4; height: 8px; position: relative; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bal .bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.bal .bar::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--muted); opacity: .4; }

.calc-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.calc-table th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12px; padding: 10px 8px; }
.calc-table th:first-child, .calc-table td:first-child { text-align: left; padding-left: 16px; }
.calc-table td { text-align: right; padding: 10px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
.calc-table td:last-child, .calc-table th:last-child { padding-right: 16px; }
.table-scroll { overflow-x: auto; }

/* stats */
.stat-bars { display: grid; gap: 14px; padding: 16px; }
.stat-bar { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; align-items: center; }
.stat-bar .track { grid-column: 2 / 4; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.stat-bar .track i { display: block; height: 100%; border-radius: 5px; background: var(--ink); }
.stat-bar .nm { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-bar .v { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); padding: 0 16px 14px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.duo { display: grid; gap: 3px; grid-column: 2 / 4; }
.duo .track { height: 8px; }
.duo .track.share i { background: var(--accent); }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 36px 20px; }
.empty .art { font-size: 44px; margin-bottom: 8px; }
.empty h3 { margin: 0 0 6px; font: 600 18px/1.25 var(--font-display); text-wrap: balance; }
.empty p { margin: 0 auto 18px; max-width: 32ch; color: var(--muted); }

/* ---------- onboarding ---------- */
.welcome { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 32px 0; }
.welcome h1 { font: 700 40px/1.05 var(--font-display); margin: 0; letter-spacing: -.03em; text-wrap: balance; }
.welcome h1 b { color: var(--accent); font-weight: 700; }
.welcome p.lead { margin: 12px 0 0; font-size: 17px; color: var(--muted); max-width: 34ch; }
.split-art { display: flex; gap: 8px; align-items: flex-end; height: 72px; }
.split-art span { flex: 1; border-radius: 14px 14px 4px 4px; }
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot { width: 40px; height: 40px; border-radius: 50%; background: var(--c); }
.color-dot[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }

/* ---------- sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade .2s ease; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 12px);
  background: var(--bg); border-radius: 26px 26px 0 0; display: flex; flex-direction: column;
  animation: up .28s cubic-bezier(.2, .9, .25, 1);
  box-shadow: 0 -10px 40px rgba(0,0,0,.18);
}
.sheet.full { height: calc(100dvh - env(safe-area-inset-top, 0px) - 12px); }
.sheet-closing .sheet { animation: down .2s ease forwards; }
.sheet-closing .sheet-scrim { animation: fade .2s ease reverse forwards; }
.sheet-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 4px;
  padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px));
  flex: none; position: relative;
}
.sheet-head::before { content: ''; position: absolute; top: 6px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--line); }
.sheet-head h2 { flex: 1; text-align: center; margin: 10px 0 0; font: 600 16px/1.2 var(--font-display); }
.sheet-head .icon-btn { margin-top: 6px; }
.sheet-body {
  overflow-y: auto; overscroll-behavior: contain; flex: 1; -webkit-overflow-scrolling: touch;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 18px;
}
.sheet-foot {
  flex: none; padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--line); background: var(--bg); display: grid; gap: 8px;
}
.hint-line { font-size: 13px; text-align: center; min-height: 18px; color: var(--muted); }
.hint-line.bad { color: var(--neg); font-weight: 600; }

.block { background: var(--surface); border-radius: var(--r-lg); padding: 14px 16px; display: grid; gap: 12px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.block-head .label { font-size: 14px; color: var(--ink); }
.split-list { display: grid; gap: 0; }
.split-item { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.split-item + .split-item { border-top: 1px solid var(--line); }
.split-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-item .share { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.check {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); flex: none;
  display: grid; place-items: center; color: transparent;
}
.check svg { width: 16px; height: 16px; }
[aria-checked="true"] .check { background: var(--ink); border-color: var(--ink); color: var(--bg); }
button.split-item { width: 100%; text-align: left; }

.scan-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: var(--r-lg); background: var(--accent-soft); border: 1.5px dashed color-mix(in srgb, var(--accent) 70%, var(--ink));
}
.scan-btn .tile { background: var(--accent); color: var(--accent-ink); }
.scan-btn b { display: block; }
.scan-btn.busy { pointer-events: none; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }

.item-row { display: grid; gap: 8px; padding: 12px 0; }
.item-row + .item-row { border-top: 1px solid var(--line); }
.item-top { display: flex; gap: 8px; align-items: center; }
.item-top .mini-input.wide { flex: 1; }
.item-people { display: flex; gap: 6px; flex-wrap: wrap; }
.item-people button { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px 0 4px; border-radius: 999px; border: 1.5px solid var(--line); font-size: 13px; }
.item-people button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.item-people button[aria-pressed="false"] .avatar { opacity: .4; }
.item-people .all { padding: 0 12px; }

.receipt-thumb { width: 100%; max-height: 360px; object-fit: contain; border-radius: var(--r-md); background: var(--surface-2); }
.detail-hero { text-align: center; display: grid; gap: 6px; justify-items: center; padding-top: 4px; }
.detail-hero .big { font: 600 38px/1.1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.code-box { text-align: center; padding: 18px; display: grid; gap: 6px; }
.code-box .code { font: 700 34px/1 var(--font-display); letter-spacing: .18em; padding-left: .18em; }

.cur-list .row { min-height: 56px; }
.flag { font-size: 24px; width: 32px; text-align: center; flex: none; }

.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.emoji-grid button { height: 48px; border-radius: 12px; font-size: 24px; background: var(--surface); }
.emoji-grid button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ink); }

/* ---------- toast ---------- */
#toast {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  max-width: min(92vw, 440px); width: max-content;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 16px;
  display: flex; align-items: center; gap: 14px; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: pop .25s ease;
}
#toast button { color: var(--accent); font-weight: 700; }

.loading { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }

@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes down { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* sheet children keep their natural height inside the scrolling column */
.sheet-body > *, #ed > *, #st > *, #ng > *, #gs > * { flex-shrink: 0; }
.actionbar .btn { white-space: nowrap; padding: 0 16px; }
.color-dot { width: 34px; height: 34px; }
.color-row { gap: 8px; }
.debt .flow { flex-wrap: wrap; row-gap: 4px; }
.debt .flow .nm { white-space: normal; overflow-wrap: anywhere; }
.hero-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 12px; }
.row-title { white-space: normal; display: -webkit-box !important; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }

/* tappable people */
button.bal, button.stat-bar { width: 100%; text-align: left; }
button.bal:active, button.stat-bar:active, .debt .who:active { background: var(--surface-2); }
.debt .who { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; border-radius: 10px; padding: 0 2px; min-width: 0; text-align: left; }
.person-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.person-stats > div { background: var(--surface); border-radius: var(--r-md); padding: 10px 12px; min-width: 0; }
.person-stats b { display: block; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.segmented { scrollbar-width: none; }
.or-line { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.or-line::before, .or-line::after { content: ''; flex: 1; border-top: 1px solid var(--line); }

/* rows, buttons and icons that are real links shouldn't look like links */
a.row, a.btn, a.icon-btn, a.tile { color: inherit; text-decoration: none; }
a.row .row-sub { color: var(--muted); }

/* bills */
.row-sub.warn, .warn { color: #B26A00; }
:root[data-theme="dark"] .warn { color: #FFB83A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .warn { color: #FFB83A; } }
.tab-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--neg); margin-left: 4px; vertical-align: 2px; }
.segmented button { font-size: 13px; padding: 0 2px; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▸ '; }
details[open] > summary::before { content: '▾ '; }

/* planned payments */
.planned-row { padding: 0; gap: 0; }
.planned-row .row-tap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 4px 12px 16px; text-align: left; }
.planned-row .row-tap:active { background: var(--surface-2); }
.pay-check { flex: none; width: 56px; align-self: stretch; display: grid; place-items: center; }
.pay-check span { width: 30px; height: 30px; border-radius: 50%; border: 2.5px solid var(--line); position: relative; transition: border-color .15s, background .15s; }
.pay-check:hover span, .pay-check:focus-visible span { border-color: var(--pos); }
.pay-check:active span { background: var(--pos-soft); border-color: var(--pos); }
.pay-check span::after { content: ''; position: absolute; left: 9px; top: 5px; width: 7px; height: 12px; border: solid var(--line); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.paid-mark { font-size: 13px; }
.plan-toggle { cursor: pointer; }

/* long values wrap instead of pushing the block wider than the screen */
.block { grid-template-columns: minmax(0, 1fr); }
.block > * { min-width: 0; }
.split-item .nm { white-space: normal; overflow-wrap: anywhere; line-height: 1.3; padding-block: 6px; }
.field { min-width: 0; }
.mini-input.wide, input[type="date"].mini-input { min-width: 0; max-width: 100%; }

/* radio rows and currency headings */
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; position: relative; }
[aria-checked="true"] > .radio { border-color: var(--ink); }
[aria-checked="true"] > .radio::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--ink); }
.cur-head { margin: 22px 2px -4px; font: 600 13px/1.2 var(--font-body); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

/* collapsible form sections (contract form) */
.form-section { background: var(--surface); border-radius: var(--r-lg); }
.form-section > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 16px; min-height: 56px; }
.form-section > summary::-webkit-details-marker { display: none; }
.form-section > summary::before { content: none; }
.form-section > summary::after { content: '›'; margin-left: auto; font-size: 22px; color: var(--muted); transition: transform .15s; }
.form-section[open] > summary::after { transform: rotate(90deg); }
.form-section > summary > span { min-width: 0; }
.form-section-body { display: grid; gap: 12px; padding: 0 16px 16px; min-width: 0; }
.toggle-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle-row > span:first-child { flex: 1; min-width: 0; }
.cf-list { display: grid; gap: 8px; }
.cf-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: 6px; align-items: center; }
.doc-btn { flex: none; width: 40px; align-self: stretch; display: grid; place-items: center; font-size: 18px; }
.doc-btn:active { background: var(--surface-2); }
.planned-row .row-tap { padding-right: 0; }

/* pull to refresh */
#ptr {
  position: fixed; z-index: 30; left: 50%; top: calc(env(safe-area-inset-top, 0px) - 34px);
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); opacity: 0;
  transform: translate(-50%, 0); transition: opacity .15s; pointer-events: none; font-weight: 700;
}
#ptr .ptr-arrow { transition: transform .2s; }
#ptr.ready .ptr-arrow { transform: rotate(180deg); }
#ptr.ptr-loading { transform: translate(-50%, 60px) !important; opacity: 1 !important; }
#ptr .spinner { width: 20px; height: 20px; border-width: 2.5px; }
.file-open { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: left; }
.file-open .tile { width: 36px; height: 36px; font-size: 18px; }

/* language picker */
.lang-row { display: flex; gap: 6px; flex-wrap: wrap; }
.lang-btn { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 9px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-size: 12px; font-weight: 700; color: var(--muted); }
.lang-btn svg { border-radius: 2px; flex: none; }
.lang-btn[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }

/* tabs scroll sideways when the words are long (Tatar, Turkish) instead of being cut off */
.tabs-wrap .segmented { grid-auto-columns: minmax(max-content, 1fr); overflow-x: auto; scrollbar-width: none; }
.tabs-wrap .segmented::-webkit-scrollbar { display: none; }
.tabs-wrap .segmented button { padding: 0 10px; }

/* Unbounded has no ә ө ү ң җ һ — Tatar headings use Geologica, which has them all */
:root:lang(tt) { --font-display: 'Geologica', 'Onest', system-ui, sans-serif; }

/* rounded flags */
.flag-svg { border-radius: 4px; clip-path: inset(0 round 4px); flex: none; }

/* About page */
.info-link { font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 999px; background: var(--surface); white-space: nowrap; }
.app.info { max-width: 640px; padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
.info .topbar { gap: 8px; }
.info .topbar .icon-btn { font-size: 20px; }

.info-hero {
  position: relative; overflow: hidden; margin-top: 6px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 28px; padding: 96px 22px 84px;
}
.info-bars { position: absolute; top: 22px; left: 22px; right: 22px; display: flex; gap: 8px; align-items: flex-end; height: 52px; }
.info-bars span { flex: 1; border-radius: 12px 12px 4px 4px; background: rgba(255,255,255,.45); animation: bar-grow .9s cubic-bezier(.2,.8,.2,1) both; transform-origin: bottom; }
.info-bars span:nth-child(1) { height: 100%; background: rgba(35,23,0,.85); }
.info-bars span:nth-child(2) { height: 62%; animation-delay: .08s; }
.info-bars span:nth-child(3) { height: 80%; animation-delay: .16s; }
.info-bars span:nth-child(4) { height: 45%; animation-delay: .24s; }
@keyframes bar-grow { from { transform: scaleY(0); } }
.info-hero h1 { font: 800 clamp(40px, 13vw, 64px)/1 var(--font-display); margin: 0 0 14px; letter-spacing: -.04em; }
.info-tagline { font: 600 18px/1.3 var(--font-body); margin: 0; max-width: 30ch; text-wrap: balance; }

.info-demo {
  position: relative; z-index: 1; margin: -64px 14px 0; padding: 16px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow), 0 18px 40px rgba(20,30,25,.12);
  transform: rotate(-1.5deg); display: grid; gap: 12px;
  animation: demo-in .7s .25s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes demo-in { from { opacity: 0; transform: translateY(24px) rotate(-1.5deg); } }
.info-demo-head { display: flex; align-items: center; gap: 10px; }
.info-demo-head b { flex: 1; min-width: 0; }
.info-demo-head .num { font: 700 17px/1 var(--font-display); }
.info-demo-people { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.info-demo-people > div { position: relative; display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border-radius: var(--r-md); background: var(--surface-2); font-size: 13px; min-width: 0; }
.info-demo-people > div > span:not(.avatar) { color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-demo-people i { position: absolute; top: 4px; right: 6px; font-style: normal; font-size: 14px; }
.info-demo .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; flex: 0 0 auto; }
.info-demo-who { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.info-demo-move { display: flex; align-items: center; gap: 8px; }
.info-demo-move .avatar { width: 28px; height: 28px; font-size: 13px; }
.info-demo-move .arrow { flex: 0 0 44px; height: 2px; background: linear-gradient(90deg, var(--line), var(--pos)); position: relative; }
.info-demo-move .arrow::after { content: ''; position: absolute; right: -1px; top: -4px; border: 5px solid transparent; border-left: 7px solid var(--pos); border-right: 0; }
.info-demo-move b { margin-left: auto; color: var(--pos); }

.info-lead { font-size: 17px; line-height: 1.5; color: var(--muted); margin: 26px 4px 0; }
.info-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.info-facts > div { background: var(--surface); border-radius: var(--r-lg); padding: 14px 10px; display: grid; gap: 2px; text-align: center; }
.info-facts b { font: 800 26px/1.1 var(--font-display); color: var(--accent); letter-spacing: -.03em; }
.info-facts span { font-size: 12.5px; color: var(--muted); line-height: 1.25; }

.info-h { font: 700 24px/1.2 var(--font-display); margin: 40px 4px 16px; letter-spacing: -.02em; }
.info-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; position: relative; }
.info-steps li { display: flex; gap: 16px; align-items: flex-start; padding: 0 4px 22px; position: relative; }
.info-steps li:not(:last-child)::before { content: ''; position: absolute; left: 25px; top: 46px; bottom: 4px; border-left: 2px dashed var(--line); }
.info-steps b { font-size: 17px; }
.info-steps p, .info-feat p { margin: 4px 0 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.info-num { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--ink); color: var(--bg); font: 700 18px/1 var(--font-display); transform: rotate(-4deg); }
.info-steps li:nth-child(2) .info-num { transform: rotate(3deg); background: var(--accent); color: var(--accent-ink); }
.info-steps li:nth-child(3) .info-num { transform: rotate(-2deg); background: var(--pos); color: #fff; }

.info-chapters { display: grid; gap: 14px; }
.info-chapter { background: color-mix(in srgb, var(--c) 9%, var(--surface)); border-radius: 26px; padding: 18px 16px 6px; border: 1px solid color-mix(in srgb, var(--c) 18%, transparent); }
.info-chapter-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.info-chapter-no { font: 800 30px/1 var(--font-display); color: var(--c); letter-spacing: -.04em; }
.info-chapter h3 { margin: 0; font: 700 18px/1.2 var(--font-display); letter-spacing: -.01em; }
.info-feat { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid color-mix(in srgb, var(--c) 16%, transparent); }
.info-chapter-head + .info-feat { border-top: 0; }
.info-feat .tile { flex: 0 0 auto; background: color-mix(in srgb, var(--c) 20%, var(--surface)); }
.info-feat > div { min-width: 0; }
.info-modes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.info-modes span { padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); }
.info-modes span:first-child { background: var(--c); color: #fff; border-color: transparent; }

.info-faq { display: grid; gap: 8px; }
.info-faq details { background: var(--surface); border-radius: var(--r-lg); padding: 16px 18px; }
.info-faq summary { font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; text-align: left; }
.info-faq summary::-webkit-details-marker { display: none; }
.info-faq summary::before { content: none; }
.info-faq details[open] > summary::before { content: none; }
.info-faq summary::after { content: '+'; font: 600 22px/1 var(--font-display); color: var(--muted); transition: transform .2s; }
.info-faq details[open] summary::after { transform: rotate(45deg); }
.info-faq details p { margin: 10px 0 0; color: var(--muted); line-height: 1.5; }

.info-cta { margin-top: 40px; background: var(--ink); color: var(--bg); border-radius: 28px; padding: 28px 22px 22px; display: grid; gap: 18px; }
.info-cta h2 { margin: 0; font: 700 26px/1.15 var(--font-display); letter-spacing: -.02em; text-wrap: balance; }

.reveal.pending { opacity: 0; transform: translateY(18px); transition: opacity .5s ease, transform .5s cubic-bezier(.2,.8,.2,1); }
.reveal.pending.shown { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .info-bars span, .info-demo { animation: none; } }
@media (min-width: 620px) {
  .info-hero { padding: 104px 32px 92px; }
  .info-demo { margin: -64px 40px 0; }
}
.receipt-open { display: block; width: 100%; padding: 0; border-radius: var(--r-md); }
.receipt-thumb:not([src]) { min-height: 160px; }

/* expense search + filters */
.search-row { display: flex; gap: 8px; margin-top: 4px; }
.search-row .input { flex: 1; min-width: 0; min-height: 46px; }
.filter-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; min-height: 46px; border-radius: var(--r-md); background: var(--surface); font-weight: 600; font-size: 15px; }
.filter-btn[aria-pressed="true"] { background: var(--accent-soft); }
.filter-btn b { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; display: grid; place-items: center; }
@media (max-width: 359px) { .filter-btn span { display: none; } }
.who-chip { padding-left: 6px; }
.who-chip .avatar.sm { width: 26px; height: 26px; font-size: 12px; margin-left: 0; }
.member-row { padding: 0; gap: 0; }
.member-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 0 10px 14px; text-align: left; min-height: 62px; }
.member-row .icon-btn { margin-right: 6px; }
.hello h2 .hi-name { color: var(--accent); font-weight: inherit; }

/* group settings head, own emoji, leave/delete */
.group-head { display: flex; align-items: center; gap: 12px; padding: 4px 2px 2px; }
.group-head h2 { flex: 1; min-width: 0; margin: 0; font: 600 22px/1.2 var(--font-display); overflow-wrap: anywhere; }
.custom-emoji { display: grid; grid-template-columns: 1fr 76px; align-items: center; gap: 10px; }
.custom-emoji label { font-size: 14px; color: var(--muted); }
.custom-emoji .input { text-align: center; font-size: 26px; padding: 0; min-height: 52px; }
.danger-zone { border: 1.5px solid var(--neg-soft); }
.warn-box { background: var(--accent-soft); border-radius: var(--r-md); padding: 10px 12px; font-size: 14px; line-height: 1.45; }
.pay-block .link { font-size: 14px; }

/* archive and home edit mode */
.archived-banner { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: var(--surface-2); border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.archive-list { margin-top: 16px; }
.archive-list > summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 8px 2px; }
.archive-list .list { opacity: .75; margin-top: 6px; }
.section-title .edit-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
.section-title .edit-toggle svg { width: 16px; height: 16px; }
.period-btn { flex: 1; min-width: 0; justify-content: flex-start; }
.period-btn span { display: inline !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* home: every group in its own card; arrows to reorder in edit mode */
.group-cards { display: grid; gap: 10px; }
.group-cards > .row { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.group-cards > .row + .row::before { content: none; }
.reorder { display: flex; align-items: center; gap: 2px; flex: none; }
.reorder .icon-btn { width: 38px; height: 38px; font-size: 18px; font-weight: 700; }
.reorder .icon-btn:disabled { opacity: .25; }
.archive-list .group-cards { opacity: .75; margin-top: 6px; }
.home-total { font-size: 14px; color: var(--muted); line-height: 1.3; }
.home-total .val { display: block; margin: 2px 0; }

/* welcome screen: «how it works» and the four flags on one line; on phones only the flags */
.welcome-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: calc(env(safe-area-inset-top, 0px) + 12px); }
.welcome-top .info-link { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.welcome-top .lang-row { flex-wrap: nowrap; flex: none; gap: 4px; }
@media (max-width: 520px) {
  .welcome-top .lang-btn span { display: none; }
  .welcome-top .lang-btn { padding: 0 7px; }
}
.add-bill { margin-top: 10px; width: 100%; border: 1.5px dashed var(--line); }

/* sheets never move sideways: iPhone date fields keep to the screen width */
.sheet-body { overflow-x: hidden; }
input[type="date"].input, input[type="date"].mini-input.wide { display: block; min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.form-section-body, .field { min-width: 0; }
.debt.upcoming { flex-wrap: wrap; }
.debt .upcoming-for { flex-basis: 100%; padding-left: 2px; }
