.sheet { max-height: 85vh; overflow-y: auto; }

/* Variables */
:root {
  /* Core (Stripe-inspired dark) */
  --bg: #0B1020;
  --surface: rgba(255,255,255,0.06);
  --text: #E6E9F5;
  --muted: #9AA5C3;
  --border: rgba(255,255,255,0.12);

  --primary: #635BFF;
  --primary-600: #4F46E5;
  --primary-700: #4338CA;

  /* Semantic */
  --success: #22C55E;
  --success-50: rgba(34,197,94,0.14);
  --error: #EF4444;
  --error-50: rgba(239,68,68,0.14);
  --warn: #F59E0B;
  --warn-50: rgba(245,158,11,0.14);
  --premium: #FFD166;
  --premium-50: rgba(255, 209, 102, 0.14);

  /* Radii & Shadows */
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.25), 0 12px 30px rgba(5,12,32,.45);

  /* Typography */
  --font-display: "Inter", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";

  /* Motion */
  --transition-fast: 180ms ease-out;
  --transition-slow: 240ms ease;

  /* Legacy compatibility (aliases) */
  --color-primary: var(--primary);
  --color-secondary: var(--muted);
  --color-surface: var(--surface);
  --primary-color: var(--primary);
  --secondary-color: var(--muted);
  --danger-color: var(--error);
  --success-color: var(--success);
  --warning-color: var(--warn);
  --background-color: var(--bg);
  --border-color: var(--border);
  --text-color: var(--text);
  --heading-color: var(--text);
  --color-secondary-rgb: 154, 165, 195;
}

/* Card and surface */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, var(--shadow);
  transition: transform 250ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow var(--transition-slow);
}
.card:hover { box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 16px 36px rgba(5,12,32,.55); }

/* Buttons */
.btn-primary,
.subscription-status .premium-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: none;
}
.btn-primary:hover,
.subscription-status .premium-btn:hover { filter: brightness(1.06); }
.btn-primary:active,
.subscription-status .premium-btn:active { filter: brightness(0.96); }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: rgba(255,255,255,0.16);
}
.btn-secondary:hover { background: rgba(255,255,255,0.10); }

/* Inputs */
input,
select,
textarea {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.16);
}
input::placeholder,
textarea::placeholder { color: rgba(230,233,245,0.55); }

/* Pricing */
.pricing-column { background: rgba(255,255,255,0.06); }
.pricing-column.premium {
  background: linear-gradient(180deg, #7C73FF, #5F57FF);
  color: #fff;
}

/* Misc */
.plan-note {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.18);
}
.answer-option-box { background: rgba(255,255,255,0.06); }
.modal-content { background: #0F162E; border: 1px solid rgba(255,255,255,0.10); }

/* Containers and sections */
body.theme-stripe .setup-wrapper {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
body.theme-stripe #question-block {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.16);
}

/* Sticky bar removed */

/* Divider chip */
body.theme-stripe .divider span { background: transparent; color: var(--muted); }

/* User email chip */
body.theme-stripe #userEmail {
  background: rgba(99,91,255,0.16);
  border: 1px solid rgba(99,91,255,0.35);
  color: var(--text);
}

/* Category tiles */
body.theme-stripe .category-list label:not(.all-category) {
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
  border-color: rgba(255,255,255,0.14);
}
body.theme-stripe .all-category {
  background: linear-gradient(180deg, #7C73FF, #5F57FF);
  border-color: #7C73FF;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-body);
  font-feature-settings: "tnum" 1, "cv05" 1;
  background:
    radial-gradient(1000px 400px at 70% -80px, rgba(99,91,255,0.20), transparent 60%),
    radial-gradient(900px 420px at -10% -40%, rgba(0,212,255,0.12), transparent 50%),
    linear-gradient(180deg, #0B1020 0%, #0E1426 50%, #0B1020 100%);
  color: var(--text);
  line-height: 1.6;
  padding: 1rem;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
}

/* iOS tap highlight */
button, .btn, input {
  -webkit-tap-highlight-color: transparent;
}
button:focus, .btn:focus, input:focus {
  outline: none;
}

/* Header & Hero */
.hero {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(1200px 420px at 70% -60px, rgba(99,91,255,0.10), transparent 60%),
    radial-gradient(800px 340px at 10% -80px, rgba(0,212,255,0.08), transparent 60%),
    linear-gradient(180deg, #0A0F22 0%, #070C1A 85%);
  color: var(--text);
  text-align: center;
  padding: 1.25rem 1rem;
  margin: -3rem -1rem 1.5rem;
  width: calc(100% + 2rem);
}
#heroBanner {
  cursor: pointer;
  transition: opacity 0.2s ease;
  position: relative;
}
#heroBanner:hover {}
.hero::before { display: none; }
.hero #gradient-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: -1;
}
/* Tilted bottom edge drawn as an overlay so content isn't clipped */
.hero { padding-bottom: clamp(84px, 11vw, 180px); }
.hero::after {
  content: "";
  position: absolute;
  inset: 0 -1px -1px; /* avoid hairline gaps */
  background: var(--bg);
  -webkit-clip-path: polygon(0 84%, 100% 66%, 100% 100%, 0 100%);
          clip-path: polygon(0 84%, 100% 66%, 100% 100%, 0 100%);
  z-index: 0; /* above gradient canvas, below content */
  pointer-events: none;
}
@media (min-width: 768px) {
  .hero { padding-bottom: clamp(96px, 10vw, 200px); }
  .hero::after {
    -webkit-clip-path: polygon(0 78%, 100% 58%, 100% 100%, 0 100%);
            clip-path: polygon(0 78%, 100% 58%, 100% 100%, 0 100%);
  }
}
@media (min-width: 1200px) {
  .hero { padding-bottom: clamp(108px, 9vw, 220px); }
  .hero::after {
    -webkit-clip-path: polygon(0 74%, 100% 54%, 100% 100%, 0 100%);
            clip-path: polygon(0 74%, 100% 54%, 100% 100%, 0 100%);
  }
}
.hero-inner {
  position: relative;
  z-index: 1;
  padding: 56px 0.5rem 16px;
}
.hero-compact .hero-inner { padding: calc(18px + env(safe-area-inset-top, 0px)) 0.5rem 8px; }
.hero-compact h1 { font-size: 1.1rem; margin-bottom: 0; }
.hero-compact .tagline { display: none; }
.hero-compact .trust-badges { display: none; }
/* Hide non-essential hero content during an active quiz */
.hero-compact .cta-row,
.hero-compact .trust-line,
.hero-compact .trust-more,
.hero-compact .quiz-preview-card { display: none !important; }
.hero h1 {
  font-size: 2.1rem;
  line-height: 2.3rem;
  letter-spacing: -0.02em;
  font-weight: 800;
  margin-bottom: 0.5rem;
  max-width: 22ch;
  margin-left: auto;
  margin-right: auto;
}

/* Blend-mode title layering for mesh gradient */
.hero .title { position: relative; display: inline-block; }
.hero .title > span { position: absolute; inset: 0; }
.hero .title .above   { position: relative; color: #E6E9F5; }
.hero .title .blend   { mix-blend-mode: screen; opacity: 0.80; }
.hero .title .overlay { opacity: 0.34; }

@media (prefers-reduced-motion: reduce) {
  #gradient-canvas { animation: none; }
}

/* Dark mode palette override for the gradient (optional) */
@media (prefers-color-scheme: dark) {
  #gradient-canvas {
    --gradient-color-1: #3aa9ff;
    --gradient-color-2: #5a54ff;
    --gradient-color-3: #ff4fa3;
    --gradient-color-4: #6b9bff;
  }
}
.hero .tagline {
  font-size: 1.05rem;
  color: var(--muted);
  margin-top: 0.55rem;
  line-height: 1.5;
}
/* CTA row beneath tagline */
.cta-row { display: inline-flex; gap: 0.6rem; margin-top: 0.9rem; align-items: center; }
.cta-row .btn-primary { min-width: 172px; transform: translateY(0); box-shadow: 0 10px 20px rgba(99,91,255,0.35); }
.cta-row .btn-primary:hover { box-shadow: 0 16px 28px rgba(99,91,255,0.45); }
.cta-row .btn-ghost { color: var(--muted); }
.cta-row .btn-ghost:hover { text-decoration: underline; }
.tiny-link { margin-top: 0.25rem; }
.tiny-link a { font-size: 0.9rem; color: #a5b4fc; text-decoration: none; }
.tiny-link a:hover { text-decoration: underline; }
.trust-line { color: var(--muted); margin-top: 0.55rem; font-size: 0.95rem; }
.notice-banner {
  margin-top: 0.6rem;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.55);
  color: #fde68a;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-weight: 700;
}
.notice-banner .btn.small { margin-left: 0.5rem; border: none; color: #fed7aa; }
/* Trust center chips (not used on homepage) */
.credibility-stack { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: center; margin-top: 0.6rem; }
.cred-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 9999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.cred-chip:hover { background: rgba(255,255,255,0.10); }
/* Minimal trust link */
.trust-more { margin-top: 0.5rem; }
.trust-more a { color: #a5b4fc; text-decoration: none; }
.trust-more a:hover { text-decoration: underline; }
/* Trust badges under tagline */
/* Hide old pill badges in favor of compact trust line */
.trust-badges { display: none; }
.home-icon {
  position: absolute;
  top: 10px;
  left: 15px;
  font-size: 1.5rem;
  opacity: 0.8;
  transition: opacity 0.2s ease;
  z-index: 2;
}
#heroBanner:hover .home-icon {}
#heroBanner .hamburger-btn {
  position: absolute;
  top: 2rem;
  right: 1rem;
  font-size: 1.5rem;
  color: #E6E9F5;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 0.25rem 0.5rem;
  z-index: 2;
}

/* Account trigger replaces hamburger */
#heroBanner .account-trigger {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  color: #E6E9F5;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 9999px;
  cursor: pointer;
  z-index: 10;
}
#heroBanner .account-trigger:hover { background: rgba(255,255,255,0.12); }
/* Logged-in: present a tighter circular avatar-only control */
#heroBanner .account-trigger.is-logged-in {
  padding: 0.25rem; /* tighter hit target around the avatar */
  background: transparent;
  border: none;
}
#heroBanner .account-trigger.is-logged-in .avatar-chip {
  background: transparent;
  border: none;
  padding: 0;
}

/* Inline header nav for desktops */
.header-nav {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 7.5rem;
  display: none;
  gap: 1rem;
  z-index: 2; /* ensure above hero tilt overlay */
}
.header-nav .header-link { color: #E6E9F5; text-decoration: none; opacity: 0.9; text-shadow: 0 1px 6px rgba(0,0,0,0.35); }
.header-nav .header-link:hover { text-decoration: underline; opacity: 1; }
/* Hero content with preview card */
.hero-content { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; }
.quiz-preview-card { display: block; background: rgba(15,22,46,0.9); border: 1px solid rgba(255,255,255,0.18); border-radius: 12px; padding: 0.9rem; box-shadow: var(--shadow); text-align: left; max-width: 380px; margin: 0 auto; }
.quiz-preview-card .preview-header { font-weight: 700; margin-bottom: 0.5rem; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.quiz-preview-card .preview-close { background: transparent; border: none; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; padding: 0.25rem; border-radius: 8px; }
.quiz-preview-card .preview-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.quiz-preview-card .preview-body { font-size: 0.95rem; }
.quiz-preview-card .preview-question { margin-bottom: 0.5rem; }
.quiz-preview-card .preview-options { list-style: disc; padding-left: 1.25rem; margin: 0; }
.quiz-preview-card .preview-options .muted { opacity: 0.7; }
.quiz-preview-card .preview-hint { margin-top: 0.6rem; color: var(--muted); font-size: 0.9rem; }
.quiz-preview-card .preview-reveal {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.9rem;
  color: #a5b4fc;
  text-decoration: none;
}
.quiz-preview-card .preview-reveal:hover { text-decoration: underline; }
.quiz-preview-card .preview-options li.correct { color: var(--success); font-weight: 600; }

/* Visually hidden but accessible text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 900px) {
  .hero-content { grid-template-columns: 1.5fr 1fr; gap: 2rem; text-align: left; }
  .hero-inner { text-align: left; margin-left: auto; margin-right: auto; }
  .hero h1 { max-width: 28ch; }
}
/* Bottom sheet overlay */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
}
.sheet-overlay.visible { display: block; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(15,22,46,1);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.45);
  transform: translateY(100%);
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 16px));
}
.sheet-overlay.visible .sheet { transform: translateY(0); }

.sheet-header { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.15rem; margin-bottom: 0.5rem; padding-right: 2.5rem; }
.sheet-title { font-weight: 800; font-size: 1.1rem; }
.sheet-subtitle { color: var(--muted); font-size: 0.95rem; overflow-wrap: anywhere; }
.sheet-close { position: absolute; top: 0.5rem; right: 0.5rem; font-size: 1.5rem; background: none; border: none; color: var(--text); padding: 0.75rem; cursor: pointer; line-height: 1; z-index: 2; }

.sheet-body { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.sheet-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem 0.9rem; border-radius: 12px; color: var(--text); text-decoration: none; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); font-size: 1rem; font-weight: 600; min-height: 44px; }
.sheet-item:hover { background: rgba(255,255,255,0.10); }
.sheet-item.primary { background: linear-gradient(180deg, #7C73FF, var(--primary)); border-color: #7C73FF; color: #fff; font-weight: 700; justify-content: center; }
.sheet-item.secondary { background: rgba(255,255,255,0.06); }
.sheet-item.danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); color: #fecaca; }

.avatar-chip { display: inline-flex; align-items: center; gap: 0.5rem; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.16); padding: 0.25rem 0.5rem; border-radius: 9999px; min-height: 32px; }
.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(180deg, #877EFF, #5B54FF);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 14px rgba(99,91,255,0.35);
}
/* Slight scale on hover for feedback */
#heroBanner .account-trigger.is-logged-in .avatar-circle { transition: transform 120ms ease; }
#heroBanner .account-trigger.is-logged-in:hover .avatar-circle { transform: none; }

/* Popover (desktop) */
.popover {
  position: fixed;
  top: 64px; /* drop below fixed header controls to avoid clipping */
  right: 12px;
  width: 320px;
  background: rgba(15,22,46,0.98);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  padding: 0.5rem;
  z-index: 1001;
}
/* Prevent hero tilt overlay from overlapping the popover */
.hero::after { z-index: 0; }
.popover { z-index: 1100; }
.popover.visible { display: block !important; }
.popover.hidden { display: none !important; }
.popover .sheet-item { width: 100%; }

/* Responsive presentation switch */
@media (min-width: 1025px) {
  /* Hide account bottom-sheet on desktop; use popover. Keep other sheets (e.g., builder). */
  #accountSheet.sheet-overlay { display: none !important; }
  /* Builder presented as sidebar without blocking scrim */
  #builderOverlay.sheet-overlay { display: block; background: transparent; pointer-events: none; }
  #builderOverlay .builder-sheet { pointer-events: auto; }
}

/* Hide inline header nav at all sizes to avoid overlap; links live in Account menu */
.header-nav { display: none !important; }

/* Items inside hamburger menu */
#collapsingMenu .btn {
  width: 100%;
  justify-content: center;
}
#collapsingMenu .btn-secondary {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.16);
}
#collapsingMenu .btn-secondary:hover {
  background: rgba(255,255,255,0.10);
}
#collapsingMenu .btn-ghost {
  color: var(--text);
}

/* Banner Modes - keep dark theme consistently */
.hero.free,
.hero.premium {
  background:
    radial-gradient(1200px 420px at 70% -60px, rgba(99,91,255,0.18), transparent 60%),
    radial-gradient(800px 340px at 10% -80px, rgba(0,212,255,0.12), transparent 60%),
    linear-gradient(180deg, rgba(12,18,36,1) 0%, rgba(9,14,28,1) 85%);
}

/* --- New styles for Subscription Status in Hero --- */
.subscription-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 0.4rem;
    padding-bottom: 0.3rem;
}
#freeStatus { font-weight: 600; color: var(--muted); background: none; border: 0; padding: 0; }
.subscription-status.subtle #freeStatus { opacity: 0.85; }

#freeStatus {
    color: var(--muted);
    font-weight: 600;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.16);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
}

.subscription-status .premium-btn {
    background-color: var(--primary);
    color: #fff;
    border: 2px solid var(--primary);
    box-shadow: none;
    font-weight: 700;
}
.subscription-status .premium-btn:hover { background-color: var(--primary-600); border-color: var(--primary-600); }
.subscription-status .premium-btn:active { background-color: var(--primary-700); border-color: var(--primary-700); }
/* --- End New Styles --- */

/* Faint divider between cards */
.or-divider {
  text-align: center;
  color: var(--muted);
  opacity: 0.7;
  margin: -0.5rem 0 0.5rem;
}

/* Legacy Header */
.app-header { margin-bottom: 1.5rem; }
.app-title {
  font-size: 1.75rem;
  margin: 0.5rem 0;
  color: var(--heading-color);
  cursor: pointer;
  user-select: none;
}

/* Layout */
.app-main {
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
}
/* Social proof under CTA */
.social-proof { margin-top: 0.4rem; color: var(--muted); font-size: 0.95rem; }
.app-main .card h2, .premium-copy h3, #results-container h2, #manageQuestionsContainer h2, #admin-container h2 {
  color: var(--text);
}
.setup-wrapper {
  padding: 0.5rem 1rem;
  border-radius: 0.4rem;
  background: transparent;
  box-shadow: none;
  border: none;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* Cards & Forms */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
}
.card > * + * { margin-top: 1.25rem; }
.card [class*="container"], .card [class*="group"], .card [class*="wrapper"] {
  gap: 1.25rem;
}
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}
input, select, .btn { margin-top: 0.25rem; }
.magic-link-form,
.auth-form { display: flex; flex-direction: column; gap: 1rem; width: 100%; max-width: 400px; margin: 0 auto; }
.magic-link-form input[type="email"], .auth-form input {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  min-height: 44px;
}
.magic-link-form input[type="email"]:focus,
.auth-form input:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99,91,255,0.35);
}

/* Category List */
.category-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px,1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.category-list label:not(.all-category) {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1), background var(--transition-fast), border-color var(--transition-fast);
}
.category-list label:not(.all-category):hover { transform: none; }
.category-list label small { margin-top: 0.25rem; font-size: 0.8rem; }
/* Compact count badge */
.category-list label small.badge { display: inline-block; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); border-radius: 9999px; padding: 0.15rem 0.45rem; font-size: 0.78rem; }
.category-list input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-bottom: 0.4rem;
  accent-color: var(--color-primary);
}

/* Hide checkboxes in the categories container */
#categories-container label input.category-checkbox {
	display: none;
}

/* Style for selected category label */
#categories-container label.selected {
	background: linear-gradient(180deg, rgba(124,115,255,0.22), rgba(95,87,255,0.18));
	cursor: pointer;
	padding: 1rem;
	border-radius: 12px;
  border: 1px solid #7C73FF;
  color: var(--text);
}
/* Remove extra checkmark on selected tiles; color change is enough */
#categories-container label.selected::after { content: none; }
.category-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary-600), var(--primary));
  width: var(--progress, 0%);
}

/* New styles for the All categorie label to mimic button styles */

/* Ensure Select All chip is high-contrast */
.all-category {
	/* Mimic .btn styles */
	display: inline-flex; /* if needed */
	align-items: center;
	justify-content: center;
	font-size: 1rem;
	padding: 0.75rem 1.25rem;
	background: linear-gradient(180deg, #7C73FF, var(--primary));
	color: #fff;
	border: 2px solid #7C73FF;
	border-radius: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: background var(--transition-fast), border-color var(--transition-fast), filter var(--transition-fast);
	text-decoration: none;
	min-height: 44px;
	gap: 0.5rem;
}
.all-category:hover:not(:disabled) { background: var(--primary-600); border-color: var(--primary-600); }
/* Ensure any embedded checkbox is hidden */
.all-category input.category-checkbox {
	display: none;
}

#allCategories {
	opacity: 0;
	position: absolute;
	width: 0;
	height: 0;
	pointer-events: none;
}

/* When the "All" category is toggled selected, change its background color */
.all-category.selected {
    background-color: #EFF6FF;
    color: var(--text);
    border-color: var(--primary-600);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1), background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
  text-decoration: none;
  border: 2px solid transparent;
  min-height: 44px;
  white-space: normal;
  text-align: center;
}
.btn:hover { transform: none; }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(99,91,255,0.35); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  min-width: 140px;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-600); border-color: var(--primary-600); }
.btn-primary:active:not(:disabled) { background: var(--primary-700); border-color: var(--primary-700); }
.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.10);
}
.btn-ghost {
  background: none;
  color: var(--text);
  border: none;
  padding: 0;
  font-weight: 600;
}
.btn-ghost:hover:not(:disabled) { text-decoration: underline; }
.btn.small { min-height: 38px; padding: 0.5rem 0.75rem; font-size: 0.9rem; }
.btn.full-width { width: 100%; }
.btn.danger { --color-primary: var(--error); }
.btn.success { --color-primary: var(--success); }

/* Deprecated button variants */
.secondary-btn, .quiz-btn, .exam-btn, .review-btn, .streak-btn, .danger-btn, .admin-toggle {
  all: unset;
}

/* Quick Start Card */
.quick-start-card {
  display: grid;
  gap: 0.75rem;
}
.qs-header h2 { margin: 0; }
.qs-subtitle { color: var(--muted); font-size: 0.95rem; }
.qs-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
}
.qs-note { font-size: 0.85rem; color: var(--muted); }
.qs-note span { font-weight: 600; color: #334155; }

/* Premium Teaser */
.premium-teaser { padding: 1rem; }
.premium-content { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.premium-copy h3 { margin: 0 0 0.25rem 0; }
.checklist { list-style: none; margin: 0.25rem 0 0; padding: 0; }
.checklist li { position: relative; padding-left: 1.25rem; margin: 0.25rem 0; }
.checklist li::before { content: "✓"; position: absolute; left: 0; color: #16a34a; font-weight: 700; }
.premium-cta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; }
.price-note { color: #64748b; font-size: 0.85rem; }

@media (max-width: 700px) {
  .premium-content { flex-direction: column; align-items: stretch; }
  .premium-cta { align-items: stretch; }
}

/* Tab subtext */
.tab-subtext { margin: 0.25rem 0 0.5rem; color: #475569; font-size: 0.95rem; }

/* Sticky Start Bar removed */
/* Haptics-like visual feedback */
.category-list label:not(.all-category):active { transform: scale(0.98); }

/* Slightly brighter helper text for contrast */
.tab-subtext, .plan-note, .trust-line, .social-proof { color: #AEB6D6; }

/* Hide legacy mode controls and frontpage categories on the main page; use Presets + Builder */
#setup-container .tab-nav, #setup-container .tab-content, #setup-container h2, #categories-container, #allCategoryLabel, #planNote { display: none !important; }

/* Presets */
.preset-actions { display: inline-flex; gap: 0.5rem; align-items: stretch; }

/* Mobile-first improvements for Presets and Builder launcher */
#presetsSection .segmented { width: 100%; flex-wrap: nowrap; justify-content: space-between; }
#presetsSection .segmented .seg-btn { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#presetsSection .microcopy { text-align: center; }
#buildLauncher .qs-subtitle { color: var(--muted); }

@media (max-width: 600px) {
  #presetsSection .preset-actions,
  #buildLauncher .preset-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  #presetsSection .preset-actions .btn,
  #buildLauncher .preset-actions .btn { width: 100%; }
  #presetsSection .segmented { gap: 0.15rem; padding: 0.2rem; }
  #presetsSection .segmented .seg-btn { padding: 0.5rem 0.6rem; font-size: 0.95rem; }
}

/* Builder launcher under presets */
.build-seg { margin-top: 0.5rem; }

/* Improve All chip visuals */
#allCategoryLabel { gap: 0.5rem; }
#allCategoryLabel .tick { font-weight: 700; color: var(--primary-600); }

/* Subtle premium badge for limited categories */
.premium-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.4rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 600;
  background: rgba(124,115,255,0.18);
  color: var(--text);
  border: 1px solid rgba(124,115,255,0.45);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 1;
}
.premium-user .premium-badge { display: none !important; }

.category-list label:hover .premium-badge,
.category-list label.selected .premium-badge {
  opacity: 1;
}

/* Hide duplicate controls in quiz/results views */
.app-main.view-quiz .premium-teaser { display:none; }

/* Plan note */
.plan-note { color: #475569; background: #f8fafc; border: 1px dashed #cbd5e1; padding: 0.5rem 0.75rem; border-radius: 8px; margin: 0.25rem 0 0.75rem; }
.plan-note { color: var(--muted); background: var(--surface); border: 1px dashed var(--border); padding: 0.5rem 0.75rem; border-radius: 12px; margin: 0.25rem 0 0.75rem; }

/* Progress & Score */
.progress-score-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.progress-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 0.75rem;
}
#progressBar {
  flex: 1;
  height: 12px;
  appearance: none;
  border-radius: 6px;
  overflow: hidden;
}
#progressBar::-webkit-progress-bar { background: var(--border); }
#progressBar::-webkit-progress-value { background: linear-gradient(90deg, #7C73FF, var(--primary)); }
.score-streak-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}
#streakWrapper, #bestStreakWrapper, #streakAnsweredWrapper { display: none; }
#streak-progress-container {
  display: none;
  width: 100%;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 10px;
}
#streakProgressBar {
  height: 20px;
  width: 0;
  background: var(--primary);
  transition: width 0.5s ease, background-color 0.5s ease;
}
#streakProgressText { text-align: center; margin-top: 5px; font-weight: bold; }

/* Question & Answers */
#question-block {
  margin-top: 1rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* Keep the quiz controls (Next Question) visible without scrolling */
.quiz-controls {
  position: sticky;
  bottom: 0;
  display: none; /* hidden by default; toggled with .has-next */
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(15,22,46,0.85), rgba(15,22,46,0.95));
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  z-index: 5;
}
.quiz-controls.has-next { display: flex; }
.quiz-controls .btn { min-width: 150px; }

/* Hide border and background when empty */
#question-block:empty {
  border: none;
  background: none;
  padding: 0;
  box-shadow: none;
}

.answer-option-box {
  display: flex;
  align-items: center;
  padding: 1rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  cursor: pointer;
  word-break: break-word;
  overflow-wrap: anywhere;
  background: rgba(255,255,255,0.06);
}
.answer-option-box:not(.correct-answer):not(.incorrect-answer):hover { background: var(--surface); }
.answer-option-box input[type="radio"] { margin-right: 0.5rem; width: 1.2em; height: 1.2em; }
.correct-answer { background: var(--success-50); color: var(--success); border: 1px solid var(--success); }
.correct-answer-light { background: var(--success-50); color: var(--success); border: 1px solid var(--success); }
.incorrect-answer { background: var(--error-50); color: var(--error); border: 1px solid var(--error); }
.feedback-text { font-weight: 600; margin-top: 0.75rem; color: var(--muted); font-size: 0.95rem; }
.missed-question { background: var(--error-50); padding: 0.75rem; border-left: 5px solid var(--error); margin-bottom: 1.5rem; border-radius: 8px; }

/* Admin Sections */
.admin-section { margin-bottom: 2rem; }
#questionsList .manage-question { border: 1px solid var(--border-color); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.75rem; }
#manageQuestionsContainer h2 { margin-top: 0; }

/* Modal & Overlays */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; transition: opacity var(--transition-slow); }
.modal.visible { display: block !important; }
.modal-content { position: relative; background: #0F162E; max-width: 900px; border-radius: 12px; box-shadow: 0 30px 80px rgba(0,0,0,0.45); width: 95%; max-height: 85vh; overflow-y: auto; padding: 1.25rem; margin: 3rem auto; border: 1px solid rgba(255,255,255,0.08); }
.modal-close { position: absolute; top: 1rem; right: 1rem; font-size: 2rem; background: none; border: none; cursor: pointer; padding: 0.75rem; }

/* Upgrade Modal */
.upgrade-modal-content { max-width: 95vw; width: 100%; max-height: 90vh; overflow-y: auto; padding: 1.2rem; box-sizing: border-box; background: transparent; border: none; box-shadow: none; }

/* Unified Plans grid */
.plans-grid { display: grid; grid-template-columns: repeat(2, minmax(260px,1fr)); gap: 1rem; margin: 0.5rem 0; align-items: stretch; }
@media (max-width: 720px) { .plans-grid { grid-template-columns: 1fr; } .plan-card.premium { order: -1; } }

/* Black-glass cards */
.plan-card {
  background: #0B0B0F;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  padding: 1.5rem; /* ~24px */
  display: grid;
  grid-template-rows: auto auto auto 1fr auto; /* Keep CTA directly under price; features take remaining space */
  gap: 1rem;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.plan-card .plan-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0; }
.plan-card .plan-title { font-weight: 900; font-size: 1.25rem; letter-spacing: -0.01em; color: rgba(255,255,255,0.9); margin: 0; }
.plan-card .plan-badge { font-size: 0.8rem; font-weight: 700; color: rgba(255,255,255,0.75); background: rgba(124,115,255,0.12); border: 1px solid rgba(124,115,255,0.35); border-radius: 9999px; padding: 0.2rem 0.5rem; }
.plan-card .plan-badge.subtle { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.14); color: rgba(255,255,255,0.7); }

/* Price hierarchy */
.plan-card .plan-price { display: inline-grid; grid-auto-flow: column; align-items: baseline; justify-content: start; text-align: left; gap: 0.12rem; color: rgba(255,255,255,0.9); font-variant-numeric: tabular-nums; margin-top: 1rem; }
.plan-card .plan-price .currency { font-size: 0.8rem; letter-spacing: 0.02em; color: rgba(255,255,255,0.75); }
.plan-card .plan-price .amount { font-size: clamp(3.5rem, 7.5vw, 4rem); font-weight: 900; letter-spacing: -0.02em; }
.plan-card .plan-price .period { font-size: 0.85rem; color: rgba(255,255,255,0.75); font-weight: 700; }

/* CTA */
.plan-card .plan-cta { margin-top: 0.5rem; min-height: 46px; height: 48px; grid-row: 3; }
.plan-card .btn-primary { box-shadow: none; }

/* Explicit grid placement to keep CTAs aligned */
.plan-card .plan-head { grid-row: 1; }
.plan-card .plan-price { grid-row: 2; }
.plan-card .plan-features { grid-row: 4; }
.plan-card .plan-footnote { grid-row: 5; }

/* Feature list with check icons */
.plan-features { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 0.5rem; }
.plan-features li { display: grid; grid-template-columns: 18px 1fr; align-items: start; column-gap: 0.5rem; font-size: 0.98rem; line-height: 1.5; color: rgba(255,255,255,0.85); }
.plan-features li .li-check { position: relative; width: 12px; height: 12px; margin-top: 0.35rem; opacity: 0.85; }
.plan-features li .li-check::after { content: ""; position: absolute; left: 2px; top: 1px; width: 4px; height: 7px; border: solid var(--primary); border-width: 0 2px 2px 0; transform: rotate(45deg); opacity: 0.9; }
.plan-features li.muted-intro { grid-template-columns: 1fr; color: rgba(255,255,255,0.72); font-weight: 700; padding-left: 0; margin-top: 1.25rem; margin-bottom: 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.10); padding-bottom: 0.5rem; }

.plan-footnote { color: rgba(255,255,255,0.65); font-size: 0.9rem; margin-top: 1rem; }

.plan-card.premium { border-color: rgba(124,115,255,0.35); background: #0B0B0F; }

/* Outline button variant for Free */
.btn.btn-outline {
  background: transparent;
  color: rgba(255,255,255,0.9);
  border: 2px solid rgba(255,255,255,0.28);
}
.btn.btn-outline:hover { border-color: rgba(255,255,255,0.45); background: rgba(255,255,255,0.04); }
.btn.btn-outline:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,0.20); }


/* Auth & Notifications */
.auth-modal { max-width: 400px; padding: 2rem; }
.auth-options { margin-bottom: 2rem; }
.google-login-btn { display: flex; align-items: center; justify-content: center; gap: 1rem; width: 100%; padding: 0.8rem; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,0.06); color: var(--text); text-decoration: none; font-weight: 500; transition: background 0.2s ease; }
.google-login-btn { border-color: var(--border); border-radius: 12px; background: rgba(255,255,255,0.06); color: var(--text); }
.google-login-btn:hover { background: rgba(255,255,255,0.10); }
.google-login-btn img { width: 18px; height: 18px; }
.divider { text-align: center; margin: 1.5rem 0; position: relative; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 45%; height: 1px; background: var(--border); }
.divider::before { left: 0; }
.divider::after { right: 0; }
.divider span { background: transparent; padding: 0 10px; color: var(--muted); font-size: 0.9rem; }
.switch-auth { text-align: center; margin-top: 1.5rem; color: var(--muted); }
.switch-auth a { color: var(--primary); text-decoration: none; }
.switch-auth a:hover { text-decoration: underline; }
.forgot-password { text-align: center; margin: 1rem 0; font-size: 0.9em; }
.forgot-password a { color: var(--primary); text-decoration: none; }
.forgot-password a:hover { text-decoration: underline; }
#resendVerificationBtn { margin-top: 0.5rem; background: #90caf9; color: #1565c0; border: none; }
#resendVerificationBtn:hover { background: #64b5f6; }
.toast { position: fixed; top: 20px; right: 20px; background: var(--success); color: #fff; padding: 1rem 2rem; border-radius: 10px; box-shadow: 0 10px 24px rgba(0,0,0,0.35); z-index: 1000; animation: slideIn 0.3s ease-out; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.info { background: var(--primary); }
.toast.warn { background: var(--warn); }
.toast.error { background: var(--error); }

/* User Auth Display */
.user-auth { display: flex; align-items: center; gap: 0.8rem; }
#userEmail { background: rgba(99,91,255,0.16); padding: 0.5rem 1rem; border-radius: 8px; font-size: 0.95rem; color: var(--text); border: 1px solid rgba(99,91,255,0.35); display: flex; align-items: center; gap: 0.5rem; }
#userEmail::before { content: "👤"; margin-right: 0.3rem; }

/* Utilities */
.hidden { display: none !important; }
.visible { display: block !important; }
.visible-flex { display: flex !important; }

/* Forms & Inputs */
input[type="number"] { width: 100%; max-width: 100px; padding: 0.5rem; font-size: 1rem; min-height: 44px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,0.06); color: var(--text); }
.form-group label[for="autoAdvanceCheckbox"] { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--color-primary); }

/* Tab Navigation Styles */
.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-link {
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  position: relative;
  bottom: -2px; /* Aligns with the parent's border */
  border-bottom: 2px solid transparent;
}

.tab-link:hover { background-color: var(--surface); }

.tab-link.active {
  font-weight: 700;
  color: #CBD1FF;
  border-bottom-color: #7C73FF;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Responsive */
@media (min-width: 600px) {
  .quiz-controls-row { flex-direction: row; align-items: center; }
  .progress-score-container { flex-direction: row; align-items: center; }
  .progress-group { flex: 1 1 auto; margin-bottom: 0; margin-right: 1rem; }
  .score-streak-info { flex: 2 1 auto; justify-content: flex-end; }
}
@media (min-width: 1024px) {
  .setup-wrapper { max-width: 900px; }
}
@media (max-width: 600px) {
  .setup-wrapper { padding: 0.7rem 0.3rem; max-width: 98vw; overflow-x: hidden; }
  .pricing-table { grid-template-columns: 1fr; gap: 1rem; margin: 1rem 0; }
  .pricing-column { padding: 1rem 0.5rem; }
  .modal-content.upgrade-modal-content { padding: 0.7rem 0.3rem 1.2rem; max-width: 99vw; width: 98vw; max-height: 95vh; border-radius: 8px; }
  /* Keep quiz header compact on mobile */
  .progress-score-container { flex-direction: row; align-items: center; padding: 0.5rem 0.5rem; }
  .progress-group { margin-bottom: 0; gap: 0.5rem; }
  #progressText { font-size: 0.9rem; }
  .score-streak-info { gap: 0.35rem; justify-content: space-between; }
}

/* Responsive hero scaling */
@media (min-width: 480px) {
  .hero-inner { padding: 52px 0.5rem 14px; }
  .hero h1 { font-size: 2.25rem; line-height: 2.6rem; }
  .hero .tagline { font-size: 1.075rem; }
}
@media (min-width: 768px) {
  .hero-inner { padding: 66px 0.5rem 18px; }
  .hero h1 { font-size: 2.6rem; line-height: 3rem; }
  .hero .tagline { font-size: 1.1rem; }
}
@media (min-width: 1024px) {
  .hero-inner { padding: 80px 0.5rem 22px; }
  .hero h1 { font-size: 3rem; line-height: 3.4rem; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Ultra-compact stats labels on very small screens */
@media (max-width: 420px) {
  .score-streak-info .stat-block strong { display: none; }
  .score-streak-info { font-size: 0.9rem; }
}

/* Builder (bottom sheet / sidebar) */
.builder-sheet { max-width: 680px; margin: 0 auto; }
.builder-stepper { color: var(--muted); font-weight: 600; margin-bottom: 0.5rem; }
.segmented { display: inline-flex; background: rgba(255,255,255,0.06); border: 1px solid var(--border); border-radius: 9999px; padding: 0.25rem; gap: 0.25rem; }
.segmented .seg-btn { background: transparent; border: none; color: var(--text); padding: 0.5rem 0.9rem; border-radius: 9999px; cursor: pointer; font-weight: 700; }
.segmented .seg-btn.active { background: var(--primary); color: #fff; }
.microcopy { color: var(--muted); margin-top: 0.4rem; }
.builder-meta { color: var(--muted); margin: 0.25rem 0 0.5rem; }
.builder-actions { display: flex; justify-content: flex-end; margin: 0.25rem 0; }
.builder-cat-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; max-height: 38vh; overflow: auto; }
.chip { background: rgba(255,255,255,0.06); border: 1px solid var(--border); color: var(--text); padding: 0.35rem 0.6rem; border-radius: 9999px; font-weight: 600; cursor: pointer; }
.chip.active { background: linear-gradient(180deg, #7C73FF, var(--primary)); border-color: #7C73FF; color: #fff; }
.pill-row { display: inline-flex; gap: 0.5rem; margin-top: 0.5rem; }
.pill { background: rgba(255,255,255,0.06); border: 1px solid var(--border); color: var(--text); padding: 0.5rem 0.8rem; border-radius: 9999px; cursor: pointer; font-weight: 700; }
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.even-toggle { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; }
.builder-footer { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.75rem; }
.builder-footer .btn { min-width: 120px; }

/* Desktop sidebar presentation for builder */
@media (min-width: 1025px) {
  .builder-sheet { position: fixed; top: 0; right: 0; bottom: 0; left: auto; width: 360px; transform: none !important; border-radius: 0; }
  .sheet-overlay.visible .builder-sheet { transform: none; }
}

/* --- Layout Improvements for Quiz/Exam Sections --- */

.quiz-controls-row {
    display: flex;
    flex-direction: column; /* Stack quick buttons and input/button group on small screens */
    gap: 1.5rem;
    align-items: flex-start;
}

.quick-buttons {
    display: flex; /* Arrange buttons in a row */
    gap: 0.5rem;
    flex-wrap: wrap; /* Wrap buttons on small screens */
}

.question-input-group {
    display: flex;
    flex-direction: column; /* Stack label, input, and button vertically by default */
    gap: 0.75rem;
    align-items: flex-start;
    width: 100%;
}

.question-input-group .num-questions-label {
    margin-bottom: 0; /* Remove default margin when using flex gap */
}

.question-input-group input[type="number"] {
     width: 80px; /* Set a fixed width for the input */
     max-width: none; /* Override any max-width */
     box-sizing: border-box;
}

.additional-actions {
    display: flex; /* Arrange buttons in a row */
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: center; /* Center buttons when wrapping */
}

@media (min-width: 600px) {
    .quiz-controls-row {
        flex-direction: row; /* Place quick buttons and input/button group side-by-side */
        align-items: center; /* Vertically center items */
        gap: 2rem;
    }
    .question-input-group {
        flex-direction: row; /* Arrange label, input, and button in a row */
        align-items: center; /* Vertically align items */
        gap: 0.75rem;
        flex-grow: 1; /* Allow taking up available space */
        justify-content: flex-end; /* Push input and button towards the right */
    }
    .question-input-group .num-questions-label {
        margin-right: auto; /* Push label to the left */
        margin-bottom: 0;
    }
    .question-input-group .btn-primary {
         min-width: 140px; /* Ensure consistent minimum width for the Start button */
    }
    .additional-actions {
        justify-content: flex-start; /* Align to the left on wider screens */
    }
}

/* --- End Layout Improvements --- */

/* --- State-based View Management --- */

/* Default view (setup) hides quiz and results */
.app-main:not(.view-quiz):not(.view-results) #quiz-container,
.app-main:not(.view-quiz):not(.view-results) #results-container {
    display: none;
}

/* Quiz view shows the quiz and hides setup/results */
.app-main.view-quiz .setup-wrapper,
.app-main.view-quiz .quick-start-card,
.app-main.view-quiz .premium-teaser,
.app-main.view-quiz #results-container {
    display: none;
}
.app-main.view-quiz #quiz-container {
    display: block;
}

/* Results view shows the results and hides setup/quiz */
.app-main.view-results .setup-wrapper,
.app-main.view-results .quick-start-card,
.app-main.view-results .premium-teaser,
.app-main.view-results #quiz-container {
    display: none;
}
.app-main.view-results #results-container {
    display: block;
}

/* Default state for quiz and results containers */
#quiz-container,
#results-container {
  display: none;
}

/* Only show quiz container borders when it has content */
#quiz-container:empty {
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

#quiz-container.card {
  display: none; /* Start hidden */
  background: transparent; /* remove heavy surface in quiz */
  border: none; /* remove outermost card border for quiz */
  box-shadow: none;
}

/* When quiz view is active, show the container */
.app-main.view-quiz #quiz-container.card {
  display: block;
}

/* Builder category selection nudge */
.shake-nudge {
  animation: shake-nudge 0.6s ease-in-out;
}

@keyframes shake-nudge {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
  20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* Disabled button styling */
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Subtle pulse to draw attention to Unlock Premium CTA */
.pulse-cta {
  animation: pulse-cta 1.2s ease-in-out 3;
}
@keyframes pulse-cta {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(124,115,255,0.4); }
  50% { transform: scale(1.03); box-shadow: 0 0 0 8px rgba(124,115,255,0.0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(124,115,255,0.0); }
}

/* Inline auto-advance notice */
.auto-advance-ui {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  color: var(--muted);
  font-weight: 600;
}

/* Compact preferences row between cards */
.prefs-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  margin: 0.25rem 0 1rem;
  padding: 0.25rem 0.25rem;
}
.prefs-row .switch-label { color: var(--muted); font-weight: 600; }
.prefs-row .help-icon { opacity: 0.8; }

/* Slick toggle switch */
.switch { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(255,255,255,0.10);
  border: 1px solid var(--border);
  border-radius: 9999px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.switch .slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 9999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  transition: transform var(--transition-fast);
}
.switch input:checked + .slider { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

@media (max-width: 600px) {
  .prefs-row { justify-content: center; }
  .prefs-row .switch-label { font-size: 0.95rem; }
}