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

:root {
  --primary: #6c63ff;
  --primary-dark: #5a52d5;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #252540;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #2d2d4e;
  --radius: 12px;
  --font-title: 'Century Gothic', 'AppleGothic', 'Gill Sans', 'Trebuchet MS', sans-serif;
  --font-body: 'Century Gothic', 'AppleGothic', 'Gill Sans', 'Trebuchet MS', sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Layout ── */
.container { max-width: 900px; margin: 0 auto; padding: 24px 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
}

/* ── Auth page ── */
.auth-wrapper {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 100%; max-width: 420px;
}
.auth-card h1 { font-size: 1.8rem; margin-bottom: 8px; }
.auth-card p { color: var(--text-muted); margin-bottom: 28px; }
.tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.tab-btn {
  flex: 1; padding: 10px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted);
  border-radius: 8px; cursor: pointer; font-size: 0.9rem; transition: all .2s;
}
.tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%; padding: 12px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.95rem;
  transition: border-color .2s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
}
textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 8px; border: none;
  font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all .2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Navbar ── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.nav-user { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; color: var(--text-muted); }

/* ── Quiz cards ── */
.quiz-grid { display: grid; gap: 16px; }
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; justify-content: space-between;
  transition: border-color .2s;
}
.quiz-card:hover { border-color: var(--primary); }
.quiz-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.quiz-desc { font-size: 0.85rem; color: var(--text-muted); }
.badge {
  padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}
.badge-active { background: rgba(34,197,94,.15); color: var(--success); }
.badge-draft { background: rgba(148,163,184,.1); color: var(--text-muted); }
.badge-closed { background: rgba(239,68,68,.1); color: var(--danger); }

/* ── Question ── */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.question-num { font-size: 0.8rem; color: var(--primary); font-weight: 600; margin-bottom: 8px; font-family: var(--font-body); }
.question-text {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  font-family: var(--font-title);
  letter-spacing: 0.01em;
  line-height: 1.3;
}
.options-grid { display: grid; gap: 10px; }
.option-btn {
  padding: 14px 18px;
  background: var(--surface2); border: 2px solid var(--border);
  border-radius: 10px; color: var(--text); text-align: left;
  cursor: pointer; transition: all .2s;
  font-size: 1rem;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
}
.option-btn:hover { border-color: var(--primary); background: rgba(108,99,255,.1); }
.option-btn.selected { border-color: var(--primary); background: rgba(108,99,255,.2); color: white; }
.option-btn.answered { border-color: var(--success); background: rgba(34,197,94,.1); cursor: default; }

/* ── Progress ── */
.progress-bar {
  height: 6px; background: var(--surface2);
  border-radius: 3px; overflow: hidden; margin-bottom: 24px;
}
.progress-fill {
  height: 100%; background: var(--primary);
  border-radius: 3px; transition: width .4s ease;
}

/* ── Charts (admin) ── */
.stats-grid { display: grid; gap: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card h3 { font-size: 0.95rem; margin-bottom: 16px; color: var(--text-muted); }
.stat-card .q-text { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 16px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { font-size: 0.85rem; min-width: 120px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 28px; background: var(--surface2); border-radius: 6px; overflow: hidden; position: relative; }
.bar-fill {
  height: 100%; background: var(--primary);
  border-radius: 6px; transition: width .6s ease;
  display: flex; align-items: center; padding-left: 8px;
  font-size: 0.8rem; font-weight: 600; color: white; min-width: 2px;
}
.bar-count { font-size: 0.85rem; color: var(--text-muted); min-width: 40px; text-align: right; }

/* ── Admin panel ── */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .admin-grid { grid-template-columns: 1fr; } }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); }

/* ── Alerts ── */
.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem;
}
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.alert-info { background: rgba(108,99,255,.1); border: 1px solid rgba(108,99,255,.3); color: #a5b4fc; }

/* ── Misc ── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Question builder (admin) ── */
.question-builder {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-bottom: 12px;
}
.question-builder .q-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.options-list { display: grid; gap: 8px; margin-top: 10px; }
.option-input-row { display: flex; gap: 8px; }
.option-input-row input { flex: 1; }
.options-area.hidden { display: none; }

/* ── Live indicator ── */
.live-dot {
  display: inline-block; width: 8px; height: 8px;
  background: var(--success); border-radius: 50%;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(1.3); }
}

.chart-toggle.active-toggle {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.section-title {
  font-size: 1.3rem; font-weight: 700; margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
