/* -- Sequence Editor ---------------------------------- */
.sequence-step {
  border: 1.5px dashed var(--k-border);
  border-radius: var(--k-radius-sm); padding: 0;
  margin-bottom: 12px; background: var(--k-surface);
  transition: all var(--k-dur-normal) var(--k-ease);
  overflow: hidden;
}
.sequence-step.active {
  border: 2px solid var(--k-instant-blue); background: #f9f9f9;
}
.sequence-step:hover { box-shadow: var(--k-shadow-md); }
.sequence-step .step-title {
  font-size: 13px; font-weight: 600; color: var(--k-text); text-transform: none;
  letter-spacing: 0; padding: 16px 20px 8px; margin: 0;
}
/* Step header row — title + delay badge + delete button */
.step-hdr-row {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px 4px;
}
.step-hdr-row .step-title { flex: 1; padding: 0; color: var(--k-text); text-transform: none; letter-spacing: 0; font-weight: 600; }
.step-delay-badge {
  font-size: 11px; font-weight: 500; color: var(--k-text-secondary);
  background: var(--k-surface-sunken); border-radius: 4px; padding: 2px 7px;
  white-space: nowrap; flex-shrink: 0;
}
.step-delete-btn { opacity: 0; transition: opacity 0.15s; flex-shrink: 0; }
.sequence-step:hover .step-delete-btn { opacity: 0.45; }
.step-delete-btn:hover { opacity: 1 !important; }
.variant-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border: none; border-radius: 0;
  background: var(--k-surface); cursor: pointer;
  transition: all var(--k-dur-fast) var(--k-ease);
  position: relative;
}
.variant-item:hover { background: var(--k-surface-hover); }
.variant-item.active {
  background: var(--k-surface);
}
.variant-item + .variant-item { border-top: 1px solid #f0f2f5; }
.variant-item:first-of-type { border-radius: 0; }
.variant-item:last-of-type { border-radius: 0; }
.variant-subject {
  font-size: 14px; color: var(--k-text); flex: 1; min-width: 0; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 144px;
}
.variant-winner-badge {
  font-size: 14px; line-height: 1; margin-left: 4px;
}
.variant-actions { display: flex; align-items: center; gap: 4px; }
/* Toggle switch — replaces checkbox */
.variant-toggle-wrap {
  position: relative; width: 40px; height: 22px; flex-shrink: 0;
}
.variant-toggle-wrap input {
  opacity: 0; width: 0; height: 0; position: absolute;
}
.variant-toggle-slider {
  position: absolute; inset: 0; border-radius: 11px;
  background: #ccc; cursor: pointer;
  transition: background 0.2s;
}
.variant-toggle-slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 3px; top: 3px; border-radius: 50%; background: #fff;
  transition: transform 0.2s;
}
.variant-toggle-wrap input:checked + .variant-toggle-slider {
  background: #1b1f2a;
}
.variant-toggle-wrap input:checked + .variant-toggle-slider::before {
  transform: translateX(18px);
}
/* Non-selected variant controls hidden until hover — Instantly parity */
.variant-toggle-wrap.variant-ctrl-hover { opacity: 0; transition: opacity 0.15s; }
.variant-item:hover .variant-toggle-wrap.variant-ctrl-hover { opacity: 1; }
.variant-toggle { width: 36px; height: 20px; }
/* Delete icon — hidden by default, visible on active/hover */
.variant-item .btn-delete-variant {
  opacity: 0; transition: opacity 0.15s;
}
.variant-item.active .btn-delete-variant,
.variant-item:hover .btn-delete-variant {
  opacity: 0.5;
}
.variant-item .btn-delete-variant:hover {
  opacity: 1;
}
.btn-add-variant {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px 20px; color: var(--k-material-blue); font-size: 14px; font-weight: 500;
  background: none; border: none; cursor: pointer;
}
.btn-add-variant:hover { color: var(--k-instant-blue); }
.btn-add-step {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--k-border); border-radius: var(--k-radius-sm);
  padding: 10px 20px; background: transparent;
  color: var(--k-instant-blue); font-size: 14px; font-weight: 500;
  cursor: pointer; margin-top: 8px; width: 100%;
}
.btn-add-step:hover { background: var(--k-surface-hover); }

/* -- Email Editor ------------------------------------- */
.email-editor { padding: 28px 32px; }
.email-editor-subject {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px; border-bottom: 1px solid var(--k-border-light);
  margin-bottom: 0;
  position: sticky; top: 0; z-index: 3;
  background: var(--k-surface);
}
.email-editor-subject label {
  font-size: 13px; font-weight: 400; color: var(--k-text-secondary); white-space: nowrap;
}
.email-editor-subject input {
  flex: 1; border: none; outline: none; font-size: 15px; font-weight: 600; color: var(--k-text);
}
.email-editor-subject .btn-preview {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid #d0e3ff; border-radius: var(--k-radius-sm);
  padding: 7px 14px; background: #e8f2ff; color: var(--k-cta);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.email-editor-subject .btn-preview:hover { background: #d8ecff; }
.email-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  padding: 24px 32px;
  border: none;
  font-size: 15px; line-height: 1.75; color: var(--k-text);
}
.email-body img { max-width: 100%; height: auto; border-radius: var(--k-radius-xs); }
.email-body[contenteditable] { outline: none; }
.email-body[contenteditable]:focus { outline: none; }
/* Tiptap editor host: flex parent for the ProseMirror node so it inherits
   the same height/scroll behaviour as the contenteditable fallback. */
.email-body-host { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; }
.email-body-host > .ProseMirror { flex: 1 1 auto; min-height: 0; outline: none; }
/* GrapesJS host needs an explicit min-height because the editor measures the
   container on init; an unsized flex child collapses to 0 and the canvas
   never paints. The editor manages its own internal scroll. */
.email-body-visual-host { min-height: 600px; display: block; flex: 1 1 auto; }
.email-editor-slot { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; }
/* Visual-mode toggle button shares the seq-tb-code-toggle outline styles
   so the toolbar reads consistently regardless of which mode is active. */
.seq-tb-visual-toggle.is-active { background: #e8f0fe; color: var(--k-material-blue); }
/* Variable chip — {{firstName}} etc. rendered as a single deletable atom
   by the Variable node in tiptap-bridge.js. */
.tt-variable {
  display: inline-block; padding: 1px 6px; margin: 0 1px; border-radius: 4px;
  background: #e8f0fe; color: var(--k-material-blue); font-weight: 600; font-size: 0.95em;
  line-height: 1.35; user-select: all; cursor: default;
}
/* Placeholder text shown by the Tiptap Placeholder extension on an empty
   first paragraph. Uses ProseMirror's ::before convention. */
.email-body .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder); float: left; color: #9aa0a6;
  pointer-events: none; height: 0;
}
.editor-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 16px;
  border-top: 1px solid var(--k-border-light);
  flex-wrap: wrap; background: var(--k-surface);
  flex-shrink: 0; z-index: 2;
}
/* Sequence editor: toolbar is pinned to the BOTTOM of the panel (Instantly parity) */
.split-panel.sequence-split .editor-toolbar { border-top: 1px solid var(--k-border-light); }
.editor-toolbar .btn-icon { width: 36px; height: 36px; }
.editor-toolbar .btn-save-blue {
  background: var(--k-instant-blue); color: #fff; border: none; border-radius: 6px 0 0 6px;
  padding: 8px 20px; font-size: 16px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.editor-toolbar .btn-save-blue:hover { background: var(--k-instant-blue-hover); }
.editor-toolbar .btn-save-blue:disabled { background: #6ba8ff; cursor: not-allowed; opacity: 0.8; }
.editor-toolbar .btn-save-dropdown {
  background: var(--k-instant-blue); color: #fff; border: none; border-radius: 0 6px 6px 0;
  padding: 8px 10px; cursor: pointer; border-left: 1px solid rgba(255,255,255,0.3);
}
.editor-toolbar .btn-save-dropdown:hover { background: var(--k-instant-blue-hover); }
.editor-toolbar .btn-tool {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: none; background: none;
  color: #3c4858; font-size: 14px; cursor: pointer; border-radius: 4px;
}
.editor-toolbar .btn-tool:hover { background: var(--k-surface-hover); }
.editor-toolbar .toolbar-sep {
  width: 1px; height: 24px; background: var(--k-border); margin: 0 4px;
}
/* ··· More formatting panel — collapsed by default (Instantly parity) */
.toolbar-more-panel {
  display: none; align-items: center; gap: 4px; flex-wrap: wrap;
  flex: 0 0 100%; padding-top: 6px; margin-top: 2px;
  border-top: 1px solid #f0f2f5;
}
.toolbar-more-panel.is-open { display: flex; }
.toolbar-more-panel .toolbar-sep { height: 20px; }
.editor-toolbar .seq-tb-more {
  padding: 6px 8px; font-size: 15px; letter-spacing: 2px;
  line-height: 1; min-width: 36px; font-weight: 600; color: #3c4858;
}
.editor-toolbar .seq-tb-more.is-active { background: #e8f0fe; color: var(--k-material-blue); }

/* ── Variables button in subject bar ─────────────────────────────── */
.seq-vars-btn {
  display: inline-flex !important; align-items: center; gap: 5px;
  padding: 6px 10px !important; font-size: 12px; font-weight: 600;
  border: 1px solid rgba(80,70,228,0.3) !important;
  background: rgba(80,70,228,0.07) !important;
  color: var(--k-primary) !important;
  border-radius: var(--k-radius-sm) !important; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  letter-spacing: 0.1px;
  transition: all 120ms ease;
}
.seq-vars-btn:hover {
  background: rgba(80,70,228,0.14) !important;
  border-color: var(--k-primary) !important;
}
.seq-vars-btn .material-symbols-outlined { font-size: 15px; }

/* ── Variable Picker Panel ───────────────────────────────────────── */
.seq-var-picker {
  position: fixed;
  z-index: 99999;
  width: 340px;
  max-height: 480px;
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: svp-appear .12s ease;
}
@keyframes svp-appear {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.svp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--k-border-light);
  flex-shrink: 0;
}
.svp-title {
  font-size: 13px; font-weight: 600; color: var(--k-text);
  letter-spacing: .1px;
}
.svp-close {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border: none; background: none;
  border-radius: 6px; cursor: pointer; color: var(--k-text-secondary);
}
.svp-close:hover { background: var(--k-surface-hover); color: var(--k-text); }
.svp-close .material-symbols-outlined { font-size: 16px; }

.svp-search-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--k-border-light);
  flex-shrink: 0;
}
.svp-search-icon { font-size: 16px !important; color: var(--k-text-secondary); }
.svp-search {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 13px; color: var(--k-text);
}
.svp-search::placeholder { color: var(--k-text-muted); }

.svp-body {
  flex: 1; overflow-y: auto; padding: 6px 0 8px;
}
.svp-body::-webkit-scrollbar { width: 4px; }
.svp-body::-webkit-scrollbar-thumb { background: var(--k-border); border-radius: 2px; }

.svp-group { padding: 0 0 4px; }
.svp-group-hdr {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px 3px;
  font-size: 11px; font-weight: 600; color: var(--k-text-secondary);
  text-transform: uppercase; letter-spacing: .5px;
}
.svp-group-icon { font-size: 13px !important; }

.svp-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 7px 14px;
  border: none; background: none; cursor: pointer; text-align: left;
  gap: 10px;
  transition: background .08s;
}
.svp-item:hover { background: var(--k-surface-hover); }
.svp-item--spintax .svp-chip {
  background: #fef3c7; color: #92400e; border-color: #fde68a;
}
.svp-item-left {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.svp-chip {
  display: inline-block;
  font-size: 11px; font-family: 'Menlo','Consolas',monospace;
  padding: 1px 5px; border-radius: 4px;
  background: #eef2ff; color: var(--k-primary);
  border: 1px solid #c7d7fe;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}
.svp-item-label {
  font-size: 12px; font-weight: 500; color: var(--k-text); margin-top: 1px;
}
.svp-item-desc {
  font-size: 11px; color: var(--k-text-muted); white-space: nowrap;
  flex-shrink: 0; max-width: 100px; overflow: hidden; text-overflow: ellipsis;
}
.svp-empty {
  padding: 24px; text-align: center;
  font-size: 13px; color: var(--k-text-secondary);
}

/* ── Sequence editor UX improvements ─────────────────────────────── */
/* Step list: slightly taller variant items for better touch target */
.variant-item { padding: 12px 16px; }
/* Active variant gets a left accent bar */
.variant-item.active {
  border-left: 3px solid var(--k-instant-blue);
  padding-left: 13px;
}
/* Variant color circles: larger, more vibrant */
.variant-badge {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
/* Subject row: sticky with border shadow when scrolled */
.email-editor-subject {
  box-shadow: 0 1px 0 var(--k-border-light);
}
/* Editor slot: add subtle top border */
.email-editor-slot {
  border-top: 1px solid var(--k-border-light);
}
/* Timing row improvements */
.email-editor-timing-row {
  padding: 10px 24px;
  background: var(--k-surface-secondary, #fafafa);
  border-bottom: 1px solid var(--k-border-light);
}
.email-editor-timing-row label span.text-muted {
  font-weight: 500; text-transform: uppercase; letter-spacing: .4px;
}

/* Responsive: stack editor on small screens */
@media (max-width: 900px) {
  .split-panel.sequence-split {
    flex-direction: column !important;
  }
  .split-panel.sequence-split > .split-left {
    max-height: 220px; overflow-y: auto;
  }
}


