:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --surface-3: #e7e7e3;
  --text: #121212;
  --muted: #6e6e6a;
  --faint: #a3a39e;
  --line: #ebebe7;
  --primary: #121212;
  --on-primary: #ffffff;
  --accent: #10b981;
  --accent-soft: #e3f7ef;
  --pos: #068a52;
  --pos-soft: #e3f5ec;
  --neg: #d4471c;
  --neg-soft: #fcebe4;
  --warn: #e49b0f;
  --hero: #121212;
  --hero-text: #ffffff;
  --shadow: 0 1px 2px rgba(18, 18, 18, .04);
  --shadow-lg: 0 12px 40px rgba(18, 18, 18, .12);
  --r: 20px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0b; --surface: #161616; --surface-2: #1f1f1f; --surface-3: #2a2a2a; --text: #f2f2f0; --muted: #9a9a95; --faint: #61615d;
    --line: #232323; --primary: #f2f2f0; --on-primary: #0b0b0b; --accent: #34d399; --accent-soft: #10291f;
    --pos: #34d399; --pos-soft: #10291f; --neg: #fb7f55; --neg-soft: #2e1710; --hero: #1a1a1a; --hero-text: #f2f2f0;
    --shadow: none; --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0b; --surface: #161616; --surface-2: #1f1f1f; --surface-3: #2a2a2a; --text: #f2f2f0; --muted: #9a9a95; --faint: #61615d;
  --line: #232323; --primary: #f2f2f0; --on-primary: #0b0b0b; --accent: #34d399; --accent-soft: #10291f;
  --pos: #34d399; --pos-soft: #10291f; --neg: #fb7f55; --neg-soft: #2e1710; --hero: #1a1a1a; --hero-text: #f2f2f0;
  --shadow: none; --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.i { flex: none; display: block; }
.num, .big-num, .end, .kv { font-variant-numeric: tabular-nums; }

#app {
  max-width: 540px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px);
  min-height: 100vh;
}
body.no-nav #app { padding-bottom: calc(env(safe-area-inset-bottom) + 36px); }
.boot { display: grid; place-items: center; min-height: 70vh; }

.logo-mark {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary);
}
.logo-mark svg { width: 55%; height: 55%; }

/* ---------- Top bar ---------- */
.top { display: flex; align-items: center; gap: 8px; margin: 2px 0 18px; min-height: 44px; }
.top h1 { font-size: 26px; line-height: 1.15; margin: 0; flex: 1; font-weight: 700; letter-spacing: -.025em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top.sub-page h1 { font-size: 18px; letter-spacing: -.01em; text-align: center; }
.top .sub { color: var(--muted); font-size: 14px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 999px; border: 0; background: var(--surface); color: var(--text);
  display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: var(--shadow);
}
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn:active { transform: scale(.95); }
.spacer { width: 40px; flex: none; }

/* ---------- Cards & lists ---------- */
.card { background: var(--surface); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .card + .list, .list + .card { margin-top: 12px; }
.section { margin-top: 26px; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.section-h h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -.01em; }
.section-h .small { color: var(--muted); }
.list { background: var(--surface); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; position: relative;
  width: 100%; background: none; border: 0; text-align: left; cursor: pointer; color: inherit;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 64px; right: 16px; height: 1px; background: var(--line); }
.row:active { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { text-align: right; flex: none; font-weight: 600; }
.row .end .s { white-space: nowrap; font-weight: 400; }
.static { cursor: default; }
.static:active { background: none; }

.emoji-box { width: 40px; height: 40px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; font-size: 20px; flex: none; }
.cat { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; flex: none; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.cat.sm { width: 32px; height: 32px; border-radius: 11px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: 13px; font-weight: 650; color: var(--a); background: color-mix(in srgb, var(--a) 15%, var(--surface));
}
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.avatars { display: inline-flex; }
.avatars .avatar { box-shadow: 0 0 0 2px var(--surface); margin-left: -6px; }
.avatars .avatar:first-child { margin-left: 0; }
.flow { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); flex: none; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.big-num { font-size: 34px; font-weight: 700; letter-spacing: -.035em; line-height: 1.1; }
.center { text-align: center; }
.stack > * + * { margin-top: 10px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--pos-soft); color: var(--pos); }
.pill.bad { background: var(--neg-soft); color: var(--neg); }
.pill.brand { background: var(--surface-2); color: var(--text); }

/* Black balance card */
.hero {
  background: radial-gradient(120% 90% at 100% 0%, rgba(16, 185, 129, .35), transparent 55%), var(--hero);
  color: var(--hero-text); border-radius: 24px; padding: 20px; position: relative; overflow: hidden;
}
:root[data-theme="dark"] .hero { border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { border: 1px solid var(--line); } }
.hero .muted { color: rgba(255, 255, 255, .62); }
.hero .lbl { font-size: 13px; color: rgba(255, 255, 255, .62); }
.hero .big-num { font-size: 38px; margin-top: 4px; }
.hero-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.hero-split > div { background: rgba(255, 255, 255, .07); border-radius: 14px; padding: 10px 12px; }
.hero-split b { display: block; font-size: 17px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.hero .bar { background: rgba(255, 255, 255, .14); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 999px; border: 0; background: var(--surface-2); font-weight: 600; cursor: pointer; color: var(--text);
  transition: transform .1s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.danger { color: var(--neg); background: var(--neg-soft); }
.btn.ghost { background: none; color: var(--muted); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 20px 0 22px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 7px; background: none; border: 0; cursor: pointer; font-size: 12.5px; font-weight: 550; color: var(--text); padding: 0; }
.action .ai { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); transition: transform .1s; }
.action .ai.primary { background: var(--primary); color: var(--on-primary); }
.action:active .ai { transform: scale(.94); }

.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 999px; font-weight: 550; font-size: 13px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 0; font-weight: 550; font-size: 14px; color: var(--muted); cursor: pointer; position: relative; white-space: nowrap; }
.tabs button.on { color: var(--text); }
.tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px; }

.filters { display: flex; gap: 6px; margin: 14px 0 4px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span, .label { display: block; font-size: 13px; font-weight: 550; color: var(--muted); margin: 0 2px 7px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid transparent;
  background: var(--surface); outline: none; font-size: 16px; transition: border-color .15s;
}
.sheet .input { background: var(--surface-2); }
.input:focus { border-color: var(--text); }
.input.money { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.inline { display: flex; gap: 8px; }
.inline > .input { flex: 1; min-width: 0; }
.inline > select.input { flex: none; width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 0; background: var(--surface-2); border-radius: 999px; padding: 8px 13px; color: var(--text);
  font-size: 13px; font-weight: 550; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.card .chip, .chips.on-bg .chip { background: var(--surface); }
.chip.on { background: var(--primary); color: var(--on-primary); }
.chip .i { width: 15px; height: 15px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.check-row + .check-row { border-top: 1px solid var(--line); }
.check-row .grow { flex: 1; min-width: 0; }
.check-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.check-row .input { width: 110px; min-height: 42px; text-align: right; }
.hint { font-size: 13px; color: var(--muted); margin: 7px 2px 0; }
.warn { font-size: 13px; color: var(--neg); margin: 7px 2px 0; }

/* ---------- Progress ---------- */
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.bar.over > i { background: var(--neg); }
.bar.warnc > i { background: var(--warn); }

/* ---------- Receipt claiming ---------- */
.item-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; position: relative; transition: background .15s; }
.item-row + .item-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: 1px; background: var(--line); }
.item-row.mine { background: var(--accent-soft); }
.claim-btn {
  flex: none; min-width: 72px; min-height: 36px; border-radius: 999px; border: 1.5px solid var(--surface-3);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.claim-btn.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.rcpt-item { display: grid; grid-template-columns: 1fr 100px 40px; gap: 6px; margin-bottom: 6px; }
.rcpt-item .input { min-height: 46px; }
.rcpt-img { width: 100%; max-height: 280px; object-fit: contain; border-radius: 16px; background: var(--surface-2); display: block; }

.qr-box { background: #fff; border-radius: 18px; padding: 14px; text-align: center; }
.qr-box img { max-height: 340px; width: auto; }

/* ---------- Charts ---------- */
.hbar { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; }
.hbar .name { font-size: 13px; font-weight: 550; margin-bottom: 6px; }

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; max-width: 108px; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 11px; font-weight: 550; color: var(--faint);
}
.nav a.on { color: var(--text); }

/* ---------- Sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); animation: fade .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 540px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 28px 28px 0 0; padding: 6px 18px calc(env(safe-area-inset-bottom) + 22px);
  animation: up .28s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg);
}
.sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 4px auto 14px; }
.sheet h2 { margin: 0 0 18px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.sheet .card { background: var(--surface-2); box-shadow: none; }
.sheet .list { background: var(--surface-2); box-shadow: none; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  z-index: 30; background: var(--primary); color: var(--on-primary); padding: 11px 18px; border-radius: 999px; font-weight: 550; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: var(--shadow-lg); animation: fade .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .e { width: 52px; height: 52px; border-radius: 18px; background: var(--surface-2); color: var(--text); display: grid; place-items: center; margin: 0 auto 12px; }
.empty b { color: var(--text); display: block; margin-bottom: 2px; font-weight: 600; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--text); animation: spin .7s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { background: var(--surface); border-radius: 18px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; margin-bottom: 14px; box-shadow: var(--shadow); }
.banner .grow { flex: 1; }
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.month-nav b { font-size: 15px; font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.kv { display: flex; justify-content: space-between; padding: 4px 0; }
code.code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; background: var(--surface-2); padding: 10px 12px; border-radius: 12px; display: block; }
.hello { display: flex; align-items: center; gap: 12px; margin: 4px 0 20px; }
.hello .grow { flex: 1; min-width: 0; }
.hello h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.025em; }

/* ---------- Date & month pickers ---------- */
.date-pick { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr; gap: 8px; }
.date-pick select.input { width: 100%; padding-right: 8px; }
.month-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: var(--shadow);
}
.month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.month-grid button {
  min-height: 52px; border: 0; border-radius: 16px; background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 15px; cursor: pointer;
}
.month-grid button.on { background: var(--primary); color: var(--on-primary); }
.month-grid button:disabled { opacity: .3; cursor: default; }

/* ---------- Google sign-in ---------- */
.g-slot { display: flex; justify-content: center; min-height: 44px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 13px; margin: 18px 0 14px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Confirm dialog ---------- */
.dialog-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 24px; animation: fade .15s; }
.dialog { background: var(--surface); border-radius: 24px; padding: 22px 20px 18px; width: 100%; max-width: 360px; box-shadow: var(--shadow-lg); }
.dialog h3 { margin: 0 0 8px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.dialog p { margin: 0 0 20px; color: var(--muted); font-size: 15px; }
.dialog .btn-row { margin-top: 4px; }
.btn.danger-solid { background: var(--neg); color: #fff; }

/* ---------- Quantity stepper, search, comments ---------- */
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 999px; padding: 3px; flex: none; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text); font-size: 18px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper span { min-width: 26px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.search-row .input { min-height: 44px; }
.search-row select.input { max-width: 140px; }
.comment-box { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.comment-box:first-child { border-top: 0; }
.comment-box .input { min-height: 42px; background: var(--surface-2); }

/* ---------- Welcome tour ---------- */
.tour { padding: 10px 4px 4px; }
.tour-icon { width: 84px; height: 84px; border-radius: 28px; margin: 6px auto 0; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 100% 0%, rgba(16, 185, 129, .45), transparent 60%), var(--hero); color: #fff; }
.tour-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 20px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 999px; background: var(--surface-3); transition: width .2s; }
.tour-dots i.on { width: 22px; background: var(--text); }

/* ---------- Photos ---------- */
img.avatar { object-fit: cover; padding: 0; background: var(--surface-2); }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.photo-btn { position: relative; border: 0; background: none; padding: 0; cursor: pointer; flex: none; border-radius: 50%; }
.photo-badge { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); box-shadow: 0 0 0 2px var(--surface); }
.link-btn { border: 0; background: none; padding: 0; color: var(--muted); font-weight: 550; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
img.emoji-box { display: block; }
.avatar.emoji-av { background: var(--surface-2); font-size: 1.15em; line-height: 1; }
.avatar.sm.emoji-av { font-size: 14px; }
.avatar.lg.emoji-av { font-size: 30px; }
.avatar.xl { width: 96px; height: 96px; font-size: 34px; }
.avatar.xl.emoji-av { font-size: 52px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.emoji-grid button { aspect-ratio: 1; border: 0; border-radius: 16px; background: var(--surface-2); font-size: 26px; cursor: pointer; }
.emoji-grid button.on { box-shadow: 0 0 0 2.5px var(--primary); }

/* ---------- Group & person profiles ---------- */
.group-head { display: flex; align-items: center; gap: 14px; margin: 0 2px 18px; width: calc(100% - 4px); padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.group-head:active { opacity: .7; }
.group-head > .i { color: var(--faint); flex: none; }
.profile-hero { text-align: center; padding: 10px 0 18px; margin: -6px -18px 4px; position: relative;
  background: radial-gradient(70% 90% at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%); }
.profile-hero h2 { font-size: 23px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.stat-row > div { background: var(--surface-2); border-radius: 16px; padding: 12px 10px; text-align: center; min-width: 0; }
.stat-row b { display: block; font-size: 16px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.stat-row span { font-size: 11.5px; color: var(--muted); }
.member-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 6px; }
.member-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer; color: var(--text); font: inherit; font-size: 12.5px; font-weight: 550; padding: 0; min-width: 0; }
.member-grid button span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-grid button:active .avatar { transform: scale(.94); }
.add-av { background: var(--surface-2) !important; color: var(--muted) !important; border: 1.5px dashed var(--surface-3); }
.rel-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface-2); border-radius: 18px; padding: 14px 16px; margin: 4px 0 12px; flex-wrap: wrap; }
.rel-card b { font-size: 22px; letter-spacing: -.02em; }
.rel-card.pos-bg { background: var(--pos-soft); }
.rel-card.pos-bg b, .rel-card.pos-bg .small { color: var(--pos); }
.rel-card.neg-bg { background: var(--neg-soft); }
.rel-card.neg-bg b, .rel-card.neg-bg .small { color: var(--neg); }
.rel-card .btn-row { flex: none; }
.rel-card .btn:not(.primary) { background: var(--surface); }
.rel-card .btn { white-space: nowrap; }

/* ---------- Upload status ---------- */
.up-status { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 550; color: var(--muted); min-height: 0; text-align: center; }
.up-status:not(:empty) { margin: 2px 0 12px; min-height: 24px; }
.up-status.ok { color: var(--pos); }
.up-status.err { color: var(--neg); }
.spinner.tiny { width: 15px; height: 15px; border-width: 2px; margin: 0; display: inline-block; vertical-align: middle; }
#pic-preview img.avatar { object-fit: cover; }

/* ---------- Tappable pictures, viewer, upload confirm ---------- */
.av-tap { display: inline-flex; flex: none; border-radius: 50%; cursor: pointer; transition: transform .1s; }
.av-tap:active { transform: scale(.92); }
.avatars .av-tap { margin-left: -6px; }
.avatars .av-tap:first-child { margin-left: 0; }
.avatars .av-tap .avatar { margin-left: 0; }
.pic-btn { border: 0; background: none; padding: 0; cursor: zoom-in; border-radius: 50%; display: inline-block; }
.pic-btn:active { transform: scale(.97); }
.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; animation: fade .15s; cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 75vh; border-radius: 20px; object-fit: contain; }
.viewer-emoji { font-size: 160px; line-height: 1; }
.viewer-cap { color: #fff; font-weight: 600; font-size: 17px; }
.viewer-x { position: absolute; top: calc(env(safe-area-inset-top) + 14px); right: 14px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .15); color: #fff; display: grid; place-items: center; }
.up-thumb { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }
.up-status.ask { color: var(--text); font-size: 14px; gap: 10px; }
#up-status.ask + [data-act="avatarGallery"] { display: none; }

/* ---------- Quick add ---------- */
.quick-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 12px 2px 0; }
.quick-row .chip { padding: 7px 12px; font-size: 13px; }

/* ---------- Icon avatars ---------- */
.avatar.icon-av { color: #fff; }
.avatar.icon-av svg { width: 56%; height: 56%; }
.avatar.huge { width: 200px; height: 200px; }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.icon-grid button { border: 0; background: none; padding: 0; cursor: pointer; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; }
.icon-grid .avatar { width: 100%; height: 100%; }
.icon-grid button.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5.5px var(--text); }
.icon-grid button:active { transform: scale(.92); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; }
.swatches button.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5.5px var(--text); }

/* ---------- Cartoon avatars ---------- */
.avatar.cartoon-av { object-fit: cover; background: var(--surface-2, #eee); }
.cartoon-grid { grid-template-columns: repeat(6, 1fr); }
.cartoon-grid button.busy { opacity: .5; }
.av-styles { margin-bottom: 12px; }
.swatches { gap: 8px; }
.swatches button { width: 30px; height: 30px; }
