/* =========================================================================
   Formo — Modern Glassmorphism & High-Tech Design System
   ========================================================================= */

:root {
  /* Colors & Gradients */
  --bg-main: #0B0F19;
  --bg-card: #151C2D;
  --bg-card-hover: #1E293B;
  --bg-glass: rgba(21, 28, 45, 0.75);
  --bg-input: #0F172A;
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-faint: #64748B;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #6366F1;
  --border-hover: rgba(255, 255, 255, 0.18);
  
  --accent: #6366F1;
  --accent-hover: #4F46E5;
  --accent-light: rgba(99, 102, 241, 0.12);
  --accent-glow: rgba(99, 102, 241, 0.35);
  
  --ai-gradient: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%);
  --ai-glow: rgba(139, 92, 246, 0.3);
  
  --emerald: #10B981;
  --emerald-soft: rgba(16, 185, 129, 0.12);
  --amber: #F59E0B;
  --amber-soft: rgba(245, 158, 11, 0.12);
  --rose: #F43F5E;
  --rose-soft: rgba(244, 63, 94, 0.12);
  
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 35px -10px rgba(0, 0, 0, 0.4), 0 0 20px rgba(99, 102, 241, 0.15);
  
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100vh; }

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.12) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.4em;
  letter-spacing: -0.02em;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: #818CF8; }
p { margin: 0 0 1em; color: var(--text-muted); }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.mono { font-family: var(--font-mono); }

/* ---------- Navigation & Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 21px;
  color: var(--text-main);
  text-decoration: none;
}

.brand:hover { text-decoration: none; opacity: 0.95; }

.mark-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--ai-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  box-shadow: 0 0 15px var(--ai-glow);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.nav-logout {
  color: var(--text-faint);
  margin-left: 8px;
}

.nav-logout:hover {
  color: var(--rose);
  background: var(--rose-soft);
}

/* ---------- Layout Container ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.container.narrow { max-width: 680px; }

/* ---------- Header & Titles ---------- */
.dashboard-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.header-titles h1 { font-size: 32px; margin: 0; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-create-form {
  display: flex;
  gap: 8px;
}

.quick-create-form input {
  width: 220px;
  background: var(--bg-card);
  border-color: var(--border-color);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--bg-card-hover);
  color: var(--text-main);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 20px var(--accent-glow);
  color: #FFFFFF;
}

.btn-ai-gradient {
  background: var(--ai-gradient);
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: 0 4px 18px var(--ai-glow);
  border: none;
}

.btn-ai-gradient:hover {
  opacity: 0.94;
  box-shadow: 0 6px 24px var(--ai-glow);
  color: #FFFFFF;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--border-hover);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.btn-danger {
  background: var(--rose-soft);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.btn-danger:hover {
  background: var(--rose);
  color: #FFFFFF;
}

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: var(--radius); }
.btn-block { width: 100%; }

.btn-icon-only {
  padding: 6px 8px;
  color: var(--text-faint);
}

.btn-icon-only:hover { color: var(--text-main); }

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ---------- Cards & Form Grid ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease;
}

.toolbar-filter {
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  max-width: 320px;
}

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
}

.search-box input {
  padding-left: 38px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.form-card:hover {
  transform: translateY(-3px);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-title {
  font-size: 18px;
  margin: 0;
  line-height: 1.3;
  color: var(--text-main);
}

.live-link-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 8px;
  border-radius: var(--radius-pill);
}

.card-stats {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.stat-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.stat-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-main);
}

.stat-lbl {
  font-size: 12px;
  color: var(--text-faint);
}

.card-actions {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-published {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-published .status-dot { background: var(--emerald); }

.status-draft {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-draft .status-dot { background: var(--amber); }

.status-closed {
  background: var(--rose-soft);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.status-closed .status-dot { background: var(--rose); }

.empty-state {
  text-align: center;
  padding: 64px 32px;
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ---------- Inputs & Form Controls ---------- */
label.field-label {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 6px;
  color: var(--text-main);
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=date], input[type=datetime-local], input[type=time], input[type=url], textarea, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-main);
  color-scheme: dark;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

::-webkit-calendar-picker-indicator {
  filter: invert(0.9);
  cursor: pointer;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}


textarea { resize: vertical; min-height: 90px; }

.help-text { font-size: 12.5px; color: var(--text-faint); margin-top: 5px; }
.field-error { font-size: 12.5px; color: var(--rose); margin-top: 5px; font-weight: 600; }
.required-mark { color: var(--rose); margin-left: 3px; }
.field-group { margin-bottom: 20px; }

/* ---------- AI Builder Hero ---------- */
.ai-hero-container {
  max-width: 720px;
  margin: 0 auto;
}

.ai-hero-head {
  text-align: center;
  margin-bottom: 28px;
}

.ai-spark-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--accent-light);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.ai-hero-head h1 { font-size: 32px; }
.ai-hero-head .subtitle { font-size: 16px; color: var(--text-muted); }

.ai-card {
  background: var(--bg-card);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 20px 40px -15px var(--ai-glow);
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 16px 0 24px;
}

.chips-label {
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 600;
}

.chip-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.ai-form-actions {
  display: flex;
  justify-content: flex-end;
}

/* ---------- Builder Page Shell ---------- */
.builder-shell {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .builder-shell { grid-template-columns: 1fr; }
}

.q-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
  transition: border-color 0.15s ease;
}

.q-card:hover { border-color: var(--border-hover); }

.q-card .q-no {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  position: absolute;
  top: 18px;
  right: 18px;
}

.add-q-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

.add-q-btn {
  font-size: 13px;
  padding: 8px 14px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.add-q-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px -24px -80px;
  z-index: 90;
}

.save-status {
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-faint);
}

.save-status.ok { color: var(--emerald); }
.save-status.err { color: var(--rose); }

/* ---------- Public Form View ---------- */
.public-wrap {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
  background: var(--bg-main);
}

.public-form-card {
  width: 100%;
  max-width: 640px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.public-form-banner {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.public-form-head {
  padding: 28px 32px 14px;
  border-bottom: 1px dashed var(--border-color);
}

.public-form-body {
  padding: 28px 32px 32px;
}

.pf-question {
  padding: 18px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 6px 12px;
}

.pf-question:last-of-type { border-bottom: none; }

.pf-question .q-index {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  padding-top: 3px;
}

.radio-row, .checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.15s ease;
}

.radio-row:hover, .checkbox-row:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.04);
}

.radio-row input, .checkbox-row input {
  width: auto;
  accent-color: var(--accent);
}

.rating-row { display: flex; gap: 8px; margin-top: 6px; }

.rating-star {
  font-size: 28px;
  cursor: pointer;
  color: var(--text-faint);
  background: none;
  border: none;
  padding: 2px;
  transition: color 0.15s ease, transform 0.15s ease;
}

.rating-star:hover, .rating-star.active {
  color: #F59E0B;
  transform: scale(1.15);
}

/* ---------- Chat Shell ---------- */
.chat-shell {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 75px);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: var(--radius);
  line-height: 1.5;
  font-size: 14.5px;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
}

.chat-empty .mark-lg {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 0 20px var(--accent-glow);
}

.chat-input-container {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input-bar textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  border-radius: var(--radius);
}

.btn-icon-send {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius);
  flex-shrink: 0;
}

/* ---------- Tables & Data View ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

table.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------- Analytics Stat Grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.stat-box .num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
}

.stat-box .lbl {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.dist-row .dist-label {
  width: 140px;
  font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dist-row .dist-bar-track {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-pill);
  height: 8px;
  overflow: hidden;
}

.dist-row .dist-bar-fill {
  background: var(--ai-gradient);
  height: 100%;
  border-radius: var(--radius-pill);
}

/* ---------- Banner & Notifications ---------- */
.banner-msg {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner-err {
  background: var(--rose-soft);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.banner-ok {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ---------- Login Page Styling ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-main);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-card .brand {
  justify-content: center;
  margin-bottom: 24px;
}

/* ---------- Google Forms Builder Styling ---------- */
.builder-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.builder-status-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.back-link:hover {
  border-color: var(--border-hover);
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.builder-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gf-header-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: 6px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.gf-title-input {
  font-family: var(--font-display) !important;
  font-size: 26px !important;
  font-weight: 700 !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  padding: 4px 0 !important;
  margin-bottom: 12px !important;
  color: var(--text-main) !important;
}

.gf-title-input:focus {
  border-bottom-color: var(--accent) !important;
  box-shadow: none !important;
}

.gf-desc-input {
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid transparent !important;
  border-radius: 0 !important;
  padding: 4px 0 !important;
  color: var(--text-muted) !important;
}

.gf-desc-input:focus {
  border-bottom-color: var(--border-focus) !important;
  box-shadow: none !important;
}

.public-link-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
  flex-wrap: wrap;
}

.mono-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  color: var(--accent);
}

.add-q-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin: 24px 0;
}

.toolbar-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-main);
  display: block;
  margin-bottom: 10px;
}

.ai-inline-card {
  border: 1px dashed rgba(139, 92, 246, 0.4);
  background: linear-gradient(135deg, rgba(21, 28, 45, 0.9) 0%, rgba(99, 102, 241, 0.05) 100%);
}

.ai-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--accent);
  margin-bottom: 12px;
}

.ai-inline-row {
  display: flex;
  gap: 10px;
}

.color-swatch-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #FFFFFF; transform: scale(1.1); box-shadow: 0 0 10px var(--accent); }

.save-indicator {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shortcut-hint {
  font-size: 11px;
  color: var(--text-faint);
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.opt-bullet {
  font-size: 16px;
  color: var(--text-faint);
  user-select: none;
  width: 20px;
  text-align: center;
}

/* Responsive fixes */
@media (max-width: 640px) {
  .topbar-inner { padding: 12px 16px; }
  .brand-text { display: none; }
  .container { padding: 20px 14px 60px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Live Preview Modal ---------- */
.preview-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.preview-modal-container {
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.preview-modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-glass);
}

.preview-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-main);
}

.preview-device-toggle {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 4px;
}

.device-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
}

.device-btn.active {
  background: var(--accent);
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.preview-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.preview-modal-close:hover {
  color: var(--rose);
}

.preview-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 24px 60px;
  background: var(--bg-main);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
}

#preview-form-card {
  align-self: flex-start;
  margin: 0 auto;
  transition: max-width 0.3s ease;
}

/* ---------- Thank You Page & Cards ---------- */
.thanks-card {

  text-align: center;
  padding: 56px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.thanks-check-badge {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  animation: popScale 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes popScale {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.thanks-title {
  font-size: 26px;
  margin-bottom: 12px;
}

.thanks-message {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 440px;
  margin-bottom: 28px;
  line-height: 1.5;
}

.thanks-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.form-footer-mark {
  text-align: center;
  padding: 24px;
  font-size: 12.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.back-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  text-transform: none;
}

.back-nav-link:hover {
  color: var(--accent);
}

.badge-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
  font-size: 12.5px;
}

/* ---------- Modern Analytics Styling ---------- */
.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.analytics-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.analytics-card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.analytics-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-main);
  margin: 32px 0 16px;
}

.stat-box-modern {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-indigo { background: rgba(99, 102, 241, 0.15); color: #6366F1; }
.icon-emerald { background: rgba(16, 185, 129, 0.15); color: #10B981; }

.stat-val {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-lbl {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.choice-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
}

@media (max-width: 540px) {
  .choice-charts-grid { grid-template-columns: 1fr; }
}

.chart-flex-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.donut-canvas-wrap {
  width: 160px;
  height: 160px;
  position: relative;
  flex-shrink: 0;
}

.chart-list-wrap {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dist-row-modern {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.dist-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dist-label-text {
  width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
  flex-shrink: 0;
}

.dist-track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.dist-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

.dist-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.dist-count {
  font-size: 11.5px;
  color: var(--text-faint);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}





