:root {
  --tomato: #E4412B; --tomato-dark: #B8301D; --tomato-text: #C2361F;
  --lemon: #FFD23F; --lemon-dark: #D9AB12; --lemon-soft: #FFF6D6; --lemon-line: #F5DE8A;
  --ink: #2A1D1A; --muted: #6E5F59; --faint: #8F807A; --line: #F0E6E1; --line2: #F3ECE8;
  --cream: #FBF1EC; --paper: #FBF6F3; --white: #fff; --green: #1E7A45; --green-soft: #E3F4EA;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Rubik, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--tomato);
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--tomato-text); }
input::placeholder, textarea::placeholder { color: #9A8B85; }
:focus-visible { outline: 3px solid var(--lemon); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
@media (min-width: 520px) { body { background: #C93A26; } #app { box-shadow: 0 0 60px rgba(0,0,0,.25); } }

/* ---------- shared pieces ---------- */
.screen { flex: 1; display: flex; flex-direction: column; min-height: 100dvh; }
.top { padding: 22px 20px 18px; color: #fff; display: flex; flex-direction: column; gap: 12px; padding-top: max(22px, env(safe-area-inset-top)); }
.top h1 { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.1; }
.top p { margin: 0; font-size: 15px; opacity: .95; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.sheet { flex: 1; background: #fff; border-radius: 28px 28px 0 0; padding: 18px 18px 110px; display: flex; flex-direction: column; gap: 14px; }
.sheet.paper { background: var(--paper); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 99px; background: rgba(255,255,255,.18); color: #fff; text-decoration: none; font-weight: 500; font-size: 14px; border: 0; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); background: #fff; display: grid; place-items: center; flex: none; text-decoration: none; color: var(--ink); }
.icon-btn.dark { background: rgba(255,255,255,.14); border: 0; color: #fff; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 500; color: var(--muted); }
.input { height: 52px; border: 2px solid var(--line); border-radius: 14px; padding: 0 16px; font-size: 17px; background: #fff; outline: none; width: 100%; }
.input:focus { border-color: var(--tomato); }
textarea.input { height: auto; min-height: 110px; padding: 12px 16px; resize: vertical; }
.btn { height: 56px; border-radius: 16px; border: 0; background: var(--tomato); color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 18px; text-decoration: none; box-shadow: 0 4px 0 var(--tomato-dark); width: 100%; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--tomato-dark); }
.btn[disabled] { opacity: .6; cursor: default; }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: none; font-weight: 500; font-size: 16px; height: 52px; }
.btn.lemon { background: var(--lemon); color: var(--ink); box-shadow: 0 4px 0 var(--lemon-dark); }
.btn.small { height: 44px; font-size: 15px; width: auto; padding: 0 16px; box-shadow: none; }
.link-btn { background: none; border: 0; color: var(--tomato-text); font-weight: 600; padding: 8px; min-height: 44px; }
.muted { color: var(--muted); }
.note { margin: 0; display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.note svg { flex: none; margin-top: 2px; }
.error { background: #FDE7E3; color: #8E2A1C; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.card { background: #fff; border: 1.5px solid var(--line); border-radius: 20px; padding: 16px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 600; color: #fff; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar.lg { width: 36px; height: 36px; font-size: 15px; }
.avatars { display: flex; }
.avatars .avatar { border: 2px solid var(--tomato); }
.avatars .avatar + .avatar { margin-right: -9px; }
.h2 { margin: 6px 0 2px; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.yellow { color: #7A5A00; background: #FFE9A3; }
.badge.gray { color: var(--muted); background: var(--cream); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .big { width: 72px; height: 72px; border-radius: 22px; background: var(--lemon-soft); display: grid; place-items: center; transform: rotate(-6deg); }
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; z-index: 50; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: pop .2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.dark { border-color: var(--line); border-top-color: var(--tomato); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.hero { flex: 1; min-height: 260px; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px; padding: 40px 28px 50px; color: #fff; text-align: center; overflow: hidden;
  background: radial-gradient(circle at 20% 15%, rgba(255,210,63,.35) 0 60px, transparent 61px), radial-gradient(circle at 85% 30%, rgba(255,255,255,.12) 0 90px, transparent 91px), radial-gradient(circle at 70% 85%, rgba(0,0,0,.12) 0 120px, transparent 121px), var(--tomato); }
.logo { width: 64px; height: 64px; border-radius: 20px; background: var(--lemon); display: grid; place-items: center; box-shadow: 0 6px 0 var(--lemon-dark); transform: rotate(-6deg); }
.hero h1 { margin: 8px 0 0; font-size: 34px; font-weight: 700; line-height: 1.1; }
.hero p { margin: 0; font-size: 17px; line-height: 1.45; max-width: 290px; }
.auth { margin-top: -26px; position: relative; background: #fff; border-radius: 30px 30px 0 0; padding: 24px 24px 30px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 -12px 30px rgba(0,0,0,.18); }
.tabs { display: flex; background: var(--cream); border-radius: 14px; padding: 4px; gap: 4px; }
.tabs button { flex: 1; height: 44px; border: 0; border-radius: 11px; font-weight: 600; font-size: 16px; background: transparent; color: var(--muted); }
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(42,29,26,.12); }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#google-btn { display: flex; justify-content: center; min-height: 44px; }

/* ---------- list ---------- */
.add-form { display: flex; gap: 8px; }
.add-form .input { flex: 1; min-width: 0; border-radius: 16px; }
.add-btn { flex: none; width: 52px; height: 52px; border: 0; border-radius: 16px; background: var(--lemon); box-shadow: 0 3px 0 var(--lemon-dark); display: grid; place-items: center; }
.cost-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 18px; background: var(--lemon-soft); color: var(--ink); text-decoration: none; border: 1.5px solid var(--lemon-line); }
.cost-card .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--lemon); display: grid; place-items: center; flex: none; }
.cost-card .val { font-size: 22px; font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }
.item { display: flex; align-items: center; gap: 8px; min-height: 56px; border-bottom: 1px solid var(--line2); position: relative; background: #fff; touch-action: pan-y; transition: transform .15s; }
.check { flex: none; width: 44px; height: 44px; border: 0; background: none; display: grid; place-items: center; padding: 0; }
.check span { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid #B3A49E; background: #fff; display: grid; place-items: center; transition: all .15s; }
.item.done .check span { border-color: var(--tomato); background: var(--tomato); }
.check svg { opacity: 0; }
.item.done .check svg { opacity: 1; }
.item .name { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; font-size: 17px; background: none; border: 0; text-align: right; padding: 8px 0; }
.item.done .name { color: var(--faint); text-decoration: line-through; }
.qty { font-size: 14px; font-weight: 600; color: var(--tomato-text); }
.price { font-size: 13px; color: var(--muted); white-space: nowrap; }
.del { flex: none; width: 36px; height: 44px; border: 0; background: none; color: #B3A49E; display: grid; place-items: center; }
.scan-cta { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 54px; border-radius: 16px; border: 2px dashed #D9C9C2; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 16px; margin-top: 6px; }
.fam-switch { background: none; border: 0; color: #fff; padding: 0; display: flex; align-items: center; gap: 6px; text-align: right; }

/* ---------- bottom nav ---------- */
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; height: calc(74px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: space-around; align-items: flex-start; padding-top: 8px; z-index: 10; }
.nav a { width: 76px; min-height: 52px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.nav a[aria-current="page"] { color: var(--tomato-text); font-weight: 600; }

/* ---------- invite ---------- */
.invite-hero { min-height: 170px; flex: 1; background: linear-gradient(160deg, #8E2A1C, #C93A26); display: grid; place-items: center; margin-bottom: -28px; padding-bottom: 28px; }
.linkbox { display: flex; align-items: center; gap: 10px; padding: 8px; padding-right: 16px; border-radius: 16px; background: var(--cream); }
.linkbox span { flex: 1; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
.share-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.share-grid a, .share-grid button { min-height: 76px; border: 2px solid var(--line); border-radius: 16px; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink); text-decoration: none; }
.member { display: flex; align-items: center; gap: 12px; min-height: 54px; border-bottom: 1px solid var(--line2); }
.member:last-child { border-bottom: 0; }

/* ---------- scan ---------- */
.dark-screen { background: #1B1412; color: #fff; }
.viewer { flex: 1; position: relative; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 45%, #4A3A34 0%, #241A17 70%); min-height: 360px; padding: 24px; }
.frame { position: absolute; inset: 40px 48px 70px; pointer-events: none; }
.frame span { position: absolute; width: 34px; height: 34px; border: 4px solid var(--lemon); }
.frame .a { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.frame .b { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.frame .c { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.frame .d { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.viewer img { max-width: 100%; max-height: 52vh; border-radius: 6px; box-shadow: 0 18px 40px rgba(0,0,0,.5); transform: rotate(-1.5deg); }
.viewer .hint { position: absolute; bottom: 22px; margin: 0; padding: 8px 16px; border-radius: 99px; background: rgba(0,0,0,.55); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.scan-scanline { position: absolute; left: 56px; right: 56px; height: 3px; border-radius: 2px; background: var(--lemon); box-shadow: 0 0 18px 4px rgba(255,210,63,.55); animation: scanline 1.6s ease-in-out infinite alternate; top: 30%; }
@keyframes scanline { to { top: 70%; } }
.controls { padding: 22px 26px calc(30px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.shutter { width: 84px; height: 84px; border-radius: 50%; border: 5px solid #fff; display: grid; place-items: center; background: none; padding: 0; }
.shutter span { width: 64px; height: 64px; border-radius: 50%; background: var(--lemon); }
.side-btn { width: 72px; min-height: 60px; border: 0; background: none; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.side-btn span { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.dark-screen .note { color: #D9CFCB; }

/* ---------- review ---------- */
.summary { background: var(--tomato); color: #fff; border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.stats div { background: rgba(255,255,255,.16); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.stats div.hl { background: var(--lemon); color: var(--ink); }
.stats small { font-size: 12px; }
.stats b { font-size: 20px; }
.rline { display: flex; align-items: center; gap: 8px; min-height: 64px; border-bottom: 1px solid var(--line2); margin: 0 -14px; padding: 6px 14px; }
.rline.warn { background: var(--lemon-soft); }
.rline.off > :not(.box) { opacity: .45; }
.box { flex: none; width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; display: grid; place-items: center; }
.box span { width: 24px; height: 24px; border-radius: 7px; border: 2.5px solid var(--tomato); background: var(--tomato); display: grid; place-items: center; }
.rline.off .box span { border-color: #B3A49E; background: #fff; }
.rline .fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rline input { border: 0; border-bottom: 1.5px dashed transparent; background: transparent; padding: 2px 0; outline: none; }
.rline input:focus { border-bottom-color: var(--tomato); }
.rline .n { font-size: 16px; font-weight: 500; width: 100%; }
.rline .p { width: 72px; text-align: left; font-size: 16px; font-weight: 600; direction: ltr; }
.rline .raw { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-bar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: #fff; border-top: 1px solid var(--line); padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; z-index: 10; }

/* ---------- cost ---------- */
.big-total { background: var(--lemon); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 5px 0 var(--lemon-dark); }
.big-total b { font-size: 44px; line-height: 1; }
.cline { display: flex; align-items: center; gap: 10px; min-height: 52px; border-bottom: 1px solid var(--line2); }
.cline .nm { flex: 1; min-width: 0; }
.bar { height: 10px; border-radius: 99px; background: var(--cream); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--tomato); border-radius: 99px; }

/* ---------- next / donate ---------- */
.feature { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px solid var(--line); border-radius: 18px; background: #fff; }
.feature .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.feature .tx { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.feature .tx small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.vote { flex: none; min-width: 64px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 4px; }
.vote[aria-pressed="true"] { background: var(--tomato); border-color: var(--tomato); color: #fff; }
.menu a, .menu button { display: flex; align-items: center; gap: 12px; min-height: 56px; border: 0; border-bottom: 1px solid var(--line2); background: none; width: 100%; text-align: right; text-decoration: none; color: var(--ink); font-size: 16px; padding: 0 4px; }
.menu .danger { color: var(--tomato-text); }
.prose { font-size: 15px; line-height: 1.65; }
.prose h2 { font-size: 18px; margin: 18px 0 6px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td, .table th { text-align: right; padding: 8px 4px; border-bottom: 1px solid var(--line2); }
dialog { border: 0; border-radius: 22px; padding: 20px; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(42,29,26,.5); }
