/* Conv Builder — hell, HoPla-Builder-orientiert (Header + horizontale Nav + Liste links) */

:root {
  --cb-head-h: 56px;
  --cb-nav-h: 48px;
  --cb-sidebar-w: minmax(240px, 300px);
  --cb-preview-w: minmax(300px, 420px);
  --cb-border: var(--c-border, #e5e5e5);
  --cb-surface: #fff;
  --cb-surface-muted: #fafafa;
  --cb-text: #111;
  --cb-text-muted: #666;
  --cb-accent: var(--journey-accent, #0aa37f);
}

.conv-builder-body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f6f6f6 0%, #fff 32%);
  color: var(--cb-text);
}

.conv-builder-body:has(#app-shell:not(.hidden)) {
  height: 100vh;
  overflow: hidden;
}

.hidden,
.cb-login-error.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ——— Login ——— */
.cb-login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #f5f5f5 0%, #fff 100%);
}

.cb-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--cb-surface);
  padding: 40px 44px;
  border-radius: var(--radius, 14px);
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--cb-border);
}

.cb-login-head {
  text-align: center;
  margin-bottom: 28px;
}

.cb-login-head h1 {
  margin: 0 0 8px;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--cb-text);
}

.cb-login-head p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--cb-text-muted);
}

.cb-login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cb-login-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
}

.cb-login-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--cb-border);
  border-radius: var(--radius, 12px);
  font: inherit;
  font-size: 0.95rem;
  background: #fff;
  box-sizing: border-box;
}

.cb-login-form input:focus {
  outline: none;
  border-color: #000;
}

.cb-login-error {
  padding: 10px 12px;
  background: #fff0f0;
  border: 1px solid #fcc;
  border-radius: var(--radius, 10px);
  color: #b00;
  font-size: 0.9rem;
  text-align: center;
}

.cb-login-foot {
  margin: 20px 0 0;
  text-align: center;
}

.cb-login-foot small {
  color: #999;
  font-size: 0.8rem;
}

/* ——— Dialog (Neuer Flow / Sequence) ——— */
.cb-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.cb-dialog.hidden {
  display: none !important;
}

.cb-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.cb-dialog__card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  border-radius: var(--radius, 14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  padding: 24px 26px;
}

.cb-dialog__title {
  margin: 0 0 18px;
  font-size: 1.2rem;
  font-weight: 700;
}

.cb-dialog__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cb-dialog__form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
}

.cb-dialog__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.cb-dialog__input:focus {
  outline: none;
  border-color: #000;
}

.cb-dialog__hint {
  margin: -4px 0 6px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--cb-text-muted);
}

.cb-dialog__hint code {
  font-size: 0.76rem;
}

.cb-dialog__error {
  padding: 10px 12px;
  background: #fff0f0;
  border: 1px solid #fcc;
  border-radius: 10px;
  color: #b00;
  font-size: 0.88rem;
}

.cb-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* ——— Buttons ——— */
.cb-btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.cb-btn--sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.cb-btn--xs {
  padding: 4px 8px;
  font-size: 0.75rem;
  line-height: 1.2;
}

.cb-btn--icon {
  min-width: 2rem;
  padding-left: 6px;
  padding-right: 6px;
  font-weight: 700;
}

.cb-btn--chip {
  padding: 3px 7px;
  font-size: 0.68rem;
  line-height: 1.25;
  border-radius: 6px;
  border: 1px solid #d8deda;
  background: #fff;
  color: #333;
}

.cb-btn--chip:hover {
  border-color: var(--cb-accent);
  color: var(--cb-accent);
  background: rgba(10, 163, 127, 0.06);
}

.cb-btn--primary {
  background: var(--btn-bg, #000);
  color: var(--btn-fg, #fff);
}

.cb-btn--primary:hover {
  opacity: 0.88;
}

.cb-btn--ghost {
  background: transparent;
  color: var(--cb-text-muted);
  border-color: var(--cb-border);
}

.cb-btn--ghost:hover {
  color: var(--cb-text);
  border-color: #ccc;
  background: #f5f5f5;
}

.cb-btn--danger {
  background: #fff;
  color: #a00;
  border-color: #eaa;
}

.cb-btn--danger:hover {
  background: #fff5f5;
}

/* ——— App shell ——— */
.cb-app {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--cb-surface-muted);
}

.cb-header {
  flex-shrink: 0;
  height: var(--cb-head-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--cb-surface);
  border-bottom: 1px solid var(--cb-border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.cb-header__brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cb-header__brand strong {
  font-size: 1.05rem;
}

.cb-header__tag {
  font-size: 0.78rem;
  color: var(--cb-text-muted);
}

/* Horizontale Bereichswahl (wie HoPla builder-nav) */
.cb-topnav {
  flex-shrink: 0;
  height: var(--cb-nav-h);
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 12px;
  background: var(--cb-surface);
  border-bottom: 1px solid var(--cb-border);
}

.cb-topnav__btn {
  display: flex;
  align-items: center;
  padding: 0 18px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  color: var(--cb-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.cb-topnav__btn:hover {
  color: var(--cb-text);
  background: #f7f7f7;
}

.cb-topnav__btn.active {
  color: var(--cb-text);
  font-weight: 600;
  border-bottom-color: #000;
}

/* 3-Spalten: Liste | Editor | Preview */
.cb-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--cb-sidebar-w) 1fr var(--cb-preview-w);
  gap: 0;
}

.cb-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--cb-surface-muted);
  border-right: 1px solid var(--cb-border);
}

.cb-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
}

.cb-pane.hidden {
  display: none;
}

.cb-pane__toolbar {
  flex-shrink: 0;
}

.cb-pane__toolbar--stack .cb-upload {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cb-pane__head {
  font-weight: 700;
  font-size: 0.9rem;
}

.cb-pane__hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--cb-text-muted);
  line-height: 1.4;
}

.cb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  border-radius: 10px;
}

.cb-list li {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  font-size: 0.88rem;
}

.cb-list li:last-child {
  border-bottom: none;
}

.cb-list li:hover {
  background: #f7f7f7;
}

.cb-list li.active {
  background: rgba(10, 163, 127, 0.1);
  box-shadow: inset 3px 0 0 0 var(--cb-accent);
}

.cb-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--cb-surface);
  border-right: 1px solid var(--cb-border);
}

.cb-editor__sheet {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 10px;
}

.cb-editor__sheet.hidden {
  display: none;
}

.cb-editor__empty {
  margin: 0;
  color: var(--cb-text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

#flow-json {
  flex: 1;
  min-height: 200px;
  resize: none;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
  padding: 12px;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
  background: #fff;
  color: #1a1a1a;
}

/* —— Sequence Builder (grafisch) —— */
.seq-builder {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.seq-builder--idle .seq-builder__grid {
  opacity: 0.55;
  pointer-events: none;
}

.seq-builder__meta {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px 16px;
  align-items: end;
}

@media (max-width: 800px) {
  .seq-builder__meta {
    grid-template-columns: 1fr;
  }
}

.seq-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.seq-req {
  color: #c62828;
  font-weight: 700;
}

.seq-field-hint {
  margin: 2px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--cb-text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

.seq-field__label,
.seq-field > label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--cb-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.seq-field--id {
  align-items: flex-start;
}

.seq-input,
.seq-textarea {
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--cb-border);
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
}

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

.seq-id-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 6px 10px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.82rem;
  background: #f0f4f2;
  border-radius: 8px;
  border: 1px solid var(--cb-border);
}

.seq-builder__grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(168px, 220px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
  align-items: stretch;
}

.seq-builder__grid > * {
  min-width: 0;
  min-height: 0;
}

.seq-builder__grid > .seq-step-panel {
  height: 100%;
  max-height: 100%;
}

@media (max-width: 900px) {
  .seq-builder__grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(140px, 34vh) minmax(0, 1fr);
  }
}

.seq-builder__rail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  background: linear-gradient(165deg, #fafcfb 0%, #f3f6f4 100%);
  border: 1px solid var(--cb-border);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.seq-rail__hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--cb-text-muted);
  line-height: 1.45;
}

.seq-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.seq-step {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8e4;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.seq-step__num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cb-accent);
  background: rgba(10, 163, 127, 0.1);
  border-radius: 999px;
}

.seq-step--active .seq-step__num {
  background: var(--cb-accent);
  color: #fff;
}

.seq-step__main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.seq-step:hover {
  border-color: var(--cb-accent);
}

.seq-step--active {
  border-color: var(--cb-accent);
  box-shadow: 0 0 0 1px var(--cb-accent);
}

.seq-step__badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cb-accent);
}

.seq-step__txt {
  font-size: 0.82rem;
  color: #333;
  line-height: 1.35;
  word-break: break-word;
}

.seq-builder__add {
  flex-shrink: 0;
  margin-top: auto;
  border-top: 1px dashed var(--cb-border);
  padding-top: 6px;
}

.seq-builder__add-summary {
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cb-accent);
  list-style: none;
  user-select: none;
  padding: 4px 0;
}

.seq-builder__add-summary::-webkit-details-marker {
  display: none;
}

.seq-builder__add[open] .seq-builder__add-summary {
  margin-bottom: 6px;
}

.seq-builder__add-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 5.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0;
}

/* Mittlerer Bereich: nur vertikal scrollen */
.seq-step-panel {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--cb-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.seq-field-error {
  color: #b42318;
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
  line-height: 1.35;
}

.seq-panel__header,
.seq-panel__head {
  flex-shrink: 0;
  padding: 14px 16px 12px;
  border-bottom: 1px solid #ececec;
  background: linear-gradient(180deg, #fafcfb 0%, #fff 100%);
}

.seq-panel__header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.seq-panel__header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.seq-panel__actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.seq-panel__step-idx {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--cb-text-muted);
  font-variant-numeric: tabular-nums;
}

.seq-panel__type-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--cb-accent);
  background: rgba(10, 163, 127, 0.1);
  border: 1px solid rgba(10, 163, 127, 0.2);
}

.seq-panel__title,
.seq-panel__head h3 {
  margin: 0 0 4px;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.25;
}

.seq-panel__sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--cb-text-muted);
  line-height: 1.45;
}

.seq-panel__sub code {
  font-size: 0.78rem;
}

.seq-panel__body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.seq-panel__body > * {
  max-width: 100%;
  min-width: 0;
}

/* Legacy: Footer wird per JS in den Header verschoben */
.seq-panel__footer,
.seq-panel__rowact {
  display: none;
}

.seq-panel__empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  min-height: 12rem;
}

.seq-panel__empty-title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--cb-text);
}

.seq-panel__empty {
  margin: 0;
  max-width: 28rem;
  color: var(--cb-text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.seq-section {
  padding: 12px 14px;
  border: 1px solid #ebebeb;
  border-radius: 10px;
  background: #fcfcfc;
}

.seq-section--compact {
  padding: 10px 12px;
  background: #f6f8f7;
}

.seq-section__title {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cb-text-muted);
}

.seq-field-grid,
.seq-field--row,
.seq-field--row2,
.seq-field--row4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr));
  gap: 12px;
}

.seq-input,
.seq-textarea,
.seq-field select.seq-input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.seq-input--mono {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.82rem;
}

.seq-field--check label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.seq-textarea--code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
}

#sf-optrows,
#sf-btnrows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.seq-optrow,
.seq-btnrow {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  margin: 0;
  background: #f8faf9;
  border-radius: 10px;
  border: 1px solid #e6ebe8;
  border-left: 3px solid var(--cb-accent);
}

.seq-optrow__head,
.seq-btnrow__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.seq-optrow__title,
.seq-btnrow__title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cb-text-muted);
}

.seq-optrow__fields,
.seq-btnrow__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 10px;
  align-items: end;
}

.seq-btnrow .sf-ret.hidden,
.seq-field.sf-ret.hidden {
  display: none;
}

.seq-optrow .sf-o-remove,
.seq-btnrow .sf-b-remove {
  flex-shrink: 0;
}

.seq-json-details {
  flex-shrink: 0;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fafafa;
}

.seq-json-details summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cb-text-muted);
}

.seq-json-details[open] summary {
  margin-bottom: 8px;
}

#seq-json {
  width: 100%;
  min-height: 140px;
  max-height: 36vh;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
  padding: 12px;
  border: 1px solid var(--cb-border);
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  box-sizing: border-box;
}

.cb-editor__actions {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--cb-border);
  background: var(--cb-surface);
}

.cb-editor__actions--flow {
  position: sticky;
  bottom: 0;
  z-index: 4;
}

.flow-json-details {
  flex-shrink: 0;
  max-height: 22vh;
  overflow: auto;
}

.cb-save-status {
  font-size: 0.85rem;
  color: var(--cb-text-muted);
}

.cb-save-status--ok {
  color: var(--cb-accent);
}

.cb-save-hint {
  flex: 1;
  min-width: 12rem;
  font-size: 0.82rem;
  color: #b45309;
  font-weight: 500;
}

.cb-save-hint.hidden {
  display: none;
}

.cb-save-hint--ok {
  color: var(--cb-accent);
}

.cb-save-hint--warn {
  color: #b45309;
}

.fg-save-status {
  font-size: 0.78rem;
  color: var(--cb-accent);
  font-weight: 600;
  white-space: nowrap;
}

.fg-save-status.hidden {
  display: none;
}

.cb-save-status--err {
  color: #a00;
}

.cb-analytics {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 12px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
  background: #fafafa;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
}

.cb-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #ececec;
}

.cb-preview__bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--cb-surface);
  border-bottom: 1px solid var(--cb-border);
  font-size: 0.88rem;
  font-weight: 600;
}

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

.cb-preview__device-switch {
  display: inline-flex;
  border: 1px solid var(--cb-border);
  border-radius: 8px;
  overflow: hidden;
}

.cb-preview-device-btn {
  padding: 5px 10px;
  border: none;
  background: #fff;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--cb-text-muted);
}

.cb-preview-device-btn + .cb-preview-device-btn {
  border-left: 1px solid var(--cb-border);
}

.cb-preview-device-btn.is-active {
  background: #111;
  color: #fff;
}

.cb-preview__viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
}

.cb-preview__viewport > .preview-viewport-root {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(165deg, #e6e9f0 0%, #dce1ea 48%, #d5dae6 100%);
}

.preview-viewport-scaler {
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.preview-viewport--mobile .preview-viewport-device {
  box-sizing: border-box;
  width: 410px;
  height: 864px;
  padding: 10px;
  background: #1c1c1e;
  border-radius: 40px;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.06) inset,
    0 24px 56px rgba(0, 0, 0, 0.22);
}

.preview-viewport--mobile .cb-preview-iframe {
  display: block;
  width: 390px;
  height: 844px;
  border: none;
  border-radius: 28px;
  background: #fff;
}

.preview-viewport--desktop.preview-viewport-root {
  position: relative;
  align-items: stretch;
  justify-content: stretch;
}

.preview-viewport--desktop .preview-viewport-scaler {
  position: absolute;
  inset: 0;
  width: auto !important;
  height: auto !important;
}

.preview-viewport--desktop .preview-viewport-device {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  transform: none !important;
}

.preview-viewport--desktop .cb-preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  background: #fff;
}

.seq-json-details textarea {
  max-height: 28vh;
  overflow: auto;
}

/* —— Flow Builder (grafisch) —— */
.flow-builder {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.flow-builder--idle .flow-builder__grid {
  opacity: 0.55;
  pointer-events: none;
}

.flow-builder__meta {
  flex-shrink: 0;
}

.flow-builder__meta-title {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cb-text-muted);
}

.flow-builder__meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
  gap: 10px 14px;
  align-items: end;
}

.flow-builder__view-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.flow-view-toggle {
  display: inline-flex;
  padding: 3px;
  background: #eef2f0;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
  gap: 2px;
}

.flow-view-toggle__btn {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--cb-text-muted);
}

.flow-view-toggle__btn:hover {
  color: var(--cb-text);
}

.flow-view-toggle__btn.is-active {
  background: #fff;
  color: var(--cb-text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.flow-builder__grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(160px, 200px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.flow-builder__grid--map {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  flex: 1;
  min-height: 0;
  gap: 12px;
}

.flow-builder__grid--map .flow-graph-root {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.flow-builder--map-focus .flow-builder__grid--map .flow-node-panel {
  position: static;
  width: auto;
  max-height: none;
  min-height: 0;
}

.cb-workspace--flow-map {
  grid-template-columns: var(--cb-sidebar-w) 1fr !important;
}

.cb-workspace--flow-map .cb-preview {
  display: none;
}

.flow-builder__grid--map .flow-builder__rail--list {
  display: none !important;
}

.flow-builder__grid--list .flow-graph-root {
  display: none !important;
}

.flow-graph-root {
  min-height: 0;
  border-radius: 14px;
  border: 1px solid var(--cb-border);
  overflow: hidden;
  background: #eef2f0;
}

.flow-graph-root.hidden {
  display: none !important;
}

.flow-builder__grid > * {
  min-width: 0;
  min-height: 0;
}

.flow-builder__grid > .flow-node-panel {
  height: 100%;
  max-height: 100%;
}

.flow-builder__rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
  background: linear-gradient(165deg, #f8faf9 0%, #f0f4f2 100%);
  border: 1px solid var(--cb-border);
  border-radius: 12px;
}

.flow-rail__hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--cb-text-muted);
  line-height: 1.4;
}

.flow-rail__search {
  flex-shrink: 0;
}

.flow-rail__search .seq-input {
  font-size: 0.82rem;
  padding: 6px 10px;
}

.flow-nodes {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.flow-node {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid #e2e8e4;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.flow-node:hover {
  border-color: var(--cb-accent);
}

.flow-node--active {
  border-color: var(--cb-accent);
  box-shadow: 0 0 0 1px var(--cb-accent);
}

.flow-node__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.flow-node__type {
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 999px;
  color: var(--cb-accent);
  background: rgba(10, 163, 127, 0.1);
}

.flow-node__id {
  font-size: 0.75rem;
  font-family: ui-monospace, Menlo, monospace;
  color: #333;
}

.flow-node__txt {
  font-size: 0.78rem;
  color: var(--cb-text-muted);
  line-height: 1.35;
  word-break: break-word;
}

.flow-rail__add {
  flex-shrink: 0;
  width: 100%;
}

.flow-node-panel {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--cb-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.flow-panel__header,
.flow-panel__head {
  flex-shrink: 0;
  padding: 14px 16px 12px;
  border-bottom: 1px solid #ececec;
  background: linear-gradient(180deg, #fafcfb 0%, #fff 100%);
}

.flow-panel__header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.flow-panel__header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.flow-panel__node-id {
  font-size: 0.8rem;
  font-family: ui-monospace, Menlo, monospace;
  padding: 2px 8px;
  background: #f0f4f2;
  border-radius: 6px;
}

.flow-panel__type-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--cb-accent);
  background: rgba(10, 163, 127, 0.1);
}

.flow-panel__actions {
  display: inline-flex;
  gap: 4px;
}

.flow-panel__title,
.flow-panel__head h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
}

.flow-panel__sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--cb-text-muted);
  line-height: 1.45;
}

.flow-panel__body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.flow-section {
  padding: 12px 14px;
  border: 1px solid #ebebeb;
  border-radius: 10px;
  background: #fcfcfc;
}

.flow-section__title {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cb-text-muted);
}

.flow-section__hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #999;
}

.flow-bubble-row,
.flow-btnrow {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 9px;
  border: 1px solid #e8ecea;
  background: #f9fbfa;
}

.flow-bubble-row__head,
.flow-btnrow__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cb-text-muted);
}

.flow-btnrow__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 10px;
  align-items: end;
}

.shopify-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.shopify-item-row {
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid #e8ecea;
  background: #f9fbfa;
}

.shopify-item-row__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cb-text-muted);
}

.shopify-item-row__fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flow-shopify-timing {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.seq-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  cursor: pointer;
}

.seq-check input {
  margin: 0;
}

.flow-panel__empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  text-align: center;
}

.flow-panel__empty-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.flow-panel__empty {
  margin: 0;
  color: var(--cb-text-muted);
  font-size: 0.9rem;
}

.flow-json-details {
  flex-shrink: 0;
  border: 1px solid var(--cb-border);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fafafa;
}

.flow-json-details summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cb-text-muted);
}

.flow-json-details #flow-json {
  width: 100%;
  min-height: 120px;
  max-height: 28vh;
  resize: vertical;
  margin-top: 8px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
  padding: 12px;
  border: 1px solid var(--cb-border);
  border-radius: 8px;
  box-sizing: border-box;
}

/* —— Flow-Karte (interaktiver Graph) —— */
.fg-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.fg-cy-root {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: linear-gradient(145deg, #f4f7f5 0%, #e8eeea 100%);
}

.flow-builder--map-focus .flow-json-details {
  display: none;
}

.fg-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--cb-border);
  backdrop-filter: blur(8px);
}

.fg-toolbar__left,
.fg-toolbar__center,
.fg-toolbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fg-toolbar__left {
  flex: 1;
  min-width: 0;
}

.fg-toolbar__right {
  margin-left: auto;
}

.fg-toolbar__title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cb-text-muted);
}

.fg-seg {
  display: inline-flex;
  padding: 2px;
  background: #eef2f0;
  border-radius: 8px;
}

.fg-seg__btn {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--cb-text-muted);
}

.fg-seg__btn.is-active {
  background: #fff;
  font-weight: 600;
  color: var(--cb-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.fg-search__input {
  font: inherit;
  font-size: 0.8rem;
  padding: 5px 10px;
  border: 1px solid var(--cb-border);
  border-radius: 8px;
  width: min(160px, 100%);
}

.fg-legend {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--cb-text-muted);
}

.fg-legend__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 2px;
  vertical-align: middle;
}

.fg-legend__dot[data-k='call'] {
  background: #0aa37f;
}
.fg-legend__dot[data-k='goto'] {
  background: #2563eb;
}
.fg-legend__dot[data-k='return'] {
  background: #d97706;
}
.fg-legend__dot[data-k='entry'] {
  background: #6366f1;
}

.fg-warnings {
  font-size: 0.75rem;
  font-weight: 600;
  color: #b45309;
  background: #fffbeb;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #fcd34d;
}

.fg-btn {
  border: 1px solid var(--cb-border);
  background: #fff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}

.fg-btn:hover {
  background: #f7f7f7;
}

.fg-btn--primary {
  width: auto;
  padding: 0 12px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--cb-accent);
  color: #fff;
  border-color: var(--cb-accent);
}

.fg-btn--primary:hover {
  filter: brightness(1.05);
}

.fg-canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  cursor: grab;
  touch-action: none;
}

.fg-canvas-wrap:active {
  cursor: grabbing;
}

.fg-svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 400px;
}

.fg-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  margin: 0;
  font-size: 0.72rem;
  color: var(--cb-text-muted);
  pointer-events: none;
  opacity: 0.85;
}

.fg-spine {
  fill: none;
  stroke: rgba(10, 163, 127, 0.35);
  stroke-width: 3;
  stroke-linecap: round;
  pointer-events: none;
}

.fg-spine-label {
  font-size: 11px;
  fill: #0aa37f;
  font-weight: 700;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.fg-layer--dim {
  opacity: 0.12;
  transition: opacity 0.08s ease-out;
}


.fg-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 0.9rem;
  color: var(--cb-text-muted);
  pointer-events: none;
}

.fg-empty.hidden {
  display: none;
}

.fg-edge path {
  fill: none;
  stroke-width: 2;
  pointer-events: stroke;
  cursor: pointer;
  transition: stroke-width 0.12s;
}

.fg-edge--selected path {
  stroke-width: 3.5;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.2));
}

.fg-edge--invalid path {
  stroke-dasharray: 6 4;
}

.fg-edge__label {
  font-size: 10px;
  fill: #64748b;
  text-anchor: middle;
  pointer-events: none;
}

.fg-connect-preview {
  fill: none;
  stroke: #0aa37f;
  stroke-width: 2;
  stroke-dasharray: 6 4;
  pointer-events: none;
}

.fg-node {
  cursor: pointer;
  will-change: transform;
}

.fg-card {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 10px 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.06);
  font-family: inherit;
  position: relative;
  transition:
    box-shadow 0.15s,
    border-color 0.15s;
}

.fg-card:hover {
  border-color: rgba(10, 163, 127, 0.45);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.06),
    0 12px 28px rgba(10, 163, 127, 0.1);
}

.fg-card--selected {
  border-color: var(--cb-accent);
  box-shadow:
    0 0 0 2px rgba(10, 163, 127, 0.25),
    0 12px 28px rgba(10, 163, 127, 0.12);
}

.fg-card--orphan {
  opacity: 0.55;
  border-style: dashed;
}

.fg-card--sequence {
  background: linear-gradient(165deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 14px;
}

.fg-card--entry,
.fg-card--entry_returning {
  background: linear-gradient(165deg, #eef2ff 0%, #e0e7ff 100%);
  border-color: #a5b4fc;
}

.fg-card__head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.fg-card__badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
}

.fg-card__badge[data-type='choice'] {
  background: #dbeafe;
  color: #1d4ed8;
}
.fg-card__badge[data-type='bridge'] {
  background: #ffedd5;
  color: #c2410c;
}
.fg-card__badge[data-type='cta'] {
  background: #ede9fe;
  color: #6d28d9;
}
.fg-card__badge[data-type='end'] {
  background: #f1f5f9;
  color: #64748b;
}
.fg-card__badge--seq {
  background: #ccfbf1;
  color: #0f766e;
}
.fg-card__badge--entry {
  background: #c7d2fe;
  color: #4338ca;
}

.fg-card__id {
  font-size: 0.78rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.fg-card__sub {
  margin: 0;
  font-size: 0.72rem;
  color: var(--cb-text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fg-card__port {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--cb-accent);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.fg-card__port--in {
  top: -5px;
}

.fg-card__port--out {
  bottom: -5px;
  cursor: crosshair;
}

.fg-card__drag {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #94a3b8;
  cursor: grab;
  border-radius: 6px;
  user-select: none;
}

.fg-card__drag:active {
  cursor: grabbing;
  color: var(--cb-accent);
  background: rgba(10, 163, 127, 0.1);
}

.fg-edge--return path {
  opacity: 0.55;
}

@media (max-width: 1100px) {
  .cb-workspace {
    grid-template-columns: 220px 1fr 300px;
  }

  .flow-builder--map-focus .flow-builder__grid--map .flow-node-panel {
    position: static;
    width: 100%;
    max-height: 40vh;
  }
}

@media (max-width: 900px) {
  .cb-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr 280px;
  }

  .cb-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--cb-border);
    max-height: 280px;
  }

  .cb-editor {
    border-right: none;
    min-height: 360px;
  }
}
