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

:root {
  --bg: #0f0f0f;
  --panel-bg: #1a1a1a;
  --card-bg: #222222;
  --accent: #e8ff47;
  --text-primary: #f0f0f0;
  --text-muted: #888888;
  --border-subtle: #333333;
  --border-hover: #444444;
  --danger: #ff5555;
  --radius-card: 8px;
  --radius-input: 6px;
  --radius-sm: 4px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Background orbs ── */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  display: block;
  border-radius: 50%;
}

/* Yellow-green — top left */
.orb-1 {
  width: 720px;
  height: 620px;
  top: -260px;
  left: -180px;
  background: radial-gradient(circle at 42% 44%,
    rgba(232,255,71,0.22) 0%,
    rgba(232,255,71,0.10) 38%,
    transparent 65%);
  border-radius: 44% 56% 38% 62% / 50% 44% 56% 50%;
  filter: blur(72px);
}

/* Teal — top right */
.orb-2 {
  width: 640px;
  height: 580px;
  top: -200px;
  right: -180px;
  background: radial-gradient(circle at 52% 42%,
    rgba(79,189,186,0.18) 0%,
    rgba(79,189,186,0.07) 40%,
    transparent 65%);
  border-radius: 58% 42% 52% 48% / 46% 54% 46% 54%;
  filter: blur(65px);
}

/* Purple — bottom center */
.orb-3 {
  width: 580px;
  height: 520px;
  bottom: -200px;
  left: 28%;
  background: radial-gradient(circle at 50% 46%,
    rgba(160,120,255,0.13) 0%,
    rgba(160,120,255,0.05) 42%,
    transparent 65%);
  border-radius: 52% 48% 44% 56% / 56% 44% 56% 44%;
  filter: blur(80px);
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(15,15,15,0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.app-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}


/* ── Main layout ── */
.app-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.builder-panel {
  border-right: 1px solid var(--border-subtle);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.panel-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-input);
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:active {
  opacity: 0.85;
}

.btn-accent {
  background: var(--accent);
  color: #0f0f0f;
}

.btn-accent:hover {
  background: #f5ff6e;
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid #666;
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ── Inputs ── */
.input {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  padding: 6px 10px;
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
}

.input::placeholder {
  color: var(--text-muted);
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

/* ── Steps list ── */
.steps-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.steps-list::-webkit-scrollbar { width: 4px; }
.steps-list::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

/* ── Step card ── */
.step-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: border-color 0.15s;
}

.step-card.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 255, 71, 0.15);
}

.step-card.dragging {
  opacity: 0.4;
}

.step-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: default;
  user-select: none;
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 16px;
  padding: 2px 4px;
  flex-shrink: 0;
  line-height: 1;
}

.drag-handle:active {
  cursor: grabbing;
}

.step-name-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 3px 6px;
  flex: 1;
  min-width: 0;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.step-name-input:hover {
  border-color: var(--border-subtle);
  background: rgba(255,255,255,0.03);
}

.step-name-input:focus {
  border-color: var(--accent);
  background: var(--bg);
}

.step-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
  line-height: 1;
}

.collapse-btn:hover {
  color: var(--text-primary);
}

.delete-step-btn {
  background: none;
  border: none;
  color: transparent;
  cursor: pointer;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

.step-card:hover .delete-step-btn {
  color: var(--danger);
}

.delete-step-btn:hover {
  background: rgba(255, 85, 85, 0.1);
}

/* ── Step card body ── */
.step-card-body {
  padding: 0 12px 12px;
}

.step-card.collapsed .step-card-body {
  display: none;
}

.fields-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  min-height: 4px;
}

.empty-fields-msg {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  padding: 12px 0 4px;
  text-align: center;
}

/* ── Field card (compact) ── */
.field-card {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

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

.field-card.drag-over {
  border-color: var(--accent);
}

.field-card.dragging {
  opacity: 0.4;
}

.field-drag-handle {
  color: #555;
  cursor: grab;
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1;
}

.field-drag-handle:active {
  cursor: grabbing;
}

.field-type-pill {
  font-size: 11px;
  font-weight: 700;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  flex-shrink: 0;
  line-height: 1.5;
  white-space: nowrap;
}

.field-card-label {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.field-card-req {
  color: var(--danger);
}

.field-edit-btn {
  background: none;
  border: none;
  color: transparent;
  cursor: pointer;
  font-size: 13px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.field-card:hover .field-edit-btn {
  color: var(--text-muted);
}

.field-edit-btn:hover {
  color: var(--text-primary) !important;
  background: rgba(255,255,255,0.06);
}

.delete-field-btn {
  background: none;
  border: none;
  color: transparent;
  cursor: pointer;
  font-size: 14px;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
  flex-shrink: 0;
}

.field-card:hover .delete-field-btn {
  color: var(--danger);
}

.delete-field-btn:hover {
  background: rgba(255, 85, 85, 0.1);
}

/* ── Toggle checkbox ── */
.toggle-checkbox {
  appearance: none;
  width: 32px;
  height: 18px;
  background: var(--border-subtle);
  border-radius: 9px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}

.toggle-checkbox::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  background: #666;
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}

.toggle-checkbox:checked {
  background: var(--accent);
}

.toggle-checkbox:checked::after {
  transform: translateX(14px);
  background: #0f0f0f;
}

/* ── Options editor (in field editor) ── */
.options-editor {
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.options-editor-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.option-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.option-item input {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
}

.option-item input:focus {
  border-color: var(--accent);
}

.remove-option-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  transition: color 0.15s;
}

.remove-option-btn:hover {
  color: var(--danger);
}

.add-option-btn {
  background: none;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, color 0.15s;
}

.add-option-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Step tabs bar (mobile only) ── */
.step-tabs-bar {
  display: none;
}

/* ── Button labels section ── */
.button-labels-section {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 520px;
}

.settings-section-gap {
  margin-top: 18px;
}

.language-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 6px;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.button-labels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.field-label-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Preview panel ── */
.preview-panel {
  background: var(--panel-bg);
}

.preview-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
}

.preview-container::-webkit-scrollbar { width: 4px; }
.preview-container::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

/* ── Preview form ── */
.preview-form-wrap {
  width: 100%;
  max-width: 480px;
}

.preview-step-indicator {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-weight: 500;
}

.preview-step {
  display: none;
}

.preview-step.active {
  display: block;
  animation: previewStepIn 0.18s ease;
}

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

.preview-field-group {
  margin-bottom: 16px;
}

.preview-field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.preview-field-group.preview-group-err > .preview-field-label {
  color: var(--danger);
}

.preview-field-group.preview-group-err .preview-input {
  border-color: var(--danger);
}

.preview-err-msg {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

.required-star {
  color: var(--danger);
  margin-left: 3px;
}

.preview-input {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.preview-input:focus {
  border-color: var(--accent);
}

.preview-input::placeholder {
  color: #555;
}

textarea.preview-input {
  resize: vertical;
  min-height: 80px;
}

select.preview-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

select.preview-input option {
  background: var(--card-bg);
  color: var(--text-primary);
}

.preview-radio-group,
.preview-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-radio-item,
.preview-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

.preview-radio-item input[type="radio"],
.preview-checkbox-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── Yes / No preview ── */
.preview-yesno {
  display: flex;
  gap: 10px;
}

.preview-yesno-btn {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-input);
  background: var(--card-bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  text-align: center;
}

.preview-yesno-btn:hover {
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.04);
}

.preview-yesno-btn.selected {
  border-color: var(--accent);
  background: rgba(232, 255, 71, 0.1);
  color: var(--accent);
}

/* ── Rating preview ── */
.preview-rating {
  display: flex;
  gap: 4px;
}

.preview-star {
  font-size: 28px;
  color: var(--border-hover);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.1s, transform 0.1s;
}

.preview-star:hover {
  transform: scale(1.15);
  color: #f5a623;
}

.preview-star.active {
  color: #f5a623;
}

/* ── Opinion scale preview ── */
.preview-scale {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-scale-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 6px;
}

.preview-scale-numbers {
  display: flex;
  justify-content: space-between;
}

.preview-scale-numbers span {
  font-size: 12px;
  color: var(--text-muted);
}

.preview-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
}

.preview-scale-labels span {
  font-size: 12px;
  color: #555;
  font-style: italic;
}

/* ── Statement preview ── */
.preview-statement {
  padding: 4px 0 8px;
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.65;
}

/* ── Preview nav ── */
.preview-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
}

.preview-btn-next,
.preview-btn-submit {
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  border-radius: var(--radius-input);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.preview-btn-next:hover,
.preview-btn-submit:hover {
  background: #f5ff6e;
}

.preview-btn-back {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid #666;
  border-radius: var(--radius-input);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.preview-btn-back:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-hover);
}

.preview-success {
  text-align: center;
  padding: 48px 24px;
}

.preview-success-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.preview-success h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.preview-success p {
  color: var(--text-muted);
  font-size: 14px;
}

.preview-empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.preview-empty-state p {
  font-size: 14px;
}

/* ── Bottom bar ── */
.bottom-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 10px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(15,15,15,0.60);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.status-label {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s;
}

.status-label.visible {
  opacity: 1;
}

/* ── Field type picker modal ── */
.field-type-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.field-type-modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}

.modal-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 20px;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
}

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

.modal-close:hover {
  color: var(--text-primary);
}

/* ── Field type categories ── */
.field-type-categories {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-type-category {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ftc-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.field-type-btn {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 11px 6px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}

.field-type-btn:hover {
  border-color: var(--accent);
  background: rgba(232, 255, 71, 0.06);
  color: var(--accent);
}

.field-type-icon {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.field-type-btn:hover .field-type-icon {
  filter: brightness(1.25) saturate(1.1);
}

/* ── Progress style picker ── */
.progress-style-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.progress-style-btn {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.progress-style-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.progress-style-btn.active {
  border-color: var(--accent);
  background: rgba(232, 255, 71, 0.08);
  color: var(--accent);
}

.progress-style-icon {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.03em;
}

/* ── Submission settings ── */
.submission-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.submission-method-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.method-toggle {
  display: flex;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  overflow: hidden;
}

.method-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  transition: background 0.15s, color 0.15s;
}

.method-btn.active {
  background: var(--accent);
  color: #0f0f0f;
}

.method-btn:not(.active):hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

/* ── Data destination picker ── */
.destination-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 8px;
}

.destination-btn {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 11.5px;
  color: var(--text-primary);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.destination-btn:last-child {
  grid-column: span 2;
}

.destination-btn:hover {
  border-color: var(--accent);
  background: rgba(232, 255, 71, 0.04);
}

.destination-btn.active {
  border-color: var(--accent);
  background: rgba(232, 255, 71, 0.08);
}

.destination-btn-icon {
  font-size: 13px;
  flex-shrink: 0;
  opacity: 0.6;
}

.destination-btn-name {
  font-weight: 600;
}

.destination-config {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 2px;
}

.destination-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.destination-help {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* ── Preview progress indicators ── */
.preview-progress-dots {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  align-items: center;
}

.preview-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-hover);
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.preview-dot.active {
  background: var(--accent);
  transform: scale(1.2);
}

.preview-progress-bar-wrap {
  height: 3px;
  background: var(--border-subtle);
  border-radius: 2px;
  margin-bottom: 20px;
  overflow: hidden;
}

.preview-progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.preview-progress-numbers {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-weight: 500;
}

/* ── Add field button in step ── */
.add-field-row {
  display: flex;
  justify-content: flex-start;
}

/* ── Field editor sheet / modal ── */
.field-editor {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.field-editor.hidden {
  display: none;
}

.field-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
}

.field-editor-panel {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  width: 400px;
  max-width: calc(100vw - 40px);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
  overflow: hidden;
}

.field-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.field-editor-type-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-editor-type-icon {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  line-height: 1;
}

.field-editor-type-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.field-editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-editor-body::-webkit-scrollbar { width: 4px; }
.field-editor-body::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

/* ── Editor form groups ── */
.editor-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.editor-toggle-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}

.editor-toggle-row .editor-group-label {
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-primary);
}

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

.validation-auto-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: -4px 0 4px;
  line-height: 1.4;
}

/* ── Conditional logic (field editor) ── */
.condition-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.condition-empty-msg {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.condition-rule {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Field card condition badge ── */
.field-condition-badge {
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
  line-height: 1;
  opacity: 0.85;
}

/* ── Templates modal ── */
.templates-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.templates-modal.hidden {
  display: none;
}

.templates-modal-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 24px;
  width: 620px;
  max-width: calc(100vw - 32px);
  max-height: 88vh;
  overflow-y: auto;
  z-index: 1;
}

.templates-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: -4px 0 20px;
}

.templates-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.template-card {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: border-color 0.15s, background 0.15s;
}

.template-card:hover {
  border-color: var(--accent);
  background: rgba(232, 255, 71, 0.04);
}

.template-icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 2px;
}

.template-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.template-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Empty state template chips ── */
.preview-template-hint {
  margin-top: 28px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 24px;
  width: 100%;
}

.preview-template-hint > p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

.preview-template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-template-chip {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
}

.preview-template-chip:hover {
  border-color: var(--accent);
  background: rgba(232, 255, 71, 0.06);
}

/* ── Scrollbar global ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 2px; }

/* ── Mobile tabs ── */
.mobile-tabs {
  display: none;
}

.mobile-settings-header {
  display: none;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .app-header {
    padding: 12px 16px;
  }

  /* Tab bar */
  .mobile-tabs {
    display: flex;
    flex-shrink: 0;
    background: rgba(15,15,15,0.70);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: relative;
    z-index: 1;
  }

  .mobile-tab {
    flex: 1;
    padding: 11px 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
  }

  .mobile-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }

  /* Panel visibility — position absolute so panels fill exact app-body height,
     giving steps-list a real boundary to scroll within */
  .app-body {
    grid-template-columns: 1fr;
    position: relative;
  }

  .panel {
    display: none;
  }

  .panel.mobile-active {
    display: flex;
    position: absolute;
    inset: 0;
  }

  .builder-panel {
    border-right: none;
  }

  /* Builder tab: show steps, hide button labels */
  body[data-mobile-tab="builder"] .button-labels-section {
    display: none;
  }

  /* Settings tab: show button labels, hide everything else in builder */
  body[data-mobile-tab="settings"] .panel-header,
  body[data-mobile-tab="settings"] .steps-list {
    display: none;
  }

  body[data-mobile-tab="settings"] .button-labels-section {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    border-top: none;
  }

  body[data-mobile-tab="settings"] .button-labels-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mobile-settings-header {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 20px;
  }

  /* ── Step tabs (mobile only) ── */
  .step-tabs-bar {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .step-tabs-bar::-webkit-scrollbar {
    display: none;
  }

  .step-tab {
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    flex-shrink: 0;
  }

  .step-tab.active {
    background: var(--accent);
    color: #0f0f0f;
    border-color: var(--accent);
    font-weight: 600;
  }

  .step-tab-add {
    border-style: dashed;
  }

  /* Step cards on mobile: hide all, show only the active one */
  .step-card {
    display: none;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
  }

  .step-card.mobile-step-active {
    display: flex;
    flex-direction: column;
  }

  /* Always show the active step's body even if it's collapsed */
  .step-card.mobile-step-active .step-card-body {
    display: flex !important;
    flex-direction: column;
    padding: 12px 0 0;
  }

  /* On mobile, drag handle and collapse btn aren't useful */
  .step-card.mobile-step-active .drag-handle,
  .step-card.mobile-step-active .collapse-btn {
    display: none;
  }

  /* Remove "Add Step" from header on mobile (tabs bar has "+ Step") */
  #addStepBtn {
    display: none;
  }

  /* Field cards: always show edit button on touch devices */
  .field-edit-btn {
    opacity: 1;
    color: var(--text-muted);
  }

  .field-card:hover .delete-field-btn {
    color: var(--danger);
  }

  /* Settings: clear max-height so it scrolls naturally */
  body[data-mobile-tab="settings"] .button-labels-section {
    max-height: none;
  }

  /* Progress style: 2x2 on small screens */
  .progress-style-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Destination picker: single column on small screens */
  .destination-picker {
    grid-template-columns: 1fr;
  }

  .destination-btn:last-child {
    grid-column: span 1;
  }

  /* Field type modal and templates modal: narrower, bottom-friendly */
  .modal-card,
  .templates-modal-card {
    width: calc(100vw - 24px);
    max-height: 85vh;
  }

  .templates-grid {
    grid-template-columns: 1fr;
  }

  .field-type-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }

  .field-type-btn {
    padding: 10px 4px;
    font-size: 10px;
  }

  /* Field editor: bottom sheet on mobile */
  .field-editor {
    align-items: flex-end;
  }

  .field-editor-panel {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
  }

  /* Step cards: slightly more breathing room */
  .step-card-body {
    padding: 0 10px 14px;
  }

  .fields-list {
    gap: 8px;
  }
}
