:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f1f3f6; --text: #0f172a; --muted: #64748b;
  --line: #e2e8f0; --accent: #f97316; --accent-ink: #ffffff; --ok: #16a34a; --info: #2563eb; --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px -12px rgba(15,23,42,.18);
  --radius: 16px; --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #121a2b; --surface-2: #1a2438; --text: #e5e7eb; --muted: #94a3b8;
    --line: #243044; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.7);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif; }
a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.01em; color: var(--text); text-decoration: none; font-size: 18px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
#topbar-right { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }

/* layout */
.app { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
.loading { color: var(--muted); text-align: center; padding: 40px; }
h1 { font-size: 24px; margin: 8px 0 16px; letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 24px 0 10px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.meta { color: var(--muted); font-size: 14px; margin: 4px 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.card.cancelled { opacity: .6; }
.session-card { display: grid; grid-template-columns: 64px 1fr; gap: 14px; cursor: pointer; }
.datebox { text-align: center; background: var(--surface-2); border-radius: 12px; padding: 8px 4px; align-self: start; }
.datebox .d { font-size: 26px; font-weight: 800; line-height: 1; }
.datebox .m { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.datebox .w { font-size: 11px; color: var(--muted); }
.title { font-weight: 700; font-size: 17px; margin: 0; }
.price { font-weight: 800; font-size: 20px; color: var(--accent); white-space: nowrap; }
.price small { font-weight: 500; font-size: 12px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.chip.going { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chip.interested { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.chip.declined { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.chip.warn { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.badge-cancel { color: var(--danger); font-weight: 700; font-size: 13px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; transition: transform .05s, background .15s; min-height: 44px; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 14px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.going.primary { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.interested.primary { background: var(--info); border-color: var(--info); color: #fff; }
.btn.declined.primary { background: var(--muted); border-color: var(--muted); color: #fff; }
.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segment .btn { padding: 10px 6px; font-size: 14px; }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
input, select, textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); outline: none; min-height: 44px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text); font-weight: 500; }
.check input { width: 20px; height: 20px; min-height: 0; }
.alert { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 12px 14px; border-radius: 12px; font-weight: 600; margin: 10px 0; }
.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); padding: 12px 14px; border-radius: 12px; font-weight: 600; margin: 10px 0; }

/* participants */
.plist { list-style: none; padding: 0; margin: 0; }
.plist li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; margin-right: 10px; }

/* bottom nav */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line); z-index: 10; }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.bottomnav a .ic { font-size: 20px; }
.bottomnav a.active { color: var(--accent); }
@media (min-width: 720px) { .bottomnav { max-width: 720px; left: 50%; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; } }

/* auth */
.auth { max-width: 400px; margin: 40px auto; }
.auth .logo { font-size: 40px; text-align: center; margin-bottom: 8px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 20; box-shadow: var(--shadow); max-width: 90vw; }

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat.going b { color: var(--ok); } .stat.interested b { color: var(--info); } .stat.declined b { color: var(--danger); }
.pricebox { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, var(--surface)), var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.pricebox .big { font-size: 34px; font-weight: 800; color: var(--accent); line-height: 1; }

/* rsvp standalone page */
.rsvp-body { padding: 24px 16px; }
.rsvp-card { max-width: 440px; margin: 24px auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.rsvp-card h1 { margin-top: 0; }

/* panel */
.grp { border-top: 1px solid var(--line); padding: 8px 0; }
.grp summary { cursor: pointer; list-style: none; display: flex; align-items: center; }
.grp summary::-webkit-details-marker { display: none; }
.plist.compact li { padding: 6px 0; font-size: 14px; }
.title a { color: inherit; text-decoration: none; }

.bulkbar { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; box-shadow: var(--shadow); }
.pick { width: 22px; height: 22px; min-height: 0; margin: 4px 10px 0 0; accent-color: var(--accent); }

.check.small { font-size: 13px; color: var(--muted); gap: 6px; }
.check.small input { width: 16px; height: 16px; }
.segment.two { grid-template-columns: 1fr 1fr; }

.qr { width: 200px; height: 200px; background: #fff; border-radius: 12px; padding: 8px; }
.secret { display: inline-block; font-family: ui-monospace, monospace; font-size: 13px; background: var(--surface-2); padding: 6px 10px; border-radius: 8px; word-break: break-all; user-select: all; }
.codes { font-family: ui-monospace, monospace; font-size: 15px; line-height: 1.7; background: var(--surface-2); padding: 12px; border-radius: 10px; user-select: all; margin: 0; }
.grow { flex: 1; min-width: 140px; }

/* utility */
.tc { text-align: center; } .mb16 { margin-bottom: 16px; } .mt12 { margin-top: 12px; } .mt8 { margin-top: 8px; } .mt0 { margin-top: 0; }
.my12 { margin: 12px 0; } .prewrap { white-space: pre-line; } .muted { color: var(--muted); } .full { width: 100%; } .top { align-items: flex-start; }
