:root {
  --bg: #f5ece4;
  --ink: #2c2420;
  --muted: #86766b;
  --card: #fffaf6;
  --card2: #f4e8dd;
  --hi: rgba(255, 255, 255, .85);
  --lo: rgba(120, 70, 30, .07);
  --shadow: 70, 35, 10;
  --field: #f6ede5;
  --accent: #ff7a59;
  --accent-d: #d8553a;
  --accent-ink: #fff;
  --ok: #2bb39a;
  --u0: #22a99a;
  --u1: #f2667f;
  --u2: #8a6cf0;
  --u3: #f0a33a;
  --radius: 22px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17131c;
    --ink: #f3ebe6;
    --muted: #a3958f;
    --card: #2a2430;
    --card2: #221d27;
    --hi: rgba(255, 255, 255, .08);
    --lo: rgba(0, 0, 0, .25);
    --shadow: 0, 0, 0;
    --field: #1d1922;
    --accent-d: #b9452c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.muted { color: var(--muted); }

/* ---------- floating background ---------- */
.scene { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(50px); opacity: .55;
  animation: drift 22s ease-in-out infinite alternate;
}
.b1 { width: 420px; height: 420px; background: #ffb38f; top: -120px; left: -100px; }
.b2 { width: 360px; height: 360px; background: #9fe3d4; bottom: -80px; right: -120px; animation-delay: -7s; }
.b3 { width: 280px; height: 280px; background: #ffc3d0; top: 40%; left: 55%; animation-delay: -14s; }
@media (prefers-color-scheme: dark) { .blob { opacity: .22; } }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }

/* ---------- 3D surfaces ---------- */
.card {
  background: linear-gradient(160deg, var(--card), var(--card2));
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 var(--hi),
    inset 0 -2px 0 var(--lo),
    0 1px 2px rgba(var(--shadow), .08),
    0 14px 30px -14px rgba(var(--shadow), .38);
}

.logo3d {
  width: 46px; height: 46px; border-radius: 15px; flex: none;
  display: grid; place-items: center; font-size: 24px;
  background: linear-gradient(145deg, #ffb08f, #ff6f61);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.5), inset 0 -4px 0 rgba(0,0,0,.12), 0 10px 20px -8px rgba(255, 100, 80, .7);
  transform: perspective(300px) rotateX(12deg) rotateY(-14deg);
  animation: bob 5s ease-in-out infinite;
}
.logo3d span { transform: translateZ(14px); filter: drop-shadow(0 3px 2px rgba(0,0,0,.25)); }
.logo3d.big { width: 86px; height: 86px; font-size: 46px; border-radius: 26px; margin: 0 auto 14px; }
@keyframes bob {
  50% { transform: perspective(300px) rotateX(-6deg) rotateY(12deg) translateY(-3px); }
}

.btn3d {
  border: 0; border-radius: 16px; padding: 12px 18px; font-weight: 700;
  background: linear-gradient(180deg, var(--card), var(--card2));
  box-shadow: inset 0 1px 0 var(--hi), 0 4px 0 rgba(var(--shadow), .18), 0 10px 16px -8px rgba(var(--shadow), .4);
  transition: transform .08s, box-shadow .08s;
}
.btn3d.primary {
  color: var(--accent-ink);
  background: linear-gradient(180deg, #ff9471, var(--accent));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 4px 0 var(--accent-d), 0 12px 18px -8px rgba(255, 110, 80, .75);
}
.btn3d:active { transform: translateY(3px); box-shadow: inset 0 1px 0 var(--hi), 0 1px 0 rgba(var(--shadow), .2); }
.btn3d.primary:active { box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 1px 0 var(--accent-d); }
.btn3d.wide { width: 100%; }

.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 14px;
  display: grid; place-items: center; font-size: 19px; flex: none;
}
.icon-btn:hover { background: var(--lo); }
.icon-btn.small { width: 34px; height: 34px; font-size: 14px; opacity: .55; }
.icon-btn.small:hover, .icon-btn.small.on { opacity: 1; }

.field {
  width: 100%; border: 0; border-radius: 14px; padding: 12px 14px; min-width: 0;
  background: var(--field);
  box-shadow: inset 0 2px 4px rgba(var(--shadow), .12), inset 0 -1px 0 var(--hi);
  outline: none;
}
.field:focus { box-shadow: inset 0 2px 4px rgba(var(--shadow), .12), 0 0 0 3px rgba(255, 122, 89, .45); }
.field::placeholder { color: var(--muted); }
select.field { appearance: none; padding-right: 10px; }
textarea.field { resize: vertical; min-height: 80px; }

/* ---------- layout ---------- */
#app { max-width: 720px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px calc(120px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; }
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand h1 { font-size: 22px; letter-spacing: -.02em; }
.status { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: #c9b8ad; }
.sdot.live { background: var(--ok); box-shadow: 0 0 0 0 rgba(43,179,154,.6); animation: pulse 2.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(43,179,154,0); } 100% { box-shadow: 0 0 0 0 rgba(43,179,154,0); } }

.who { display: flex; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 0; margin-left: -8px;
  display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.55), transparent 45%), var(--c);
  box-shadow: 0 0 0 3px var(--bg), 0 6px 12px -4px rgba(var(--shadow), .5);
}
.avatar.me { transform: translateY(-2px) scale(1.08); z-index: 1; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--c), 0 8px 14px -4px rgba(var(--shadow), .55); }

/* ---------- composer ---------- */
.composer {
  padding: 12px; display: grid; gap: 10px;
  grid-template-columns: 1fr 1fr auto;
  grid-template-areas: "name name scan" "qty cat urgent" "add add add";
}
.composer .name { grid-area: name; font-size: 17px; }
.composer .scan { grid-area: scan; }
.composer .qty { grid-area: qty; }
.composer .cat { grid-area: cat; }
.composer .add { grid-area: add; }
#item-urgent { grid-area: urgent; }
@media (min-width: 620px) {
  .composer { grid-template-columns: auto 1fr 84px 150px auto auto; grid-template-areas: "scan name qty cat urgent add"; }
}
.chip-toggle {
  border: 0; border-radius: 14px; padding: 0 12px; white-space: nowrap; font-weight: 600; font-size: 14px;
  background: var(--field); color: var(--muted);
  box-shadow: inset 0 2px 4px rgba(var(--shadow), .12);
}
.chip-toggle[aria-pressed="true"] {
  color: #fff; background: linear-gradient(180deg, #ff9c5a, #ff6a3d);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 6px 12px -6px rgba(255, 106, 61, .9);
}

.suggest { display: flex; gap: 8px; overflow-x: auto; padding: 14px 2px 6px; scrollbar-width: none; }
.suggest::-webkit-scrollbar { display: none; }
.suggest-chip {
  border: 0; flex: none; border-radius: 999px; padding: 7px 13px; font-size: 14px;
  background: var(--card); box-shadow: inset 0 1px 0 var(--hi), 0 3px 0 rgba(var(--shadow), .1), 0 6px 10px -6px rgba(var(--shadow), .35);
}
.suggest-chip:active { transform: translateY(2px); }

/* ---------- shopping list ---------- */
.group { margin-top: 18px; }
.group-title {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 6px 8px;
}
.group-title .count { background: var(--lo); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.group-title .link { margin-left: auto; border: 0; background: none; color: var(--accent); font-weight: 700; text-transform: none; letter-spacing: 0; font-size: 14px; }
.group.urgent-group .group-title { color: #ef5b33; }

.list { display: grid; gap: 9px; perspective: 900px; }
.item {
  --who: var(--u0);
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; position: relative;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
  transition: transform .25s ease, box-shadow .25s, opacity .3s;
}
.item::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--who);
}
.item.urgent { background: linear-gradient(160deg, var(--card), color-mix(in srgb, #ff7a3d 14%, var(--card2))); }
.item.enter { animation: drop-in .55s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes drop-in { from { transform: translateY(-14px) rotateX(-70deg); opacity: 0; } }

.check {
  width: 32px; height: 32px; flex: none; border: 0; padding: 0; background: none;
  position: relative; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3, 1.5, .5, 1);
}
.check .face {
  position: absolute; inset: 0; border-radius: 10px; display: grid; place-items: center;
  backface-visibility: hidden; font-weight: 900; font-size: 17px;
}
.check .front { background: var(--field); box-shadow: inset 0 2px 4px rgba(var(--shadow), .2), inset 0 -1px 0 var(--hi); }
.check .back {
  transform: rotateX(180deg); color: #fff;
  background: linear-gradient(180deg, #43d1b4, var(--ok));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 4px 10px -3px rgba(43, 179, 154, .8);
}
.item.done .check { transform: rotateX(180deg); }
.item-main { flex: 1; min-width: 0; cursor: pointer; transform: translateZ(10px); }
.item-name { font-weight: 650; font-size: 16.5px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.qty-tag { font-weight: 700; font-size: 12.5px; color: var(--accent); background: rgba(255, 122, 89, .14); padding: 1px 8px; border-radius: 999px; }
.item-meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.item-meta .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--who); }
.item.done { opacity: .62; }
.item.done .item-name { text-decoration: line-through; text-decoration-thickness: 2px; }

.empty { text-align: center; padding: 34px 20px; margin-top: 18px; }
.empty-emoji { font-size: 46px; display: inline-block; animation: bob2 3.5s ease-in-out infinite; filter: drop-shadow(0 10px 8px rgba(var(--shadow), .25)); }
.empty p { margin: 8px 0 0; color: var(--muted); }
@keyframes bob2 { 50% { transform: translateY(-8px) rotate(-6deg); } }

/* ---------- notes ---------- */
.note-composer { grid-template-columns: 1fr; grid-template-areas: none; }
.note-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.to-label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); font-size: 14px; }
.field.small { padding: 9px 12px; width: auto; }
.swatches { display: flex; gap: 7px; }
.note-row .btn3d { margin-left: auto; }
@media (max-width: 420px) { .note-row .btn3d { width: 100%; } .swatches { flex: 1; justify-content: flex-end; } }
.swatch {
  width: 28px; height: 28px; border-radius: 9px; border: 0; background: var(--n);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 3px 0 rgba(0,0,0,.12);
  transition: transform .15s;
}
.swatch[aria-checked="true"] { transform: translateY(-3px) rotate(-8deg); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--n), 0 6px 8px -2px rgba(0,0,0,.25); }

.n-yellow { --n: #ffe48a; } .n-pink { --n: #ffc4d1; } .n-mint { --n: #b7efd6; } .n-sky { --n: #bfdcff; } .n-lilac { --n: #ddccff; }

.notes-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px;
  margin-top: 22px; perspective: 1000px; padding: 4px;
}
.note {
  position: relative; color: #3a2e22; padding: 22px 14px 10px; min-height: 150px;
  display: flex; flex-direction: column;
  background: linear-gradient(170deg, color-mix(in srgb, var(--n) 75%, #fff), var(--n) 60%);
  border-radius: 4px 4px 4px 22px;
  transform: rotate(var(--rot, 0deg)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
  box-shadow: 0 1px 1px rgba(0,0,0,.08), 0 12px 18px -10px rgba(60, 40, 10, .55), 0 26px 30px -24px rgba(60, 40, 10, .5);
  transition: transform .3s ease, box-shadow .3s;
}
.note:hover { transform: rotate(0deg) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(24px); box-shadow: 0 2px 2px rgba(0,0,0,.08), 0 26px 34px -14px rgba(60, 40, 10, .6); z-index: 2; }
.note::before {
  content: ""; position: absolute; top: -9px; left: 50%; width: 64px; height: 20px; margin-left: -32px;
  background: rgba(255, 255, 255, .55); border: 1px solid rgba(0,0,0,.05);
  transform: rotate(-3deg); box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.note.pinned::before { width: 18px; height: 18px; margin-left: -9px; top: -7px; border-radius: 50%; border: 0;
  background: radial-gradient(circle at 35% 30%, #ff9a9a, #e0343a 60%, #9e1d22); box-shadow: 0 4px 4px rgba(0,0,0,.3); transform: none; }
.note.enter { animation: stick .6s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes stick { from { transform: translateZ(120px) rotate(-12deg) scale(1.15); opacity: 0; } }
.note.fresh { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--accent), 0 16px 22px -10px rgba(60, 40, 10, .55); }
.note-head { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; font-weight: 700; opacity: .7; }
.note-text { margin: 8px 0 10px; flex: 1; white-space: pre-wrap; word-break: break-word; font-size: 16px; line-height: 1.4;
  font-family: "Bradley Hand", "Segoe Print", "Comic Sans MS", ui-rounded, cursive; }
.note-foot { display: flex; align-items: center; gap: 2px; font-size: 12px; }
.note-foot .seen { margin-right: auto; opacity: .65; font-weight: 600; }
.note .icon-btn.small { color: #3a2e22; }
.note .icon-btn.small:hover { background: rgba(0,0,0,.07); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px; border-radius: 999px; z-index: 10;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: inset 0 1px 0 var(--hi), 0 18px 34px -12px rgba(var(--shadow), .5);
}
.tabbar button {
  border: 0; background: none; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; gap: 7px; color: var(--muted); position: relative; transition: all .2s;
}
.tabbar button.active {
  color: var(--ink); background: linear-gradient(180deg, var(--card), var(--card2));
  box-shadow: inset 0 1px 0 var(--hi), 0 4px 0 rgba(var(--shadow), .12), 0 8px 14px -6px rgba(var(--shadow), .4);
  transform: translateY(-2px);
}
.ti { font-size: 18px; }
.badge:empty { display: none; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; display: grid; place-items: center;
  background: var(--lo); color: var(--ink); }
.badge.alert { background: var(--accent); color: #fff; box-shadow: 0 3px 6px -1px rgba(255, 110, 80, .7); }

/* ---------- gate ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.gate-card { width: min(380px, 100%); padding: 30px 24px; text-align: center; }
.gate-card h1 { font-size: 28px; margin-bottom: 6px; }
.gate-card form { display: grid; gap: 12px; }
.gate-card .field { text-align: center; font-size: 22px; letter-spacing: .3em; }
.err { color: #e0443a; min-height: 1.2em; margin: 0; font-size: 14px; }
.picker-users { display: grid; gap: 12px; margin-top: 14px; }
.picker-users .btn3d { display: flex; align-items: center; gap: 12px; font-size: 18px; padding: 14px 16px; }
.picker-users .avatar { margin: 0; }

/* ---------- sheet / toasts ---------- */
.sheet { border: 0; padding: 16px; background: transparent; width: min(420px, 100%); color: var(--ink); }
.sheet::backdrop { background: rgba(20, 10, 5, .35); backdrop-filter: blur(3px); }
.sheet-inner { padding: 18px; display: grid; gap: 8px; }
.sheet-inner h2 { font-size: 19px; margin: 2px 4px 8px; }
.row-btn { border: 0; text-align: left; padding: 13px 14px; border-radius: 14px; background: var(--field); font-size: 15.5px; color: var(--ink); text-decoration: none; }
.row-btn:hover { filter: brightness(.97); }

.toasts { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { padding: 12px 16px; font-weight: 600; font-size: 14.5px; animation: toast-in .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.toast.out { animation: toast-out .3s ease forwards; }
@keyframes toast-in { from { transform: translateY(-30px) rotateX(60deg); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-20px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- scan button ---------- */
.btn3d.scan { display: flex; align-items: center; gap: 6px; padding: 0 14px; color: #fff;
  background: linear-gradient(180deg, #4fd3bd, #1fa58f);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 4px 0 #157a69, 0 12px 18px -8px rgba(31, 165, 143, .8); }
.btn3d.scan:active { box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 1px 0 #157a69; }
.scan-ico { font-size: 20px; transform: scaleX(1.3); }

/* item thumbnails */
.thumb { width: 44px; height: 44px; flex: none; border-radius: 12px; object-fit: contain; background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.05), 0 6px 12px -6px rgba(var(--shadow), .5); transform: translateZ(16px); cursor: zoom-in; }

/* ---------- scanner ---------- */
.scanner { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: #000; color: #fff; }
.scanner::backdrop { background: #000; }
.scanner[open] { display: flex; flex-direction: column; }
.scan-stage { position: relative; flex: 1; overflow: hidden; display: grid; place-items: center; }
#scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: relative; width: min(78vw, 340px); aspect-ratio: 1.6; border-radius: 22px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); transform: perspective(600px) rotateX(8deg); }
.scan-frame i { position: absolute; width: 34px; height: 34px; border: 5px solid #4fd3bd; filter: drop-shadow(0 0 6px rgba(79, 211, 189, .9)); }
.scan-frame i:nth-child(1) { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-radius: 20px 0 0 0; }
.scan-frame i:nth-child(2) { top: -3px; right: -3px; border-left: 0; border-bottom: 0; border-radius: 0 20px 0 0; }
.scan-frame i:nth-child(3) { bottom: -3px; left: -3px; border-right: 0; border-top: 0; border-radius: 0 0 0 20px; }
.scan-frame i:nth-child(4) { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-radius: 0 0 20px 0; }
.laser { position: absolute; left: 8%; right: 8%; height: 3px; top: 50%; border-radius: 3px; background: #ff6a5a;
  box-shadow: 0 0 12px 2px rgba(255, 90, 80, .9); animation: laser 1.8s ease-in-out infinite alternate; }
@keyframes laser { from { top: 12%; } to { top: 88%; } }
.scan-msg { position: absolute; bottom: 24px; left: 16px; right: 16px; text-align: center; margin: 0; font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,.8); }
.scan-manual { margin: 12px 16px 0; padding: 10px; display: flex; gap: 8px; color: var(--ink); }
.scan-close { margin: 10px 16px calc(14px + env(safe-area-inset-bottom)); }

/* ---------- product card ---------- */
.product-card { text-align: center; }
.product-img { width: 168px; height: 168px; margin: 0 auto 6px; border-radius: 26px; background: #fff; display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 2px 0 rgba(0,0,0,.04), 0 26px 30px -18px rgba(var(--shadow), .7);
  transform: perspective(500px) rotateX(10deg); animation: product-pop .6s cubic-bezier(.2, 1.4, .4, 1) both; }
.product-img img { width: 100%; height: 100%; object-fit: contain; }
.product-img.none { font-size: 64px; background: var(--field); }
@keyframes product-pop { from { transform: perspective(500px) rotateX(70deg) translateY(30px) scale(.7); opacity: 0; } }
.product-card h2 { font-size: 21px; margin: 8px 0 2px; }
.product-card .muted { margin: 0 0 10px; font-size: 14px; }
.product-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.on-list { background: rgba(43, 179, 154, .14); color: var(--ok); border-radius: 14px; padding: 10px; font-weight: 700; font-size: 14px; }
.spinner { width: 46px; height: 46px; margin: 30px auto; border-radius: 50%; border: 5px solid var(--lo); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.photo-preview { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.photo-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }

/* ---------- bills ---------- */
.bill-summary { padding: 18px; position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(140deg, #6c5ce7, #a06cf0 55%, #ff7a8a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.12), 0 22px 34px -16px rgba(108, 92, 231, .75);
  transform: perspective(900px) rotateX(4deg); }
.bill-summary::after { content: ""; position: absolute; width: 220px; height: 220px; right: -60px; top: -80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.35), transparent 65%); }
.sum-label { font-size: 13px; font-weight: 700; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.sum-big { font-size: 40px; font-weight: 850; letter-spacing: -.02em; line-height: 1.1; margin: 2px 0 12px; text-shadow: 0 3px 8px rgba(0,0,0,.2); }
.sum-bar { height: 12px; border-radius: 999px; background: rgba(255,255,255,.25); overflow: hidden; box-shadow: inset 0 2px 3px rgba(0,0,0,.15); }
.sum-bar b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(180deg, #fff, #e8ffe9); transition: width .6s; }
.sum-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-top: 8px; opacity: .95; flex-wrap: wrap; }
.sum-chips { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.sum-chip { background: rgba(255,255,255,.22); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; font-weight: 700; }
.sum-chip.bad { background: #fff; color: #e0443a; }
.post-bill { margin-top: 14px; }
.bill-composer { display: block; margin-top: 14px; }
.bill-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.b-name { grid-column: 1 / -1; font-size: 17px; }
.b-amount { font-size: 17px; font-weight: 700; }
.b-due { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.b-due .field { padding: 10px; }
.b-cat { grid-column: 1 / -1; }
.chip-toggle.b-repeat, .chip-toggle.b-photo { padding: 11px 10px; }
.chip-toggle.b-repeat[aria-pressed="true"] { background: linear-gradient(180deg, #8f7cf5, #6c5ce7); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 6px 12px -6px rgba(108, 92, 231, .9); }
.bill-composer .photo-preview { margin-top: 10px; }
.bill-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 12px; }

.bill { display: flex; align-items: center; gap: 12px; padding: 12px; position: relative;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transform-style: preserve-3d; transition: transform .25s; }
.bill.enter { animation: drop-in .55s cubic-bezier(.2, 1.4, .4, 1) both; }
.bill-ico { width: 46px; height: 46px; flex: none; border-radius: 15px; display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(145deg, var(--card), var(--card2));
  box-shadow: inset 0 1px 0 var(--hi), 0 4px 0 rgba(var(--shadow), .1), 0 8px 14px -6px rgba(var(--shadow), .4); transform: translateZ(14px); }
.bill-main { flex: 1; min-width: 0; transform: translateZ(8px); }
.bill-name { font-weight: 700; font-size: 16.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.pill { font-size: 11.5px; font-weight: 800; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.paid { background: rgba(43, 179, 154, .16); color: var(--ok); }
.pill.soon { background: rgba(240, 163, 58, .18); color: #c77a10; }
.pill.later { background: var(--lo); color: var(--muted); }
.pill.late { background: #e0443a; color: #fff; box-shadow: 0 3px 8px -2px rgba(224, 68, 58, .7); }
.bill-side { text-align: right; display: grid; gap: 6px; justify-items: end; transform: translateZ(12px); }
.bill-amt { font-weight: 850; font-size: 17px; letter-spacing: -.01em; }
.btn3d.mini { padding: 6px 11px; font-size: 13px; border-radius: 11px; }
.btn3d.pay { color: #fff; background: linear-gradient(180deg, #43d1b4, var(--ok));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 3px 0 #1d8572, 0 8px 12px -6px rgba(43, 179, 154, .8); }
.btn3d.pay:active { box-shadow: 0 1px 0 #1d8572; }
.bill.late { box-shadow: inset 0 1px 0 var(--hi), 0 0 0 2px rgba(224, 68, 58, .55), 0 14px 30px -14px rgba(224, 68, 58, .5); }
.bill.paid .bill-name, .bill.paid .bill-amt { opacity: .6; }
.bill .stamp { position: absolute; right: 90px; top: 50%; margin-top: -16px; font-weight: 900; font-size: 18px; letter-spacing: .12em;
  color: var(--ok); border: 3px solid var(--ok); border-radius: 8px; padding: 0 8px; opacity: .55; transform: rotate(-14deg); pointer-events: none; }
.bill.stamping .stamp { animation: stamp .5s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes stamp { from { transform: rotate(-14deg) scale(3) translateZ(80px); opacity: 0; } }
.bill-thumb { width: 26px; height: 26px; border-radius: 7px; object-fit: cover; cursor: zoom-in; vertical-align: middle; }

/* ---------- lightbox ---------- */
.lightbox { border: 0; padding: 16px; background: transparent; max-width: 100vw; max-height: 100dvh; }
.lightbox::backdrop { background: rgba(0,0,0,.85); }
.lightbox[open] { display: grid; gap: 12px; justify-items: center; }
.lightbox img { max-width: calc(100vw - 32px); max-height: calc(100dvh - 110px); border-radius: 16px; background: #fff; }

/* three tabs need tighter buttons on small phones */
@media (max-width: 400px) { .tabbar button { padding: 10px 13px; } }
.chip-toggle.wide-chip { padding: 12px; width: 100%; }
.product-card .chip-toggle { padding: 12px; }
.bill .stamp { right: auto; left: 47%; top: auto; bottom: 10px; margin-top: 0; font-size: 15px; }

/* invites & devices */
.gate-help { font-size: 15px; line-height: 1.5; margin: 6px 0 0; }
.m-who { margin: -4px 4px 6px; font-size: 14px; }
#invite-out { display: grid; gap: 10px; }
#invite-url { font-size: 13px; }
.devices-list { display: grid; gap: 8px; }
.device-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--field); font-size: 14px; }
.device-row .grow { flex: 1; min-width: 0; }
.device-row b { display: block; font-size: 15px; }
.device-row .muted { font-size: 12.5px; }

/* install as an app */
.pair-form { display: grid; gap: 10px; margin: 14px 0 6px; }
.pair-label { font-weight: 700; font-size: 15px; }
.gate-card .code-field, .code-field { text-align: center; font-size: 28px; font-weight: 800; letter-spacing: .35em; }
.install-steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; font-size: 15.5px; line-height: 1.45; }
.install-steps li::marker { font-weight: 800; color: var(--accent); }
.kbd { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--field); box-shadow: inset 0 -2px 0 rgba(0,0,0,.08); }
.code-box { display: grid; justify-items: center; gap: 4px; padding: 14px; border-radius: 18px;
  background: linear-gradient(145deg, #6c5ce7, #a06cf0); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 14px 24px -12px rgba(108, 92, 231, .8); transform: perspective(600px) rotateX(6deg); }
.code-box .muted { color: rgba(255,255,255,.85); font-size: 13px; }
.code-box b { font-size: 38px; letter-spacing: .12em; font-variant-numeric: tabular-nums; text-shadow: 0 3px 8px rgba(0,0,0,.2); }

/* update card */
.update-card { position: fixed; z-index: 40; left: 50%; top: max(12px, env(safe-area-inset-top)); width: min(440px, calc(100% - 32px));
  transform: translateX(-50%); padding: 16px; display: grid; gap: 10px; animation: toast-in .5s cubic-bezier(.2, 1.4, .4, 1) both;
  box-shadow: inset 0 1px 0 var(--hi), 0 0 0 2px rgba(108, 92, 231, .35), 0 24px 40px -16px rgba(var(--shadow), .55); }
.update-head { display: flex; gap: 12px; align-items: center; }
.update-head b { display: block; font-size: 16.5px; }
.update-head .muted { font-size: 13px; }
.update-ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; flex: none;
  background: linear-gradient(145deg, #8f7cf5, #6c5ce7); box-shadow: 0 8px 14px -6px rgba(108, 92, 231, .8); }
.update-notes { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14.5px; }
.m-version { text-align: center; font-size: 12.5px; margin: 4px 0 0; }
.get-app-card { text-align: center; }
.get-app-card h2 { margin: 0; }
