@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap");

/* ── Design Tokens ── */
:root {
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-lighter: #eef2ff;
  --primary-bg: #f5f3ff;
  --primary-glow: rgba(79, 70, 229, 0.2);
  --accent: #4f46e5;
  --accent-light: #818cf8;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --bg: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.85);
  --text: #1e1b4b;
  --text-secondary: #7c7c7c;
  --text-muted: #adadad;
  --border: #ddd;
  --border-focus: var(--primary);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px var(--primary-glow);
  --radius-sm: 0.5rem;
  --radius: 0.5rem;
  --radius-lg: 0;
  --radius-xl: 0;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.header-brand svg {
  width: 32px;
  height: 32px;
}

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

.btn-pro {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: all var(--transition);
}
.btn-pro:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* ── Buttons ── */
.btn {
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: var(--primary-bg);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: #f3f4f6;
  color: var(--text);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.btn-danger:hover {
  background: #fecaca;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}
.btn-icon:hover {
  background: #f3f4f6;
  color: var(--text);
}

/* ── Layout ── */
.app-layout {
  display: block;
  padding-top: 0;
  min-height: 100vh;
}

/* ── Action Bar (Sticky) ── */
.action-bar-wrap {
  position: sticky;
  top: 50px; /* Sticks below main header */
  z-index: 90;
  background: var(--bg);
  padding: 0.5rem 0;
}
.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  width: max-content;
  margin: 0;
}

.action-bar-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition);
}
.action-bar-btn span {
  display: none;
}
.action-bar-btn svg {
  width: 18px;
  height: 18px;
}
.action-bar-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary-lighter);
}
.action-bar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}
.action-bar-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fca5a5;
}

.action-bar-btn.btn-save {
  color: var(--primary);
  background: var(--primary-bg);
  border-color: var(--primary-lighter);
}
.action-bar-btn.btn-save:hover {
  background: var(--primary);
  color: #fff;
}
@keyframes savingPulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.98);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.action-bar-btn.saving {
  pointer-events: none;
  animation: savingPulse 1s infinite ease;
}

/* ── Canvas ── */
.canvas {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0.5rem !important;
}

/* ── Form Header Card ── */
.form-header-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 0.5rem;
}

.form-title-input {
  width: 100%;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border-bottom: 2px solid transparent;
  padding-bottom: 6px;
  transition: border-color var(--transition);
}
.form-title-input:focus {
  border-bottom-color: var(--primary);
}
.form-title-input::placeholder {
  color: var(--text-muted);
}

.form-desc-input {
  width: 100%;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-secondary);
  background: transparent;
  margin-top: 10px;
  resize: none;
  height: 60px;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition);
}
.form-desc-input:focus {
  border-bottom-color: var(--primary-lighter);
}
.form-desc-input::placeholder {
  color: var(--text-muted);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin-top: 20px;
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.empty-state-icon svg {
  width: 32px;
  height: 32px;
}
.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ── Add Element Button & Popup ── */
.add-element-wrap {
  position: relative;
  margin: 20px 0 8px;
  text-align: center;
}
.add-element-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 1rem;
  background: var(--primary);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bg);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.add-element-btn svg {
  width: 18px;
  height: 18px;
}

.add-element-popup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.add-element-popup.open {
  display: flex;
}
.add-popup-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 520px;
  max-width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: popupSlide 0.25s ease;
}
@keyframes popupSlide {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.add-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
}
.add-popup-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all var(--transition);
}
.add-popup-close:hover {
  background: #f3f4f6;
  color: var(--text);
}
.add-popup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px;
}
.add-popup-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 6px;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}
.add-popup-item svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}
.add-popup-item span {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}
.add-popup-item:hover {
  background: var(--primary-bg);
  border-color: var(--primary-lighter);
  transform: translateY(-1px);
}

/* ── Element Card ── */
.element-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem 1rem;
  margin-bottom: 0.5rem;
  position: relative;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.element-card:hover {
  box-shadow: var(--shadow-md);
}

.element-card.active {
  border-color: var(--primary-lighter);
  box-shadow:
    0 0 0 3px var(--primary-glow),
    var(--shadow-md);
}

.element-card.dragging {
  opacity: 0.5;
  transform: rotate(1deg);
  box-shadow: var(--shadow-lg);
}

.element-card.drag-over {
  border-color: var(--primary);
  border-style: dashed;
}

/* Card top row */
.card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  margin-top: 8px;
}

.drag-handle {
  position: absolute;
  top: 10px;
  right: 10px;
  cursor: grab;
  color: var(--text-muted);
  padding: 8px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
  z-index: 10;
}
.drag-handle:active {
  cursor: grabbing;
}
.drag-handle:hover {
  color: var(--primary);
}
.element-card:hover .drag-handle {
  opacity: 1;
}

.drag-handle svg {
  width: 18px;
  height: 18px;
}

.card-label-input {
  flex: 1;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  border: none;
  outline: none;
  background: transparent;
  border-bottom: 1.5px solid transparent;
  padding: 4px 0;
  transition: border-color var(--transition);
}
.card-label-input:focus {
  border-bottom-color: var(--primary);
}

.card-type-badge {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 4px 8px;
  border-radius: var(--radius-lg) 0 var(--radius-lg) 0;
  z-index: 10;
}

/* Card body — element-specific config */
.card-body {
  margin-bottom: 16px;
}

.card-body .preview-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text-muted);
  background: #fafafa;
  transition: border-color var(--transition);
  pointer-events: none;
}

.card-body textarea.preview-input {
  resize: none;
  min-height: 80px;
}

/* Options list (for dropdown, radio, checkbox) */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
}
.option-icon.checkbox {
  border-radius: 4px;
}
.option-icon.dropdown {
  border: none;
  color: var(--text-muted);
}

.option-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
  color: var(--text);
  transition: border-color var(--transition);
  background: transparent;
}
.option-input:focus {
  border-bottom-color: var(--primary);
}

.option-remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition);
}
.option-remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.option-remove svg {
  width: 16px;
  height: 16px;
}

.add-option-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 500;
  padding: 6px 0;
  margin-top: 4px;
  transition: color var(--transition);
}
.add-option-btn:hover {
  color: var(--accent);
}

/* Scale config */
.scale-config {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.scale-config label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.scale-config select,
.scale-config input[type="text"] {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color var(--transition);
}
.scale-config select:focus,
.scale-config input[type="text"]:focus {
  border-color: var(--primary);
}

.scale-preview {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}
.scale-preview span {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.scale-dot {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Section header & paragraph content */
.section-content-input {
  width: 100%;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text-secondary);
  border: none;
  outline: none;
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
  height: 60px;
  background: transparent;
  transition: border-color var(--transition);
}
.section-content-input:focus {
  border-bottom-color: var(--primary);
}

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.card-footer .btn-icon {
  width: 24px;
  height: 24px;
}
.card-footer .btn-icon svg {
  width: 20px;
  height: 20px;
}
.card-footer-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
}
.btn-icon-primary {
  color: var(--primary) !important;
}
.btn-icon-primary:hover {
  background: var(--primary-bg) !important;
}

.required-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}
.required-toggle label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 22px;
  transition: all var(--transition);
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: all var(--transition-spring);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.toggle input:checked + .toggle-slider {
  background: var(--primary);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 80px;
  height: 80px;
  color: var(--primary-lighter);
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.empty-state p {
  font-size: 0.9rem;
}

/* ── Preview Modal ── */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 16px;
}
.preview-overlay.open {
  display: flex;
}

.preview-container {
  width: 100%;
  max-width: 680px;
  animation: previewIn 0.3s ease;
}

@keyframes previewIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.preview-close-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.preview-header-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border-top: 4px solid var(--primary);
  padding: 1rem 0;
  margin-bottom: 12px;
}
.preview-header-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.preview-header-card p {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.preview-element-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem 0;
  margin-bottom: 0.5rem;
  border-top: 1px solid var(--border);
}

.preview-label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.preview-label .required-star {
  color: var(--danger);
  font-weight: 700;
}

.preview-element-card input[type="text"],
.preview-element-card input[type="number"],
.preview-element-card input[type="email"],
.preview-element-card input[type="tel"],
.preview-element-card input[type="date"],
.preview-element-card input[type="time"],
.preview-element-card input[type="file"],
.preview-element-card textarea,
.preview-element-card select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: #f3f3f3;
  outline: none;
  transition: border-color var(--transition);
}
.preview-element-card input:focus,
.preview-element-card textarea:focus,
.preview-element-card select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.preview-element-card textarea {
  resize: vertical;
  min-height: 80px;
}

/* File Drop Zone in preview */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: #ffffff;
}
.file-drop-zone:hover,
.file-drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.drop-zone-content svg {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  margin-bottom: 12px;
  transition: color var(--transition);
}
.file-drop-zone:hover svg,
.file-drop-zone.dragover svg {
  color: var(--primary);
}
.drop-zone-content p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin: 0;
}
.drop-zone-content p span {
  color: var(--primary);
  font-weight: 600;
}
.file-name {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}
.file-name.active {
  color: var(--success);
  font-weight: 600;
}
.preview-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.preview-option input[type="radio"],
.preview-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}
.preview-option label {
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

/* Scale in preview */
.preview-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
}
.preview-scale-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 30px;
}
.preview-scale-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.preview-scale-option input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}
.preview-scale-option span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.preview-section-header {
  border: none;
  box-shadow: none;
  padding: 16px 0;
  margin-bottom: 4px;
}
.preview-section-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}
.preview-section-header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.preview-paragraph {
  border: none;
  box-shadow: none;
  padding: 8px 0;
}
.preview-paragraph p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.preview-submit-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation:
    toastIn 0.35s ease,
    toastOut 0.3s ease 2.7s forwards;
  max-width: 360px;
}
.toast.success {
  background: #059669;
}
.toast.error {
  background: var(--danger);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}

/* ── Mobile sidebar toggle ── */
.sidebar-toggle {
  display: none;
  background: var(--primary);
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 300;
  box-shadow:
    var(--shadow-lg),
    0 0 20px var(--primary-glow);
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}
.sidebar-toggle:hover {
  transform: scale(1.08);
}
.sidebar-toggle svg {
  width: 24px;
  height: 24px;
}

/* ── Import Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 250;
  display: none;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 16px;
}
@media (max-width: 600px) {
  .modal-overlay {
    align-items: flex-start;
    padding: 20px 10px;
  }
}
.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: previewIn 0.3s ease;
  position: relative;
}
.modal-box h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.modal-box textarea {
  width: 100%;
  min-height: 180px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: "Courier New", monospace;
  font-size: 0.82rem;
  resize: vertical;
  outline: none;
  color: var(--text);
  transition: border-color var(--transition);
}
.modal-box textarea:focus {
  border-color: var(--primary);
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ── Placeholder text ── */
.placeholder-input::placeholder {
  color: var(--text-muted);
}

/* File upload preview area */
.file-upload-preview {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}
.file-upload-preview svg {
  width: 32px;
  height: 32px;
  margin-bottom: 6px;
  color: var(--primary-lighter);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .canvas {
    padding: 20px 0;
  }

  .canvas-tabs-wrap {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 500px) {
  .header {
    padding: 0.5rem !important;
  }
  .header-brand span {
    display: none;
  }
  .btn span.btn-label {
    display: none;
  }
  .form-header-card {
    padding: 1rem;
  }
  .element-card {
    padding: 18px;
  }
  .sidebar-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ── Canvas Tabs ── */
.canvas-tabs-wrap {
  padding-top: 3.5rem;
  max-width: 1000px;
  margin: 0 auto;
}
@media (max-width: 856px) {
  .canvas-tabs-wrap {
    max-width: none;
    padding-left: 32px;
  }
}
.canvas-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}
.canvas-tab {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 1rem;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  flex: 1;
  text-align: center;
}
.canvas-tab::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  border-radius: 3px 3px 0 0;
  transition: background var(--transition);
}
.canvas-tab:hover {
  color: var(--text);
}
.canvas-tab.active {
  color: var(--primary);
}
.canvas-tab.active::after {
  background: var(--primary);
}
.response-count {
  font-size: 0.7rem;
  background: var(--primary);
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 2px;
}
.response-count:empty {
  display: none;
}

/* ── Tab Panels ── */
.tab-panel-center {
  max-width: 1000px;
  padding: 0.5rem;
  margin: 0 auto;
}

/* ── Page Break Card ── */
.page-break-card {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 8px 0 !important;
}
.page-break-card:hover {
  box-shadow: none !important;
}
.page-break-card.active {
  box-shadow: none !important;
  border: none !important;
}

.page-break-content {
  display: flex;
  align-items: center;
}
.page-break-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--primary-lighter),
    transparent
  );
}
.page-break-card svg {
  width: 20px;
}
.page-break-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  padding: 6px 16px;
  border-radius: 20px;
  white-space: nowrap;
}

.page-break-btn {
  grid-column: 1 / -1;
  flex-direction: row !important;
  padding: 10px 14px !important;
  background: var(--primary-bg) !important;
  border-color: var(--primary-lighter) !important;
}
.page-break-btn:hover {
  background: #ddd6fe !important;
}

/* Save Dot Indicator */
.save-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid var(--bg-card);
  display: none;
  pointer-events: none;
}
.save-dot.visible {
  display: block;
}

/* ── Preview Progress Bar ── */
.preview-progress {
  background: var(--border);
  border-radius: 10px;
  height: 6px;
  margin-bottom: 6px;
  overflow: hidden;
}
.preview-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.preview-step-info {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  text-align: right;
}

/* ── Settings Panel (now in modal) ── */
.settings-group {
  padding: 16px 0;
  border-bottom: 1px solid #f3f4f6;
}

.settings-group:last-child {
  border-bottom: none;
}
.settings-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}
.settings-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.settings-row .settings-label {
  margin-bottom: 0;
}
.settings-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: #fff;
  outline: none;
  resize: vertical;
  transition: border-color var(--transition);
}
.settings-input:focus {
  border-color: var(--primary);
}

/* ── Responses Panel ── */
.responses-empty {
  text-align: center;
  padding: 80px 24px;
}
.responses-empty svg {
  width: 80px;
  height: 80px;
  color: var(--primary-lighter);
  opacity: 0.4;
  margin-bottom: 16px;
}
.responses-empty h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.responses-empty p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.responses-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.response-stat {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.response-stat .stat-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
}
.response-stat .stat-label {
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.responses-table-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.responses-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.responses-list-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.table-scroll {
  overflow-x: auto;
  width: 100%;
}
.responses-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}
.responses-table th {
  background: #fafafa;
  padding: 12px 16px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.responses-table td {
  padding: 12px 16px;
  color: var(--text);
  border-bottom: 1px solid #f3f4f6;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.responses-table tr:hover td {
  background: #f9fafb;
}
.responses-table tr:last-child td {
  border-bottom: none;
}

/* ── Footer ── */
.landing-footer {
  padding: 60px 40px;
  background: var(--bg-card);
  text-align: center;
}

.footer-content {
  max-width: 1100px;
  margin: 0 auto;
  gap: 40px;
  font-size: 0.8em;
}

.footer-brand h2 {
  color: var(--primary);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.footer-links a {
  color: #000;
  text-decoration: none;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .canvas {
    padding: 0.5rem !important;
  }
}

@media (max-width: 768px) {
  .canvas-tabs-wrap {
    padding: 3.5rem 0.5rem 0;
  }
  .canvas-tab {
    padding: 10px 0.5rem;
    font-size: 0.85rem;
  }
  .action-bar-wrap {
    top: 48px;
    padding: 0.5rem;
  }
  .action-bar {
    width: 100%;
    justify-content: center;
  }
  .header {
    padding: 0.8rem 1rem;
  }
  .header-brand span {
    display: inline-block !important;
    font-size: 1.1rem;
  }
}

/* ── Upload Progress ── */
.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.upload-modal {
  background: var(--bg-card);
  padding: 2.5rem;
  border-radius: 1.5rem;
  width: 400px;
  max-width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.upload-modal h3 {
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.upload-progress-container {
  height: 12px;
  background: #f1f5f9;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1rem;
  border: 1px solid #e2e8f0;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent-light) 100%);
  border-radius: 6px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--primary-glow);
}

.upload-status {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

.file-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.file-link:hover {
  text-decoration: underline;
}
