/* EventPix — mobile-first stylesheet.
 * Base rules target small screens (phones); @media (min-width: …) rules
 * progressively enhance for tablets and desktops. */

:root {
  --bg: #0d1017;
  --bg-2: #12161f;
  --card: #171c28;
  --card-2: #1d2332;
  --border: #262d3f;
  --text: #e7eaf3;
  --text-dim: #9aa3b8;
  --text-faint: #6b7280;
  --accent: #6366f1;
  --accent-2: #a855f7;
  --grad: linear-gradient(135deg, #6366f1, #a855f7);
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --tap: 44px; /* minimum touch target */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-size: 16px;
  overflow-wrap: break-word;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
a, button { -webkit-tap-highlight-color: transparent; }
input, textarea, select { font: inherit; color: var(--text); }

/* ---------- layout ---------- */
.container { width: 100%; padding: 0 1rem; margin: 0 auto; flex: 1; }
@media (min-width: 1120px) {
  .container { width: min(1080px, 100% - 2rem); padding: 0; }
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; row-gap: 0.4rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 16, 23, 0.9);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 40;
}
@media (min-width: 640px) {
  .topbar { padding: 0.9rem 1.25rem; background: rgba(13, 16, 23, 0.85); }
}
.brand { display: flex; align-items: center; gap: 0.45rem; font-weight: 700; font-size: 1.05rem; min-height: var(--tap); }
.brand-mark { font-size: 1.2rem; display: inline-flex; align-items: center; color: var(--accent); }

/* inline SVG icons — size with the surrounding font, tint with currentColor */
svg.ic {
  width: 1em; height: 1em; vertical-align: -0.125em;
  display: inline-block; flex-shrink: 0;
}
.btn svg.ic, .chip svg.ic, .cam-event-sub svg.ic { margin-right: 0.3em; }
.tile-kind svg.ic { width: 13px; height: 13px; vertical-align: 0; }
.brand-name { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.nav { display: flex; align-items: center; gap: 0.2rem; flex-wrap: wrap; }
.nav a, .nav button.navbtn {
  padding: 0.45rem 0.7rem; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 600; font-size: 0.9rem;
  background: none; border: none; min-height: var(--tap);
  display: inline-flex; align-items: center;
}
.nav a:hover, .nav button.navbtn:hover { color: var(--text); background: var(--card-2); }
.nav a.active { color: var(--text); background: var(--card-2); }
@media (min-width: 640px) {
  .nav { gap: 0.35rem; }
  .nav a, .nav button.navbtn { padding: 0.45rem 0.85rem; font-size: 0.92rem; }
}

/* profile icon in the top bar + the account panel it opens */
.nav-profile-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); font-size: 1.15rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, transform 0.05s;
}
.nav-profile-btn:hover { border-color: var(--accent); color: #fff; }
.nav-profile-btn:active { transform: translateY(1px); }
.nav-avatar {
  width: 28px; height: 28px; border-radius: 50%; font-size: 0.85rem; font-weight: 700;
  background: var(--grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-avatar.big { width: 46px; height: 46px; font-size: 1.2rem; }

.nav-panel {
  position: absolute; top: calc(100% + 8px); right: 0.6rem; z-index: 60;
  width: min(92vw, 380px); max-height: min(78vh, 560px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.nav-panel[hidden] { display: none; }
.nav-panel-body { padding: 1rem; }
.nav-me { display: flex; align-items: center; gap: 0.8rem; padding-bottom: 0.9rem; border-bottom: 1px solid var(--border); margin-bottom: 0.7rem; }
.nav-me-email { font-weight: 700; word-break: break-all; }
.nav-events { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.8rem; }
.nav-event {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-2); transition: border-color 0.15s;
}
.nav-event:hover { border-color: var(--accent); }
.nav-event-main { min-width: 0; }
.nav-event-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-event-arrow { color: var(--text-dim); flex-shrink: 0; }
.nav-actions { display: flex; flex-direction: column; gap: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.8rem; }
.nav-panel .auth-card { max-width: none; padding-top: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.6rem 1.15rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.95rem; border: 1px solid transparent;
  background: var(--card-2); color: var(--text);
  min-height: var(--tap);
  transition: filter 0.15s, transform 0.05s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-danger { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.22); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; min-height: 38px; }
.btn-block { width: 100%; }
.btn-lg { padding: 0.85rem 1.5rem; font-size: 1.05rem; border-radius: 12px; min-height: 52px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px; border: none;
  background: var(--card-2); color: var(--text-dim); font-size: 1rem;
}
.icon-btn:hover { color: var(--text); background: #252c3d; }
.icon-btn.danger:hover { color: #fca5a5; background: rgba(239,68,68,.15); }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.15rem; margin-bottom: 0.4rem; }
.card .sub { color: var(--text-dim); font-size: 0.9rem; }
@media (min-width: 640px) {
  .card { padding: 1.4rem; }
}

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; gap: 1.25rem; } }
@media (min-width: 860px) { .grid-3 { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; } }

/* ---------- forms ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-dim); margin-bottom: 0.35rem; }
.field input, .field textarea, .field select {
  width: 100%; padding: 0.65rem 0.85rem;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); outline: none; min-height: var(--tap);
  font-size: 16px; /* prevents iOS zoom-on-focus */
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 84px; }

/* ---------- landing / marketing ---------- */
.hero { padding: 2.2rem 0 0; }
.hero-inner {
  display: grid; grid-template-columns: 1fr; gap: 2.2rem; align-items: center;
}
@media (min-width: 960px) {
  .hero-inner { grid-template-columns: 1.1fr 0.9fr; gap: 3rem; padding: 1rem 0 2rem; }
}
.hero-copy { text-align: center; }
@media (min-width: 960px) { .hero-copy { text-align: left; } }

.hero-badge {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: rgba(99,102,241,.12); border: 1px solid rgba(99,102,241,.4);
  color: #c7c9ff; font-size: 0.82rem; font-weight: 600;
  padding: 0.35rem 0.9rem; border-radius: 999px; margin-bottom: 1.1rem;
}
.hero h1 { font-size: clamp(2rem, 6.5vw, 3.6rem); font-weight: 800; line-height: 1.12; letter-spacing: -0.02em; }
.hero h1 .accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--text-dim); font-size: 1.05rem; max-width: 560px; margin: 1rem auto 1.6rem; }
@media (min-width: 960px) { .hero-sub { margin: 1.1rem 0 1.7rem; } }

.hero-cta { display: flex; flex-direction: column; gap: 0.8rem; align-items: stretch; }
.hero-cta .btn-lg { width: 100%; }
@media (min-width: 640px) {
  .hero-cta { flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: center; }
  .hero-cta .btn-lg { width: auto; }
}
@media (min-width: 960px) { .hero-cta { justify-content: flex-start; } }

.hero-trust { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 1.1rem; font-size: 0.85rem; color: var(--text-dim); }
.hero-trust span { display: inline-flex; align-items: center; gap: 0.4rem; }
.hero-trust svg.ic { color: var(--green); }
@media (min-width: 640px) { .hero-trust { flex-direction: row; gap: 1.4rem; justify-content: center; } }
@media (min-width: 960px) { .hero-trust { justify-content: flex-start; } }

/* enter-code box (hero + split) */
.scan-input { display: flex; gap: 0.5rem; max-width: 100%; }
.scan-input input {
  flex: 1; min-width: 0; padding: 0.7rem 0.9rem; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
  text-transform: uppercase; letter-spacing: 0.12em; text-align: center; outline: none;
  font-size: 16px;
}
.scan-input input:focus { border-color: var(--accent); }
@media (min-width: 640px) { .scan-input { max-width: 380px; } }

/* phone mockup */
.hero-visual { display: flex; flex-direction: column; align-items: center; gap: 1rem; position: relative; }
.phone {
  width: 260px; border-radius: 40px; padding: 10px;
  background: linear-gradient(160deg, #232a3b, #141926);
  border: 1px solid var(--border); box-shadow: 0 30px 60px rgba(0,0,0,.45);
}
@media (min-width: 640px) { .phone { width: 280px; } }
.phone-notch { width: 90px; height: 18px; border-radius: 0 0 12px 12px; background: #0a0d14; margin: 0 auto 8px; }
.phone-screen { border-radius: 30px; overflow: hidden; background: #000; aspect-ratio: 9/19; display: flex; flex-direction: column; }
.p-top { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; padding: 0.7rem 0.75rem 0.4rem; }
.p-avatar, .p-flash {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3);
  background: rgba(0,0,0,.5); color: #fff; font-size: 0.7rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.p-event { color: #fff; font-size: 0.68rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-stage {
  flex: 1; position: relative; margin: 0 6px 6px; border-radius: 14px; overflow: hidden;
  background: linear-gradient(#6fb6ff, #b8d9ff 40%, #7fb06b 75%, #4a7a44);
}
.p-scene { position: absolute; inset: 0; }
.p-sun { position: absolute; top: 14%; right: 16%; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle, #fff8c9, #ffd76e 70%); }
.p-hill { position: absolute; border-radius: 50% 50% 0 0; }
.p-h1 { bottom: -18%; left: -10%; width: 130%; height: 52%; background: linear-gradient(#6da45c, #3f6b38); }
.p-h2 { bottom: -22%; right: -14%; width: 120%; height: 48%; background: linear-gradient(#58894a, #34592f); }
.p-timer {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.62rem; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.55); padding: 0.25rem 0.6rem; border-radius: 999px;
}
.p-pill {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.6rem; font-weight: 600;
  color: #fcd34d; background: rgba(13,16,23,.8); border: 1px solid rgba(245,158,11,.5);
  padding: 0.22rem 0.55rem; border-radius: 999px; white-space: nowrap;
}
.p-bottom { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.9rem 0.75rem; }
.p-badge { position: relative; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; }
.p-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.p-ring .ring-bg { fill: none; stroke: rgba(255,255,255,.25); stroke-width: 3; }
.p-ring .ring-fg { fill: none; stroke: #fcd34d; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100.53; stroke-dashoffset: 100.53; }
.p-badge b { font-size: 0.55rem; color: #fff; }
.p-shutter { width: 46px; height: 46px; border-radius: 50%; border: 3px solid #fff; background: var(--red); }
.p-tool {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3);
  background: rgba(0,0,0,.5); color: #fff; font-size: 0.75rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.hero-float {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.4); color: #86efac;
  font-size: 0.8rem; font-weight: 600; padding: 0.4rem 0.9rem; border-radius: 999px;
}

/* stats band */
.stats-strip {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin: 2.5rem 0 0;
}
@media (min-width: 800px) { .stats-strip { grid-template-columns: repeat(4, 1fr); } }
.stats-strip .stat { background: var(--card); padding: 1.1rem 0.8rem; text-align: center; }
.stat-num { font-size: 1.6rem; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-lbl { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.15rem; }

/* sections */
.section { padding: 3rem 0 1rem; }
@media (min-width: 800px) { .section { padding: 4rem 0 1.5rem; } }
.section-title { font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 800; text-align: center; letter-spacing: -0.01em; }
.section-sub { text-align: center; color: var(--text-dim); margin: 0.5rem auto 1.6rem; max-width: 520px; }

.steps { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 800px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; } }
.step { text-align: center; padding: 1.4rem 1rem; }
.step-num {
  width: 46px; height: 46px; margin: 0 auto 0.8rem; border-radius: 50%;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
}
.step h3 { margin-bottom: 0.35rem; }
.step p { color: var(--text-dim); font-size: 0.92rem; }

/* features */
.features-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .features-grid { grid-template-columns: repeat(2, 1fr); gap: 1.1rem; } }
@media (min-width: 960px) { .features-grid { grid-template-columns: repeat(3, 1fr); } }
.feature { padding: 1.2rem 1.1rem; }
.feature-icon {
  width: 46px; height: 46px; border-radius: 12px; margin-bottom: 0.8rem;
  background: rgba(99,102,241,.14); border: 1px solid rgba(99,102,241,.35); color: #a5b4fc;
  font-size: 1.3rem; display: inline-flex; align-items: center; justify-content: center;
}
.feature h3 { font-size: 1.05rem; margin-bottom: 0.35rem; }
.feature p { color: var(--text-dim); font-size: 0.9rem; }

/* hosts vs guests */
.split { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 800px) { .split { grid-template-columns: 1fr 1fr; gap: 1.25rem; } }
.split-card { padding: 1.4rem 1.2rem; }
.split-card h3 { margin-bottom: 0.8rem; }
.split-card .scan-input { margin-top: 1rem; }
.split-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.1rem; }
.split-list li { display: flex; align-items: center; gap: 0.5rem; color: var(--text-dim); font-size: 0.93rem; }
.split-list svg.ic { color: var(--green); flex-shrink: 0; }

/* closing CTA */
.cta-band {
  margin: 3.5rem 0 1rem; padding: 2.6rem 1.5rem; text-align: center;
  background: linear-gradient(135deg, rgba(99,102,241,.16), rgba(168,85,247,.14));
  border: 1px solid var(--border); border-radius: var(--radius);
}
.cta-band h2 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; }
.cta-band p { color: var(--text-dim); margin: 0.5rem auto 1.4rem; max-width: 440px; }

/* ---------- guest QR landing (desktop) ---------- */
.desktop-qr {
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem 1rem 3rem; min-height: calc(100vh - 8rem);
}
.qr-card {
  max-width: 460px; width: 100%; text-align: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem 1.5rem; box-shadow: var(--shadow);
}
.qr-icon { font-size: 2.4rem; color: var(--accent-2); }
.qr-card h2 { margin: 0.6rem 0 0.4rem; }
.qr-card .muted { margin-bottom: 1.2rem; }
.qr-big svg { width: min(240px, 70vw); height: auto; background: #fff; border-radius: 14px; padding: 10px; margin: 0 auto 1.2rem; display: block; }
.qr-url {
  display: block; margin: 0.5rem auto 1.2rem; padding: 0.5rem 0.75rem;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.8rem; color: var(--text-dim); word-break: break-all;
}

/* ---------- auth ---------- */
.auth-wrap { max-width: 420px; margin: 2.5rem auto; padding: 0 0.25rem; }
@media (min-width: 640px) { .auth-wrap { margin: 4rem auto; } }
.auth-switch { text-align: center; margin-top: 1.2rem; color: var(--text-dim); font-size: 0.93rem; }
.auth-switch a { color: var(--accent-2); font-weight: 600; }

/* ---------- dashboard ---------- */
.page-head { display: flex; flex-direction: column; align-items: stretch; gap: 0.8rem; margin: 1.5rem 0 1.25rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 800; }
.page-head .btn { width: 100%; }
@media (min-width: 640px) {
  .page-head { flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; margin: 2rem 0 1.4rem; }
  .page-head h1 { font-size: 1.6rem; }
  .page-head .btn { width: auto; }
}

.event-card { display: flex; flex-direction: column; align-items: stretch; gap: 0.9rem; padding: 1.1rem; margin-bottom: 0.9rem; }
@media (min-width: 640px) {
  .event-card { flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.3rem; }
}
.event-main { flex: 1; min-width: 0; }
.event-main h3 { font-size: 1.08rem; }
.event-meta { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.2rem; line-height: 1.9; }
.event-meta .chip { display: inline-block; margin-right: 0.4rem; }
.event-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.event-actions .btn { width: 100%; }
@media (min-width: 640px) {
  .event-actions { display: flex; gap: 0.45rem; }
  .event-actions .btn { width: auto; }
}
.empty-state { text-align: center; color: var(--text-dim); padding: 2.5rem 1rem; }
@media (min-width: 640px) { .empty-state { padding: 3rem 1rem; } }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.78rem; color: var(--text-dim);
  white-space: nowrap;
}
.chip.green { color: #86efac; border-color: rgba(34,197,94,.35); background: rgba(34,197,94,.08); }
.chip.red { color: #fca5a5; border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.08); }

/* ---------- event detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; align-items: start; }
@media (min-width: 900px) {
  .detail-grid { grid-template-columns: 300px 1fr; }
  .detail-grid.guest-grid { grid-template-columns: 1fr 1fr; }
}

.qr-box { text-align: center; }
.qr-box svg { width: 100%; max-width: 200px; height: auto; background: #fff; border-radius: 12px; padding: 8px; }
@media (min-width: 640px) { .qr-box svg { max-width: 240px; } }
.qr-link { display: block; margin: 0.8rem auto 1rem; font-size: 0.85rem; color: var(--text-dim); word-break: break-all; }

.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-bottom: 1.25rem; }
@media (min-width: 700px) { .stat-row { grid-template-columns: repeat(4, 1fr); gap: 0.75rem; } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.85rem 1rem; text-align: center; }
.stat .num { font-size: 1.5rem; font-weight: 800; }
.stat .lbl { color: var(--text-dim); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.1rem; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: 0.2s; cursor: pointer; }
.slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- gallery ---------- */
.gallery-toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 0.7rem; margin-bottom: 1rem; }
@media (min-width: 640px) {
  .gallery-toolbar { flex-direction: row; align-items: center; justify-content: space-between; gap: 0.8rem; }
}
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; max-width: 100%; overflow-x: auto; }
.seg button {
  border: none; background: transparent; color: var(--text-dim); padding: 0.4rem 0.9rem;
  border-radius: 7px; font-weight: 600; font-size: 0.88rem; white-space: nowrap; min-height: 38px;
}
.seg button.active { background: var(--grad); color: #fff; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; }
@media (min-width: 900px) { .gallery { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.8rem; } }
.tile {
  position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1 / 1;
  background: var(--card-2); border: 1px solid var(--border); cursor: pointer;
}
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35); color: #fff; font-size: 2rem; pointer-events: none;
}
.tile .tile-kind {
  position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 0.68rem; padding: 2px 7px; border-radius: 999px; pointer-events: none;
}
.tile .tile-del {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 8px;
  border: none; background: rgba(0,0,0,.65); color: #fff; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
@media (hover: hover) {
  .tile .tile-del { opacity: 0; transition: opacity 0.15s; }
  .tile:hover .tile-del { opacity: 1; }
}

/* ---------- modal (mobile: full-screen sheet; desktop: centered) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 7, 12, 0.92); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.modal-backdrop > div { width: 100%; display: flex; justify-content: center; }
.modal-backdrop .card { width: min(92vw, 460px); }
.modal {
  background: var(--card); border: 1px solid var(--border);
  width: 100%; max-width: none; min-height: 100vh; min-height: 100dvh;
  border-radius: 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.modal-media { display: block; max-width: 100%; max-height: 62vh; margin: 0 auto; object-fit: contain; }
.modal-bar {
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 0.9rem 1.1rem; margin-top: auto;
  border-top: 1px solid var(--border);
}
.modal-bar .meta { color: var(--text-dim); font-size: 0.85rem; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.5rem; }
.modal-actions .btn { width: 100%; }
@media (min-width: 640px) {
  .modal-backdrop { padding: 1.5rem; background: rgba(5, 7, 12, 0.85); }
  .modal-backdrop > div { width: auto; display: block; }
  .modal { width: auto; max-width: 92vw; max-height: 90vh; min-height: 0; border-radius: var(--radius); }
  .modal-media { max-width: min(86vw, 1000px); max-height: 74vh; }
  .modal-bar { flex-direction: row; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.8rem 1.1rem; border-top: none; margin-top: 0; }
  .modal-actions { display: flex; gap: 0.5rem; }
  .modal-actions .btn { width: auto; }
}

/* ---------- guest / camera (full-screen camera UI) ---------- */
body.camera-mode .topbar,
body.camera-mode .footer { display: none; }

.cam-screen {
  position: fixed; inset: 0; z-index: 40;
  background: #000; color: var(--text); overflow: hidden;
}
.cam-stage { position: absolute; inset: 0; background: #000; }
.cam-stage video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000;
}
/* When the stream's aspect disagrees with the phone (rare browsers that hand
   back the raw sensor stream), the JS sizes the video exactly and rotates it
   per camera — clockwise for back, counter-clockwise + mirror for front. */

/* top strip: leave · event name · flash */
.cam-screen-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.6rem;
  padding: max(.7rem, env(safe-area-inset-top)) .9rem .5rem;
  background: linear-gradient(rgba(0,0,0,.5), transparent);
}
.cam-close {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.5);
  color: #fff; font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.cam-event { flex: 1; min-width: 0; text-align: center; color: #fff; }
.cam-event-name {
  font-weight: 700; font-size: 1rem; text-shadow: 0 1px 4px rgba(0,0,0,.6);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cam-event-sub { font-size: .78rem; color: rgba(255,255,255,.75); text-shadow: 0 1px 3px rgba(0,0,0,.6); }

/* start overlay */
.cam-start {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.8rem; padding: 2rem 1rem; text-align: center; color: #fff;
  background: rgba(13,16,23,.35);
}
.cam-start .big { font-size: 3.2rem; }
.cam-start p { color: rgba(255,255,255,.9); }
.cam-start .small { color: rgba(255,255,255,.6); }

/* recording timer (top-center under the strip) */
.cam-overlay {
  position: absolute; top: 0; left: 0; right: 0; z-index: 7;
  display: flex; justify-content: center; padding-top: 3.6rem; pointer-events: none;
}
.cam-overlay[hidden], .rec-timer[hidden] { display: none; }

/* network / slow-connection pill (below the top strip and timer) */
.net-pill {
  position: absolute; top: 6.2rem; left: 50%; transform: translateX(-50%); z-index: 7;
  pointer-events: none;
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 600; color: #fff;
  background: rgba(13,16,23,.78); border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px; padding: 0.35rem 0.85rem;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.net-pill[hidden] { display: none; }
.net-pill.slow { border-color: rgba(245,158,11,.6); color: #fcd34d; }
.net-pill.down { border-color: rgba(239,68,68,.65); color: #fca5a5; }


/* bottom bar: uploads badge · shutters · flip */
.cam-screen-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 8;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 0.8rem;
  padding: .6rem .9rem calc(.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.55));
}
.cam-shutters { display: flex; align-items: center; gap: 1.2rem; }

.cam-tool {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3);
  background: rgba(13,16,23,.55); color: #fff; font-size: 1.35rem;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background .15s, border-color .15s;
}
.cam-tool:disabled { opacity: 0.35; cursor: not-allowed; }
.cam-tool.active { background: var(--accent); border-color: var(--accent); }
.cam-btn {
  width: 64px; height: 64px; border-radius: 50%; border: 3px solid #fff;
  background: var(--card-2); color: var(--text); font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cam-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cam-btn.shutter { background: var(--red); color: #fff; }
.cam-btn.shutter.recording { background: var(--amber); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.rec-timer {
  display: flex; align-items: center; gap: 0.45rem; font-variant-numeric: tabular-nums;
  font-weight: 700; color: #fff; font-size: 0.95rem; letter-spacing: 0.03em;
  background: rgba(0,0,0,.55); padding: 0.4rem 0.8rem; border-radius: 999px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.rec-max { opacity: .6; font-weight: 500; font-size: 0.85rem; }
.rec-timer.limit-warn { animation: limitwarn .9s infinite; }
@keyframes limitwarn { 50% { background: rgba(190, 70, 40, .8); } }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 6; }
.cam-flash.on { animation: camflash .18s ease-out; }
@keyframes camflash { 0% { opacity: .85; } 100% { opacity: 0; } }

/* uploads badge: circular progress (uploaded/captured) */
.cam-badge {
  position: relative; width: 54px; height: 54px; border-radius: 50%;
  border: none; background: transparent; padding: 0; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.cam-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.22); stroke-width: 3; }
.ring-fg {
  fill: none; stroke: #fcd34d; stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 100.53; stroke-dashoffset: 100.53;
  transition: stroke-dashoffset .3s ease, stroke .3s ease;
}
.cam-badge-num {
  font-size: .72rem; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px rgba(0,0,0,.7);
}

/* profile panel (tap the profile icon) */
.cam-profile {
  position: absolute; inset: 0; z-index: 20;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column;
}
.cam-profile[hidden] { display: none; }
.cam-profile-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: max(.7rem, env(safe-area-inset-top)) .9rem .6rem;
  border-bottom: 1px solid var(--border);
}
.cam-profile-title { font-weight: 700; font-size: 1.05rem; }
.cam-profile-spacer { width: 40px; }
.cam-profile-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 1rem .9rem calc(1rem + env(safe-area-inset-bottom));
}
.auth-card { max-width: 420px; margin: 0 auto; padding-top: 1.2rem; text-align: center; }
.auth-card h2 { margin: .8rem 0 .4rem; }
.auth-card .muted { margin-bottom: 1.2rem; }
.auth-form { display: flex; flex-direction: column; gap: .9rem; text-align: left; }
.auth-avatar {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 1.7rem;
  display: flex; align-items: center; justify-content: center;
}
.profile-me { display: flex; align-items: center; gap: .9rem; padding: .4rem 0 1rem; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 1.35rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.profile-event { margin-bottom: 1.3rem; }
.profile-event-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.profile-event-name { font-weight: 700; }
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.profile-thumb {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--border); padding: 0; background: var(--card-2);
}
.profile-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.4rem; text-shadow: 0 1px 6px rgba(0,0,0,.7);
}
.profile-actions { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.2rem; }
.device-card {
  margin-top: 1rem; padding: .85rem .95rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card);
  display: flex; flex-direction: column; gap: .55rem;
}
.device-card-title { font-weight: 700; font-size: .95rem; }
.device-status { margin-top: .15rem; font-size: .78rem; }
.device-ok { color: var(--green); }
.device-wait { color: #fcd34d; }
.device-err { color: var(--red); }
.cam-lightbox {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.cam-lightbox[hidden] { display: none; }
.cam-lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.cam-lb-close {
  position: absolute; top: max(.8rem, env(safe-area-inset-top)); right: .9rem;
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3);
  background: rgba(0,0,0,.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
}

/* uploads sheet (tap the badge) */
.cam-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9;
  max-height: 45vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: .8rem 1rem calc(.9rem + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; margin-bottom: .6rem; font-size: .95rem;
}
.sheet-actions { display: flex; align-items: center; gap: .5rem; }

.banner {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  margin-bottom: 1rem; font-size: 0.92rem; font-weight: 500;
}
.banner.paused { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.35); color: #fcd34d; }
.banner.ok { background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.3); color: #86efac; }

.upload-list { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.upload-item {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem 0.85rem;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.upload-thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--card-2); flex-shrink: 0; }
.upload-info { flex: 1; min-width: 0; }
.save-folder-btn { margin-top: 0.4rem; align-self: flex-start; }
.uri-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.45rem; }
.uri-code {
  flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.4rem 0.55rem; font-size: 0.78rem; color: var(--text-dim);
}
.upload-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-status { font-size: 0.78rem; color: var(--text-dim); display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.upload-status .err { color: #fca5a5; }
.progress { height: 5px; background: var(--card-2); border-radius: 999px; overflow: hidden; margin-top: 0.3rem; }
.progress > div { height: 100%; background: var(--grad); width: 0%; transition: width 0.2s; }
.spin { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: rot 0.8s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.6rem 1rem;
  text-align: center; color: var(--text-dim); cursor: pointer; transition: 0.15s;
  min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); color: var(--text); background: rgba(99,102,241,.05); }
@media (min-width: 640px) { .dropzone { padding: 2rem 1rem; } }

/* ---------- toast ---------- */
.toast-root {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 120;
  display: flex; flex-direction: column; gap: 0.5rem; align-items: center;
  width: min(92vw, 480px);
}
/* On the camera screen, keep toasts clear of the controls: just above the
   bottom bar (badge · shutters · flip) and never click-blocking. */
body.camera-mode .toast-root {
  bottom: calc(6.6rem + env(safe-area-inset-bottom));
  pointer-events: none;
}
.toast {
  background: var(--card-2); border: 1px solid var(--border); color: var(--text);
  padding: 0.7rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow);
  font-size: 0.9rem; font-weight: 500; animation: slideup 0.2s ease;
  width: 100%;
}
.toast.error { border-color: rgba(239,68,68,.5); color: #fca5a5; }
.toast.success { border-color: rgba(34,197,94,.5); color: #86efac; }
@keyframes slideup { from { transform: translateY(10px); opacity: 0; } }

.footer { text-align: center; color: var(--text-faint); font-size: 0.82rem; padding: 1.6rem 1rem 1.2rem; }
@media (min-width: 640px) { .footer { padding: 2rem 1rem 1.5rem; } }
.footer-credits { margin-top: 0.4rem; }
.footer-credits a { color: var(--text-dim); text-decoration: underline; text-underline-offset: 2px; }
.footer-credits a:hover { color: var(--accent-2); }

.spinner-wrap { display: flex; justify-content: center; padding: 4rem 0; }
.big-spin { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: rot 0.8s linear infinite; }

h1.page-title { font-size: 1.5rem; font-weight: 800; }
@media (min-width: 640px) { h1.page-title { font-size: 1.6rem; } }
.muted { color: var(--text-dim); }
.small { font-size: 0.85rem; }
.row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.spacer { flex: 1; }
