@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --bg: #07051a;
  --bg-2: #0e0a2b;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-2: rgba(255, 255, 255, 0.09);
  --stroke: rgba(255, 255, 255, 0.11);
  --stroke-2: rgba(255, 255, 255, 0.2);
  --text: #f3f1ff;
  --muted: #a7a3c9;
  --dim: #6f6a99;
  --accent: #7c5cff;
  --accent-2: #ff5ca8;
  --accent-3: #2ee6d6;
  --good: #2ee6a6;
  --warn: #ffb547;
  --bad: #ff5c7a;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
  --grad: linear-gradient(120deg, var(--accent), var(--accent-2) 55%, var(--warn));
  --grad-cool: linear-gradient(120deg, var(--accent-3), var(--accent));
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  line-height: 1.5;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 60%, transparent); }

/* ---------- animated backdrop ---------- */
#backdrop { position: fixed; inset: 0; z-index: -2; width: 100%; height: 100%; }
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.06; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 80px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 18px; }
.grid > *, .stagewrap > *, .cr > *, .g2 > *, .g3 > *, .g-2-1 > *, .layout > * { min-width: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.hidden { display: none !important; }
.center { text-align: center; }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; }

h1, h2, h3, .display { font-family: var(--display); letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.05; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.05rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.gradient-text {
  background: var(--grad); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: sheen 6s ease-in-out infinite;
}
@keyframes sheen { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px; position: sticky; top: 0; z-index: 20;
  background: linear-gradient(to bottom, rgba(7, 5, 26, 0.85), rgba(7, 5, 26, 0.4));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--stroke);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; position: relative;
  background: var(--grad); box-shadow: 0 0 24px -4px var(--accent-2);
}
.brand-mark::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; border: 2px solid var(--accent-2); animation: ping 2.4s cubic-bezier(0, 0, .2, 1) infinite;
}
.brand-mark svg { width: 20px; height: 20px; }
@keyframes ping { 0% { transform: scale(1); opacity: .8; } 80%, 100% { transform: scale(1.6); opacity: 0; } }

/* ---------- cards ---------- */
.card {
  background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 22px;
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow); position: relative;
}
.card.glow::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 80%, transparent), transparent 40%, transparent 60%, color-mix(in srgb, var(--accent-2) 70%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title h3 { font-size: 1rem; }
.card-title .eyebrow { margin-left: auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 999px;
  border: 1px solid var(--stroke-2); background: var(--panel-2); cursor: pointer; font-weight: 600; text-decoration: none;
  transition: transform .15s ease, background .2s, box-shadow .2s, border-color .2s; white-space: nowrap; user-select: none;
}
.btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn.primary {
  background: var(--grad); background-size: 160% 100%; border-color: transparent; color: white;
  box-shadow: 0 10px 30px -10px var(--accent-2), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.btn.primary:hover { background-position: 100% 0; box-shadow: 0 14px 40px -10px var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: #ffd1da; }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 25%, transparent); }
.btn.good { background: linear-gradient(120deg, #19c98b, #2ee6d6); color: #04261c; border-color: transparent; }
.btn.sm { padding: 7px 12px; font-size: .85rem; }
.btn.icon { width: 40px; height: 40px; padding: 0; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- forms ---------- */
label.field { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 500; }
.input, textarea.input, select.input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--stroke-2);
  background: rgba(0, 0, 0, 0.25); color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); background: rgba(0, 0, 0, .35); }
textarea.input { resize: vertical; min-height: 90px; }
select.input option { background: var(--bg-2); }
input[type=datetime-local].input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .6; }
.seg { display: inline-flex; background: rgba(0, 0, 0, .3); border: 1px solid var(--stroke); border-radius: 999px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: .88rem; transition: all .2s; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--stroke-2); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9rem; user-select: none; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: rgba(255, 255, 255, .15); position: relative; transition: background .25s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; transition: transform .25s cubic-bezier(.5, 1.6, .4, 1); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ---------- chips & pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; letter-spacing: .04em; background: var(--panel-2); border: 1px solid var(--stroke); }
.pill.live { background: rgba(255, 70, 110, .18); border-color: rgba(255, 92, 122, .5); color: #ffc0cf; }
.pill.live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #ff3d6e; box-shadow: 0 0 0 0 rgba(255, 61, 110, .7); animation: livepulse 1.6s infinite; }
.pill.scheduled { color: #c9c2ff; }
.pill.ended { color: #9ff2d4; background: rgba(46, 230, 166, .12); border-color: rgba(46, 230, 166, .35); }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(255, 61, 110, .7); } 70% { box-shadow: 0 0 0 10px rgba(255, 61, 110, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 61, 110, 0); } }

.code-chip {
  font-family: var(--display); font-weight: 700; letter-spacing: .18em; font-size: 1.1rem; padding: 6px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, .35); border: 1px dashed var(--stroke-2); cursor: copy;
}

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; pointer-events: none; width: min(92vw, 420px); }
.toast {
  padding: 12px 16px; border-radius: 14px; background: rgba(20, 16, 48, .92); border: 1px solid var(--stroke-2); box-shadow: var(--shadow);
  animation: toastIn .4s cubic-bezier(.2, 1.4, .4, 1) both; font-weight: 500; backdrop-filter: blur(10px); text-align: center;
}
.toast.out { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.95); } }

/* ---------- floating reactions ---------- */
.float-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.floater { position: absolute; bottom: -60px; font-size: 2rem; will-change: transform, opacity; animation: floatUp var(--dur, 3.2s) cubic-bezier(.2, .6, .4, 1) forwards; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .4)); }
@keyframes floatUp {
  0% { transform: translate(0, 0) scale(.4) rotate(0); opacity: 0; }
  10% { opacity: 1; transform: translate(calc(var(--dx) * .1), -10vh) scale(1.15) rotate(calc(var(--rot) * .2)); }
  100% { transform: translate(var(--dx), -105vh) scale(.9) rotate(var(--rot)); opacity: 0; }
}

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(3, 2, 14, .7); backdrop-filter: blur(8px); z-index: 200; display: grid; place-items: center; padding: 16px; animation: fade .25s ease; }
.modal { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; overflow-x: hidden; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.9) translateY(20px); } }

/* ---------- misc animation helpers ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .8, .2, 1); }
.reveal.in { opacity: 1; transform: none; }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; color: var(--dim); padding: 28px 10px; font-size: .9rem; }
.empty .big { font-size: 2.2rem; display: block; margin-bottom: 6px; filter: grayscale(.3); }

.scroll { overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 8px; }

/* ---------- chat (shared) ---------- */
.chat-list { display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.msg { display: flex; gap: 10px; align-items: flex-start; animation: msgIn .4s cubic-bezier(.2, 1.2, .4, 1) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(12px) scale(.96); } }
.msg .av { width: 34px; height: 34px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; background: color-mix(in srgb, var(--c, #7c5cff) 30%, transparent); border: 1px solid color-mix(in srgb, var(--c, #7c5cff) 60%, transparent); }
.msg .bubble { background: var(--panel); border: 1px solid var(--stroke); padding: 8px 12px; border-radius: 4px 14px 14px 14px; max-width: 100%; overflow-wrap: anywhere; }
.msg .who { font-size: .75rem; font-weight: 700; color: var(--c, var(--muted)); display: flex; gap: 8px; align-items: center; }
.msg .who time { color: var(--dim); font-weight: 500; }
.msg.mine { flex-direction: row-reverse; }
.msg.mine .bubble { background: color-mix(in srgb, var(--accent) 28%, transparent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 14px 4px 14px 14px; }
.msg.mine .who { justify-content: flex-end; }
.msg.presenter .bubble { background: linear-gradient(120deg, rgba(124, 92, 255, .35), rgba(255, 92, 168, .25)); border-color: rgba(255, 92, 168, .5); }
.msg.system { justify-content: center; }
.msg.system .av { display: none; }
.msg.system .bubble { background: transparent; border: 1px dashed var(--stroke-2); color: var(--muted); font-size: .85rem; border-radius: 999px; text-align: center; padding: 6px 14px; }
.msg.system .who { display: none; }
.msg .tools { display: none; gap: 4px; margin-left: 6px; }
.msg:hover .tools { display: inline-flex; }
.msg .tools button { background: none; border: 0; cursor: pointer; opacity: .6; padding: 0 2px; }
.msg .tools button:hover { opacity: 1; }
.badge { font-size: .62rem; padding: 1px 6px; border-radius: 6px; background: var(--grad); color: white; letter-spacing: .05em; }

.composer { display: flex; gap: 8px; align-items: center; }
.composer .input { border-radius: 999px; }

/* ---------- questions (shared) ---------- */
.q { display: flex; gap: 12px; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--stroke); align-items: flex-start; animation: msgIn .4s both; transition: transform .4s; }
.q.answered { opacity: .5; }
.q .vote { display: grid; justify-items: center; min-width: 44px; padding: 6px; border-radius: 12px; border: 1px solid var(--stroke-2); background: transparent; cursor: pointer; transition: all .2s; }
.q .vote .n { font-weight: 700; font-family: var(--display); }
.q .vote.on { background: var(--grad); border-color: transparent; }
.q .vote:active { transform: scale(.9); }
.q .qtext { flex: 1; overflow-wrap: anywhere; }
.q .meta { font-size: .75rem; color: var(--dim); margin-top: 4px; }

/* ---------- poll (shared) ---------- */
.poll-opt { position: relative; display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--stroke-2); background: rgba(0, 0, 0, .2); cursor: pointer; overflow: hidden; margin-top: 8px; width: 100%; text-align: left; transition: border-color .2s, transform .15s; }
.poll-opt:hover { border-color: var(--accent); }
.poll-opt:active { transform: scale(.98); }
.poll-opt .fill { position: absolute; inset: 0; width: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), color-mix(in srgb, var(--accent-2) 40%, transparent)); transition: width .8s cubic-bezier(.2, .9, .2, 1); z-index: 0; }
.poll-opt span { position: relative; z-index: 1; font-weight: 600; }
.poll-opt.mine { border-color: var(--accent-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 40%, transparent); }

/* ---------- gauge ---------- */
.gauge { position: relative; width: 100%; max-width: 360px; margin: 0 auto; }
.gauge svg { width: 100%; display: block; overflow: visible; }
.gauge .readout { position: absolute; left: 0; right: 0; bottom: 6%; text-align: center; }
.gauge .readout .num { font-family: var(--display); font-weight: 700; font-size: clamp(2.2rem, 7vw, 3.4rem); line-height: 1; }
.gauge .readout .lbl { color: var(--muted); font-weight: 600; font-size: .9rem; }
.gauge .face { font-size: 2rem; display: block; transition: transform .4s cubic-bezier(.2, 1.6, .4, 1); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; border-radius: 16px; background: var(--panel); border: 1px solid var(--stroke); position: relative; overflow: hidden; }
.kpi .v { font-family: var(--display); font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.kpi .k { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.kpi .s { font-size: .78rem; color: var(--dim); }
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(var(--kc, var(--accent)), transparent 70%); opacity: .35; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .wrap { padding: 16px 14px 90px; }
  .card { padding: 16px; border-radius: 16px; }
  .topbar { padding: 10px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* "phones need https for cameras" hint (dashboard + control room) */
.https-hint { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 4px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 181, 71, .35); background: rgba(255, 181, 71, .08); font-size: .8rem; line-height: 1.45; color: var(--muted); }
.https-hint b { color: var(--text); }
.https-hint code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; background: rgba(255, 255, 255, .08); padding: 1px 6px; border-radius: 6px; color: var(--text); white-space: nowrap; }
.https-hint .btn { margin-left: 4px; vertical-align: middle; }
