:root {
  --purple: #31006f;
  --purple-2: #59249a;
  --pink: #e20e5a;
  --blue: #0879c9;
  --sky: #e9f5ff;
  --ink: #241d2f;
  --muted: #6f6878;
  --line: #e8e4ec;
  --surface: #ffffff;
  --canvas: #f7f5f9;
  --success: #15805d;
  --danger: #b4234b;
  --shadow: 0 18px 55px rgba(49, 0, 111, 0.12);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
a { color: inherit; }

.brand-logo { display: block; width: 210px; height: auto; }
.brand-logo--small { width: 165px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.72rem 1.12rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--purple);
  color: white;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  gap: 0.55rem;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 9px 24px rgba(49, 0, 111, 0.2); }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(8, 121, 201, 0.28);
  outline-offset: 2px;
}
.button--pink { background: var(--pink); }
.button--quiet { color: var(--purple); background: white; border-color: #d9d0e2; }
.button--danger { color: var(--danger); background: #fff5f7; border-color: #f3c7d4; }
.button--small { min-height: 38px; padding: 0.5rem 0.85rem; font-size: 0.88rem; }
.button[disabled] { opacity: 0.55; cursor: wait; transform: none; }

.field { display: grid; gap: 0.5rem; }
.field label { font-size: 0.88rem; font-weight: 750; color: #4d4557; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid #d8d2dc;
  border-radius: 14px;
  padding: 0.84rem 0.95rem;
  background: white;
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(8, 121, 201, 0.08);
}
.help { color: var(--muted); font-size: 0.84rem; margin: 0; line-height: 1.5; }
.eyebrow { margin: 0 0 0.45rem; color: var(--pink); font-size: 0.76rem; font-weight: 850; letter-spacing: 0.12em; text-transform: uppercase; }

/* Admin */
.admin-shell { min-height: 100vh; background: linear-gradient(135deg, #f8f6fa 0%, #f1edf5 100%); }
.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem clamp(1.2rem, 4vw, 4rem);
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.admin-header__actions { display: flex; gap: 0.65rem; align-items: center; }
.admin-main { width: min(1180px, calc(100% - 2.4rem)); margin: 0 auto; padding: 2.6rem 0 5rem; }
.admin-titlebar { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 2rem; }
.admin-titlebar h1 { font-size: clamp(2rem, 4vw, 3.45rem); letter-spacing: -0.055em; line-height: 1; margin: 0; color: var(--purple); }
.admin-titlebar p { max-width: 600px; margin: 0.8rem 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 1.25rem; box-shadow: 0 8px 30px rgba(49,0,111,.05); }
.stat strong { display: block; color: var(--purple); font-size: 2rem; letter-spacing: -0.04em; }
.stat span { color: var(--muted); font-size: .85rem; }
.live-card { display: grid; grid-template-columns: 1fr auto; gap: 1.2rem; align-items: center; padding: 1.5rem; background: var(--purple); color: white; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 2.4rem; overflow: hidden; position: relative; }
.live-card::after { content: ""; position: absolute; width: 240px; height: 240px; right: -80px; top: -105px; border: 55px solid rgba(255,255,255,.07); border-radius: 50%; pointer-events: none; }
.live-card h2 { margin: 0.25rem 0 0.35rem; font-size: clamp(1.35rem, 3vw, 2rem); }
.live-card p { margin: 0; color: rgba(255,255,255,.75); }
.live-card__actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 0.65rem; z-index: 1; }
.live-card .button--quiet { border-color: transparent; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 2rem 0 1rem; }
.section-heading h2 { margin: 0; color: var(--purple); font-size: 1.5rem; }
.question-list { display: grid; gap: .85rem; }
.question-card { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; padding: 1.15rem; background: white; border: 1px solid var(--line); border-radius: 18px; transition: border 150ms, transform 150ms; }
.question-card:hover { transform: translateY(-1px); border-color: #d4c7df; }
.question-card--active { border-left: 5px solid var(--pink); }
.question-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; font-size: 1.35rem; background: #f2edf7; }
.question-card h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.question-card p { margin: 0; color: var(--muted); font-size: .9rem; }
.question-card__meta { display: flex; gap: .5rem; margin-top: .55rem; align-items: center; }
.pill { display: inline-flex; align-items: center; min-height: 25px; padding: .25rem .55rem; border-radius: 999px; background: #f0edf3; color: #5f5669; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.pill--live { background: #ffe8f0; color: #ad1748; }
.question-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: .45rem; }
.editor { margin-top: 2rem; padding: 1.5rem; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(49,0,111,.06); }
.editor h2 { margin: 0 0 1.2rem; color: var(--purple); }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.editor .field--wide { grid-column: 1 / -1; }
.editor-actions { display: flex; align-items: center; gap: .75rem; margin-top: 1.2rem; }
.inline-form { display: inline; }
.notice { padding: .9rem 1rem; border-radius: 13px; margin-bottom: 1rem; background: #eaf8f2; color: #086346; border: 1px solid #b9e3d2; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: linear-gradient(140deg, var(--purple), #561998 58%, #8c206d); }
.login-card { width: min(430px, 100%); padding: 2rem; background: white; border-radius: 28px; box-shadow: 0 30px 90px rgba(20, 0, 45, .35); }
.login-card h1 { color: var(--purple); margin: 1.8rem 0 .5rem; font-size: 2rem; letter-spacing: -.04em; }
.login-card .button { width: 100%; margin-top: 1rem; }
.error { color: var(--danger); background: #fff3f6; border: 1px solid #f3c6d2; border-radius: 12px; padding: .75rem .9rem; font-size: .9rem; }
.qr-panel { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; align-items: center; }
.qr-panel img { width: 220px; height: 220px; padding: 12px; background: white; border-radius: 18px; border: 1px solid var(--line); }
.qr-panel code { word-break: break-all; color: var(--purple); font-size: .82rem; }

/* Audience */
.audience-page { min-height: 100vh; background: #f4f1f6; }
.audience-hero { padding: 1.4rem 1.25rem 4.7rem; background: radial-gradient(circle at 85% -20%, #874bb8 0, transparent 48%), var(--purple); color: white; }
.audience-hero__inner { width: min(620px, 100%); margin: 0 auto; }
.audience-hero .brand-logo { width: 175px; }
.audience-main { width: min(620px, calc(100% - 2rem)); margin: -3.2rem auto 0; padding-bottom: 4rem; }
.response-card { background: white; border-radius: 26px; padding: clamp(1.25rem, 5vw, 2rem); box-shadow: 0 18px 55px rgba(33, 0, 72, .17); }
.response-card h1 { color: var(--purple); margin: 0 0 .45rem; font-size: clamp(1.65rem, 7vw, 2.35rem); letter-spacing: -.045em; line-height: 1.08; }
.response-card__prompt { margin: 0 0 1.5rem; color: var(--muted); font-size: 1rem; line-height: 1.5; }
.type-badge { display: inline-flex; gap: .45rem; align-items: center; margin-bottom: 1rem; color: var(--pink); font-size: .74rem; font-weight: 850; text-transform: uppercase; letter-spacing: .1em; }
.response-card .button { width: 100%; margin-top: .9rem; min-height: 52px; }
.response-status { min-height: 1.5rem; margin: .85rem 0 0; font-size: .9rem; color: var(--success); font-weight: 700; }
.history { margin-top: 2rem; }
.history h2 { color: var(--purple); font-size: 1rem; margin: 0 0 .8rem; }
.history-list { display: grid; gap: .65rem; }
.history-item { background: white; border: 1px solid var(--line); border-radius: 15px 15px 4px 15px; padding: .9rem 1rem; box-shadow: 0 5px 18px rgba(49,0,111,.05); animation: history-in 400ms cubic-bezier(.2,.8,.2,1) both; }
.history-item p { margin: 0; line-height: 1.42; }
.history-item time { display: block; margin-top: .38rem; color: var(--muted); font-size: .72rem; }
.waiting { text-align: center; padding: 1rem 0 .4rem; }
.waiting__dots { display: flex; justify-content: center; gap: .35rem; margin-bottom: 1rem; }
.waiting__dots span { width: 8px; height: 8px; background: var(--pink); border-radius: 50%; animation: dot 1.1s infinite ease-in-out; }
.waiting__dots span:nth-child(2) { animation-delay: .15s; }
.waiting__dots span:nth-child(3) { animation-delay: .3s; }
.waiting p { color: var(--muted); margin: 0; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-6px); opacity: 1; } }
@keyframes history-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }

@media (max-width: 800px) {
  .admin-header { position: static; padding: 1rem; }
  .admin-header .brand-logo { width: 140px; }
  .admin-header__actions .button:first-child { display: none; }
  .admin-main { width: min(100% - 1.4rem, 1180px); padding-top: 1.5rem; }
  .admin-titlebar, .live-card { display: block; }
  .live-card__actions { justify-content: start; margin-top: 1.1rem; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: 1 / -1; }
  .question-card { grid-template-columns: auto 1fr; }
  .question-actions { grid-column: 1 / -1; justify-content: start; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor .field--wide { grid-column: auto; }
  .qr-panel { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
