/* ─── DESIGN TOKENS (Polaris 13 aligned) ────────────────────────────────── */
:root {
  color-scheme: light;

  /* Colors */
  --color-bg:              #f1f2f4;
  --color-surface:         #ffffff;
  --color-border:          #c9ccd0;
  --color-border-input:    #8c9196;
  --color-text:            #303030;
  --color-text-muted:      #616161;
  --color-text-disabled:   #8c9196;
  --color-primary:         #303030;
  --color-primary-hover:   #1a1a1a;
  --color-primary-text:    #ffffff;
  --color-secondary-bg:    #f6f6f7;
  --color-secondary-hover: #edeeef;
  --color-danger:          #b42318;
  --color-danger-hover:    #912018;
  --color-success:         #1a7f5a;
  --color-success-bg:      #d1f0e0;
  --color-success-text:    #1a7f5a;

  /* Status badges */
  --badge-live-bg:         #c6f2df;
  --badge-live-text:       #1a7f5a;
  --badge-draft-bg:        #f0f0f0;
  --badge-draft-text:      #616161;

  /* Answer type chips */
  --chip-active-bg:        #e8f0fd;
  --chip-active-border:    #2c5cc5;
  --chip-active-text:      #2c5cc5;

  /* Preview checkout mock */
  --checkout-bg:           #ffffff;
  --checkout-accent:       #1a7f5a;
  --checkout-btn-bg:       #1c305e;
  --checkout-btn-text:     #ffffff;

  /* Spacing (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --text-xs:    11px;
  --text-sm:    13px;
  --text-base:  14px;
  --text-lg:    16px;
  --text-xl:    20px;
  --fw-normal:  400;
  --fw-medium:  500;
  --fw-semibold:600;
  --lh-body:    20px;

  /* Border radius */
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   8px;
  --radius-xl:   12px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card:      0 0 0 1px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-card-hover:0 0 0 1px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.1);
}

/* ─── RESET & BASE ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-sm);
  line-height: var(--lh-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

/* ─── VIEWS ─────────────────────────────────────────────────────────────── */
/* Ensure the hidden attribute is not overridden by any display rule */
.view[hidden] { display: none; }

/* ─── LIST VIEW ─────────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--sp-6);
}

/* Survey grid */
.survey-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
}

.survey-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transition: box-shadow 150ms;
}
.survey-card:hover { box-shadow: var(--shadow-card-hover); }

.survey-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

/* Live toggle on survey card */
.card-live-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.card-live-toggle__label {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--color-text-muted);
}
.toggle-input:checked ~ .card-live-toggle__label {
  color: var(--color-success);
}
.card-live-toggle .toggle-input {
  /* slightly smaller than the question-card toggle */
  width: 28px;
  height: 16px;
}
.card-live-toggle .toggle-input::after {
  width: 12px;
  height: 12px;
}
.card-live-toggle .toggle-input:checked::after { transform: translateX(12px); }

.survey-card__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  line-height: 1.3;
}
.survey-card__meta {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.survey-card__actions { margin-top: var(--sp-2); display: flex; justify-content: flex-end; }

/* Empty state */
/* ─── ONBOARDING EMPTY STATE ─────────────────────────────────────────────── */
.onboarding-wrap { padding: var(--sp-8) 0; }
.onboarding { display: flex; flex-direction: column; gap: var(--sp-6); }
.onboarding__greeting { margin: 0 0 var(--sp-1); font-size: var(--text-xl); font-weight: var(--fw-semibold); }
.onboarding__sub { margin: 0; color: var(--color-text-muted); line-height: 1.6; }

.ob-hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-card);
}
.ob-hero__tag {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--sp-3);
}
.ob-hero__name { font-size: var(--text-xl); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-2); }
.ob-hero__question { font-size: var(--text-base); font-style: italic; color: var(--color-text-muted); margin: 0 0 var(--sp-3); }
.ob-hero__desc { font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.6; margin: 0 0 var(--sp-5); max-width: 560px; }
.ob-hero__body { display: flex; gap: var(--sp-6); align-items: flex-start; }
.ob-hero__left { flex: 1 1 0; min-width: 0; }
.ob-hero__right { flex: 0 0 240px; }
.ob-hero__actions { display: flex; align-items: center; gap: var(--sp-3); }

/* Survey preview inside hero card */
.ob-preview {
  background: #f9fafb;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.ob-preview__title { font-size: var(--text-sm); font-weight: var(--fw-semibold); margin: 0; color: var(--color-text); }
.ob-preview__q { font-size: var(--text-xs); color: var(--color-text-muted); margin: 0; line-height: 1.5; }
.ob-preview__textarea {
  width: 100%; resize: none; border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 6px 8px; font-size: var(--text-xs);
  font-family: var(--font); background: white; color: var(--color-text-disabled);
  cursor: default;
}
.ob-preview__input {
  width: 100%; border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 6px 8px; font-size: var(--text-xs);
  font-family: var(--font); background: white; color: var(--color-text-disabled);
  cursor: default;
}
.ob-preview__btn {
  align-self: flex-start; padding: 6px 12px; border: 1px solid #1a1a1a;
  background: #1a1a1a; color: white; border-radius: var(--radius-md);
  font-size: var(--text-xs); cursor: default; opacity: 0.7;
}

.onboarding__more-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin: 0 0 var(--sp-4);
}
.ob-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.ob-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  box-shadow: var(--shadow-card);
}
.ob-card--blank { border-style: dashed; box-shadow: none; }
.ob-card__name { font-size: var(--text-sm); font-weight: var(--fw-semibold); margin: 0 0 var(--sp-1); }
.ob-card__desc { font-size: var(--text-xs); color: var(--color-text-muted); margin: 0; line-height: 1.5; }
.ob-card__footer { margin-top: auto; }
.btn--link { background: none; border: none; padding: 0; color: var(--color-text-muted); font-size: var(--text-sm); cursor: pointer; text-decoration: underline; }
.btn--link:hover { color: var(--color-text); }

/* ─── IN-PAGE SAVE BAR ───────────────────────────────────────────────────── */
.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px var(--sp-6);
  background: #fafafa;
  border-bottom: 1px solid var(--color-border);
  gap: var(--sp-4);
  flex-shrink: 0;
}
.save-bar[hidden] { display: none; }
.save-bar__label { font-size: var(--text-sm); color: var(--color-text-muted); }
.save-bar__actions { display: flex; gap: var(--sp-2); }

/* ─── EDITOR LAYOUT ─────────────────────────────────────────────────────── */
/* Uses position:sticky on the preview so the two-column layout works inside
   Shopify's auto-height iframe without needing height:100% propagation. */
.editor-layout {
  display: flex;
  align-items: flex-start; /* required for sticky children */
}

.editor-panel {
  flex: 0 0 48%;
  border-right: 1px solid var(--color-border);
  min-width: 0;
}

.editor-scroll {
  padding: var(--sp-5) var(--sp-6) var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Editor topbar (back + badge | delete) */
.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-1);
}
.editor-topbar__left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* ─── CARD ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card__section { padding: var(--sp-5); }
.card__section--bordered { border-top: 1px solid var(--color-border); }
.card__section--pb16 { padding-bottom: 16px; }
.card__section-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0 0 var(--sp-3);
}

/* ─── TABS ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  font-family: var(--font);
  color: var(--color-text-muted);
  cursor: pointer;
  font-weight: var(--fw-medium);
  transition: color 120ms, border-color 120ms;
  position: relative;
  bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--color-text); }
.tab--active {
  color: var(--color-text);
  border-bottom-color: var(--color-text);
  font-weight: var(--fw-semibold);
}

.tab-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: var(--sp-4);
}

/* ─── FORM FIELDS ────────────────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: var(--sp-1); }

.field-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--color-text);
}
.field-label__optional { color: var(--color-text-muted); font-weight: var(--fw-normal); }

.field-input {
  width: 100%;
  padding: 7px 10px;
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
  line-height: var(--lh-body);
}
.field-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(48,48,48,0.12);
}
.field-input--textarea { resize: vertical; min-height: 60px; }

.field-select {
  width: 100%;
  padding: 7px 32px 7px 10px;
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23616161'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.168l3.71-3.938a.75.75 0 1 1 1.08 1.04l-4.25 4.5a.75.75 0 0 1-1.08 0l-4.25-4.5a.75.75 0 0 1 .02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E") no-repeat right 8px center / 16px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  appearance: none;
  cursor: pointer;
  transition: border-color 120ms;
}
.field-select:focus { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(48,48,48,0.12); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 7px 14px;
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
  white-space: nowrap;
}
.btn:hover { background: var(--color-secondary-bg); }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

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

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

.btn--plain { background: transparent; border-color: transparent; color: var(--color-text-muted); padding: 7px 8px; }
.btn--plain:hover { background: var(--color-secondary-bg); color: var(--color-text); }

.btn--back { color: var(--color-text-muted); font-size: var(--text-sm); }
.btn--back:hover { color: var(--color-text); }

.btn--danger { color: var(--color-danger); }
.btn--danger:hover { background: #fff0f0; border-color: #fcd6d3; }

.btn--danger-plain {
  background: transparent;
  border: none;
  color: var(--color-danger);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn--danger-plain:hover { color: var(--color-danger-hover); }

.danger-zone {
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
}

.btn--sm { padding: 5px 10px; font-size: var(--text-xs); }
.btn--icon { padding: 6px; border-color: transparent; background: transparent; color: var(--color-text-muted); border-radius: var(--radius-md); }
.btn--icon:hover { background: var(--color-secondary-bg); color: var(--color-text); }
.btn--icon.btn--danger:hover { background: #fff0f0; color: var(--color-danger); }

/* Add question button */
.btn--add-question {
  width: 100%;
  margin-top: var(--sp-3);
  padding: 10px;
  border-style: dashed;
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
}
.btn--add-question:hover { color: var(--color-text); background: var(--color-secondary-bg); }

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  line-height: 18px;
}
.badge--live  { background: var(--badge-live-bg);  color: var(--badge-live-text); }
.badge--draft { background: var(--badge-draft-bg); color: var(--badge-draft-text); }

/* ─── QUESTION CARDS ─────────────────────────────────────────────────────── */
.question-stack { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-4); }

.question-card {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: var(--sp-3);
  align-items: start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  transition: box-shadow 150ms;
}
.question-card:hover { box-shadow: var(--shadow-card-hover); }
.question-card.is-dragging { opacity: 0.4; }
.question-card.drag-over { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(48,48,48,0.15); }

.question-card__handle {
  cursor: grab;
  color: var(--color-text-disabled);
  padding-top: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.question-card__handle:hover { color: var(--color-text-muted); }
.question-card__handle:active { cursor: grabbing; }

.question-card__body { display: flex; flex-direction: column; gap: var(--sp-3); }

.question-card__header {
  display: grid;
  grid-template-columns: 28px 1fr 32px;
  gap: var(--sp-2);
  align-items: center;
}

.question-num {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
  background: var(--color-secondary-bg);
  border-radius: var(--radius-sm);
  padding: 2px 5px;
  text-align: center;
  white-space: nowrap;
}

.q-title-input {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 5px 8px;
  background: transparent;
  width: 100%;
  font-family: var(--font);
  color: var(--color-text);
  outline: none;
  transition: border-color 120ms, background 120ms;
}
.q-title-input:hover { background: var(--color-secondary-bg); }
.q-title-input:focus { background: var(--color-surface); border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(48,48,48,0.12); }
.q-title-input::placeholder { color: var(--color-text-disabled); font-weight: var(--fw-normal); }

/* Answer type chips */
.type-chips {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-family: var(--font);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
  white-space: nowrap;
}
.chip:hover { background: var(--color-secondary-bg); color: var(--color-text); }
.chip--active {
  background: var(--chip-active-bg);
  border-color: var(--chip-active-border);
  color: var(--chip-active-text);
}

/* Options editor */
.options-editor { display: flex; flex-direction: column; gap: var(--sp-2); }
.options-editor[hidden] { display: none; }
.options-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.option-row {
  display: grid;
  grid-template-columns: 12px 1fr 28px;
  gap: var(--sp-2);
  align-items: center;
}
.option-bullet { color: var(--color-text-muted); font-size: var(--text-sm); text-align: center; }
.option-input { font-size: var(--text-sm); }

/* Required toggle */
.question-card__footer { padding-top: var(--sp-1); border-top: 1px solid var(--color-border); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.toggle-label { font-size: var(--text-sm); color: var(--color-text-muted); }
.toggle-input {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  position: relative;
  cursor: pointer;
  transition: background 150ms;
  flex-shrink: 0;
}
.toggle-input:checked { background: var(--color-success); }
.toggle-input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 150ms;
}
.toggle-input:checked::after { transform: translateX(14px); }
.toggle-input:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Questions empty state */
.empty-questions {
  margin-top: var(--sp-4);
  padding: var(--sp-6);
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

/* ─── RULE CARDS ─────────────────────────────────────────────────────────── */
.rule-stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.rule-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.rule-card__row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.rule-card__label { font-size: var(--text-sm); color: var(--color-text-muted); white-space: nowrap; }

/* ─── RESPONSES ──────────────────────────────────────────────────────────── */
.responses-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--color-border);
}
.responses-header__actions { display: flex; align-items: center; gap: var(--sp-2); }
.download-group { display: flex; align-items: center; }
.download-group[hidden] { display: none; }
.dropdown { position: relative; }
.dropdown__menu { position: absolute; top: calc(100% + 4px); right: 0; min-width: 100px; background: white; border: 1px solid var(--color-border); border-radius: var(--radius-base); box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 100; overflow: hidden; }
.dropdown__menu[hidden] { display: none; }
.dropdown__item { display: block; width: 100%; padding: 8px 14px; font-size: var(--text-sm); text-align: left; background: none; border: none; cursor: pointer; color: var(--color-text); }
.dropdown__item:hover { background: var(--color-surface); }
.response-list { display: flex; flex-direction: column; }
.response-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
}
.response-row:last-child { border-bottom: none; }
.response-row__meta { display: flex; align-items: center; gap: var(--sp-4); }
.response-id { font-weight: var(--fw-semibold); color: var(--color-text-muted); font-size: var(--text-xs); }
.response-date { color: var(--color-text-muted); font-size: var(--text-xs); }
.response-answer { display: flex; flex-direction: column; gap: 2px; }
.response-answer__label { font-size: var(--text-xs); color: var(--color-text-muted); }
.response-answer__text { font-size: var(--text-sm); color: var(--color-text); }
.response-answer--empty { font-size: var(--text-xs); color: var(--color-text-muted); font-style: italic; }

/* ─── RESPONSE ORDER CONTEXT ─────────────────────────────────────────────── */
.response-order {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-secondary-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}
.oc-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  align-items: baseline;
}
.oc-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.oc-val {
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-right: var(--sp-4);
}
.oc-items {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-2);
  margin-top: var(--sp-2);
}
.oc-item {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}
.oc-discounts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-2);
  margin-top: var(--sp-2);
}
.oc-chip {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-success-text);
  background: var(--color-success-bg);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

/* Panel description & misc */
.panel-description { color: var(--color-text-muted); margin: 0 0 var(--sp-4); font-size: var(--text-sm); line-height: 1.5; }
.text-muted { color: var(--color-text-muted); font-size: var(--text-sm); }

/* ─── PREVIEW PANEL ─────────────────────────────────────────────────────── */
/* Sticky: stays in viewport while user scrolls the editor panel */
.preview-panel {
  flex: 1;
  min-width: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #e8eaed;
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.preview-title { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--color-text); }

.preview-device-toggle {
  display: flex;
  gap: 2px;
  background: var(--color-secondary-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 2px;
}
.preview-device-btn {
  padding: 4px 8px;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  transition: background 120ms, color 120ms;
}
.preview-device-btn--active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.preview-step-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.preview-step-label { font-size: var(--text-xs); color: var(--color-text-muted); min-width: 80px; text-align: center; }
.preview-step-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 120ms, color 120ms;
}
.preview-step-btn:hover:not([disabled]) { background: var(--color-secondary-bg); color: var(--color-text); }
.preview-step-btn[disabled] { opacity: 0.4; cursor: default; }

.preview-viewport {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: var(--sp-4);
  background: #f5f6f8;
}

/* ─── CHECKOUT PAGE MOCK ─────────────────────────────────────────────────── */
/* Flat page view - accurate to Shopify's actual thank-you page rendering */
.checkout-mock {
  width: 100%;
  max-width: 460px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: max-width 250ms ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.checkout-mock.is-desktop { max-width: 680px; }

/* Confirmation header - matches Shopify's blue circle check */
.cko-header {
  padding: 24px 20px 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border-bottom: 1px solid #e5e7eb;
  background: white;
}
.cko-check-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #0070f3;
  color: #0070f3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.cko-order-ref { margin: 0 0 3px; font-size: 12px; color: #6b7280; }
.cko-thankyou { margin: 0; font-size: 20px; font-weight: 700; color: #111827; line-height: 1.3; }

/* Page body */
.cko-body {
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: white;
}

/* Survey block - matches Shopify s-box border="base" */
.cko-survey-block {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 16px 16px 12px;
  background: white;
}
.cko-survey-empty { font-size: 13px; color: #9ca3af; text-align: center; margin: 4px 0; }

/* Survey internals - matches actual s-text / s-text-area / s-button output */
.cko-widget-title {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 12px;
  line-height: 1.4;
}
.cko-q {
  font-size: 14px;
  font-weight: 400;
  color: #1a1a1a;
  line-height: 1.5;
  margin: 0 0 10px;
}
.cko-req { color: #dc2626; margin-left: 2px; }

.cko-textarea, .cko-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  outline: none;
  background: white;
  color: #111827;
  margin-bottom: 12px;
  display: block;
}
.cko-textarea { resize: none; }
.cko-textarea[hidden], .cko-input[hidden] { display: none; }

.cko-choices { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.cko-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  color: #111827;
  cursor: default;
}
.cko-choice input { accent-color: #0070f3; width: 15px; height: 15px; flex-shrink: 0; }
.cko-hint { font-size: 12px; color: #9ca3af; font-style: italic; margin: 0 0 12px; }

.cko-actions { display: flex; align-items: center; gap: 8px; }
.cko-btn {
  padding: 8px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  cursor: default;
  border: 1px solid #1a1a1a;
  background: #1a1a1a;
  color: white;
}
.cko-btn--ghost { background: transparent; border-color: transparent; color: #6b7280; }

/* "Your order is confirmed" info block */
.cko-info-block {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 16px 20px;
  background: white;
}
.cko-info-block__title { margin: 0 0 4px; font-size: 15px; font-weight: 600; color: #111827; }
.cko-info-block__body { margin: 0; font-size: 13px; color: #6b7280; line-height: 1.5; }

.cko-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
  margin-top: 12px;
}
.cko-details-col { display: flex; flex-direction: column; gap: 12px; }
.cko-details-heading { margin: 0 0 2px; font-size: 12px; font-weight: 600; color: #111827; }
.cko-details-text { margin: 0; font-size: 12px; color: #6b7280; line-height: 1.5; font-style: normal; }

/* ─── TOAST ─────────────────────────────────────────────────────────────── */
.toast-region {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 9999;
  pointer-events: none;
}
.toast {
  background: #1a1a1a;
  color: white;
  padding: 10px var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms, transform 180ms;
  pointer-events: auto;
  max-width: 320px;
}
.toast--visible  { opacity: 1; transform: translateY(0); }
.toast--success  { background: var(--color-success); }
.toast--error    { background: #b42318; }
