:root {
  --bg: #0b0d17;
  --bg-2: #141829;
  --glass: rgba(20, 24, 41, 0.72);
  --glass-border: rgba(255, 255, 255, 0.09);
  --text: #eef0fb;
  --muted: #9aa0bd;
  --accent: #ff5c8a;
  --accent-2: #8b5cf6;
  --grad: linear-gradient(135deg, #ff5c8a 0%, #8b5cf6 100%);
  --live: #22e39b;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: 'Outfit', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body.page { background: radial-gradient(1200px 600px at 10% -10%, rgba(139,92,246,.25), transparent 60%),
                       radial-gradient(900px 500px at 110% 10%, rgba(255,92,138,.18), transparent 60%), var(--bg);
            min-height: 100%; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -9999px; opacity: 0; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(255,92,138,.35); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(255,92,138,.5); }
.btn-ghost { background: rgba(255,255,255,.06); border-color: var(--glass-border); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-danger { background: rgba(255,80,80,.12); border-color: rgba(255,80,80,.3); color: #ff9a9a; }
.btn-lg { padding: .9rem 1.4rem; font-size: 1.05rem; width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 1.1rem; color: var(--muted); padding: .3rem; }
.icon-btn:hover { color: var(--text); }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 20;
  display: flex; align-items: center; gap: 1rem; padding: .55rem .6rem .55rem 1.1rem; border-radius: 999px;
}
.brand { display: flex; align-items: center; gap: .5rem; font-size: 1.25rem; text-decoration: none; letter-spacing: -.02em; }
.brand b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 0 var(--live); animation: pulse 2s infinite; }
.admin-tag { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.live-count { margin-left: auto; font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: .3rem; }
.live-count b { color: var(--text); }
.topbar > .btn:last-child { margin-left: auto; }
.live-count + .btn { margin-left: 0; }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--live); margin-right: .35rem;
            box-shadow: 0 0 0 0 var(--live); animation: pulse 1.6s infinite; vertical-align: middle; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,227,155,.7); } 70% { box-shadow: 0 0 0 10px rgba(34,227,155,0); } 100% { box-shadow: 0 0 0 0 rgba(34,227,155,0); } }

/* ---------- Map page ---------- */
.map-page { overflow: hidden; }
#map { position: fixed !important; top: 0; left: 0; width: 100%; height: 100vh; height: 100dvh; background: var(--bg-2); }
.setup-msg { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 2rem; border-radius: var(--radius); text-align: center; max-width: 420px; }
.setup-msg code { background: rgba(255,255,255,.08); padding: .1rem .4rem; border-radius: 6px; }

.controls {
  position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 70px); left: 12px; z-index: 15;
  display: flex; flex-direction: column; gap: .5rem; padding: .6rem; border-radius: var(--radius); max-width: calc(100vw - 24px);
}
.chips { display: flex; gap: .4rem; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .85rem; border-radius: 999px;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.04); color: var(--muted);
  cursor: pointer; white-space: nowrap; font-size: .9rem; font-weight: 500; transition: all .2s var(--ease);
}
.chip:hover { color: var(--text); background: rgba(255,255,255,.09); }
.chip.active { background: var(--grad); color: #fff; border-color: transparent; }
.type-chip.active { background: color-mix(in srgb, var(--c) 22%, transparent); border-color: color-mix(in srgb, var(--c) 60%, transparent); color: var(--text); }
.type-chip:not(.active) { opacity: .55; }

.fab {
  position: fixed; right: 16px; z-index: 15; height: 48px; min-width: 48px; padding: 0 1rem; border-radius: 999px;
  cursor: pointer; font-size: 1.2rem; font-weight: 600; transition: transform .2s var(--ease);
}
.fab:hover { transform: scale(1.06); }
#locate-btn { bottom: calc(24px + env(safe-area-inset-bottom) + 60px); }
.list-fab { bottom: calc(24px + env(safe-area-inset-bottom)); font-size: .95rem; }

/* Pins */
.pin { position: relative; width: 44px; height: 52px; cursor: pointer; transform-origin: 50% 100%; transition: transform .25s var(--ease); }
.pin:hover, .pin.selected { transform: scale(1.18); z-index: 10; }
.pin-body {
  position: absolute; left: 2px; top: 0; width: 40px; height: 40px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--c) 100%, white 25%), var(--c));
  border: 2px solid rgba(255,255,255,.9); box-shadow: 0 6px 16px rgba(0,0,0,.5);
  display: grid; place-items: center;
}
.pin-emoji { transform: rotate(45deg); font-size: 1.15rem; }
.pin-ring { position: absolute; left: 2px; top: 0; width: 40px; height: 40px; border-radius: 50%; opacity: 0; }
.pin.live .pin-ring { animation: ring 1.8s infinite; border: 3px solid var(--c); }
.pin.live .pin-body { border-color: var(--live); }
@keyframes ring { from { transform: scale(.9); opacity: .9; } to { transform: scale(2); opacity: 0; } }
.pop-in { animation: popIn .45s var(--ease) both; }
@keyframes popIn { from { transform: scale(0) translateY(20px); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.cluster {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff;
  background: var(--grad); border: 3px solid rgba(255,255,255,.85); box-shadow: 0 0 0 6px rgba(139,92,246,.25), 0 8px 20px rgba(0,0,0,.5);
}
.user-dot { width: 18px; height: 18px; border-radius: 50%; background: #4f8cff; border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(79,140,255,.25); }

/* Card popup */
.card {
  position: fixed; z-index: 25; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px)); padding: 1.2rem 1.3rem; border-radius: 22px;
  border-top: 3px solid var(--c);
}
.card-in { animation: slideUp .35s var(--ease); }
@keyframes slideUp { from { transform: translate(-50%, 30px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.card h3 { margin: .5rem 0 .2rem; font-size: 1.35rem; line-height: 1.2; }
.card-close { position: absolute; top: .8rem; right: .8rem; background: rgba(255,255,255,.08); border: 0; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
.type-badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: .25rem .65rem; border-radius: 999px;
              background: color-mix(in srgb, var(--c) 20%, transparent); color: color-mix(in srgb, var(--c) 80%, white); }
.card-place { margin: .2rem 0; color: var(--muted); }
.card-status { margin: .5rem 0; font-weight: 600; }
.card-status.is-live { color: var(--live); }
.card-text { margin: .4rem 0 1rem; line-height: 1.5; color: #d6d9ec; }
.card-actions { display: flex; gap: .6rem; }
.card-actions .btn { flex: 1; }

/* List panel */
.panel {
  position: fixed; z-index: 18; top: calc(max(12px, env(safe-area-inset-top)) + 70px); right: 12px; bottom: 90px;
  width: 360px; border-radius: var(--radius); display: flex; flex-direction: column;
  transform: translateX(calc(100% + 24px)); transition: transform .35s var(--ease);
}
.panel.open { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1rem .4rem; }
.panel-head h2 { margin: 0; font-size: 1.1rem; }
#event-list { list-style: none; margin: 0; padding: .3rem .6rem 1rem; overflow-y: auto; }
.list-item {
  width: 100%; display: flex; gap: .75rem; align-items: flex-start; text-align: left; padding: .7rem; margin-bottom: .4rem;
  background: rgba(255,255,255,.03); border: 1px solid transparent; border-left: 3px solid var(--c); border-radius: 12px; cursor: pointer;
  transition: background .2s, transform .2s var(--ease);
}
.list-item:hover { background: rgba(255,255,255,.08); transform: translateX(-2px); }
.li-emoji { font-size: 1.4rem; }
.li-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.li-title { font-weight: 600; }
.li-sub { color: var(--muted); font-size: .85rem; }
.li-status { font-size: .82rem; color: #c9cce0; }
.is-live .li-status { color: var(--live); }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }

.demo-badge { position: fixed; left: 16px; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 15; font-size: .75rem; font-weight: 600;
              padding: .3rem .7rem; border-radius: 999px; background: rgba(255,179,71,.15); color: #ffcf8a; border: 1px solid rgba(255,179,71,.35); }
.toast {
  position: fixed; left: 50%; top: 90px; transform: translate(-50%, -20px); z-index: 50; opacity: 0; pointer-events: none;
  background: rgba(20,24,41,.95); border: 1px solid var(--glass-border); padding: .7rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow);
  transition: all .3s var(--ease); font-size: .92rem; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Form pages ---------- */
.container { max-width: 720px; margin: 0 auto; padding: 100px 16px 48px; }
.hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin: 0 0 .4rem; letter-spacing: -.03em; }
.hero p { color: var(--muted); margin: 0 0 1.5rem; font-size: 1.05rem; }
.form, .success { padding: 1.5rem; border-radius: 24px; display: flex; flex-direction: column; gap: 1.1rem; }
.form.narrow { max-width: 400px; margin: 4rem auto; }
.form h2 { margin: 0; }
.field { display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.field label { font-weight: 600; font-size: .92rem; display: flex; justify-content: space-between; }
.field label small { color: var(--muted); font-weight: 400; }
.counter { color: var(--muted); font-weight: 400; font-size: .8rem; }
input:not(.hp), textarea {
  background: rgba(255,255,255,.05); border: 1px solid var(--glass-border); border-radius: 12px; padding: .75rem .9rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px rgba(139,92,246,.2); }
textarea { resize: vertical; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; }
.row .field { min-width: 140px; }
.type-picker { display: flex; flex-wrap: wrap; gap: .4rem; }
.type-picker .type-chip:not(.active) { opacity: .7; }
.place-search gmp-place-autocomplete, .place-search gmp-placeautocomplete { width: 100%; color-scheme: dark; }
.mini-map { height: 240px; border-radius: 14px; overflow: hidden; border: 1px solid var(--glass-border); background: var(--bg-2); }
.hint { color: var(--muted); font-size: .85rem; }
.form-error { color: #ff9a9a; background: rgba(255,80,80,.1); border: 1px solid rgba(255,80,80,.25); padding: .7rem .9rem; border-radius: 12px; margin: 0; }
.success { text-align: center; align-items: center; animation: popIn .5s var(--ease); }
.success-icon { font-size: 3rem; }
.success h2 { margin: 0; }
.success p { color: var(--muted); margin: 0; }

/* Admin */
.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.admin-list { display: flex; flex-direction: column; gap: .9rem; }
.admin-item { display: flex; gap: 1rem; padding: 1.1rem 1.2rem; border-radius: var(--radius); border-left: 4px solid var(--c); transition: opacity .25s, transform .25s; }
.admin-item h3 { margin: .4rem 0 .2rem; }
.admin-main { flex: 1; min-width: 0; }
.admin-main p { margin: .25rem 0; }
.admin-actions { display: flex; flex-direction: column; gap: .5rem; justify-content: center; }
.fade-out { opacity: 0; transform: translateX(30px); }

@media (max-width: 760px) {
  .live-count { display: none; }
  .topbar .btn { padding: .5rem .9rem; font-size: .9rem; }
  .controls { right: 12px; }
  .panel { left: 12px; right: 12px; width: auto; top: auto; bottom: 0; height: 65vh; border-radius: 22px 22px 0 0;
           transform: translateY(105%); }
  .panel.open { transform: none; }
  .admin-item { flex-direction: column; }
  .admin-actions { flex-direction: row; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
