:root {
  --maroon: #7a1f3d;
  --maroon-deep: #5e1530;
  --rose: #b03a5b;
  --gold: #c8a15a;
  --gold-soft: #e7d3a8;
  --blush: #fdeee6;
  --cream: #fff8f2;
  --ink: #3b2a30;
  --muted: #8a7a80;
  --green: #2e7d52;
  --amber: #c77d12;
  --red: #b4322f;
  --line: #efdfd4;
  --shadow: 0 10px 30px rgba(122, 31, 61, .10);
  --shadow-sm: 0 4px 14px rgba(122, 31, 61, .08);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 50% -100px, #fbe6d6 0%, transparent 60%),
    linear-gradient(180deg, var(--cream), #fbeadd);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, .serif { font-family: 'Playfair Display', Georgia, serif; }
a { color: var(--maroon); }

.app-shell { max-width: 600px; margin: 0 auto; min-height: 100vh; position: relative; padding-bottom: 84px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  background: linear-gradient(120deg, var(--maroon), var(--maroon-deep));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.topbar .logo { font-size: 22px; }
.topbar .title { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.topbar .title small { display:block; font-family:'Poppins'; font-size: 10.5px; font-weight: 400; opacity:.8; letter-spacing:2px; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.topbar .presence { font-size: 12px; background: rgba(255,255,255,.16); padding: 5px 10px; border-radius: 999px; display:flex; align-items:center; gap:6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #7CFC9A; box-shadow: 0 0 0 3px rgba(124,252,154,.25); display:inline-block; }
.icon-btn { background: rgba(255,255,255,.14); border: none; color:#fff; width: 38px; height: 38px; border-radius: 12px; font-size: 17px; cursor: pointer; }
@media (max-width: 380px){ .topbar .title { font-size: 17px; } }

.avatar-lg { width:84px; height:84px; border-radius:50%; margin:0 auto; background:linear-gradient(135deg,var(--maroon),var(--rose)); color:#fff; display:grid; place-items:center; font-family:'Playfair Display', serif; font-size:38px; font-weight:700; box-shadow:var(--shadow); border:3px solid #fff; }

.ev-checks { display:flex; flex-direction:column; gap:8px; max-height:230px; overflow-y:auto; padding:4px; }
.ev-check { display:flex; align-items:center; gap:10px; padding:11px 12px; border:1px solid var(--line); border-radius:12px; background:#fff; font-size:14px; cursor:pointer; }
.ev-check input { width:auto; accent-color: var(--maroon); transform: scale(1.15); }
.ev-check:has(input:checked) { border-color: var(--gold); background: var(--blush); }

/* searchable, grouped event picker */
.epick { border:1px solid var(--line); border-radius:12px; background:#fff; overflow:hidden; }
.epick-search { border:none; border-bottom:1px solid var(--line); border-radius:0; padding:11px 13px; font-size:14px; }
.epick-search:focus { box-shadow:none; border-bottom-color: var(--gold); }
.epick-list { max-height:240px; overflow-y:auto; }
.epick-row { display:flex; align-items:center; gap:8px; padding:10px 13px; font-size:14px; cursor:pointer; border-bottom:1px solid #f6ece3; }
.epick-row:last-child { border-bottom:none; }
.epick-row.child { padding-left:30px; font-size:13.5px; color:#5a4a50; background:#fffdf9; }
.epick-row.child:before { content:"↳"; color: var(--gold); margin-right:2px; }
.epick-row.none { color: var(--muted); font-style:italic; }
.epick-row.sel { background: var(--blush); color: var(--maroon); font-weight:600; }
.epick-row .epick-check { margin-left:auto; color: var(--green); font-weight:700; }
.epick-row input[type=checkbox] { width:auto; accent-color: var(--maroon); transform: scale(1.15); }
.epick-row:has(input:checked) { background: var(--blush); }

/* sub-events */
.ev-group { margin-bottom:14px; }
.sub-toggle { margin-top:10px; font-size:12.5px; color: var(--maroon); font-weight:600; cursor:pointer; user-select:none; display:inline-block; }
.sub-list { margin:8px 0 0 18px; padding-left:12px; border-left:2px dashed var(--gold-soft); }
.sub-card { margin-bottom:8px; }
.breadcrumb { font-size:12.5px; color: var(--muted); margin-top:10px; background: var(--blush); border:1px solid var(--line); border-radius:10px; padding:7px 11px; display:inline-block; }

/* ---------- Content ---------- */
.view { padding: 18px; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }
.section-title { font-size: 19px; margin: 4px 0 12px; display:flex; align-items:center; gap:8px; }
.divider { text-align:center; color: var(--gold); margin: 18px 0; letter-spacing: 6px; }

/* ---------- Cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 14px; }
.card.tap { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.card.tap:active { transform: scale(.99); box-shadow: var(--shadow); }

/* Summary hero */
.hero { background: linear-gradient(135deg, #fff, var(--blush)); border:1px solid var(--gold-soft); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; position:relative; overflow:hidden; }
.hero:before { content:"❀"; position:absolute; right:-8px; top:-14px; font-size:90px; color: rgba(200,161,90,.12); }
.hero .big { font-family:'Playfair Display'; font-size: 30px; color: var(--maroon); font-weight:800; }
.hero .label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.stat-row { display:flex; gap: 10px; margin-top: 14px; }
.stat { flex:1; background:#fff; border:1px solid var(--line); border-radius:14px; padding:10px 12px; text-align:center; }
.stat .v { font-weight: 700; font-size: 16px; }
.stat .v.spent { color: var(--green);} .stat .v.pend { color: var(--amber);} .stat .v.est { color: var(--maroon);}
.stat .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.progress { height: 9px; background: #f1e3d8; border-radius: 999px; overflow:hidden; margin-top:12px; }
.progress > span { display:block; height:100%; background: linear-gradient(90deg, var(--gold), var(--rose)); border-radius:999px; }

/* event/expense list rows */
.ev-card { display:flex; gap: 12px; align-items:flex-start; }
.ev-ico { width: 46px; height:46px; border-radius: 13px; background: linear-gradient(135deg, var(--blush), #fff); border:1px solid var(--gold-soft); display:grid; place-items:center; font-size: 22px; flex-shrink:0; }
.ev-main { flex:1; min-width:0; }
.ev-title { font-weight:600; font-size: 15.5px; }
.ev-sub { color: var(--muted); font-size: 12.5px; margin-top:2px; }
.ev-amt { text-align:right; }
.ev-amt .a { font-weight:700; color: var(--maroon); }
.ev-amt .b { font-size: 11px; color: var(--muted); }
.chips { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--blush); color: var(--maroon); border:1px solid var(--line); display:inline-flex; gap:5px; align-items:center;}
.chip.green { background:#e7f5ec; color: var(--green); border-color:#cdebd7;}
.chip.amber { background:#fdf1df; color: var(--amber); border-color:#f6e0bf;}
.chip.priv  { background:#fbe7ea; color: var(--red); border-color:#f3cdd2;}
.chip.gold  { background:#faf2df; color:#8a6a18; border-color: var(--gold-soft);}

.thumbs { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }
.thumbs img { width: 64px; height:64px; object-fit:cover; border-radius:10px; border:1px solid var(--line); }

/* ---------- Buttons / forms ---------- */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; border:none; border-radius: 13px; padding: 12px 16px; font-size: 15px; font-weight: 600; cursor:pointer; font-family:inherit; }
.btn.primary { background: linear-gradient(120deg, var(--maroon), var(--rose)); color:#fff; box-shadow: var(--shadow-sm); }
.btn.gold { background: linear-gradient(120deg, var(--gold), #b88a3a); color:#fff; }
.btn.ghost { background: #fff; color: var(--maroon); border:1px solid var(--gold-soft); }
.btn.danger { background:#fff; color: var(--red); border:1px solid #f0cdcf; }
.btn.block { width:100%; }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius:10px; }

label.field { display:block; margin-bottom: 12px; }
label.field .lab { font-size: 12.5px; color: var(--muted); margin-bottom:5px; display:block; font-weight:500; }
input, select, textarea {
  width:100%; padding: 12px 13px; border:1px solid var(--line); border-radius: 12px; font-size: 15px;
  font-family:inherit; background:#fff; color: var(--ink); outline:none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,161,90,.16); }
textarea { resize: vertical; min-height: 70px; }
.row2 { display:flex; gap:10px; } .row2 > * { flex:1; }
.help { font-size: 11.5px; color: var(--muted); margin-top:4px; }

.toggle { display:flex; align-items:center; gap:10px; padding:12px; border:1px solid var(--line); border-radius:12px; background:#fff; }
.toggle input { width:auto; }
.toggle .warn { font-size: 11.5px; color: var(--red); }

/* ---------- Bottom nav ---------- */
.bottom-nav { position: fixed; bottom: 0; left:50%; transform: translateX(-50%); width:100%; max-width: 600px; display:flex; background: #fff; border-top:1px solid var(--line); box-shadow: 0 -8px 24px rgba(122,31,61,.07); z-index: 40; }
.bottom-nav button { flex:1; background:none; border:none; padding: 9px 0 12px; font-size: 11px; color: var(--muted); cursor:pointer; font-family:inherit; display:flex; flex-direction:column; align-items:center; gap:3px; }
.bottom-nav button .i { font-size: 20px; }
.bottom-nav button.active { color: var(--maroon); font-weight:600; }
.bottom-nav button.active .i { transform: translateY(-1px); filter: drop-shadow(0 3px 5px rgba(122,31,61,.3)); }

/* FAB */
.fab { position: fixed; bottom: 92px; left:50%; transform: translateX(calc(280px - 50%)); width: 56px; height:56px; border-radius:50%; background: linear-gradient(135deg, var(--maroon), var(--rose)); color:#fff; border:none; font-size: 28px; box-shadow: 0 10px 24px rgba(122,31,61,.35); cursor:pointer; z-index: 41; }
@media (max-width: 620px){ .fab { transform:none; right: 18px; left:auto; } }

/* ---------- Modal sheet ---------- */
.scrim { position: fixed; inset:0; background: rgba(59,42,48,.45); z-index: 50; display:flex; align-items:flex-end; justify-content:center; animation: fade .2s; }
.sheet { background: var(--cream); width:100%; max-width:600px; max-height: 92vh; overflow-y:auto; border-radius: 22px 22px 0 0; padding: 18px 18px 30px; box-shadow: var(--shadow); animation: rise .28s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { transform: translateY(40px); opacity:.6;} to {transform:none; opacity:1;} }
.sheet .grip { width:42px; height:5px; background: var(--gold-soft); border-radius:999px; margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 14px; font-size: 21px; color: var(--maroon); }
.sheet-actions { display:flex; gap:10px; margin-top:8px; }

/* canvas scratch pad */
.pad-wrap { border:1px dashed var(--gold); border-radius:12px; background:#fffdf9; padding:8px; }
.pad-tools { display:flex; gap:8px; align-items:center; margin-bottom:8px; flex-wrap:wrap; }
.pad-tools .sw { width:22px; height:22px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 1px var(--line); cursor:pointer; }
canvas.pad { width:100%; height: 180px; background:#fff; border-radius:8px; border:1px solid var(--line); touch-action: none; display:block; }

/* login */
.login-wrap { max-width: 440px; margin: 0 auto; padding: 8vh 22px 22px; text-align:center; }
.login-emblem { font-size: 54px; }
.login-wrap h1 { color: var(--maroon); font-size: 34px; margin: 6px 0 2px; }
.login-wrap .sub { color: var(--muted); margin-bottom: 26px; letter-spacing:.4px; }
.login-card { background:#fff; border:1px solid var(--gold-soft); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); text-align:left; }
.invite-banner { background: linear-gradient(120deg,#fff,var(--blush)); border:1px solid var(--gold-soft); border-radius:14px; padding:12px 14px; margin-bottom:16px; font-size:13.5px; }

/* admin */
.tabs { display:flex; gap:6px; overflow-x:auto; padding-bottom:6px; margin-bottom: 8px; }
.tabs button { white-space:nowrap; border:1px solid var(--line); background:#fff; color:var(--muted); border-radius:999px; padding:7px 14px; font-size:13px; cursor:pointer; font-family:inherit; }
.tabs button.active { background: var(--maroon); color:#fff; border-color: var(--maroon); }
.kv { display:flex; justify-content:space-between; padding:9px 0; border-bottom:1px dashed var(--line); font-size:14px; }
.kv:last-child { border-bottom:none; }
.mono { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.timeline-item { border-left:2px solid var(--gold-soft); padding: 0 0 14px 14px; position:relative; }
.timeline-item:before { content:""; position:absolute; left:-6px; top:3px; width:10px; height:10px; border-radius:50%; background: var(--gold); }
.timeline-item .t-act { font-weight:600; font-size:13.5px; }
.timeline-item .t-meta { font-size:11.5px; color: var(--muted); }
.badge { font-size:10.5px; padding:2px 8px; border-radius:999px; background:var(--blush); color:var(--maroon); border:1px solid var(--line); }
.badge.role { background:#faf2df; color:#8a6a18; }
.badge.on { background:#e7f5ec; color:var(--green); }
.badge.off { background:#f3ecee; color:var(--muted); }

.empty { text-align:center; color: var(--muted); padding: 40px 16px; }
.empty .e-ico { font-size: 44px; opacity:.5; }

/* toast */
#toast { position: fixed; top: 16px; left:50%; transform: translateX(-50%); z-index: 100; display:flex; flex-direction:column; gap:8px; width: calc(100% - 36px); max-width: 420px; }
.toast { background: var(--ink); color:#fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size:14px; animation: fade .2s; }
.toast.ok { background: var(--green);} .toast.err { background: var(--red);} .toast.info{background: var(--maroon);}

.hidden { display:none !important; }
.center { text-align:center; }
.spin { width:34px;height:34px;border:3px solid var(--gold-soft); border-top-color: var(--maroon); border-radius:50%; animation: rot 1s linear infinite; margin: 40px auto; }
@keyframes rot { to { transform: rotate(360deg);} }
