:root {
  --bg: #f5f4fb; --card: #fff; --ink: #17142b; --muted: #6c6889; --line: #e7e4f3;
  --pink: #ff4d8d; --violet: #7b5cff; --mint: #2fd4ad; --red: #e5484d;
  --grad: linear-gradient(135deg, var(--pink), var(--violet));
  --pink-rgb: 255, 77, 141; --violet-rgb: 123, 92, 255;
  --brand-text: #fff; --brand-bg: #0b0a14; --on-accent: #fff;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Poppins, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--violet); }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; margin-top: 1.4em; }
code { background: #f0eefa; padding: 2px 7px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .right { text-align: right; } .center { text-align: center; }
[hidden] { display: none !important; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: .7em 1.2em; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .1s, box-shadow .2s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--grad); color: var(--on-accent); box-shadow: 0 6px 18px -6px rgba(var(--violet-rgb), .6); }
.btn-accent { background: #17142b; color: #fff; }
.btn-ghost { background: #efedf8; color: var(--ink); }
.btn-danger { background: #fdecec; color: var(--red); }
.btn-sm { padding: .4em .8em; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: .95em 1.3em; font-size: 1.05rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.btn-row form { margin: 0; }
label { display: block; font-size: .85rem; font-weight: 500; color: var(--muted); margin-bottom: .9rem; }
label.check { display: flex; align-items: center; gap: .5em; color: var(--ink); }
input:not([type=checkbox]):not([type=file]) { display: block; width: 100%; margin-top: .3rem; padding: .7em .85em; font: inherit; color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: 10px; outline: none; transition: border-color .2s; }
input:focus { border-color: var(--violet); }
.grid-form { display: grid; grid-template-columns: 2fr 1.3fr 1fr auto; gap: .8rem; align-items: end; }
.grid-form label { margin: 0; }
.grid-form-2 { grid-template-columns: 1fr auto; }

/* Flash */
.flash { padding: .75em 1em; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.flash-ok { background: #e6faf4; color: #0b7a5b; }
.flash-err { background: #fdecec; color: #b42328; }

/* Auth */
body.auth { min-height: 100vh; display: grid; place-items: center; background: var(--grad); padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 32px 28px; box-shadow: 0 30px 60px -20px rgba(23, 20, 43, .45); }
.auth-card h1 { font-size: 1.5rem; }
.brand { font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: .5em; margin-bottom: 1rem; }
.auth-card .brand { color: var(--violet); }

/* App shell */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 14px 24px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .brand { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: .8rem; }
.back { text-decoration: none; color: var(--ink); font-size: 1.3rem; }
.tag { font-size: .75rem; font-weight: 600; background: #efedf8; color: var(--violet); padding: 3px 10px; border-radius: 99px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.section-title { margin: 8px 0 14px; }
.count { font-size: .75rem; background: #efedf8; color: var(--muted); padding: 2px 9px; border-radius: 99px; vertical-align: middle; }
.pill { font-size: .72rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; }
.pill-on { background: #e6faf4; color: #0b7a5b; } .pill-off { background: #f1f0f5; color: var(--muted); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.pop { position: relative; display: inline-block; text-align: left; }
.pop summary { list-style: none; } .pop summary::-webkit-details-marker { display: none; }
.pop-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; width: 290px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: 0 20px 40px -12px rgba(23, 20, 43, .25); display: grid; gap: 8px; }
.pop-body form { margin: 0; }

/* Events */
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.event-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--ink); transition: transform .15s, box-shadow .2s; }
.event-card:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -14px rgba(123, 92, 255, .45); }
.event-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.event-card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.event-card-stat { color: var(--muted); } .event-card-stat strong { color: var(--ink); font-size: 1.3rem; }
.event-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; }
.event-layout .card { margin-bottom: 20px; }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 12px; }
.qr-box svg { display: block; width: 100%; height: auto; }
.qr-url { margin-bottom: 12px; } .qr-url input { font-size: .82rem; background: #faf9fe; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.stats div { background: #faf9fe; border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stats strong { display: block; font-size: 1.5rem; } .stats span { font-size: .78rem; color: var(--muted); }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.mod-item { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.mod-item img { display: block; width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.mod-item.is-hidden img { opacity: .3; filter: grayscale(1); }
.mod-meta { font-size: .75rem; color: var(--muted); padding: 6px 8px 0; }
.mod-actions { display: flex; gap: 6px; padding: 6px 8px 8px; }
.mod-actions form { margin: 0; flex: 1; } .mod-actions .btn { width: 100%; }

@media (max-width: 860px) {
  .grid-form, .grid-form-2 { grid-template-columns: 1fr; }
  .event-layout { grid-template-columns: 1fr; }
  .wrap { padding: 16px; } .topbar { padding: 12px 16px; }
}

/* ---------- Guest (mobile) ---------- */
body.guest { min-height: 100vh; min-height: 100dvh; background: radial-gradient(120% 80% at 0% 0%, rgba(var(--pink-rgb), .9) 0%, transparent 55%), radial-gradient(120% 80% at 100% 100%, rgba(var(--violet-rgb), .9) 0%, transparent 55%), var(--brand-bg); color: var(--brand-text); }
.guest-wrap { max-width: 460px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 18px 28px; }
.guest-head { text-align: center; margin: 6px 0 18px; }
.brand-sm { font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.guest-head h1 { font-size: 1.5rem; margin: .3em 0 0; }
.guest-logo { display: block; max-height: 64px; max-width: 70%; margin: 0 auto 6px; object-fit: contain; }
.guest-card { background: rgba(255, 255, 255, .97); color: var(--ink); border-radius: 24px; padding: 28px 22px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5); animation: rise .45s cubic-bezier(.2, .9, .3, 1.2); }
.guest-card h2 { font-size: 1.45rem; margin-top: .4em; }
.guest-card .btn-block { margin-top: 12px; }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.btn label, label.btn { position: relative; color: inherit; margin: 0; font-size: inherit; }
label.btn-primary { color: var(--on-accent); } label.btn-ghost { color: var(--ink); }
.link-btn { position: relative; display: inline-block; margin: 16px 0 0; color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: underline; text-decoration-color: var(--pink); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.cam-ring { width: 120px; height: 120px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; font-size: 54px; background: var(--grad); box-shadow: 0 0 0 10px rgba(var(--pink-rgb), .12), 0 0 0 22px rgba(var(--violet-rgb), .08); animation: pulse 2.2s ease-in-out infinite; }
.big-emoji { font-size: 56px; }
.preview-frame { border-radius: 18px; overflow: hidden; background: #eee; aspect-ratio: 3/4; margin-bottom: 14px; }
.preview-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.btn-row-2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.progress { height: 8px; background: #efedf8; border-radius: 99px; overflow: hidden; margin: 4px 0 12px; }
.progress div { height: 100%; width: 0; background: var(--grad); transition: width .2s; }
.err { color: var(--red); font-weight: 500; margin: 0 0 12px; }
.done-badge { font-size: 60px; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
.done-thumb { width: 150px; margin: 6px auto 10px; transform: rotate(-3deg); background: #fff; padding: 8px 8px 26px; border-radius: 6px; box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .35); }
.done-thumb img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; border-radius: 2px; }

@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }
@keyframes pulse { 50% { transform: scale(1.05); } }
@keyframes pop { from { transform: scale(0); } }

/* ---------- Big screen ---------- */
body.screen { background: var(--brand-bg); color: var(--brand-text); overflow: hidden; height: 100vh; }
#stage { position: fixed; inset: 0; display: flex; flex-direction: column; }
#wall { position: relative; flex: 1; margin: 8px 8px 0; }
.tile { position: absolute; background: rgba(128, 128, 128, .18) center/cover no-repeat; border-radius: 6px; transition: left .7s cubic-bezier(.65, 0, .35, 1), top .7s cubic-bezier(.65, 0, .35, 1), width .7s cubic-bezier(.65, 0, .35, 1), height .7s cubic-bezier(.65, 0, .35, 1), opacity .4s, box-shadow .6s; }
.tile-pending { opacity: 0; }
.tile-out { opacity: 0; transform: scale(.8); transition: opacity .35s, transform .35s; }
.tile-fresh { z-index: 2; box-shadow: 0 0 0 3px #fff, 0 0 0 7px var(--pink), 0 0 40px 10px rgba(var(--pink-rgb), .7); animation: freshPulse 1.2s ease-in-out 4; }
@keyframes freshPulse { 50% { box-shadow: 0 0 0 3px #fff, 0 0 0 7px var(--violet), 0 0 60px 16px rgba(var(--violet-rgb), .8); } }

#bar { height: 13vh; min-height: 84px; display: flex; justify-content: space-between; align-items: center; padding: 0 2.2vw; gap: 2vw; }
.bar-left { display: flex; align-items: center; gap: 1.2vw; min-width: 0; }
.bar-dot { width: 14px; height: 14px; border-radius: 50%; background: #3ee6c1; box-shadow: 0 0 12px #3ee6c1; flex: none; animation: pulse 2s infinite; }
body.offline .bar-dot { background: var(--red); box-shadow: 0 0 12px var(--red); }
.bar-logo { height: 7vh; max-width: 18vw; object-fit: contain; flex: none; }
.bar-name { font-weight: 700; font-size: clamp(20px, 2.6vw, 54px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--brand-text); }
.bar-count { font-size: clamp(14px, 1.3vw, 26px); color: var(--brand-text); opacity: .65; white-space: nowrap; }
.bar-right { display: flex; align-items: center; gap: 1vw; flex: none; }
.bar-cta { text-align: right; font-size: clamp(13px, 1.2vw, 24px); color: var(--brand-text); line-height: 1.25; }
.bar-cta strong { color: var(--pink); font-size: 1.25em; }
.bar-qr { height: 11vh; min-height: 72px; aspect-ratio: 1; }
.qr-white { background: #fff; border-radius: 10px; padding: 4px; }
.qr-white svg { display: block; width: 100%; height: 100%; }

.empty { position: absolute; inset: 0 0 13vh; display: flex; align-items: center; justify-content: center; gap: 5vw; padding: 4vw; }
.empty-qr { width: min(40vh, 34vw); aspect-ratio: 1; padding: 1.4vh; border-radius: 22px; box-shadow: 0 0 0 10px rgba(var(--pink-rgb), .25), 0 0 80px 10px rgba(var(--violet-rgb), .45); animation: pulse 2.6s ease-in-out infinite; }
.empty-kicker { font-size: clamp(16px, 1.6vw, 32px); color: var(--pink); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.empty-logo { display: block; max-height: 14vh; max-width: 30vw; object-fit: contain; margin-bottom: 3vh; }
.empty h1 { font-size: clamp(32px, 4.6vw, 96px); margin: .2em 0 .3em; color: var(--brand-text); }
.empty p { font-size: clamp(18px, 2vw, 40px); color: var(--brand-text); opacity: .75; margin: 0; }
#empty ~ #bar .bar-right { visibility: visible; }

.spot { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(8, 6, 18, 0); transition: background .5s; }
.spot.show { background: rgba(8, 6, 18, .82); backdrop-filter: blur(6px); }
.spot.leaving { background: rgba(8, 6, 18, 0); backdrop-filter: none; }
#confetti { position: absolute; inset: 0; pointer-events: none; }
.spot-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3vh; }
.spot-photo { height: 64vh; aspect-ratio: 3/4; border-radius: 18px; padding: 8px; background: conic-gradient(from var(--a, 0deg), var(--pink), #fff, var(--violet), var(--pink)); animation: spin 3s linear infinite; box-shadow: 0 30px 80px -10px rgba(var(--pink-rgb), .6); }
.spot.show:not(.leaving) .spot-photo { animation: spin 3s linear infinite, zoomIn .7s cubic-bezier(.2, 1.4, .4, 1); }
.spot-photo img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 12px; }
.spot-text { text-align: center; transition: opacity .3s; }
.spot.leaving .spot-text { opacity: 0; }
.spot-hey { font-size: clamp(36px, 5vw, 110px); font-weight: 800; line-height: 1; background: linear-gradient(90deg, var(--pink), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; animation: bounceIn .8s .15s both cubic-bezier(.2, 1.6, .4, 1); }
.spot-msg { color: #fff; font-size: clamp(20px, 2.6vw, 56px); font-weight: 600; margin-top: .3em; animation: bounceIn .8s .35s both cubic-bezier(.2, 1.6, .4, 1); }
.wave { display: inline-block; -webkit-text-fill-color: initial; animation: wave 1s ease-in-out infinite; transform-origin: 70% 70%; }
.cam { display: inline-block; animation: wave 1.2s ease-in-out infinite; }
@property --a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes spin { to { --a: 360deg; } }
@keyframes zoomIn { from { transform: scale(.2) rotate(-12deg); opacity: 0; } }
@keyframes bounceIn { from { transform: translateY(40px) scale(.6); opacity: 0; } }
@keyframes wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(18deg); } 75% { transform: rotate(-12deg); } }

.fs-btn { position: fixed; top: 16px; right: 16px; z-index: 60; background: rgba(128, 128, 128, .25); color: var(--brand-text); border: 1px solid rgba(128, 128, 128, .35); border-radius: 10px; padding: 10px 16px; font: 600 14px Poppins, sans-serif; cursor: pointer; transition: opacity .4s; backdrop-filter: blur(6px); }
body.idle { cursor: none; } body.idle .fs-btn { opacity: 0; pointer-events: none; }

/* ---------- Branding panel ---------- */
.brand-layout { display: grid; grid-template-columns: 1fr 320px; gap: 28px; align-items: start; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.preset { display: inline-flex; align-items: center; gap: 8px; font: 500 .8rem Poppins, sans-serif; background: #faf9fe; border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px 5px 5px; cursor: pointer; color: var(--ink); }
.preset:hover { border-color: var(--violet); }
.preset span { width: 22px; height: 22px; border-radius: 50%; }
.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.color-field { margin: 0; }
.color-field > span { display: flex; align-items: center; gap: 8px; margin-top: .3rem; border: 1.5px solid var(--line); border-radius: 10px; padding: 5px; background: #fff; }
.color-field input[type=color] { width: 36px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; flex: none; }
.color-field code { background: none; padding: 0; font-size: .8rem; color: var(--ink); }
.brand-preview { --p: #ff4d8d; --s: #7b5cff; --t: #fff; --b: #0b0a14; --on: #fff; display: grid; gap: 10px; }
.bp-screen { position: relative; aspect-ratio: 16/9; background: var(--b); border-radius: 12px; overflow: hidden; padding: 6px; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .4); }
.bp-tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; height: 70%; }
.bp-tiles i { background: rgba(128, 128, 128, .25); border-radius: 3px; }
.bp-tiles .bp-fresh { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--p), 0 0 14px var(--p); }
.bp-bar { display: flex; align-items: center; gap: 8px; height: 30%; padding: 0 6px; }
.bp-bar img { height: 60%; max-width: 40%; object-fit: contain; }
.bp-name { color: var(--t); font-weight: 700; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-hey { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 1.6rem; background: linear-gradient(90deg, var(--p), var(--s)); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; }
.bp-btn { text-align: center; font-weight: 600; padding: .7em; border-radius: 12px; background: linear-gradient(135deg, var(--p), var(--s)); color: var(--on); }
@media (max-width: 860px) { .brand-layout { grid-template-columns: 1fr; } .color-grid { grid-template-columns: 1fr 1fr; } }
