/* ============================================================
   SUPPORTBOT BUILDER — Xenioo-inspired UI
   ============================================================ */

/* ── Confetti node header ── */
.node-type-confetti .node-hdr   { background: linear-gradient(135deg, #f59e0b, #d97706) !important; color: #fff !important; }
/* ── Place Search node header ── */
.node-type-placesearch .node-hdr { background: linear-gradient(135deg, #4285f4, #1a73e8) !important; color: #fff !important; }
/* ── Payment node header ── */
.node-type-payment .node-hdr { background: linear-gradient(135deg, #635bff, #4f46e5) !important; color: #fff !important; }

/* ════════════════════════════════════════════════════════
   STRIPE PAYMENT CARD — shared across chat.html,
   sb-chatmodal-v4.js, sb-preview-v5.js
════════════════════════════════════════════════════════ */

.stripe-card-container {
  font-family: 'Inter', system-ui, sans-serif;
  width: 100%;
  max-width: 380px;
}

/* Loading / error states */
.stripe-loading,
.stripe-error {
  padding: 18px 16px;
  border-radius: 12px;
  font-size: 13px;
  text-align: center;
}
.stripe-loading {
  background: #f8fafc;
  color: #64748b;
  border: 1.5px solid #e2e8f0;
}
.stripe-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1.5px solid #fecaca;
  line-height: 1.5;
}

/* Card wrapper */
.stripe-card-wrap {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* Amount row */
.stripe-amount-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}
.stripe-amount-label {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}
.stripe-amount-value {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}

/* Stripe card element mount target */
.stripe-card-element {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 13px 14px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}
.stripe-card-element:focus-within {
  border-color: #635bff;
  box-shadow: 0 0 0 3px rgba(99,91,255,0.12);
}

/* Simulated card inputs (preview mode) */
.stripe-sim-card { background: #f8fafc; }
.stripe-sim-row { display: flex; gap: 8px; margin-bottom: 6px; }
.stripe-sim-row:last-child { margin-bottom: 0; }
.stripe-sim-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: #94a3b8;
  font-family: inherit;
  cursor: not-allowed;
}

/* Error text */
.stripe-card-error {
  font-size: 12px;
  color: #dc2626;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: #fef2f2;
  border-radius: 7px;
  border: 1px solid #fecaca;
}

/* Pay button */
.stripe-pay-btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s, transform 0.1s;
  font-family: inherit;
}
.stripe-pay-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.stripe-pay-btn:active:not(:disabled) { transform: translateY(0); }
.stripe-pay-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Stripe badge */
.stripe-badge {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.stripe-badge strong { color: #635bff; }

/* Preview banner */
.stripe-preview-banner {
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  color: #713f12;
  text-align: center;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

/* Success card */
.stripe-success-card {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
}
.stripe-success-icon { font-size: 32px; margin-bottom: 8px; }
.stripe-success-title {
  font-size: 15px;
  font-weight: 700;
  color: #166534;
  margin-bottom: 4px;
}
.stripe-success-sub {
  font-size: 13px;
  color: #16a34a;
  margin-bottom: 6px;
}
.stripe-success-id {
  font-size: 10px;
  color: #4ade80;
  font-family: monospace;
  word-break: break-all;
}
/* ── Calculator node header ── */
.node-type-calculator .node-hdr { background: linear-gradient(135deg, #059669, #047857) !important; color: #fff !important; }
/* ── Location node header ── */
.node-type-location .node-hdr   { background: linear-gradient(135deg, #0284c7, #0369a1) !important; color: #fff !important; }
/* ── Email node header ── */
.node-type-sms .node-hdr { background: linear-gradient(135deg, #7c3aed, #6d28d9) !important; color: #fff !important; }
.node-type-email .node-hdr      { background: linear-gradient(135deg, #0ea5e9, #0369a1) !important; color: #fff !important; }

/* ══ SMTP / Email Settings UI ══ */
.smtp-row-2col {
  display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 4px;
}
.smtp-field-grow { flex: 1 1 160px; }
.smtp-field-port { flex: 0 0 90px; }
.smtp-field-enc  { flex: 0 0 130px; }
.smtp-pass-wrap  { position: relative; display: flex; align-items: center; }
.smtp-pass-input { flex: 1; padding-right: 40px !important; }
.smtp-pass-toggle {
  position: absolute; right: 10px; background: none; border: none;
  cursor: pointer; color: #9ca3af; font-size: 14px; padding: 4px;
  transition: color .15s;
}
.smtp-pass-toggle:hover { color: #374151; }
.smtp-info-banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 10px;
  padding: 12px 14px; font-size: 12px; color: #0c4a6e; margin-bottom: 4px;
}
.smtp-info-banner i { color: #0ea5e9; font-size: 14px; margin-top: 1px; flex-shrink: 0; }
.smtp-info-banner code {
  background: #e0f2fe; border-radius: 4px; padding: 1px 5px;
  font-family: monospace; font-size: 11px; color: #0369a1;
}
.smtp-actions { gap: 10px !important; }
.smtp-status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #d1fae5; color: #065f46; border: 1.5px solid #6ee7b7;
  border-radius: 20px; padding: 4px 12px; font-size: 12px; font-weight: 600;
}

/* ── email inspector panel ── */
.email-var-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px; border: 1.5px solid #bae6fd;
  background: #f0f9ff; color: #0369a1; font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: monospace; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.email-var-chip:hover { background: #e0f2fe; border-color: #7dd3fc; }
.email-body-wrap { position: relative; }
.email-body-wrap .email-var-bar {
  display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px;
}

/* ── Formula bar ── */
.calc-formula-bar.cfb-ok    { border-color: #34d399 !important; box-shadow: 0 0 0 3px #05996920; }
.calc-formula-bar.cfb-error { border-color: #f87171 !important; box-shadow: 0 0 0 3px #ef444420; }
.cfb-var-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px; border: 1.5px solid #bbf7d0;
  background: #f0fdf4; color: #059669; font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: monospace; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.cfb-var-chip:hover { background: #dcfce7; border-color: #34d399; }
.cfb-no-vars { font-size: 11px; color: #9ca3af; font-style: italic; }
.cfb-preview-err { background: #fef2f2 !important; border-color: #fca5a5 !important; }
.cfb-preview-err #cfb-preview-value { color: #dc2626 !important; }

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

:root {
  /* Teal/dark top bar like Xenioo */
  --topbar-bg: #1a2332;
  --topbar-border: #253044;
  --subnav-bg: #2d9b6f;
  --subnav-hover: #25845e;

  /* Canvas light background like Xenioo */
  --canvas-bg: #f0f2f5;
  --canvas-dot: #d1d5db;

  /* Node card */
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 6px 24px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
  --card-shadow-selected: 0 0 0 3px rgba(99,102,241,0.35), 0 6px 24px rgba(0,0,0,0.12);

  /* Node header color strips */
  --hdr-blue: #1e40af;
  --hdr-teal: #0d7c6e;
  --hdr-orange: #c2570a;
  --hdr-green: #166534;
  --hdr-red: #991b1b;
  --hdr-purple: #5b21b6;
  --hdr-gray: #374151;

  /* Sidebar / panels */
  --panel-bg: #ffffff;
  --panel-border: #e5e7eb;

  /* Text */
  --text: #111827;
  --text-2: #374151;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;

  /* Connection lines */
  --conn-blue: #6366f1;
  --conn-green: #10b981;
  --conn-red: #ef4444;
  --conn-orange: #f59e0b;

  /* UI colors */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Radii */
  --r: 10px;
  --r-sm: 6px;
  --r-xs: 4px;

  --font: 'Inter', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--canvas-bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-size: 13.5px;
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   TOP NAV BAR  (dark teal - Xenioo style)
   ============================================================ */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── Company pill ── */
.topbar-company-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(52,211,153,0.12);
  border: 1px solid rgba(52,211,153,0.25);
  border-radius: 20px;
  padding: 4px 12px 4px 9px;
  color: #34d399;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  flex-shrink: 0;
}
.topbar-company-pill i { font-size: 11px; flex-shrink: 0; }
.topbar-company-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═══════════════════════════════════════
   USER DROPDOWN MENU
═══════════════════════════════════════ */
.topbar-user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 5px 10px 5px 6px;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.topbar-user-menu:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.18);
}

.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
  pointer-events: none;
}

.topbar-user-info {
  display: inline;
  white-space: nowrap;
  pointer-events: none;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-chevron {
  color: #64748b;
  font-size: 10px;
  flex-shrink: 0;
  pointer-events: none;
  transition: transform 0.2s ease;
}
.topbar-chevron.rotated { transform: rotate(180deg); }

/* ── Dropdown panel ── */
.topbar-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: #1e2a3a;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.3);
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.topbar-dropdown.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* Dropdown header — user info summary */
.tdd-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  background: rgba(255,255,255,0.04);
}
.tdd-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tdd-name {
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}
.tdd-role {
  color: #6366f1;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
}
.tdd-company {
  color: #34d399;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  margin-top: 1px;
}

.tdd-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 2px 0;
}

/* Dropdown items */
.tdd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.13s, color 0.13s;
  text-align: left;
}
.tdd-item i {
  width: 16px;
  text-align: center;
  font-size: 13px;
  color: #475569;
  flex-shrink: 0;
  transition: color 0.13s;
}
.tdd-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.tdd-item:hover i { color: #94a3b8; }

.tdd-item-danger { color: #f87171; }
.tdd-item-danger i { color: #ef4444; }
.tdd-item-danger:hover { background: rgba(239,68,68,0.10); color: #fca5a5; }
.tdd-item-danger:hover i { color: #f87171; }

/* Topbar action buttons — spaced out with a divider before Save/Publish */
#topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* In builder mode, collapse Properties / Auto Layout / Preview / AI Context labels to icon-only
   so Save and Publish always remain visible even on smaller screens */
#topbar-actions .tbtn-ghost .btn-label,
#topbar-actions .tbtn-ai-context .btn-label {
  display: none;
}

#topbar-actions #btn-save-flow,
#topbar-actions #btn-publish-flow {
  margin-left: 6px;
}

#topbar-actions #btn-save-flow {
  position: relative;
}

#topbar-actions #btn-save-flow::before {
  content: '';
  position: absolute;
  left: -9px;
  top: 15%;
  height: 70%;
  width: 1px;
  background: rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  padding-right: 20px;
  border-right: 1px solid var(--topbar-border);
  margin-right: 16px;
  letter-spacing: -0.3px;
}

.logo i { color: #34d399; font-size: 18px; }

.top-nav { display: flex; gap: 2px; }

.tnav-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 7px;
}

.tnav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.tnav-btn.active { background: rgba(255,255,255,0.12); color: #ffffff; }
.tnav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.topbar-flow-title {
  color: #94a3b8;
  font-size: 12.5px;
  font-weight: 500;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Topbar buttons */
.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tbtn-ghost {
  background: rgba(255,255,255,0.08);
  color: #cbd5e1;
  border-color: rgba(255,255,255,0.1);
}
.tbtn-ghost:hover { background: rgba(255,255,255,0.14); color: #fff; }
.tbtn-preview-active { background: rgba(99,102,241,0.35) !important; color: #a5b4fc !important; border-color: rgba(99,102,241,0.5) !important; }

.tbtn-save {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}
.tbtn-save:hover { background: #1d4ed8; }

.tbtn-publish {
  background: #34d399;
  color: #064e3b;
  border-color: #34d399;
  font-weight: 600;
}
.tbtn-publish:hover { background: #10b981; border-color: #10b981; color: white; }

.tbtn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.tbtn-danger:hover { background: #dc2626; }

/* ============================================================
   SUB NAVBAR  (green bar - Xenioo style)
   ============================================================ */

#subnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  background: var(--subnav-bg);
  padding: 0 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 40;
}

.subnav-left, .subnav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.snav-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--r-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s;
}

.snav-btn:hover { background: rgba(255,255,255,0.25); }

/* Auto Layout subnav button — subtle accent glow */
.snav-btn.snav-btn-layout {
  background: rgba(99,102,241,0.30);
  border: 1px solid rgba(99,102,241,0.55);
}
.snav-btn.snav-btn-layout:hover {
  background: rgba(99,102,241,0.50);
  border-color: rgba(139,141,255,0.75);
}
.snav-btn.snav-btn-layout i {
  color: #c7d2fe;
}

/* AI Context button in subnav — purple accent */
.snav-btn.snav-btn-ai-context {
  background: rgba(124,58,237,0.30);
  border: 1px solid rgba(124,58,237,0.60);
  color: #e9d5ff;
  font-weight: 600;
}
.snav-btn.snav-btn-ai-context:hover {
  background: rgba(124,58,237,0.52);
  border-color: rgba(167,139,250,0.85);
  color: #fff;
}
.snav-btn.snav-btn-ai-context i {
  color: #c4b5fd;
}
.snav-btn.snav-btn-ai-context.running {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border-color: #7c3aed;
  color: #fff;
  cursor: not-allowed;
  opacity: 0.85;
}
.snav-btn.snav-btn-ai-context.done {
  background: rgba(5,150,105,0.40);
  border-color: rgba(16,185,129,0.70);
  color: #a7f3d0;
}

.subnav-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.2);
}

/* Save button in sub-nav — blue solid */
.snav-btn.snav-btn-save {
  background: #2563eb;
  border: 1px solid #3b82f6;
  font-weight: 600;
  padding: 5px 14px;
  font-size: 13px;
}
.snav-btn.snav-btn-save:hover { background: #1d4ed8; border-color: #2563eb; }
.snav-btn.snav-btn-save:disabled { opacity: 0.6; cursor: not-allowed; }

/* Publish button in sub-nav — green solid */
.snav-btn.snav-btn-publish {
  background: #059669;
  border: 1px solid #10b981;
  font-weight: 600;
  padding: 5px 14px;
  font-size: 13px;
}
.snav-btn.snav-btn-publish:hover { background: #047857; border-color: #059669; }

.snav-breadcrumb-sep {
  color: rgba(255,255,255,0.40);
  font-size: 15px;
  font-weight: 300;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}

.snav-breadcrumb {
  color: white;
  font-size: 13px;
  font-weight: 600;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snav-breadcrumb-cat {
  color: rgba(255,255,255,0.72);
  font-weight: 500;
  max-width: 160px;
}

.snav-badge {
  padding: 1px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255,255,255,0.2);
  color: white;
}

.snav-badge.published { background: rgba(52,211,153,0.3); }

.snav-zoom {
  color: white;
  font-size: 12px;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}

.snav-node-count {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
}

.snav-node-count span { font-weight: 700; color: white; }

/* ============================================================
   MAIN
   ============================================================ */

#main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view { display: none; flex: 1; overflow: hidden; flex-direction: column; }
/* Allow vertical scroll for content views that need it */
#view-knowledgebase { overflow-y: auto; }
.view.active { display: flex; }

/* ============================================================
   DASHBOARD
   ============================================================ */

.dash-hero {
  text-align: center;
  padding: 36px 32px 20px;
  background: white;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.dash-hero h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

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

.dash-stats {
  display: flex;
  justify-content: center;
  gap: 0;
  border-bottom: 1px solid var(--panel-border);
  background: white;
  flex-shrink: 0;
}

.dstat {
  flex: 1;
  max-width: 160px;
  text-align: center;
  padding: 14px 20px;
  border-right: 1px solid var(--panel-border);
}

.dstat:last-child { border-right: none; }

.dstat span {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}

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

.dash-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: var(--canvas-bg);
  flex-shrink: 0;
}

/* New Flow btn pushed to far right */
#btn-new-flow {
  margin-left: auto;
  flex-shrink: 0;
}

.dash-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--panel-border);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  width: 300px;
}

.dash-search i { color: var(--text-muted); font-size: 13px; }

.dash-search input {
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  font-family: var(--font);
  background: none;
}

.dash-filter { display: flex; gap: 4px; }

.filter-btn {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--panel-border);
  background: white;
  color: var(--text-muted);
  font-size: 12.5px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

.flows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
  padding: 20px 28px 40px;
  overflow-y: auto;
  flex: 1;
  align-content: start;
  align-items: start;   /* each card sizes to its own content — prevents taller neighbour stretching shorter cards and clipping fc-actions */
}

/* ── Loading state: dim grid and block pointer events ── */
.flows-grid.is-loading {
  pointer-events: none;
  opacity: 0.5;
}

/* ── Skeleton card ── */
.fc-skeleton {
  background: white;
  border: 1px solid var(--panel-border);
  border-radius: var(--r);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.fc-skeleton-strip {
  height: 4px;
  background: #e2e8f0;
}

.fc-skeleton-body {
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fc-skeleton-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fc-skeleton-footer {
  padding: 10px 16px;
  border-top: 1px solid #f3f4f6;
  background: #fafafa;
  display: flex;
  gap: 8px;
}

/* Shimmer base */
.skel {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skelShimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}

@keyframes skelShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skel-icon  { width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0; }
.skel-line  { height: 12px; }
.skel-line-sm { height: 10px; }
.skel-w100  { width: 100%; }
.skel-w70   { width: 70%; }
.skel-w50   { width: 50%; }
.skel-w40   { width: 40%; }
.skel-btn   { height: 28px; width: 60px; border-radius: 6px; }

/* Card entrance animation */
@keyframes fcEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fc-entering {
  animation: fcEnter 0.22s ease both;
}

/* Flow cards */
.flow-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: visible;        /* must NOT be hidden — fc-actions would get clipped */
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
  cursor: default;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  /* clip children to border-radius without using overflow:hidden */
  isolation: isolate;
}

.flow-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  transform: translateY(-3px);
  border-color: #d1d5db;
}

/* top strip: enforce border-radius clip on this element only */
.fc-top-strip {
  height: 4px;
  border-radius: 12px 12px 0 0;  /* match card radius on top corners */
  flex-shrink: 0;
}

.fc-body {
  padding: 16px 16px 12px;
  flex: 1;
  min-height: 0;           /* allow shrinking but not below content */
  display: flex;
  flex-direction: column;
}


/* New header row: icon + title/badge + chat button */
.fc-header-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.fc-header-text {
  flex: 1;
  min-width: 0;
}

.fc-header-text .fc-title { margin-bottom: 4px; }

/* ── Chat button on flow card ── */
.fc-chat-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--flow-color, #6366f1);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s, box-shadow 0.18s, filter 0.18s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
  position: relative;
  align-self: flex-start;
}

.fc-chat-btn:hover {
  transform: scale(1.12) translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.22);
  filter: brightness(1.1);
}

.fc-chat-btn:active {
  transform: scale(0.96);
}

/* Subtle pulse ring to draw attention */
.fc-chat-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--flow-color, #6366f1);
  opacity: 0;
  animation: chatBtnPing 2.5s ease-in-out infinite;
}

@keyframes chatBtnPing {
  0%, 100% { opacity: 0; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(1.18); }
}

.fc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.fc-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  align-self: flex-start;
}

.fc-badge {
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.fc-badge-active { background: #dcfce7; color: #166534; }
.fc-badge-draft { background: #f3f4f6; color: #6b7280; }

.fc-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
  line-height: 1.3;
}

.fc-desc {
  flex: 1;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fc-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.fc-cat {
  background: #f3f4f6;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
}

.fc-node-count {
  color: var(--text-dim);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.fc-actions {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid #f3f4f6;
  background: #fafafa;
  flex-shrink: 0;          /* CRITICAL: never let this shrink or get clipped */
  border-radius: 0 0 12px 12px; /* match card radius on bottom corners */
}

.fc-btn {
  padding: 5px 12px;
  border-radius: var(--r-xs);
  border: 1px solid var(--panel-border);
  background: white;
  color: var(--text-2);
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}

.fc-btn:hover { border-color: var(--primary); color: var(--primary); background: #f5f3ff; }
.fc-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: #fef2f2; }
.fc-btn.ml-auto { margin-left: auto; }

.dash-loading, .dash-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 15px;
}

.dash-empty i { font-size: 52px; color: #d1d5db; display: block; margin-bottom: 16px; }
.dash-empty h3 { font-size: 18px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.dash-empty p { font-size: 13.5px; color: var(--text-muted); }

/* ============================================================
   BUILDER LAYOUT
   ============================================================ */

.builder-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ============================================================
   LEFT PALETTE
   ============================================================ */

.node-palette {
  width: 200px;
  background: white;
  border-right: 1px solid var(--panel-border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: width 0.25s cubic-bezier(.4,0,.2,1),
              padding 0.25s cubic-bezier(.4,0,.2,1),
              opacity 0.2s ease;
  position: relative;
  z-index: 10;
}

.node-palette.collapsed {
  width: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  border-right: none;
}

.palette-section { margin-bottom: 6px; }

.palette-section h4 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-dim);
  padding: 6px 6px 6px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: grab;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.palette-item:hover { background: #f5f3ff; }
.palette-item:active { cursor: grabbing; opacity: 0.7; }

.pi-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.pi-blue   { background: #dbeafe; color: #1e40af; }
.pi-teal   { background: #ccfbf1; color: #0f766e; }
.pi-orange { background: #ffedd5; color: #c2410c; }
.pi-green  { background: #dcfce7; color: #166534; }
.pi-red    { background: #fee2e2; color: #991b1b; }
.pi-purple { background: #ede9fe; color: #5b21b6; }
.pi-sky    { background: #e0f2fe; color: #0369a1; }

.pi-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }

.node-list { display: flex; flex-direction: column; gap: 2px; }

.nl-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: var(--r-xs);
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nl-item:hover { background: #f5f3ff; color: var(--primary); }
.nl-item.selected { background: #ede9fe; color: var(--primary); font-weight: 600; }
.nl-item .nl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ============================================================
   CANVAS AREA  (center)
   ============================================================ */

.canvas-area {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--canvas-bg);
  cursor: grab;
  user-select: none;
}

.canvas-wrap {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.canvas-area.panning { cursor: grabbing !important; }
.canvas-area.wiring  { cursor: crosshair !important; }

.canvas-scene {
  position: absolute;
  top: 0; left: 0;
  width: 6000px;
  height: 4000px;
  background-image: radial-gradient(circle, var(--canvas-dot) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  background-position: 14px 14px;
  transform-origin: 0 0;
  /* do NOT set pointer-events none — nodes need events */
}

.svg-connections {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

#nodes-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 2;
}

.canvas-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-dim);
  pointer-events: none;
  z-index: 3;
}

.canvas-hint i { font-size: 48px; opacity: 0.25; }
.canvas-hint p { font-size: 14px; text-align: center; line-height: 1.6; opacity: 0.5; }
.canvas-hint.hidden { display: none; }

/* ============================================================
   FLOW NODES  (Xenioo card style)
   ============================================================ */

.flow-node {
  position: absolute;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--r);
  width: 230px;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  user-select: none;
  z-index: 2;
}

.flow-node:hover {
  box-shadow: var(--card-shadow-hover);
  border-color: #c7d2fe;
}

.flow-node.selected {
  box-shadow: var(--card-shadow-selected);
  border-color: var(--primary);
}

/* START node marker */
.flow-node.is-start::before {
  content: '▶ START';
  position: absolute;
  top: -22px;
  left: 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Node header strip (colored) */
.node-hdr {
  padding: 8px 10px 7px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.node-hdr-icon { font-size: 12px; opacity: 0.9; }
.node-hdr-label { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; flex: 1; }
.node-hdr-actions { display: flex; gap: 3px; margin-left: auto; }

.node-hdr-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.node-hdr-btn:hover { background: rgba(255,255,255,0.35); }
.node-hdr-btn[data-hdr-action="duplicate"]:hover { background: rgba(255,255,255,0.5); }

/* node type colors */
.node-type-question .node-hdr  { background: var(--hdr-blue);   color: white; }
.node-type-message .node-hdr   { background: var(--hdr-teal);   color: white; }
.node-type-condition .node-hdr { background: var(--hdr-orange); color: white; }
.node-type-end .node-hdr       { background: var(--hdr-green);  color: white; }
.node-type-escalate .node-hdr  { background: var(--hdr-red);    color: white; }
.node-type-setvar .node-hdr    { background: #7c3aed;           color: white; }
.node-type-apicall .node-hdr   { background: #0369a1;           color: white; }
.node-type-gotoflow .node-hdr  { background: #0891b2;           color: white; }
.node-type-feedback .node-hdr  { background: #d97706;           color: white; }
.node-type-aicall .node-hdr    { background: #7c3aed;           color: white; }
.node-type-sendmsg .node-hdr   { background: #4f46e5;           color: white; }
/* ── Switch node header ── */
.node-type-switch .node-hdr    { background: linear-gradient(135deg, #0891b2, #0e7490) !important; color: #fff !important; }
/* ── Audio / Voice Note node header ── */
.node-type-audio .node-hdr     { background: linear-gradient(135deg, #25D366, #1ea952) !important; color: #fff !important; }

/* ── Send Message node — canvas info block ── */
.node-sendmsg-info {
  margin: 4px 10px 6px;
  padding: 6px 10px;
  background: #4f46e50e;
  border: 1.5px solid #6366f130;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Pi icon for Send Message palette */
.pi-indigo { background: #e0e7ff; color: #4338ca; }

/* ── Send Message editor: target type toggle ── */
.sendmsg-target-toggle {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.smt-btn {
  flex: 1;
  padding: 7px 12px;
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, #64748b);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}
.smt-btn:hover {
  border-color: #6366f1;
  color: #6366f1;
}
.smt-btn.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: white;
}

/* ── Autocomplete picker dropdown ── */
.sm-picker-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--surface2, #f8fafc);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 500;
  overflow: hidden;
  max-height: 200px;
  overflow-y: auto;
}
.sm-picker-item {
  padding: 8px 12px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text, #1e293b);
  transition: background 0.1s;
}
.sm-picker-item:hover {
  background: #4f46e512;
  color: #4338ca;
}

/* ── Send Message preview bubble in simulator ── */
.sendmsg-preview-bubble {
  background: #4f46e50a;
  border: 1.5px dashed #6366f14a;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
}
.sendmsg-preview-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12px;
  color: #4338ca;
  margin-bottom: 6px;
}
.sendmsg-preview-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--text, #1e293b);
  line-height: 1.4;
  font-size: 11.5px;
  margin-bottom: 3px;
}

/* rpf-sendmsg-section header accent */
.rpf-sendmsg-section .rpf-api-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
  border: 1.5px solid #4f46e522;
  background: #4f46e508;
}

/* Go-to-flow pill shown in node canvas card */
.node-gotoflow-pill {
  display: flex; align-items: center; gap: 6px;
  margin: 6px 10px 4px;
  padding: 5px 10px;
  background: #0891b212;
  border: 1.5px dashed #0891b2;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #0891b2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Warning state — no target flow selected */
.node-gotoflow-pill.node-gotoflow-warn {
  background: #fef9c3;
  border-color: #f59e0b;
  color: #b45309;
}

/* Cyan palette icon */
.pi-cyan { background: #0891b222; color: #0891b2; }

/* Node body */
.node-body {
  padding: 10px 12px 6px;
}

.node-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-msg {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

/* Answer/option rows inside node */
.node-answers { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 4px; }

.node-answer-row {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: var(--r-xs);
  padding: 4px 8px 4px 10px;
  font-size: 11px;
  color: var(--text-2);
  position: relative;
  min-height: 26px;
}

.node-answer-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-answer-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  background: #e0e7ff;
  color: #4338ca;
  margin-right: 6px;
  white-space: nowrap;
}

/* ── Output port (right side of each answer row) ── */
.conn-port {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: white;
  border: 2.5px solid #9ca3af;
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  cursor: crosshair;
  z-index: 10;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.conn-port:hover {
  background: var(--primary);
  border-color: var(--primary);
  transform: translateY(-50%) scale(1.35);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.2);
}

.conn-port.connected {
  background: var(--primary);
  border-color: var(--primary);
}

.conn-port.connected:hover {
  background: #f59e0b;
  border-color: #f59e0b;
  transform: translateY(-50%) scale(1.35);
  box-shadow: 0 0 0 4px rgba(245,158,11,0.2);
}

/* Pulse animation when a wire is being dragged (show all ports as targets) */
.wiring .conn-port {
  animation: port-pulse 1s ease-in-out infinite;
}

@keyframes port-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.4); }
  50%       { box-shadow: 0 0 0 5px rgba(99,102,241,0); }
}

/* ── Input port (left side of node) ── */
.node-in-port {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: white;
  border: 2.5px solid #9ca3af;
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
  pointer-events: none; /* drop is handled on the node itself */
}

/* While wiring, input ports grow to show they're droppable */
.wiring .node-in-port {
  border-color: #34d399;
  background: #d1fae5;
  transform: translateY(-50%) scale(1.4);
  box-shadow: 0 0 0 4px rgba(52,211,153,0.25);
  animation: in-port-pulse 1s ease-in-out infinite;
}

@keyframes in-port-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); }
  50%       { box-shadow: 0 0 0 6px rgba(52,211,153,0); }
}

.node-type-end .node-in-port,
.node-type-escalate .node-in-port {
  border-color: var(--success);
  background: #dcfce7;
}

/* ── Wire drop target highlight ── */
.flow-node.wire-target {
  border-color: #34d399 !important;
  box-shadow: 0 0 0 3px rgba(52,211,153,0.4), var(--card-shadow-hover) !important;
}

.flow-node.wire-target .node-in-port {
  background: #34d399;
  border-color: #34d399;
  transform: translateY(-50%) scale(1.6);
  box-shadow: 0 0 0 6px rgba(52,211,153,0.3);
}

/* action blocks (text/go-to blocks inside node like Xenioo) */
.node-action-block {
  margin: 0 10px 6px;
  padding: 5px 8px;
  border-radius: var(--r-xs);
  border-left: 3px solid;
  font-size: 10.5px;
  font-weight: 500;
  background: #f8fafc;
  color: var(--text-2);
}

.nab-message { border-color: #f59e0b; }
.nab-resolve { border-color: #10b981; }
.nab-escalate { border-color: #ef4444; }
.nab-input { border-color: #6366f1; }

/* ============================================================
   CONNECTION LINES  (SVG Bezier curves)
   ============================================================ */

.conn-path {
  fill: none;
  stroke-width: 2px;
  stroke-linecap: round;
  pointer-events: visibleStroke;
  cursor: pointer;
}

.conn-path:hover { stroke-width: 3px; }

.conn-default { stroke: #c4b5fd; }
.conn-success  { stroke: #34d399; }
.conn-warning  { stroke: #fbbf24; }
.conn-danger   { stroke: #f87171; }
.conn-active   { stroke: var(--primary); stroke-width: 2.5px; }
.conn-api      { stroke: #38bdf8; stroke-dasharray: 6 3; }
.conn-var      { stroke: #a78bfa; stroke-dasharray: 6 3; }
.conn-switch-default { stroke: #f59e0b; stroke-width: 2.5px; stroke-dasharray: 5 3; }

/* Live wire preview while dragging */
.conn-wire-preview {
  stroke: #f59e0b;
  stroke-width: 2.5px;
  stroke-dasharray: 8 4;
  animation: wire-march 0.4s linear infinite;
  opacity: 0.9;
}

@keyframes wire-march {
  to { stroke-dashoffset: -12; }
}

/* ============================================================
   RIGHT PANEL
   ============================================================ */

.right-panel {
  width: 420px;
  background: white;
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.25s cubic-bezier(.4,0,.2,1),
              opacity 0.2s ease;
  position: relative;
  z-index: 10;
}

.right-panel.collapsed {
  width: 0;
  opacity: 0;
  overflow: hidden;
  border-left: none;
}

.rp-tabs {
  display: flex;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.rp-tab {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  font-size: 12.5px;
  font-family: var(--font);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.rp-tab:hover { color: var(--primary); }
.rp-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.rp-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.rp-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
}

.rp-empty i { font-size: 36px; opacity: 0.3; }
.rp-empty p { font-size: 13px; line-height: 1.6; }

/* ══════════════════════════════════════════════
   SUBNAV VARIABLE INSPECTOR
   Sits in the builder sub-navbar, next to node count
   ══════════════════════════════════════════════ */

/* Wrapper — relative so the dropdown anchors correctly */
/* Has a built-in left divider so it separates cleanly from node count */
.snav-var-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
}
.snav-var-wrap::before {
  content: '';
  display: block;
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

/* The "Variables 12" trigger button — matches subnav style */
.snav-var-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 9px;
  background: rgba(124,58,237,0.14);
  border: 1px solid rgba(167,139,250,0.45);
  border-radius: 100px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: #ddd6fe;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  height: 28px;
}

.snav-var-btn:hover,
.snav-var-btn.snav-var-btn-active {
  background: rgba(124,58,237,0.28);
  border-color: #a78bfa;
  color: #f5f3ff;
}

.snav-var-badge {
  background: #7c3aed;
  color: #fff;
  border-radius: 100px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  text-align: center;
  line-height: 16px;
  height: 16px;
}

/* Dropdown panel — opens downward below subnav */
.snav-var-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 360px;
  max-height: 480px;
  background: #ffffff;
  border: 1.5px solid #c4b5fd;
  border-radius: 14px;
  box-shadow: 0 10px 36px rgba(99,102,241,0.18), 0 2px 10px rgba(0,0,0,0.10);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Arrow pointer */
.snav-var-panel::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 7px;
  background: #ffffff;
  border-left: 1.5px solid #c4b5fd;
  border-top: 1.5px solid #c4b5fd;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.svp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 9px;
  border-bottom: 1px solid #ede9fe;
  font-size: 12.5px;
  font-weight: 700;
  color: #3b0764;
  flex-shrink: 0;
}

.svp-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.12s;
}
.svp-close:hover { color: #ef4444; }

.svp-hint {
  font-size: 11px;
  color: #6b7280;
  padding: 7px 14px 4px;
  flex-shrink: 0;
  line-height: 1.5;
}
.svp-hint code {
  background: #ede9fe;
  color: #7c3aed;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 10.5px;
}

.svp-groups {
  overflow-y: auto;
  padding: 6px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.svp-group-lbl {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  margin-bottom: 5px;
}

.svp-group-cnt {
  background: #f3f4f6;
  border-radius: 100px;
  padding: 0 5px;
  font-size: 9px;
  color: #9ca3af;
}

.svp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Individual chip */
.svp-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  background: #faf5ff;
  border: 1.5px solid #c4b5fd;
  border-radius: 100px;
  font-family: monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: #5b21b6;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  line-height: 1.5;
}
.svp-chip:hover {
  background: #ede9fe;
  border-color: #7c3aed;
  color: #4c1d95;
  transform: translateY(-1px);
  box-shadow: 0 2px 7px rgba(124,58,237,0.18);
}
.svp-chip:active { transform: translateY(0); }

.svp-chip-ok {
  background: #d1fae5 !important;
  border-color: #10b981 !important;
  color: #065f46 !important;
  font-family: var(--font) !important;
}

.svp-brace { opacity: 0.4; font-weight: 400; font-size: 11px; }

.svp-empty {
  font-size: 11.5px;
  color: #9ca3af;
  line-height: 1.6;
  padding: 6px 0;
}

/* search row inside panel */
.svp-search-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px 0;
  flex-shrink: 0;
}
.svp-search-icon { font-size: 11px; color: #9ca3af; flex-shrink:0; }
.svp-search-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-family: var(--font);
  color: #1f2937;
  background: #f9fafb;
  outline: none;
  transition: border-color 0.15s;
}
.svp-search-input:focus { border-color: #a78bfa; background: #fff; }

/* chip wrap — chip + delete side by side */
.svp-chip-wrap {
  display: inline-flex;
  align-items: center;
  position: relative;
}
.svp-chip-del {
  display: none;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  background: #fef2f2;
  color: #ef4444;
  border-radius: 50%;
  font-size: 8px;
  cursor: pointer;
  margin-left: -6px;
  margin-top: -10px;
  align-self: flex-start;
  position: relative;
  z-index: 1;
  transition: background 0.12s;
  flex-shrink: 0;
}
.svp-chip-del:hover { background: #fecaca; }
.svp-chip-wrap:hover .svp-chip-del { display: flex; }

/* ============================================================
   CAMERA CAPTURE NODE  —  chat.html UI
   ============================================================ */

/* Outer wrapper injected into the chat stream.
   FIXED FULL-SCREEN OVERLAY — not an inline chat card. Auto-scrolling
   the chat to reveal the Capture/Submit buttons proved unreliable on
   iOS Safari (the card's true height on screen didn't always match what
   the page's own scroll math expected, and the buttons stayed cut off
   below the fold with no amount of scrolling ever bringing them into
   view). Making the card a fixed overlay that always spans the full
   visible viewport removes the scrolling dependency entirely: the
   header/tabs are pinned to the top, the viewfinder flexibly fills the
   middle, and the Capture/Submit buttons are pinned to the bottom edge
   — guaranteed on-screen no matter how tall the chat history above it
   is or how the address bar is behaving. */
.cam-wrap {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  height: 100dvh;
  height: var(--real-vh, 100dvh);
  width: 100%;
  max-width: none;
  background: #fff;
  border: none;
  border-radius: 0;
  overflow: hidden;
  margin: 0;
  box-shadow: none;
  z-index: 500;
  display: flex;
  flex-direction: column;
}

/* Header with prompt text */
.cam-header {
  padding: 14px 16px 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
  flex-shrink: 0;
}
.cam-prompt {
  font-size: 15px;
  font-weight: 700;
  color: #0e7490;
  margin-bottom: 3px;
}
.cam-subtext {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

/* Tab row: Camera | Upload */
.cam-tabs {
  display: flex;
  border-bottom: 1.5px solid #e0f2fe;
  background: #f0fdfe;
  flex-shrink: 0;
}
.cam-tab {
  flex: 1;
  padding: 9px 0;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color .18s, background .18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.cam-tab.active {
  color: #0891b2;
  background: #ecfeff;
  border-bottom: 2.5px solid #0891b2;
}

/* Content panels — the active panel flexes to fill all remaining space
   between the pinned header/tabs above and the pinned actions/submit
   buttons below, so its own overflow (if any) scrolls internally and
   never pushes the buttons off the bottom of the screen. */
.cam-panel {
  display: none;
  padding: 14px 14px 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  flex-direction: column;
}
.cam-panel.active { display: flex; }

/* Live viewfinder — flexibly fills whatever space is left in the panel
   (between the header/tabs above and Capture/Retake buttons below)
   instead of a fixed aspect-ratio box, so it can never grow taller than
   the screen allows and push the buttons out of view. */
.cam-viewfinder-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 120px;
  background: #0f172a;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}
.cam-viewfinder-wrap video,
.cam-viewfinder-wrap canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cam-viewfinder-wrap canvas { display: none; }
.cam-viewfinder-wrap.captured video  { display: none; }
.cam-viewfinder-wrap.captured canvas { display: block; }

/* Flip camera button */
.cam-flip-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  z-index: 2;
}
.cam-flip-btn:hover { background: rgba(0,0,0,0.7); }

/* Permission denied / error banner */
.cam-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  color: #dc2626;
  font-size: 13px;
  text-align: center;
}
.cam-error i { font-size: 28px; }

/* Camera action buttons row — pinned, never scrolls out of view */
.cam-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-shrink: 0;
}
.cam-btn {
  flex: 1;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter .15s, transform .1s;
}
.cam-btn:active { transform: scale(.97); }
.cam-btn-capture {
  background: #0891b2;
  color: #fff;
}
.cam-btn-capture:hover { filter: brightness(1.1); }
.cam-btn-retake {
  background: #f1f5f9;
  color: #475569;
  display: none;
}
.cam-btn-retake:hover { background: #e2e8f0; }

/* Upload drag-drop zone */
.cam-upload-zone {
  border: 2px dashed #a5f3fc;
  border-radius: 10px;
  background: #f0fdfe;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s;
  margin-bottom: 10px;
}
.cam-upload-zone:hover,
.cam-upload-zone.drag-over {
  border-color: #0891b2;
  background: #e0f9fd;
}
.cam-upload-zone-icon { font-size: 32px; color: #0891b2; margin-bottom: 8px; }
.cam-upload-zone-main { font-size: 13px; font-weight: 600; color: #0e7490; }
.cam-upload-zone-sub  { font-size: 11px; color: #94a3b8; margin-top: 3px; }

/* Preview card for uploaded image */
.cam-img-preview {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
  border: 1.5px solid #a5f3fc;
  margin-bottom: 10px;
  display: none;
}
.cam-img-preview.visible { display: block; }

/* Submit row — pinned to the very bottom of the full-screen card,
   always on-screen regardless of viewfinder/panel height above it. */
.cam-submit-row {
  padding: 10px 14px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid #e0f2fe;
  flex-shrink: 0;
  background: #fff;
}
.cam-submit-btn {
  width: 100%;
  padding: 12px;
  background: #0891b2;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter .15s, transform .1s;
}
.cam-submit-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.cam-submit-btn:not(:disabled):hover { filter: brightness(1.08); }
.cam-submit-btn:not(:disabled):active { transform: scale(.98); }

/* In-chat photo bubble */
.cam-chat-bubble {
  background: #ecfeff !important;
  border: 1.5px solid #a5f3fc !important;
  padding: 10px 12px !important;
  max-width: 320px !important;
}
.cam-chat-label {
  font-size: 11px;
  font-weight: 700;
  color: #0891b2;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cam-chat-img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #a5f3fc;
  display: block;
}

/* ════════════════════════════════════════════
   CALCULATOR — Excel-style formula bar (inspector)
   ════════════════════════════════════════════ */

/* Outer formula bar row */
.calc-formula-bar {
  display: flex;
  align-items: center;
  border: 2px solid #6ee7b7;
  border-radius: 9px;
  background: #fff;
  overflow: hidden;
  transition: border-color .18s, box-shadow .18s;
  margin-bottom: 4px;
}
.calc-formula-bar:focus-within {
  border-color: #059669;
  box-shadow: 0 0 0 3px #05996920;
}
.calc-formula-bar.cfb-error {
  border-color: #f87171;
  box-shadow: 0 0 0 3px #ef444420;
}
.calc-formula-bar.cfb-ok {
  border-color: #34d399;
  box-shadow: 0 0 0 3px #10b98120;
}

/* "fx" label prefix — like Excel name box */
.cfb-fx {
  flex-shrink: 0;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
  font-style: italic;
  color: #059669;
  background: #f0fdf4;
  border-right: 1.5px solid #bbf7d0;
  height: 38px;
  display: flex;
  align-items: center;
  user-select: none;
  letter-spacing: -.02em;
}

/* The actual formula input */
.cfb-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0 10px;
  height: 38px;
  font-size: 13.5px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: #0f172a;
  background: transparent;
  min-width: 0;
}
.cfb-input::placeholder {
  color: #94a3b8;
  font-style: italic;
}

/* Status dot — green tick / red x / grey empty */
.cfb-status {
  flex-shrink: 0;
  width: 32px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: color .15s;
}

/* Live preview strip */
.cfb-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 7px;
  margin-bottom: 8px;
}
.cfb-preview-label {
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .06em;
  flex-shrink: 0;
}
.cfb-preview-value {
  font-size: 15px;
  font-weight: 800;
  color: #047857;
  font-family: monospace;
  flex: 1;
  text-align: right;
}
.cfb-preview-row.cfb-preview-err .cfb-preview-value {
  color: #dc2626;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
}

/* Quick-insert operator buttons */
.cfb-ops-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.cfb-op {
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  font-family: monospace;
  border: 1.5px solid #d1fae5;
  border-radius: 6px;
  background: #f0fdf4;
  color: #065f46;
  cursor: pointer;
  transition: background .13s, border-color .13s, transform .1s;
  line-height: 1.5;
}
.cfb-op:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}
.cfb-op:active { transform: scale(.93); }
.cfb-op-fn {
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  color: #4f46e5;
  border-color: #ddd6fe;
  background: #f5f3ff;
}
.cfb-op-fn:hover { background: #ede9fe; border-color: #a78bfa; }

/* Variable chip picker */
.cfb-var-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 28px;
}
.cfb-var-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: #f0fdf4;
  border: 1.5px solid #6ee7b7;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #047857;
  font-family: monospace;
  cursor: pointer;
  transition: background .13s, border-color .13s, transform .1s;
  user-select: none;
}
.cfb-var-chip:hover {
  background: #d1fae5;
  border-color: #34d399;
}
.cfb-var-chip:active { transform: scale(.93); }
.cfb-var-chip i { font-size: 9px; opacity: .7; }
.cfb-no-vars {
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
}

/* ════════════════════════════════════════════
   CALCULATOR NODE — chat UI components
   ════════════════════════════════════════════ */
.calc-wrap {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1.5px solid #6ee7b7;
  border-radius: 16px;
  overflow: hidden;
  margin: 8px 0 4px;
  box-shadow: 0 2px 12px #05996918;
}

/* Header with title */
.calc-header {
  padding: 12px 16px 10px;
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-bottom: 1px solid #bbf7d0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.calc-header-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.calc-header-text {}
.calc-header-title {
  font-size: 14px;
  font-weight: 700;
  color: #047857;
  margin-bottom: 1px;
}
.calc-header-sub {
  font-size: 11px;
  color: #6b7280;
  font-family: monospace;
  word-break: break-all;
}

/* Result display area */
.calc-result-area {
  padding: 16px;
  text-align: center;
}
.calc-result-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.calc-result-value {
  font-size: 32px;
  font-weight: 800;
  color: #047857;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: -.02em;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.calc-result-var-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  background: #f0fdf4;
  border: 1px solid #6ee7b7;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  color: #059669;
  font-family: monospace;
}
.calc-error-msg {
  font-size: 12px;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
  display: none;
}
.calc-error-msg.visible { display: block; }

/* In-chat result bubble */
.calc-chat-bubble {
  background: #f0fdf4 !important;
  border: 1.5px solid #6ee7b7 !important;
  padding: 10px 14px !important;
  max-width: 320px !important;
}
.calc-chat-label {
  font-size: 11px;
  font-weight: 700;
  color: #059669;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.calc-chat-value {
  font-size: 20px;
  font-weight: 800;
  color: #047857;
  font-family: monospace;
}
.calc-chat-expr {
  font-size: 10px;
  color: #94a3b8;
  font-family: monospace;
  margin-top: 3px;
  word-break: break-all;
}

/* ════════════════════════════════════════════
   LOCATION NODE — chat UI components
   ════════════════════════════════════════════ */

/* Outer card */
.loc-wrap {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border: 1.5px solid #7dd3fc;
  border-radius: 16px;
  overflow: hidden;
  margin: 8px 0 4px;
  box-shadow: 0 2px 12px #0284c718;
}

/* Header */
.loc-header {
  padding: 14px 16px 10px;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-bottom: 1px solid #bae6fd;
}
.loc-prompt {
  font-size: 15px;
  font-weight: 700;
  color: #0369a1;
  margin-bottom: 3px;
}
.loc-subtext {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

/* Map placeholder / leaflet container */
.loc-map-wrap {
  width: 100%;
  height: 200px;
  background: #e0f2fe;
  position: relative;
  overflow: hidden;
}
.loc-map-wrap iframe,
.loc-map-wrap .loc-map-inner {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
/* Static map placeholder while loading */
.loc-map-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #0369a1;
  font-size: 13px;
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
}
.loc-map-placeholder i { font-size: 32px; opacity: .6; }

/* Coordinates display strip */
.loc-coords-strip {
  padding: 10px 14px;
  background: #f0f9ff;
  border-top: 1px solid #bae6fd;
  display: none;
}
.loc-coords-strip.visible { display: block; }
.loc-coords-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #0369a1;
  font-family: monospace;
  margin-bottom: 3px;
}
.loc-coords-row:last-child { margin-bottom: 0; }
.loc-coords-label {
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  min-width: 64px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.loc-accuracy-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 12px;
  background: #dcfce7;
  color: #16a34a;
  border: 1px solid #86efac;
}
.loc-accuracy-badge.medium { background:#fef9c3;color:#a16207;border-color:#fde047; }
.loc-accuracy-badge.low    { background:#fef2f2;color:#dc2626;border-color:#fca5a5; }

/* Address line */
.loc-address-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 14px;
  background: #fff;
  border-top: 1px solid #e0f2fe;
  font-size: 12px;
  color: #374151;
  display: none;
}
.loc-address-row.visible { display: flex; }
.loc-address-row i { color: #0284c7; margin-top: 1px; flex-shrink: 0; }

/* Status / progress area */
.loc-status {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.loc-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #bae6fd;
  border-top-color: #0284c7;
  border-radius: 50%;
  animation: loc-spin .8s linear infinite;
}
@keyframes loc-spin { to { transform: rotate(360deg); } }
.loc-status-text {
  font-size: 13px;
  color: #0369a1;
  font-weight: 500;
}
.loc-error-box {
  padding: 12px 14px;
  background: #fef2f2;
  border-top: 1px solid #fca5a5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #dc2626;
  display: none;
}
.loc-error-box.visible { display: flex; }
.loc-error-box i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* Submit + retry row */
.loc-action-row {
  padding: 10px 14px 14px;
  display: flex;
  gap: 8px;
  border-top: 1px solid #e0f2fe;
}
.loc-btn {
  flex: 1;
  padding: 11px 0;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter .15s, transform .1s;
}
.loc-btn:active { transform: scale(.97); }
.loc-btn-submit {
  background: #0284c7;
  color: #fff;
}
.loc-btn-submit:disabled { opacity:.4; cursor:not-allowed; }
.loc-btn-submit:not(:disabled):hover { filter: brightness(1.1); }
.loc-btn-retry {
  background: #f1f5f9;
  color: #475569;
  flex: 0 0 auto;
  padding: 11px 16px;
}
.loc-btn-retry:hover { background: #e2e8f0; }

/* In-chat location bubble */
.loc-chat-bubble {
  background: #f0f9ff !important;
  border: 1.5px solid #7dd3fc !important;
  padding: 10px 14px !important;
  max-width: 320px !important;
}
.loc-chat-label {
  font-size: 11px;
  font-weight: 700;
  color: #0284c7;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.loc-chat-coords {
  font-size: 12px;
  font-family: monospace;
  color: #0369a1;
  margin-bottom: 3px;
}
.loc-chat-address {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.4;
}
.loc-chat-map-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #0284c7;
  text-decoration: none;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  padding: 3px 8px;
  background: #e0f2fe;
  transition: background .15s;
}
.loc-chat-map-link:hover { background: #bae6fd; }

/* ── EDITOR FORM ── */
.rpf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}

.rpf-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 10px;
  border-radius: 100px;
  background: #ede9fe;
  color: var(--primary-dark);
}

.rpf-delete-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--r-xs);
  font-size: 13px;
  transition: all 0.15s;
}

.rpf-delete-btn:hover { color: var(--danger); background: #fef2f2; }

.rpf-section { margin-bottom: 14px; }

.rpf-section label, label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.rpf-input, .rpf-textarea, .rpf-select {
  width: 100%;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color 0.15s;
}

.rpf-input:focus, .rpf-textarea:focus, .rpf-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.rpf-textarea { resize: vertical; min-height: 90px; }

/* Larger textarea for API headers / body — more room to enter JSON */
.rpf-mono { min-height: 100px; }
.rpf-select { cursor: pointer; }

.rpf-answers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.rpf-answers-header label { margin: 0; }

.rpf-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  background: #ede9fe;
  color: var(--primary-dark);
  border: 1px solid #c4b5fd;
  border-radius: var(--r-xs);
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}

.rpf-add-btn:hover { background: #ddd6fe; }

.rpf-answers-list { display: flex; flex-direction: column; gap: 7px; }

.rpf-answer-row {
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--r-sm);
  padding: 9px 10px;
}

.rpf-ans-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.rpf-ans-label {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--r-xs);
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  background: white;
}

.rpf-ans-label:focus { border-color: var(--primary); }

.rpf-ans-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: var(--r-xs);
  font-size: 12px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.rpf-ans-remove:hover { color: var(--danger); background: #fef2f2; }

.rpf-ans-goto {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rpf-ans-goto label {
  font-size: 10px;
  white-space: nowrap;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
}

.rpf-ans-select {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--r-xs);
  padding: 4px 7px;
  font-size: 11.5px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  background: white;
}

.rpf-ans-select:focus { border-color: var(--primary); }

.rpf-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.rpf-end-types { display: flex; flex-direction: column; gap: 8px; }

.end-type-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.end-type-opt input { cursor: pointer; }

.end-chip {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.end-chip.green { background: #dcfce7; color: #166534; }
.end-chip.red   { background: #fee2e2; color: #991b1b; }
.end-chip.blue  { background: #dbeafe; color: #1e40af; }

.rpf-node-id {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-dim);
}

.rpf-node-id code {
  font-size: 10px;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 3px;
}

.start-tag {
  background: #dcfce7;
  color: #166534;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
  letter-spacing: 0.5px;
}

/* ── SIMULATOR PANEL ── */
.sim-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #1a2332;
  border-radius: var(--r-sm);
  margin-bottom: 12px;
  flex-shrink: 0;
}

.sim-avatar {
  width: 34px;
  height: 34px;
  background: #34d399;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #064e3b;
  font-size: 15px;
  flex-shrink: 0;
}

.sim-header strong {
  display: block;
  font-size: 13px;
  color: white;
  font-weight: 600;
}

.sim-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #94a3b8;
}

.sim-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  animation: simpulse 2s infinite;
}

@keyframes simpulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.sim-restart-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #94a3b8;
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
}

.sim-restart-btn:hover { background: rgba(255,255,255,0.2); color: white; }

.sim-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 0;
  max-height: 280px;
}

.sim-bubble-wrap { display: flex; flex-direction: column; }

.sim-bubble-wrap.bot { align-items: flex-start; }
.sim-bubble-wrap.user { align-items: flex-end; }

.sim-node-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 3px;
  padding-left: 2px;
}

.sim-bubble {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  animation: bubblein 0.2s ease;
}

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

.sim-bubble.bot {
  background: #f3f4f6;
  color: var(--text);
  border-bottom-left-radius: 3px;
}

.sim-bubble.user {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 3px;
}

.sim-input-area {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--panel-border);
  padding-top: 10px;
}

.sim-choices { display: flex; flex-direction: column; gap: 5px; }

.sim-choice-btn {
  width: 100%;
  padding: 8px 12px;
  background: white;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  color: var(--text);
  font-size: 12.5px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.sim-choice-btn:hover {
  border-color: var(--primary);
  background: #f5f3ff;
  color: var(--primary);
}

.sim-text-row {
  display: flex;
  gap: 6px;
}

.sim-text-inp {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

.sim-text-inp:focus { border-color: var(--primary); }

.sim-send-btn {
  background: var(--primary);
  border: none;
  color: white;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.sim-send-btn:hover { background: var(--primary-dark); }

.sim-end-card {
  text-align: center;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 4px;
}

.sim-end-card.resolved { background: #dcfce7; color: #166534; }
.sim-end-card.escalate { background: #fee2e2; color: #991b1b; }
.sim-end-card.info     { background: #dbeafe; color: #1e40af; }

.sim-restart-inline {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sim-restart-inline:hover { border-color: var(--primary); color: var(--primary); background: #f5f3ff; }

.sim-tracker {
  border-top: 1px solid var(--panel-border);
  padding-top: 10px;
  margin-top: 8px;
  flex-shrink: 0;
  max-height: 200px;
  overflow-y: auto;
}

.sim-tracker-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sim-step {
  display: flex;
  gap: 10px;
  padding-bottom: 12px;
  position: relative;
}

.sim-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: #e5e7eb;
}

.sim-step-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
  z-index: 1;
}

.sim-step-dot.active { border-color: var(--primary); color: var(--primary); background: #ede9fe; }
.sim-step-dot.done   { border-color: var(--success); color: var(--success); background: #dcfce7; }
.sim-step-dot.end    { border-color: var(--warning); color: var(--warning); background: #fef3c7; }

.sim-step-info { flex: 1; }
.sim-step-title { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 1px; }
.sim-step-ans   { font-size: 11px; color: var(--text-muted); font-style: italic; }

/* typing dots */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 10px 13px;
  background: #f3f4f6;
  border-radius: 12px;
  border-bottom-left-radius: 3px;
  align-self: flex-start;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: tdot 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes tdot { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

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

.modal {
  background: white;
  border-radius: 14px;
  width: 520px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modslide 0.2s ease;
}

.modal-sm { width: 400px; }
.modal-lg { width: 600px; }

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

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--panel-border);
}

.modal-head h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: #f3f4f6;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}

.modal-close:hover { background: #e5e7eb; color: var(--text); }

.modal-body { padding: 18px 22px; }
.modal-body p { font-size: 14px; color: var(--text-2); line-height: 1.6; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--panel-border);
  background: #f9fafb;
  border-radius: 0 0 14px 14px;
}

.mf-row { margin-bottom: 14px; }
.mf-row:last-child { margin-bottom: 0; }

.mf-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

/* ============================================================
   COLOR SWATCHES
   ============================================================ */

.color-swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.swatch:hover, .swatch.active {
  border-color: var(--text);
  transform: scale(1.15);
  box-shadow: 0 0 0 2px white inset;
}

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  background: white;
  border: 1px solid var(--panel-border);
  border-radius: var(--r);
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastin 0.25s ease;
}

.toast.hidden { display: none; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }

@keyframes toastin { from{transform:translateX(80px);opacity:0} to{transform:translateX(0);opacity:1} }

/* ============================================================
   SCROLLBARS
   ============================================================ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============================================================
   DRAWER TOGGLE TABS  (floating edge buttons)
   ============================================================ */

/*
  APPROACH: Toggle tabs are position:absolute inside .builder-layout.
  When a drawer is CLOSED:  tab is at the absolute edge (left:0 / right:0)
  When a drawer is OPEN:    tab shifts inward by the drawer width
  We drive this purely via CSS classes — no JS style.left/right calculations.
  The CSS transition on the tab container handles the smooth slide.
*/

/* ── LEFT TOGGLE TAB ── */
.drawer-toggle-left {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  pointer-events: none; /* tab button handles its own events */
  transition: left 0.25s cubic-bezier(.4,0,.2,1);
}

/* When left drawer is open, shift tab right by the palette width */
.builder-layout.left-open .drawer-toggle-left {
  left: 200px;
}

@media (max-width: 1100px) {
  .builder-layout.left-open .drawer-toggle-left { left: 180px; }
}

.drawer-tab-btn {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: white;
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 14px 7px;
  cursor: pointer;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow: 2px 0 8px rgba(0,0,0,0.08);
  border-radius: 0 6px 6px 0;
  border-left: none;
  line-height: 1;
  user-select: none;
}

.drawer-tab-btn:hover {
  background: #f5f3ff;
  color: var(--primary);
  border-color: var(--primary);
}

.drawer-tab-btn.open {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.drawer-tab-btn i {
  writing-mode: horizontal-tb;
  font-size: 12px;
}

/* ── RIGHT TOGGLE TAB ── */
.drawer-toggle-right {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  pointer-events: none;
  transition: right 0.25s cubic-bezier(.4,0,.2,1);
}

/* When right drawer is open, shift tab left by the panel width */
.builder-layout.right-open .drawer-toggle-right {
  right: 420px;
}

@media (max-width: 1100px) {
  .builder-layout.right-open .drawer-toggle-right { right: 360px; }
}

.drawer-tab-btn-right {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: white;
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 14px 7px;
  cursor: pointer;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow: -2px 0 8px rgba(0,0,0,0.08);
  border-radius: 6px 0 0 6px;
  border-right: none;
  line-height: 1;
  user-select: none;
}

.drawer-tab-btn-right:hover {
  background: #f5f3ff;
  color: var(--primary);
  border-color: var(--primary);
}

.drawer-tab-btn-right.open {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.drawer-tab-btn-right i {
  writing-mode: horizontal-tb;
  font-size: 12px;
}

/* Node-selected pulse on right toggle */
@keyframes drawerPulse {
  0%   { box-shadow: -2px 0 8px rgba(0,0,0,0.08); }
  50%  { box-shadow: -2px 0 0 6px rgba(99,102,241,0.4); }
  100% { box-shadow: -2px 0 8px rgba(0,0,0,0.08); }
}

.drawer-tab-btn-right.pulse {
  animation: drawerPulse 0.55s ease;
}

/* ============================================================
   API CALL NODE  — canvas card display
   ============================================================ */

.node-api-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px 6px;
  padding: 5px 8px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--r-xs);
  font-size: 10.5px;
  overflow: hidden;
}

.node-api-method {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.method-get    { background: #dcfce7; color: #166534; }
.method-post   { background: #dbeafe; color: #1e40af; }
.method-put    { background: #fef3c7; color: #92400e; }
.method-patch  { background: #ede9fe; color: #5b21b6; }
.method-delete { background: #fee2e2; color: #991b1b; }

.node-api-url {
  color: #0369a1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.node-api-maps {
  margin: 0 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.node-api-map-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: #6b7280;
  max-width: 100%;
  overflow: hidden;
}

.nap-path { color: #0369a1; font-family: monospace; }
.nap-var  {
  color: #7c3aed;
  font-family: monospace;
  background: #ede9fe;
  padding: 1px 4px;
  border-radius: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* SET VARIABLE node */
.node-var-list {
  margin: 0 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.node-var-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  background: #f5f3ff;
  border: 1px solid #ede9fe;
  border-radius: 4px;
  padding: 3px 7px;
}

.nvar-name { color: #7c3aed; font-family: monospace; font-weight: 600; }
.nvar-sep  { color: #9ca3af; }
.nvar-val  { color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 80px; }

/* Connection line colors for new types */
.conn-api { stroke: #38bdf8; stroke-width: 2px; stroke-dasharray: 6 3; }
.conn-var { stroke: #a78bfa; stroke-width: 2px; stroke-dasharray: 6 3; }

/* ============================================================
   API EDITOR FORM  (right panel)
   ============================================================ */

.rpf-api-section {
  border: 1.5px solid #bae6fd;
  border-radius: var(--r-sm);
  padding: 12px;
  background: #f0f9ff;
}

.rpf-setvar-section {
  border: 1.5px solid #ddd6fe;
  border-radius: var(--r-sm);
  padding: 12px;
  background: #faf5ff;
}

.rpf-api-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #0369a1;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #bae6fd;
  background: #e0f2fe;
  margin: -12px -12px 12px;
  padding: 8px 12px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}

.rpf-2col {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  align-items: start;
}

/* API URL input — monospace so long URLs are easier to read/edit */
#ed-api-url {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0;
}

.rpf-mono {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
}

.rpf-hint-inline {
  font-size: 9.5px;
  color: #9ca3af;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* Variable input wrapper  {{  input  }} */
.rpf-var-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: white;
}

.rpf-var-brace {
  padding: 8px 7px;
  background: #f3f4f6;
  color: #7c3aed;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  border-right: 1.5px solid #e5e7eb;
}

.rpf-var-brace:last-child {
  border-right: none;
  border-left: 1.5px solid #e5e7eb;
}

.rpf-var-wrap .rpf-input {
  border: none;
  border-radius: 0;
  flex: 1;
}

.rpf-var-wrap .rpf-input:focus {
  box-shadow: none;
}

.rpf-var-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* API mappings list */
.api-mappings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-map-row {
  background: white;
  border: 1.5px solid #bae6fd;
  border-radius: var(--r-sm);
  padding: 8px 10px;
}

/* Pin to conversation row — shared by API mapping + Set Var */
.api-map-pin-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e5e7eb;
}
.api-map-pin-row label { white-space: nowrap; }

.api-map-fields {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.api-map-field {
  flex: 1;
}

.api-map-field label {
  font-size: 10px;
  margin-bottom: 4px;
}

.api-map-arrow {
  color: #94a3b8;
  font-size: 11px;
  padding-bottom: 9px;
  flex-shrink: 0;
}

.api-map-del {
  flex-shrink: 0;
  margin-bottom: 1px;
}

.rpf-add-btn-api {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

.rpf-add-btn-api:hover { background: #bae6fd; }

/* Switch node — case list */
.switch-cases-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.switch-case-row {
  background: white;
  border: 1.5px solid #a5f3fc;
  border-radius: var(--r-sm);
  padding: 8px 10px;
}

.switch-case-fields {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.switch-case-field { flex: 1; }
.switch-case-field label { font-size: 10px; margin-bottom: 4px; }

.switch-case-arrow {
  color: #94a3b8;
  font-size: 11px;
  padding-bottom: 9px;
  flex-shrink: 0;
}

.switch-case-del {
  flex-shrink: 0;
  margin-bottom: 1px;
}

.switch-case-num {
  font-size: 9px;
  font-weight: 700;
  color: #0891b2;
  background: #cffafe;
  border-radius: 4px;
  padding: 1px 6px;
  margin-bottom: 4px;
  display: inline-block;
}

/* Canvas node body — Switch preview */
.node-switch-preview {
  margin: 6px 8px 4px;
}
.node-switch-var-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #0891b2;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  border-radius: 5px;
  padding: 2px 7px;
  margin-bottom: 5px;
}
.node-switch-case-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  color: #0e7490;
  background: #f0fdff;
  border-radius: 4px;
  padding: 3px 6px;
  margin-bottom: 3px;
}
.node-switch-case-val {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 90px;
}
.node-switch-more {
  font-size: 9px;
  color: #94a3b8;
  padding: 2px 6px;
}
.node-switch-empty {
  font-size: 11px;
  color: #94a3b8;
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.node-switch-default-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: #dc2626;
  background: #fef2f2;
  border-radius: 4px;
  padding: 3px 6px;
  margin-top: 4px;
  font-weight: 600;
}

/* Set Variable assignments */
.setvar-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setvar-row {
  background: white;
  border: 1.5px solid #ddd6fe;
  border-radius: var(--r-sm);
  padding: 9px 10px;
}

.setvar-fields {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.setvar-field { flex: 1; }
.setvar-val-field { flex: 2; }

.setvar-field label {
  font-size: 9.5px;
  margin-bottom: 4px;
}

.setvar-name-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: white;
}

.setvar-brace {
  padding: 7px 5px;
  background: #f5f3ff;
  color: #7c3aed;
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.setvar-name-wrap .rpf-input {
  border: none;
  border-radius: 0;
  padding: 7px 7px;
  flex: 1;
  min-width: 0;
}

.setvar-name-wrap .rpf-input:focus { box-shadow: none; }
.setvar-name-wrap:focus-within { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,0.1); }

.setvar-hint {
  font-size: 9.5px;
  color: #9ca3af;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.setvar-eq {
  font-size: 14px;
  font-weight: 700;
  color: #9ca3af;
  padding-bottom: 7px;
  flex-shrink: 0;
}

.rpf-add-btn-var {
  background: #ede9fe;
  color: #5b21b6;
  border-color: #ddd6fe;
  width: 100%;
  justify-content: center;
}

.rpf-add-btn-var:hover { background: #ddd6fe; }

/* ============================================================
   API / VARIABLE STATUS BUBBLES in simulators
   ============================================================ */

.sim-api-status,
.cm-api-status {
  font-size: 11.5px;
  padding: 7px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 2px;
  animation: bubblein 0.18s ease;
}

.sim-api-calling, .cm-api-calling {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
}

.sim-api-success, .cm-api-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.sim-api-error, .cm-api-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

/* Variable panel inside tracker */
.sim-vars-panel,
.cm-vars-panel {
  margin-top: 10px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 10px;
}

.sim-vars-title,
.cm-vars-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7c3aed;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sim-var-row,
.cm-var-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  margin-bottom: 4px;
}

.sim-var-name,
.cm-var-name {
  font-family: monospace;
  color: #7c3aed;
  font-weight: 600;
  flex-shrink: 0;
  background: #f5f3ff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10.5px;
}

.sim-var-val,
.cm-var-val {
  color: #374151;
  font-size: 11px;
  word-break: break-all;
  flex: 1;
}

/* ============================================================
   CHAT MODAL POPUP  (standalone simulator from dashboard)
   ============================================================ */

/* --chat-accent CSS variable is set inline per-flow from JS */

.chat-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 35, 0.55);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 16px;
  animation: cmFadeIn 0.2s ease;
}

.chat-modal-overlay.hidden {
  display: none;
}

@keyframes cmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* The chat widget itself — looks like a real deployed chat widget */
.chat-modal {
  width: 400px;
  max-width: 100%;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.28), 0 4px 16px rgba(0,0,0,0.12);
  animation: cmSlideUp 0.25s cubic-bezier(.34,1.36,.64,1);
}

@keyframes cmSlideUp {
  from { transform: translateY(40px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* ── Header ── */
.cm-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  background: var(--chat-accent, #6366f1);
  flex-shrink: 0;
}

.cm-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 17px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.3);
}

.cm-header-info { flex: 1; min-width: 0; }

.cm-header-name {
  font-size: 14px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cm-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.75);
  margin-top: 1px;
}

.cm-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #86efac;
  animation: cmPulse 2s infinite;
  flex-shrink: 0;
}

@keyframes cmPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

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

.cm-hdr-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.cm-hdr-btn:hover { background: rgba(255,255,255,0.28); }
.cm-hdr-btn.cm-close:hover { background: rgba(239,68,68,0.5); }

/* ── Messages area ── */
.cm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fb;
  min-height: 260px;
  max-height: 340px;
}

.cm-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.cm-bubble-wrap.bot  { align-self: flex-start; align-items: flex-start; }
.cm-bubble-wrap.user { align-self: flex-end;   align-items: flex-end; }

.cm-node-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  margin-bottom: 3px;
  padding-left: 2px;
}

.cm-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  animation: cmBubbleIn 0.18s ease;
}

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

.cm-bubble.bot {
  background: white;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.cm-bubble.user {
  /* background set inline per accent color */
  color: white;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.cm-typing-dots {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  align-self: flex-start;
}

.cm-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: cmDot 1.3s infinite ease;
}

.cm-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.cm-typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes cmDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Input area ── */
.cm-input-area {
  padding: 10px 14px 12px;
  background: white;
  border-top: 1px solid #f1f3f5;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 54px;
}

/* Quick-reply pill buttons (horizontal wrap) */
.cm-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.cm-qr-btn {
  padding: 8px 16px;
  border-radius: 100px;
  border: 1.5px solid #e5e7eb;
  background: white;
  color: #374151;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.cm-qr-btn:hover {
  border-color: var(--chat-accent, #6366f1);
  color: var(--chat-accent, #6366f1);
  background: color-mix(in srgb, var(--chat-accent, #6366f1) 8%, white);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.cm-qr-btn:active { transform: scale(0.96); }

/* Continue button */
.cm-continue-btn {
  width: 100%;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1.5px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  font-size: 13.5px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.cm-continue-btn:hover {
  border-color: var(--chat-accent, #6366f1);
  color: var(--chat-accent, #6366f1);
  background: color-mix(in srgb, var(--chat-accent, #6366f1) 6%, white);
}

/* Text input row */
.cm-text-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cm-text-inp {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 100px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-family: var(--font);
  outline: none;
  background: #f9fafb;
  transition: border-color 0.15s, background 0.15s;
  color: #111827;
}

.cm-text-inp:focus {
  border-color: var(--chat-accent, #6366f1);
  background: white;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-accent, #6366f1) 12%, transparent);
}

.cm-text-inp.shake {
  animation: cmShake 0.38s ease;
}

@keyframes cmShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-3px); }
  80%       { transform: translateX(3px); }
}

.cm-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  /* background set inline from JS accent color */
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, filter 0.15s;
}

.cm-send-btn:hover { filter: brightness(1.12); transform: scale(1.08); }
.cm-send-btn:active { transform: scale(0.92); }

/* No options text */
.cm-no-options {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  padding: 6px 0;
  font-style: italic;
}

/* End state card */
.cm-end-card {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  animation: cmBubbleIn 0.2s ease;
}

.cm-end-card.resolved { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.cm-end-card.escalate { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.cm-end-card.info     { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* Restart button */
.cm-restart-btn {
  width: 100%;
  padding: 9px;
  border-radius: 10px;
  border: 1.5px solid #e5e7eb;
  background: white;
  color: #6b7280;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.15s;
  margin-top: 2px;
}

.cm-restart-btn:hover {
  border-color: var(--chat-accent, #6366f1);
  color: var(--chat-accent, #6366f1);
  background: color-mix(in srgb, var(--chat-accent, #6366f1) 5%, white);
}

/* ── Flow path tracker ── */
.cm-tracker {
  border-top: 1px solid #f1f3f5;
  background: #fafafa;
  flex-shrink: 0;
}

.cm-tracker-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: none;
  border: none;
  font-size: 11px;
  font-family: var(--font);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  cursor: pointer;
  transition: color 0.15s;
}

.cm-tracker-toggle:hover { color: #6b7280; }
.cm-tracker-toggle i { font-size: 11px; color: #9ca3af; }

.cm-step-count-badge {
  background: #f3f4f6;
  color: #6b7280;
  font-size: 9.5px;
  padding: 1px 7px;
  border-radius: 100px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.cm-tracker-body {
  padding: 4px 14px 12px;
  max-height: 160px;
  overflow-y: auto;
}

.cm-step {
  display: flex;
  gap: 10px;
  padding-bottom: 10px;
  position: relative;
}

.cm-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: #e5e7eb;
}

.cm-step-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: #9ca3af;
  flex-shrink: 0;
  z-index: 1;
}

.cm-step-dot.active { border-color: var(--chat-accent, #6366f1); color: var(--chat-accent, #6366f1); background: color-mix(in srgb, var(--chat-accent, #6366f1) 10%, white); }
.cm-step-dot.done   { border-color: #10b981; color: #10b981; background: #dcfce7; }
.cm-step-dot.end    { border-color: #f59e0b; color: #f59e0b; background: #fef3c7; }

.cm-step-info { flex: 1; padding-top: 1px; }
.cm-step-title { font-size: 12px; font-weight: 600; color: #374151; }
.cm-step-ans   { font-size: 11px; color: #9ca3af; font-style: italic; margin-top: 1px; }

/* ============================================================
   NEW NODE TYPE COLORS — Media Card + Upload File
   ============================================================ */

.node-type-mediacard .node-hdr { background: linear-gradient(135deg, #ec4899, #db2777); }
.node-type-upload    .node-hdr { background: linear-gradient(135deg, #d97706, #b45309); }
.node-type-carousel  .node-hdr { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.node-type-camera      .node-hdr { background: linear-gradient(135deg, #0891b2, #0e7490); }
.node-type-calculator  .node-hdr { background: linear-gradient(135deg, #059669, #047857); }
.node-type-location    .node-hdr { background: linear-gradient(135deg, #0284c7, #0369a1); }

/* palette icon colors */
.pi-pink   { background: #ec489922 !important; color: #ec4899 !important; }
.pi-amber  { background: #d9770622 !important; color: #d97706 !important; }
.pi-violet { background: #8b5cf622 !important; color: #8b5cf6 !important; }

/* ── Carousel node: canvas card thumbnails grid ── */
.node-carousel-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);   /* always 4 equal cols inside 230px node */
  gap: 4px;
  margin: 6px 8px 4px;
  max-height: 52px;                         /* hard cap — prevents any blowout */
  overflow: hidden;
}
.node-carousel-thumb {
  border-radius: 6px;
  overflow: hidden;
  background: #f3f0ff;
  border: 1.5px solid #e9d5ff;
  width: 100%;
  height: 44px;                             /* fixed pixel height — never auto */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.node-carousel-thumb img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.node-carousel-thumb-ph {
  font-size: 14px;
  opacity: 0.45;
  position: relative;                       /* above any img */
  z-index: 1;
}
.node-carousel-thumb-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  font-size: 7px;
  font-weight: 600;
  color: white;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  padding: 4px 2px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}
.node-carousel-summary {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 2px 8px 4px;
  font-size: 10px;
  color: #7c3aed;
  font-weight: 600;
}
.node-carousel-summary i {
  font-size: 9px;
  opacity: 0.7;
}
.nab-carousel {
  background: #f3f0ff;
  color: #7c3aed;
  border-color: #ddd6fe;
}

/* ── Node card: media preview ── */
.node-media-preview {
  margin: 4px 8px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #f3f4f6;
}
.node-media-preview img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  display: block;
}
.node-media-caption {
  font-size: 11px;
  color: #374151;
  padding: 4px 8px;
  background: #f9fafb;
  line-height: 1.4;
}
.node-media-placeholder {
  margin: 4px 8px 0;
  padding: 10px;
  border: 1.5px dashed #e5e7eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: #9ca3af;
}
.nab-media   { background: #fce7f3; color: #be185d; border-color: #fbcfe8; }
.nab-upload  { background: #fef3c7; color: #92400e; border-color: #fde68a; }

/* ============================================================
   CONDITION NODE — Editor Panel, Canvas Preview, Sim Bubbles
   ============================================================ */

/* ── Group-logic row (AND/OR between groups) ── */
.cond-group-logic-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

/* ── Logic toggle buttons (AND / OR) ── */
.cond-logic-toggle {
  display: flex;
  border: 1.5px solid #e5e7eb;
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
}

.clt-btn {
  padding: 4px 11px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  letter-spacing: 0.4px;
  border: none;
  background: white;
  color: #9ca3af;
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  line-height: 1;
}

.clt-btn + .clt-btn { border-left: 1.5px solid #e5e7eb; }

.clt-btn.active {
  background: #c2570a;
  color: white;
}

.clt-btn:not(.active):hover {
  background: #fff7ed;
  color: #c2570a;
}

/* ── Condition group card ── */
.cond-group {
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

/* group header */
.cond-group-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 7px;
  background: #ffedd5;
  border-bottom: 1px solid #fed7aa;
  gap: 8px;
}

.cond-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.cond-group-num {
  font-size: 11.5px;
  font-weight: 700;
  color: #c2570a;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.cond-hint-sm {
  font-size: 10.5px;
  color: #9ca3af;
  font-style: italic;
}

/* delete group / delete rule icon buttons */
.cond-del-group,
.cond-del-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #9ca3af;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.13s, color 0.13s;
}

.cond-del-group:hover { background: #fecaca; color: #991b1b; }
.cond-del-rule:hover  { background: #fecaca; color: #991b1b; }

/* rules list inside a group */
.cond-rules-list {
  padding: 8px 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* logic badge shown between rules */
.cond-rule-logic-badge {
  font-size: 10px;
  font-weight: 700;
  color: #c2570a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 2px 0;
}

/* single rule row */
.cond-rule-row { display: flex; flex-direction: column; gap: 3px; }

.cond-rule-fields {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

/* individual field blocks */
.cond-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.cond-field > label {
  font-size: 10px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cond-field-var { flex: 0 0 auto; }
.cond-field-op  { flex: 0 0 auto; }
.cond-field-val { flex: 1 1 80px; min-width: 60px; }

/* {{…}} variable input wrapper */
.cond-var-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}

.cond-brace {
  font-size: 12px;
  font-weight: 700;
  color: #c2570a;
  font-family: monospace;
  flex-shrink: 0;
  line-height: 1;
}

/* operator select + value input sizing */
.cond-var-inp  { width: 80px; font-size: 12px !important; padding: 4px 7px !important; }
.cond-op-sel   { font-size: 12px !important; padding: 4px 7px !important; min-width: 100px; }
.cond-val-inp  { font-size: 12px !important; padding: 4px 7px !important; width: 100%; }

/* add rule / add group buttons */
.rpf-add-btn-rule {
  margin: 6px 10px 8px;
  padding: 5px 10px;
  font-size: 11.5px;
  background: #fff7ed;
  color: #c2570a;
  border: 1.5px dashed #fed7aa;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  transition: background 0.13s, border-color 0.13s;
}
.rpf-add-btn-rule:hover { background: #ffedd5; border-color: #c2570a; }

.rpf-add-btn-cond {
  padding: 6px 12px;
  font-size: 12px;
  background: white;
  color: #c2570a;
  border: 1.5px dashed #fed7aa;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  transition: background 0.13s, border-color 0.13s;
}
.rpf-add-btn-cond:hover { background: #fff7ed; border-color: #c2570a; }

/* separator between groups showing AND/OR */
.cond-group-sep {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #c2570a;
  letter-spacing: 0.5px;
  padding: 2px 0 10px;
  position: relative;
}

.cond-group-sep::before,
.cond-group-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: #fed7aa;
}
.cond-group-sep::before { left: 0; }
.cond-group-sep::after  { right: 0; }

/* ── Canvas node condition summary ── */
.node-cond-preview {
  padding: 6px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.node-cond-rule-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  flex-wrap: wrap;
}

.ncr-var {
  font-family: monospace;
  font-size: 10px;
  color: #c2570a;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 4px;
  padding: 1px 5px;
}

.ncr-op {
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
}

.ncr-val {
  font-family: monospace;
  font-size: 10px;
  color: #374151;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 1px 5px;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-cond-more {
  font-size: 10px;
  color: #9ca3af;
  font-style: italic;
}

.node-cond-empty {
  font-size: 10.5px;
  color: #9ca3af;
  font-style: italic;
  text-align: center;
  padding: 4px 0;
}

/* ── Simulator (preview panel) condition bubble ── */
.sim-bubble.cond-bubble {
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  border-bottom-left-radius: 3px;
  padding: 10px 14px;
}

.cond-bubble-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #c2570a;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.cond-bubble-result {
  font-size: 13.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 7px;
  display: inline-block;
}

.cond-true  { background: #dcfce7; color: #166534; }
.cond-false { background: #fee2e2; color: #991b1b; }

/* ── Chat-modal condition bubble ── */
.cm-cond-bubble {
  background: #fff7ed !important;
  border: 1.5px solid #fed7aa !important;
  border-bottom-left-radius: 4px !important;
  padding: 10px 14px !important;
}

.cm-cond-bubble-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: #c2570a;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

/* ── chat.html (full-page) condition bubble ── */
.chat-cond-bubble {
  background: #fff7ed !important;
  border: 1.5px solid #fed7aa !important;
  padding: 10px 14px !important;
}

.chat-cond-bubble-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #c2570a;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

.chat-cond-bubble-result {
  font-size: 13.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 7px;
  display: inline-block;
}

/* node type color strip for condition */
.node-type-condition .node-hdr {
  background: linear-gradient(135deg, #c2570a, #9a400a);
}

/* palette icon color for condition */
.pi-orange {
  background: #c2570a22 !important;
  color: #c2570a !important;
}

/* ============================================================
   PHONE INPUT STYLING — simulator
   ============================================================ */
.sim-phone-prefix, .cm-phone-prefix {
  font-size: 18px;
  display: flex;
  align-items: center;
  padding: 0 4px 0 8px;
  user-select: none;
}
.sim-text-inp.valid, .cm-text-inp.valid {
  border-color: #10b981;
  box-shadow: 0 0 0 2px #10b98118;
}
@keyframes shake {
  0%,100%{ transform: translateX(0); }
  20%    { transform: translateX(-5px); }
  40%    { transform: translateX(5px); }
  60%    { transform: translateX(-3px); }
  80%    { transform: translateX(3px); }
}
.sim-text-inp.shake, .cm-text-inp.shake { animation: shake 0.4s; }

/* ============================================================
   UPLOAD FILE — Simulator Dropzone
   ============================================================ */
.sim-upload-wrap, .cm-upload-wrap {
  width: 100%;
  padding: 8px;
}
.sim-dropzone, .cm-dropzone {
  border: 2px dashed #d1d5db;
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.2s, background 0.2s;
  background: #f9fafb;
}
.sim-dropzone:hover, .cm-dropzone:hover { border-color: #6366f1; background: #f5f3ff; }
.sim-dropzone.selected, .cm-dropzone.selected { border-color: #10b981; background: #f0fdf4; }
.sim-dropzone i, .cm-dropzone i { font-size: 22px; color: #9ca3af; }
.sim-dropzone:hover i, .cm-dropzone:hover i { color: #6366f1; }
.sim-dropzone.selected i, .cm-dropzone.selected i { color: #10b981; }
.sim-dropzone span, .cm-dropzone span { font-size: 13px; font-weight: 600; color: #374151; }
.sim-dropzone small, .cm-dropzone small { font-size: 11px; color: #9ca3af; }
.sim-upload-status, .cm-upload-status {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}
.sim-upload-status.success, .cm-upload-status.success { background: #dcfce7; color: #166534; }
.sim-upload-status.error, .cm-upload-status.error     { background: #fee2e2; color: #991b1b; }

/* ============================================================
   MEDIA CARD — Simulator rendering (WhatsApp-style)
   ============================================================ */
.sim-media-card, .cm-media-card {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  max-width: 240px;
}
.sim-media-img, .cm-media-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
}
.sim-sticker, .cm-sticker {
  max-height: 120px;
  object-fit: contain;
  background: transparent;
  mix-blend-mode: multiply;
}
.sim-media-caption-text, .cm-media-caption-text {
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #374151;
}
.sim-media-broken, .cm-media-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  background: #f9fafb;
  color: #9ca3af;
  font-size: 12px;
}
.sim-media-broken i, .cm-media-broken i { font-size: 20px; }

/* Reply buttons (WhatsApp-style) */
.sim-reply-btns, .cm-reply-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}
.sim-reply-btn {
  padding: 9px 14px;
  background: #fff;
  border: 1.5px solid #6366f1;
  color: #6366f1;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: center;
}
.sim-reply-btn:hover { background: #6366f1; color: #fff; }
.cm-reply-btn {
  padding: 9px 14px;
  background: #fff;
  border: 1.5px solid var(--chat-accent, #6366f1);
  color: var(--chat-accent, #6366f1);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: center;
}
.cm-reply-btn:hover { background: var(--chat-accent, #6366f1); color: #fff; }

/* ============================================================
   AUDIO / VOICE NOTE — WhatsApp-style playable bubble
   Shared markup/classes used by the builder's inline preview
   (.sim-audio-*) and the dashboard chat-modal (.cm-audio-*).
   chat.html duplicates an inline-styled equivalent since it
   must stay self-contained even if this stylesheet fails to load.
   ============================================================ */
.wa-audio-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  border-radius: 18px 18px 18px 4px;
  background: #dcf8c6;
  max-width: 260px;
  min-width: 200px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.wa-audio-bubble.wa-audio-nosrc { background: #f3f4f6; }
.wa-audio-play-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #25D366;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
}
.wa-audio-play-btn:hover  { background: #1ea952; }
.wa-audio-play-btn:active { transform: scale(0.92); }
.wa-audio-play-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.wa-audio-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.wa-audio-track {
  position: relative;
  height: 4px;
  border-radius: 4px;
  background: rgba(37,211,102,0.28);
  overflow: hidden;
  cursor: pointer;
}
.wa-audio-progress {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0%;
  background: #128c4a;
  border-radius: 4px;
  transition: width 0.1s linear;
}
.wa-audio-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.wa-audio-time { font-size: 11px; color: #3f6b3f; font-weight: 500; white-space: nowrap; }
.wa-audio-mic  { font-size: 11px; color: #3f6b3f; opacity: 0.7; }
.wa-audio-caption { font-size: 12.5px; color: #1f2937; line-height: 1.4; margin-top: 2px; }
.wa-audio-nosrc-msg { font-size: 12px; color: #9ca3af; font-style: italic; }

/* ============================================================
   CONVERSATIONS VIEW — v10.3
   ============================================================ */

/* ── Scroll wrapper ── */
#view-conversations { overflow-y: auto; }

/* ── Page wrapper ── */
.conv-page-wrap {
  padding: 28px 32px 60px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  min-height: 0;
}

/* ── Page header ── */
.conv-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.conv-page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin: 0 0 4px;
}
.conv-page-header p {
  font-size: 13px;
  color: #9ca3af;
  margin: 0;
}
.conv-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Date Filter Bar ── */
.conv-date-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 14px;
}
.conv-date-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cdate-btn {
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 100px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.cdate-btn:hover { border-color: #c7d2fe; color: #4f46e5; background: #eef2ff; }
.cdate-btn.active { background: #6366f1; color: #fff; border-color: #6366f1; font-weight: 600; }
.conv-date-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
.conv-custom-field {
  display: flex;
  align-items: center;
  gap: 5px;
}
.conv-custom-field label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.conv-custom-field input[type="date"] {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.conv-custom-field input[type="date"]:focus { border-color: #6366f1; }

/* ── Stat Cards Row ── */
.conv-stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) { .conv-stats-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .conv-stats-row { grid-template-columns: repeat(2, 1fr); } }

.conv-stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.conv-stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); border-color: #c7d2fe; }
.cstat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.cstat-info { flex: 1; min-width: 0; }
.cstat-val {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  line-height: 1;
  margin-bottom: 2px;
}
.cstat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
}
.cstat-pct {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 100px;
  padding: 2px 7px;
  flex-shrink: 0;
  align-self: flex-start;
}

/* ── Daily Chart Card ── */
.conv-chart-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 18px 20px 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.conv-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.conv-chart-title {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 7px;
}
.conv-chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.cleg {
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cleg.resolved  i { color: #10b981; font-size: 8px; }
.cleg.escalated i { color: #ef4444; font-size: 8px; }
.cleg.incomplete i { color: #f59e0b; font-size: 8px; }
.conv-chart-empty {
  height: 220px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: #9ca3af;
  font-size: 13px;
}
.conv-chart-empty i { font-size: 28px; }

/* ── Toolbar ── */
.conv-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Conversations List ── */
.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

/* ── Row number ── */
.conv-row-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f3f4f6;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Pagination ── */
.conv-pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 0 0;
}
.cpag-btn {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.cpag-btn:hover:not(:disabled) { border-color: #6366f1; color: #6366f1; background: #eef2ff; }
.cpag-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cpag-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.cpag-num {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.cpag-num:hover { border-color: #6366f1; color: #6366f1; background: #eef2ff; }
.cpag-num.active { background: #6366f1; color: #fff; border-color: #6366f1; }
.cpag-ellipsis {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  color: #9ca3af;
  font-size: 14px;
}
.cpag-info {
  margin-left: auto;
  font-size: 12px;
  color: #9ca3af;
  font-weight: 500;
}

/* Conversation row card */
.conv-row {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--r);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.conv-row:hover { box-shadow: var(--card-shadow-hover); border-color: #c7d2fe; }

.conv-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.conv-outcome-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.9;
}
.conv-row-info { flex: 1; min-width: 0; }

/* ── Contact inline chips — sit inline with flow title & meta row ── */
.conv-inline-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid transparent;
  transition: opacity 0.15s;
}
.conv-inline-chip:hover { opacity: 0.8; }
.conv-inline-chip i { font-size: 9px; flex-shrink: 0; }
/* CustomerName — purple (beside title in conv-row-flow) */
.conv-inline-name   { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
/* ContactPerson — blue (in meta row) */
.conv-inline-person { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; font-size: 11px; }
/* CallbackNumber — green (in meta row) */
.conv-inline-phone  { background: #dcfce7; color: #166534; border-color: #bbf7d0; font-size: 11px; }

.conv-row-flow {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  overflow: hidden;
  line-height: 1.4;
}
.conv-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
  flex-wrap: wrap;
  line-height: 1.4;
}
.conv-sim-badge {
  background: #f3f4f6;
  color: #6b7280;
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
}
.conv-meta-sep {
  color: #d1d5db;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

/* conv_info node — custom title display */
.conv-custom-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f766e;
}
.conv-flow-sub {
  font-size: 11px;
  font-weight: 400;
  color: #9ca3af;
  margin-left: 2px;
}
.conv-flow-sub::before { content: '('; }
.conv-flow-sub::after  { content: ')'; }

/* conv_info node — notes row */
.conv-row-notes {
  font-size: 11.5px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 2px 8px;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 480px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-row-notes i { font-size: 9px; color: #f59e0b; flex-shrink: 0; }

/* ── builder: Conv Info node card preview ── */
.node-convinfo-preview {
  padding: 6px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── builder: palette item featured (Conv Info — highlighted) ── */
.palette-item-featured {
  border: 1px solid #0f766e33 !important;
  background: #f0fdf433 !important;
}
.palette-item-featured:hover {
  background: #ccfbf144 !important;
  border-color: #0f766e88 !important;
}

/* ── builder right panel: Conv Info section ── */
.rpf-convinfo-section .ci-field-row {
  margin-bottom: 12px;
}
.rpf-convinfo-section .ci-field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
}
.rpf-convinfo-section .ci-icon {
  font-size: 11px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.rpf-convinfo-section .ci-chip-preview {
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 600;
  margin-left: auto;
  border: 1px solid transparent;
}
.ci-tip-box {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #78350f;
  margin-top: 14px;
  line-height: 1.5;
}
.ci-tip-box i { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

.conv-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.conv-outcome-badge {
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.conv-view-btn {
  padding: 6px 12px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s;
}
.conv-view-btn:hover { background: #e0e7ff; color: #4f46e5; border-color: #c7d2fe; }
.conv-del-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid #fee2e2;
  background: #fff5f5;
  color: #ef4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: background 0.15s;
}
.conv-del-btn:hover { background: #fee2e2; }

/* ── Conversation ID tag (shown inline in list row) ── */
.conv-id-tag {
  display: inline-block;
  font-family: monospace;
  font-size: 9.5px;
  font-weight: 700;
  color: #7c3aed;
  background: #ede9fe;
  border: 1px solid #ddd6fe;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 7px;
  vertical-align: middle;
  letter-spacing: 0.3px;
  cursor: default;
  user-select: all;
}

/* ═══════════════════════════════════════════════════════════
   FEEDBACK DISPLAY — conversation list badge + modal hero
   ═══════════════════════════════════════════════════════════ */

/* ── List row inline badge ── */
/* ═══════════════════════════════════════════════════════════
   CONVERSATION LIST ROW — FEEDBACK DISPLAY
   ═══════════════════════════════════════════════════════════ */

/* ── Shared star icons (list row + step path) ── */
.conv-fb-star-filled {
  color: #f59e0b;
  font-size: 13px;
}
.conv-fb-star-empty {
  color: #d1d5db;
  font-size: 13px;
}

/* ── Right-side score badge (visible at a glance) ── */
.conv-fb-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 9px 3px 7px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1.5px solid #fbbf24;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  color: #92400e;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(245,158,11,0.18);
}
.conv-fb-score-badge .conv-fb-star-filled { font-size: 10px; }
.conv-fb-score-badge .conv-fb-star-empty  { font-size: 10px; color: #e5e7eb; }
.conv-fb-score-badge span {
  margin-left: 3px;
  font-size: 10.5px;
  font-weight: 800;
  color: #b45309;
}

/* ── Modal feedback hero block ── */
.conv-feedback-hero {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1.5px solid #fcd34d;
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.conv-fb-hero-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.conv-fb-hero-stars {
  font-size: 26px;
  line-height: 1;
  letter-spacing: 2px;
  color: #f59e0b;
}
.conv-fb-hero-empty {
  color: #d1d5db;
}
.conv-fb-hero-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.conv-fb-hero-score {
  font-size: 22px;
  font-weight: 800;
  color: #92400e;
  line-height: 1;
}
.conv-fb-hero-label {
  font-size: 13px;
  font-weight: 600;
  color: #b45309;
}
.conv-fb-hero-comment {
  flex: 1;
  min-width: 180px;
  font-size: 13px;
  font-style: italic;
  color: #78350f;
  background: rgba(255,255,255,0.65);
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 14px;
  line-height: 1.55;
}
.conv-fb-hero-comment .fa-quote-left {
  font-size: 10px;
  opacity: 0.55;
  margin-right: 5px;
  vertical-align: 1px;
}
.conv-fb-hero-no-comment {
  flex: 1;
  font-size: 12px;
  color: #a16207;
  opacity: 0.65;
  font-style: italic;
  align-self: center;
}

/* ── Full Chat Transcript in modal ── */
.conv-transcript {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  max-height: 360px;
  overflow-y: auto;
}

.conv-transcript-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.conv-transcript-row.user { flex-direction: row-reverse; }

.conv-transcript-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.conv-transcript-avatar.bot  { background: #6366f1; }
.conv-transcript-avatar.user { background: #f3f4f6; }

.conv-transcript-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}
.conv-transcript-row.bot  .conv-transcript-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px 14px 14px 14px;
  color: #1e293b;
}
.conv-transcript-row.user .conv-transcript-bubble {
  background: #6366f1;
  color: #ffffff;
  border-radius: 14px 4px 14px 14px;
}

.conv-transcript-ts {
  display: block;
  font-size: 9px;
  opacity: 0.55;
  margin-top: 3px;
  text-align: right;
}

.conv-transcript-divider {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #6366f1;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 20px;
  padding: 3px 12px;
  margin: 4px auto;
  display: inline-block;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ── CONVERSATION DETAIL MODAL ── */
/* ── CONVERSATION DETAIL MODAL — widened for audit view ── */
.modal-conv {
  max-width: 860px;
  width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.conv-detail-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;          /* tabs handle their own padding */
}

/* ── Summary tab legacy helpers (still used) ── */
.conv-detail-summary { padding: 20px 24px; }
.conv-detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.conv-dmeta {
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  border-radius: var(--r-sm);
  padding: 10px 14px;
}
.conv-dmeta label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  margin-bottom: 4px;
}
.conv-dmeta span {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}
.conv-dmeta-mono {
  font-family: monospace;
  font-size: 11px;
  color: #6366f1 !important;
  background: #ede9fe;
  padding: 2px 7px;
  border-radius: 5px;
  cursor: pointer;
  user-select: all;
}
.conv-dmeta-mono:hover { background: #c7d2fe; }

/* Title ID tag */
.conv-modal-id-tag {
  font-family: monospace;
  font-size: 11px;
  font-weight: 700;
  color: #6366f1;
  background: #ede9fe;
  border: 1px solid #c7d2fe;
  border-radius: 5px;
  padding: 2px 7px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

/* ── AUDIT TABS ── */
.audit-tabs {
  display: flex;
  gap: 2px;
  padding: 12px 24px 0;
  border-bottom: 2px solid #f3f4f6;
  background: #fafafa;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.audit-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px 10px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.audit-tab:hover { color: #374151; background: #f3f4f6; }
.audit-tab.active {
  color: #6366f1;
  font-weight: 700;
  border-bottom-color: #6366f1;
  background: white;
}
.audit-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #e0e7ff;
  color: #4f46e5;
  font-size: 10px;
  font-weight: 700;
  border-radius: 100px;
}
.audit-tab.active .audit-tab-count { background: #6366f1; color: white; }

/* ── PANES ── */
.audit-pane { display: none; padding: 20px 24px 28px; }
.audit-pane.active { display: block; }

/* ── EMPTY STATE ── */
.audit-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 10px;
  color: #9ca3af;
  text-align: center;
}
.audit-empty i { font-size: 36px; opacity: 0.35; }
.audit-empty p { font-size: 14px; color: #6b7280; margin: 0; }
.audit-empty-sub { font-size: 12px !important; color: #9ca3af !important; }

/* ═══════════════════════════════════════════════════════════
   AUDIT TIMELINE — Step Path tab
   ═══════════════════════════════════════════════════════════ */
.audit-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.audit-step {
  display: flex;
  gap: 0;
  align-items: stretch;
}
.audit-step-spine {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 40px;
  flex-shrink: 0;
}
.audit-step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  z-index: 1;
  background: white;
}
.audit-step-line {
  width: 2px;
  flex: 1;
  min-height: 16px;
  background: #e5e7eb;
  margin: 2px 0;
}
.audit-step-card {
  flex: 1;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 11px 14px;
  margin: 0 0 10px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.audit-step-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 2px 8px rgba(99,102,241,0.08);
}
.audit-step-last .audit-step-card { margin-bottom: 0; }
.audit-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.audit-step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.audit-step-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  flex: 1;
  min-width: 0;
}
.audit-step-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.audit-step-time {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.audit-step-id {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}
.audit-step-id code {
  font-family: monospace;
  font-size: 10.5px;
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
  color: #6b7280;
}
.audit-step-answer {
  margin-top: 7px;
  padding: 6px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 7px;
  font-size: 12px;
  color: #15803d;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.audit-step-answer i { margin-top: 2px; flex-shrink: 0; }
.audit-step-answer strong { font-weight: 600; }

/* ── Step Path — feedback node rich block ── */
.audit-step-fb-block {
  margin-top: 8px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1.5px solid #fbbf24;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.audit-step-fb-stars {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.audit-fb-star-on {
  color: #f59e0b;
  font-size: 18px;
  filter: drop-shadow(0 1px 2px rgba(245,158,11,0.35));
}
.audit-fb-star-off {
  color: #d1d5db;
  font-size: 18px;
}
.audit-step-fb-score {
  font-size: 13px;
  font-weight: 800;
  color: #92400e;
  margin-left: 5px;
  line-height: 1;
}
.audit-step-fb-label {
  font-size: 12px;
  font-weight: 600;
  color: #b45309;
  margin-left: 2px;
}
.audit-step-fb-comment {
  font-size: 12.5px;
  font-style: italic;
  color: #78350f;
  background: rgba(255,255,255,0.70);
  border: 1px solid #fde68a;
  border-radius: 7px;
  padding: 7px 11px;
  line-height: 1.55;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.audit-step-fb-comment .fa-quote-left {
  font-size: 9px;
  opacity: 0.50;
  margin-top: 3px;
  flex-shrink: 0;
}
.audit-step-fb-no-comment {
  font-size: 11px;
  font-style: italic;
  color: #a16207;
  opacity: 0.60;
}

/* ═══════════════════════════════════════════════════════════
   AUDIT VARIABLES — Variables tab
   ═══════════════════════════════════════════════════════════ */
.audit-var-group {
  margin-bottom: 18px;
}
.audit-var-group-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f3f4f6;
}
.audit-var-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: #f3f4f6;
  color: #6b7280;
  padding: 1px 7px;
  border-radius: 100px;
}
.audit-var-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.audit-var-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}
.audit-var-row:hover {
  background: #f0f4ff;
  border-color: #c7d2fe;
}
.audit-var-row:hover .audit-var-copy { opacity: 1; }
.audit-var-row-copied {
  background: #f0fdf4 !important;
  border-color: #86efac !important;
}
.audit-var-key {
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  color: #6366f1;
  flex-shrink: 0;
  white-space: nowrap;
}
.audit-var-eq {
  color: #d1d5db;
  font-size: 14px;
  flex-shrink: 0;
}
.audit-var-val {
  font-size: 13px;
  color: #111827;
  flex: 1;
  min-width: 0;
  word-break: break-all;
}
.audit-var-val-long {
  font-size: 12px;
  color: #374151;
  font-style: italic;
}
.audit-var-copy {
  flex-shrink: 0;
  opacity: 0;
  background: transparent;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  color: #6b7280;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.audit-var-copy:hover { background: #e0e7ff; color: #4f46e5; border-color: #c7d2fe; }

.audit-var-export {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f3f4f6;
}
.audit-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.audit-export-btn:hover { background: #e0e7ff; border-color: #c7d2fe; color: #4f46e5; }
.audit-var-total {
  font-size: 12px;
  color: #9ca3af;
  margin-left: auto;
}

/* legacy — still used in path/transcript */
.conv-detail-section { margin-bottom: 20px; }
.conv-detail-section h4 {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: #6b7280; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
/* old path styles kept for safety */
.conv-path-list { display: flex; flex-direction: column; gap: 6px; }
.conv-path-step {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 12px; background: #f9fafb;
  border-radius: 8px; border: 1px solid #f3f4f6;
}
.conv-path-num {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.conv-path-title { font-size: 13px; font-weight: 600; color: #111827; }
.conv-path-type  { font-size: 11px; color: #9ca3af; margin-top: 1px; }
.conv-path-answer{ font-size: 12px; color: #6b7280; font-style: italic; margin-top: 3px; }
.conv-vars-table { display: flex; flex-direction: column; gap: 4px; }
.conv-var-row-detail {
  display: flex; align-items: baseline; gap: 8px;
  padding: 6px 12px; background: #f5f3ff;
  border-radius: 6px; border: 1px solid #ede9fe;
}
.conv-var-key   { font-family: monospace; font-size: 12px; color: #7c3aed; font-weight: 600; flex-shrink: 0; }
.conv-var-eq    { color: #9ca3af; font-size: 13px; }
.conv-var-value { font-size: 12px; color: #374151; word-break: break-word; }

/* ============================================================
   CATEGORY SYSTEM
   ============================================================ */

/* ── Dashboard two-column layout ── */
.dash-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.dash-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;   /* clip horizontal; vertical scroll lives in #flows-grid child */
  min-width: 0;
}

/* flows-grid must be able to scroll — ensure it fills remaining height */
.dash-main #flows-grid {
  flex: 1;
  min-height: 0;      /* critical: allows flex child to shrink below content height */
  overflow-y: auto;
}

/* ── Category Sidebar ── */
.cat-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cat-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.cat-sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.cat-add-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: white;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  transition: all 0.15s;
}
.cat-add-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.cat-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cat-nav-divider {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 10px 8px 4px;
  opacity: 0.7;
}

.cat-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
  font-family: var(--font);
}

.cat-nav-item:hover { background: #f3f4f6; }
.cat-nav-item.active { background: #eef2ff; }
.cat-nav-item.active .cni-label { color: var(--primary); font-weight: 600; }

.cni-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.cni-label {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cni-count {
  font-size: 11px;
  color: var(--text-muted);
  background: #f3f4f6;
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 600;
  flex-shrink: 0;
}

.cat-nav-item.active .cni-count {
  background: #c7d2fe;
  color: #4338ca;
}

/* ── Category content header ── */
.cat-content-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 32px;
  background: white;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.cat-content-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.cat-content-info { flex: 1; min-width: 0; }

.cat-content-info h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.cat-content-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.cat-content-actions {
  display: flex;
  gap: 6px;
}

.cat-edit-btn, .cat-delete-btn {
  font-size: 12px;
  padding: 5px 10px;
}

.cat-delete-btn:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* ── Category modal swatches ── */
.cat-swatch {
  width: 24px; height: 24px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
  display: inline-block;
}
.cat-swatch:hover { transform: scale(1.15); }
.cat-swatch.active { border-color: #111; transform: scale(1.2); }

/* ── Adjust flows-grid padding inside dash-main ── */
.dash-main .flows-grid {
  padding: 20px 24px 40px;
}
.dash-main .dash-toolbar {
  padding: 12px 24px;
}

/* ============================================================
   SESSION NODES  — Start Session + End Session
   ============================================================ */

/* Palette swatches */
.pi-emerald { background: #d1fae5; color: #059669; }
.pi-rose    { background: #fee2e2; color: #dc2626; }

/* Node header strips */
.node-type-startsession .node-hdr { background: #059669; }
.node-type-endsession   .node-hdr { background: #dc2626; }

/* Canvas info block */
.node-session-info {
  margin: 0 10px 6px;
  padding: 6px 10px;
  border-radius: var(--r-xs);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.node-session-start {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
}
.node-session-end {
  background: #fef2f2;
  border: 1px solid #fca5a5;
}
.nsi-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
}
.node-session-start .nsi-row { color: #065f46; }
.node-session-end   .nsi-row { color: #991b1b; }
.nsi-row i { font-size: 10px; flex-shrink: 0; }

/* ── AI node canvas body ── */
.node-ai-info {
  margin: 0 10px 6px;
  padding: 6px 10px;
  border-radius: var(--r-xs);
  background: #f5f3ff;
  border: 1px solid #c4b5fd;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.node-ai-info .nsi-row { color: #5b21b6; }
.node-ai-info .nsi-row code { background: #ede9fe; color: #7c3aed; border-radius: 3px; padding: 0 3px; font-size: 10px; }

/* AI model badge in editor header */
.ai-model-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: #ede9fe;
  color: #7c3aed;
  padding: 2px 8px;
  border-radius: 100px;
  white-space: nowrap;
}

/* ── Feedback node canvas body ── */
.node-feedback-info {
  margin: 0 10px 6px;
  padding: 6px 10px;
  border-radius: var(--r-xs);
  background: #fffbeb;
  border: 1px solid #fcd34d;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.node-feedback-info .nsi-row { color: #92400e; }

/* Editor — session var list rows */
.sv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}
.sv-row {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid #d1fae5;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: white;
}
.sv-brace {
  padding: 7px 7px;
  background: #ecfdf5;
  color: #059669;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  border-right: 1.5px solid #d1fae5;
}
.sv-brace:last-of-type {
  border-right: none;
  border-left: 1.5px solid #d1fae5;
}
.sv-input {
  flex: 1;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  font-size: 13px;
}
.sv-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 8px;
  font-size: 12px;
  transition: color 0.15s;
}
.sv-remove:hover { color: var(--danger, #ef4444); }

/* End session — red-tinted var row */
#ed-es-vars-list .sv-row          { border-color: #fee2e2; }
#ed-es-vars-list .sv-brace        { background: #fef2f2; color: #dc2626; border-color: #fee2e2; }
#ed-es-vars-list .sv-brace:last-of-type { border-color: #fee2e2; }

/* Toggle checkbox row */
.ss-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.ss-toggle-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: #059669;
  cursor: pointer;
  flex-shrink: 0;
}
.ss-toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

/* Add-var / add-mapping buttons — session tint */
.rpf-add-btn-session {
  background: #d1fae5;
  color: #059669;
  border-color: #6ee7b7;
}
.rpf-add-btn-session:hover { background: #a7f3d0; }
.rpf-add-btn-session-end {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}
.rpf-add-btn-session-end:hover { background: #fecaca; }

/* ── Chat UI session status badge ── */
.session-active-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 10px 0 4px 38px;
  max-width: 420px;
  background: rgba(5,150,105,0.1);
  border: 1px solid rgba(5,150,105,0.3);
  border-radius: 12px;
  font-size: 12px;
  color: #34d399;
  font-weight: 500;
}
.session-active-bar i { font-size: 11px; flex-shrink: 0; }
.session-ended-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 10px 0 4px 38px;
  max-width: 420px;
  background: rgba(220,38,38,0.08);
  border: 1px solid rgba(220,38,38,0.25);
  border-radius: 12px;
  font-size: 12px;
  color: #f87171;
  font-weight: 500;
}
.session-ended-bar i { font-size: 11px; flex-shrink: 0; }
.session-auth-fail {
  margin: 4px 0 4px 38px;
  padding: 10px 14px;
  max-width: 420px;
  background: rgba(220,38,38,0.08);
  border: 1px solid rgba(220,38,38,0.25);
  border-radius: 12px;
  font-size: 13px;
  color: #f87171;
}

@media (max-width: 600px) {
  .session-active-bar, .session-ended-bar,
  .session-auth-fail { margin-left: 4px; max-width: 100%; }
}

/* ============================================================
   CATEGORY FLOW NODE  — canvas card + palette + editor
   ============================================================ */

/* Palette colour swatch */
.pi-violet { background: #ede9fe; color: #7c3aed; }

/* Node header strip */
.node-type-catflow .node-hdr { background: #7c3aed; }

/* Canvas pill */
.node-catflow-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px 6px;
  padding: 5px 10px;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: var(--r-xs);
  font-size: 11.5px;
  font-weight: 600;
  color: #6d28d9;
}

/* Canvas flows preview (shows up to 3 flow names) */
.node-catflow-preview {
  margin: 0 10px 6px;
  padding: 6px 8px;
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: var(--r-xs);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.node-catflow-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #6d28d9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-catflow-more {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 2px;
  padding-left: 13px;
}

/* Editor panel — flows preview list */
.catflow-flows-preview {
  background: #faf5ff;
  border: 1.5px solid #e9d5ff;
  border-radius: var(--r-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 200px;
  overflow-y: auto;
}
.catflow-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
}
.cfpr-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ede9fe;
  color: #6d28d9;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cfpr-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfpr-status {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 100px;
  flex-shrink: 0;
}
.cfpr-active { background: #dcfce7; color: #166534; }
.cfpr-draft  { background: #f1f5f9; color: #64748b; }

/* Chat UI — category menu choice buttons */
.cat-flow-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 4px 4px 38px;
  max-width: 680px;
}
.cat-flow-btn {
  background: var(--surface, #1a1a24);
  border: 1.5px solid #7c3aed55;
  color: var(--text, #f1f1f5);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  width: 100%;
  transition: all 0.2s;
  min-height: 44px;
}
.cat-flow-btn:hover {
  border-color: #7c3aed;
  background: color-mix(in srgb, #7c3aed 12%, var(--surface, #1a1a24));
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(124,58,237,0.2);
}
.cat-flow-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.cfb-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: #7c3aed22;
  color: #a78bfa;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.cfb-info { flex: 1; min-width: 0; }
.cfb-name { font-weight: 600; font-size: 13.5px; }
.cfb-desc { font-size: 11.5px; color: var(--text-muted, #8b8ba0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfb-arrow { color: #7c3aed88; font-size: 11px; flex-shrink: 0; }

@media (max-width: 600px) {
  .cat-flow-menu { padding: 4px 2px 4px 4px; }
  .cat-flow-btn  { padding: 10px 12px; font-size: 13px; border-radius: 12px; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {
  .right-panel { width: 360px; }
  .node-palette { width: 180px; }
  .cat-sidebar { width: 190px; }
}

@media (max-width: 860px) {
  .right-panel.collapsed { display: flex; width: 0; opacity: 0; }
  .conv-detail-meta-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-sidebar { width: 52px; }
  .cni-label, .cni-count, .cat-nav-divider, .cat-sidebar-title { display: none; }
  .cat-add-btn { width: 100%; justify-content: center; }
  .cat-sidebar-head { justify-content: center; }
  .cni-icon { width: 34px; height: 34px; }
}

/* ============================================================
   FLOW CARD — CATEGORY PILL (clickable, opens move picker)
   ============================================================ */
.fc-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid;
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fc-cat-pill:hover {
  filter: brightness(0.92);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ============================================================
   MOVE-TO-CATEGORY POPOVER
   ============================================================ */
.cat-picker-pop {
  position: fixed;
  z-index: 9999;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  min-width: 220px;
  max-width: 260px;
  padding: 6px;
  animation: cpp-pop-in 0.15s cubic-bezier(0.175,0.885,0.32,1.275);
}
@keyframes cpp-pop-in {
  from { opacity: 0; transform: scale(0.92) translateY(-6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.cpp-header {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 10px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cpp-divider {
  height: 1px;
  background: #f3f4f6;
  margin: 4px 0;
}
.cpp-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  color: #374151;
  text-align: left;
  transition: background 0.1s;
  position: relative;
}
.cpp-row:hover { background: #f5f3ff; color: #4f46e5; }
.cpp-row-current { background: #eef2ff; color: #4f46e5; font-weight: 600; }
.cpp-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.cpp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpp-check {
  font-size: 11px;
  color: #6366f1;
  margin-left: auto;
  flex-shrink: 0;
}

/* ============================================================
   FLOW PROPERTIES MODAL — textarea
   ============================================================ */
#fp-description {
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: var(--r-xs);
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text-1);
  background: white;
  width: 100%;
  transition: border-color 0.15s;
}
#fp-description:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

/* ============================================================
   KNOWLEDGE BASE — Full View
   ============================================================ */

/* Page wrapper */
.kb-wrap {
  padding: 28px 32px 60px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  min-height: 0;        /* allows flex child to shrink and trigger parent scroll */
  box-sizing: border-box;
}

/* Page header */
.kb-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.kb-page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}
.kb-page-header p {
  font-size: 13.5px;
  color: #64748b;
  line-height: 1.5;
}

/* Tab bar */
.kb-tab-bar {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 4px;
}
.kb-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}
.kb-tab-btn.active {
  background: white;
  color: #6366f1;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.kb-tab-btn:hover:not(.active) { background: #e2e8f0; color: #374151; }

/* Stats */
.kb-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.kb-stat {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 20px;
  min-width: 110px;
  text-align: center;
}
.kb-stat span {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: #6366f1;
  line-height: 1;
  margin-bottom: 4px;
}
.kb-stat label {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}

/* Toolbar */
.kb-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* Empty state */
.kb-empty {
  text-align: center;
  padding: 60px 32px;
  color: #9ca3af;
  grid-column: 1 / -1;
}
.kb-empty i { font-size: 40px; margin-bottom: 14px; color: #d1d5db; }
.kb-empty h3 { font-size: 16px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.kb-empty p { font-size: 13.5px; color: #6b7280; line-height: 1.6; }

/* ── Article Help-Center layout: category sidebar + grouped link list ── */
.kb-art-layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  margin-top: 18px;
}

.kb-art-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 0;
  position: sticky;
  top: 0;
}
.kb-art-sidebar-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 16px 10px;
}
.kb-art-cat-nav { display: flex; flex-direction: column; }
.kb-art-cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
}
.kb-art-cat-item:hover { background: #f9fafb; }
.kb-art-cat-item.active {
  background: #eef2ff;
  color: #4f46e5;
  border-left-color: #6366f1;
}
.kb-art-cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-art-cat-count {
  flex-shrink: 0;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
}
.kb-art-cat-item.active .kb-art-cat-count { background: #c7d2fe; color: #4338ca; }

.kb-art-main { flex: 1; min-width: 0; }

/* ── Article grid (grouped by category, help-center style) ── */
.kb-articles-grid {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* Category section heading — underlined, like a help-center page title */
.kb-art-section-title {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 2px solid #111827;
  display: inline-block;
}

/* Multi-column grid of simple, scannable article links (Skyetel-style) */
.kb-art-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px 40px;
}
.kb-art-link-col { display: flex; flex-direction: column; gap: 2px; }
.kb-art-link-col-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}
.kb-art-link-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
}
.kb-art-link {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: #4f46e5;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  transition: color .12s;
}
.kb-art-link:hover { color: #3730a3; text-decoration: underline; }
.kb-art-link i.kb-art-link-icon { font-size: 11px; color: #f43f5e; flex-shrink: 0; }
.kb-art-link-status {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 20px;
  flex-shrink: 0;
}
.kb-art-link-status.kb-status-draft { background: #fef3c7; color: #92400e; }
.kb-art-link-row .kb-art-link-actions {
  display: none;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
}
.kb-art-link-row:hover .kb-art-link-actions { display: flex; }
.kb-art-link-actions .kb-icon-btn { width: 22px; height: 22px; font-size: 10.5px; }

.kb-art-see-all {
  font-size: 12.5px;
  font-weight: 600;
  color: #6b7280;
  margin-top: 4px;
  cursor: pointer;
}
.kb-art-see-all:hover { color: #374151; text-decoration: underline; }

@media (max-width: 860px) {
  .kb-art-layout { flex-direction: column; }
  .kb-art-sidebar { width: 100%; position: static; }
  .kb-art-cat-nav { flex-direction: row; flex-wrap: wrap; }
  .kb-art-cat-item { border-left: none; border-bottom: 3px solid transparent; }
  .kb-art-cat-item.active { border-bottom-color: #6366f1; }
}

.kb-cat-group { }
.kb-cat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #94a3b8;
  margin-bottom: 10px;
}
.kb-cat-count {
  background: #e2e8f0;
  color: #64748b;
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
}
.kb-articles-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

/* ── Article card ── */
.kb-article-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.kb-article-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 4px 14px rgba(99,102,241,0.08);
}

.kb-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kb-card-status {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.kb-status-pub   { background: #dcfce7; color: #166534; }
.kb-status-draft { background: #fef3c7; color: #92400e; }

.kb-card-actions { display: flex; gap: 4px; }
.kb-icon-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.kb-icon-btn:hover { background: #f1f5f9; color: #374151; border-color: #cbd5e1; }
.kb-icon-danger:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

.kb-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  line-height: 1.4;
}
.kb-card-excerpt {
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.kb-tag {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 20px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.kb-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}
.kb-flow-link {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; color: #6366f1;
  background: #eef2ff; border: 1px solid #c7d2fe;
  border-radius: 6px; padding: 3px 9px;
  cursor: pointer; font-family: var(--font);
  transition: all 0.15s;
}
.kb-flow-link:hover { background: #e0e7ff; }
.kb-no-flow { font-size: 11px; color: #9ca3af; display: flex; align-items: center; gap: 4px; }
.kb-card-views { font-size: 11px; color: #9ca3af; display: flex; align-items: center; gap: 4px; }

/* ── API Integration Cards ── */
.kb-integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 16px;
}

.int-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--int-color, #6366f1);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.15s;
}
.int-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.int-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.int-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.int-info { flex: 1; }
.int-name { font-size: 15px; font-weight: 700; color: #111827; margin-bottom: 2px; }
.int-desc { font-size: 12.5px; color: #64748b; }
.int-badges { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

.int-status-badge, .int-test-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.int-status-active   { background: #dcfce7; color: #166534; }
.int-status-inactive { background: #f1f5f9; color: #64748b; }
.int-test-ok         { background: #dcfce7; color: #166534; }
.int-test-error      { background: #fee2e2; color: #dc2626; }
.int-test-none       { background: #f1f5f9; color: #94a3b8; }

.int-url-row, .int-auth-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: #475569;
  background: #f8fafc;
  border-radius: 7px;
  padding: 7px 10px;
}
.int-url-icon, .int-auth-icon { color: #94a3b8; font-size: 13px; flex-shrink: 0; }
.int-base-url { font-family: monospace; font-size: 12px; color: #1e40af; word-break: break-all; flex: 1; }
.int-auth-label { font-weight: 600; color: #374151; }
.int-header-name { font-family: monospace; font-size: 11px; color: #7c3aed; }

/* Endpoint list in card */
.int-endpoints { }
.int-ep-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-bottom: 6px;
}
.int-ep-list { display: flex; flex-direction: column; gap: 4px; }
.int-ep-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}
.int-ep-method {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  text-transform: uppercase; font-family: monospace; flex-shrink: 0;
}
.method-get    { background: #dcfce7; color: #166534; }
.method-post   { background: #dbeafe; color: #1e40af; }
.method-put    { background: #fef3c7; color: #92400e; }
.method-patch  { background: #fce7f3; color: #9d174d; }
.method-delete { background: #fee2e2; color: #dc2626; }

.int-ep-path { font-family: monospace; font-size: 11.5px; color: #1e293b; flex: 1; }
.int-ep-desc { font-size: 11px; color: #94a3b8; flex-shrink: 0; }
.int-ep-more { font-size: 11px; color: #94a3b8; font-style: italic; text-align: right; }

.int-card-footer {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}
.int-btn { font-size: 12px; padding: 5px 10px; }
.int-btn-danger:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* ── How-to guide ── */
.int-how-to {
  display: flex;
  align-items: center;
  gap: 0;
  background: linear-gradient(135deg, #f8fafc, #f0f4ff);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}
.int-how-step {
  display: flex; align-items: flex-start; gap: 10px;
  flex: 1; min-width: 160px;
}
.int-how-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #6366f1;
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.int-how-step strong { font-size: 13px; font-weight: 600; color: #1e293b; }
.int-how-step span   { font-size: 12px; color: #64748b; line-height: 1.4; }
.int-how-arrow { color: #c7d2fe; font-size: 16px; align-self: center; padding: 0 4px; }

/* ── Endpoint editor list ── */
.kbi-endpoints-list { display: flex; flex-direction: column; gap: 6px; }
.ep-empty {
  padding: 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px dashed #e2e8f0;
}
.ep-row {
  display: flex; flex-direction: column; gap: 0;
  border: 1px solid #e2e8f0; border-radius: 10px;
  overflow: hidden; margin-bottom: 6px;
}
.ep-row-top {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  background: #f8fafc;
}
.ep-method { width: 90px; flex-shrink: 0; font-size: 12.5px; }
.ep-path   { flex: 2; font-size: 12.5px; }
.ep-name   { flex: 1; font-size: 12.5px; }

/* Body sub-row (POST/PUT/PATCH) */
.ep-body-row {
  border-top: 1px solid #e2e8f0;
  padding: 8px 10px;
  background: #fff;
}
.ep-body-label {
  font-size: 11.5px; font-weight: 600; color: #475569;
  margin-bottom: 5px; display: flex; align-items: center; gap: 6px;
}
.ep-body-label i { color: #6366f1; }
.ep-body-hint { font-weight: 400; color: #94a3b8; font-size: 11px; }
.ep-body { font-size: 11.5px !important; width: 100%; resize: vertical; }

/* ── KB Modal backdrop ── */
.kb-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  z-index: 8000;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}
.kb-modal-backdrop.open { display: flex; }

.kb-modal {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  width: 100%;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 64px);
  overflow: hidden;
}
.kb-article-modal-content { max-width: 960px; }
.kb-int-modal-content     { max-width: 900px; }
.kb-test-modal-content    { max-width: 620px; }

.kb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.kb-modal-header h2 { font-size: 17px; font-weight: 700; color: #111827; }
.kb-modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: white;
  color: #64748b;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.kb-modal-close:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

.kb-modal-body {
  overflow-y: auto;
  flex: 1;
}

.kb-modal-cols {
  display: flex;
  gap: 0;
  min-height: 0;
}
.kb-modal-main {
  flex: 1;
  padding: 20px 20px 20px 24px;
  min-width: 0;
  border-right: 1px solid #e2e8f0;
}
.kb-modal-sidebar {
  width: 260px;
  flex-shrink: 0;
  padding: 20px 20px 20px 18px;
  background: #fafbfc;
}

.kb-content-area {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.65;
  min-height: 300px;
}

.kb-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
  background: #fafbfc;
}

/* required marker */
.req { color: #ef4444; margin-left: 2px; }

/* API reference box in sidebar */
.kb-api-ref-box {
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 12px 14px;
}
.kb-api-ref-title {
  font-size: 12px;
  font-weight: 700;
  color: #4f46e5;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.kb-api-ref-box p {
  font-size: 12px;
  color: #475569;
  line-height: 1.5;
  margin-bottom: 8px;
}
.kb-api-ref-box code {
  background: #e0e7ff;
  color: #4338ca;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}
.kb-var-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.kb-var-chip {
  font-family: monospace;
  font-size: 10.5px;
  padding: 2px 7px;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 4px;
  border: 1px solid #c7d2fe;
}

/* ── Test modal body row ── */
#kbt-body-row label {
  font-size: 13px; font-weight: 500; color: #374151;
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-bottom: 6px;
}
#kbt-req-body {
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  resize: vertical;
  min-height: 110px;
  line-height: 1.6;
}
#kbt-req-body::placeholder { color: #475569; }
#kbt-method-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  text-transform: uppercase;
  font-family: monospace;
}

/* ── Test modal ── */
.kbt-url-display {
  display: block;
  font-family: monospace;
  font-size: 12px;
  color: #1e40af;
  background: #dbeafe;
  border-radius: 6px;
  padding: 6px 10px;
  word-break: break-all;
}
.kbt-result { margin-top: 14px; }
.kbt-testing { padding: 16px; text-align: center; color: #64748b; font-size: 13px; }
.kbt-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 10px;
}
.kbt-ok  { background: #dcfce7; color: #166534; }
.kbt-err { background: #fee2e2; color: #991b1b; }
.kbt-body {
  background: #1e293b;
  color: #a5f3fc;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.65;
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  max-height: 340px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ============================================================
   API COLLECTION UI  (sb-api-collection.js)
   ============================================================ */

/* ── Full-bleed layout inside KB wrap ── */
#kb-integrations-panel {
  /* Escape the kb-wrap padding so the collection UI can fill edge-to-edge */
  margin: -28px -32px -60px;
  height: calc(100vh - 180px);
  min-height: 500px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid #e5e7eb;
}

/* ── Layout: sidebar + editor ── */
.apc-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
  overflow: hidden;
}

/* ── Sidebar / Collection Tree ── */
.apc-sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  background: #f9fafb;
  min-height: 0;
  overflow: hidden;
}
.apc-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.apc-sidebar-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 6px;
}
.apc-collection-tree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 20px;
}
.apc-tree-empty {
  padding: 24px 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.7;
}
.apc-tree-empty i { font-size: 22px; display: block; margin-bottom: 8px; color: #d1d5db; }

/* ── Collection item ── */
.apc-col-item { border-bottom: 1px solid #f3f4f6; }
.apc-col-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.apc-col-header:hover { background: #f3f4f6; }
.apc-col-item.active > .apc-col-header { background: #eef2ff; }
.apc-col-chevron {
  width: 14px;
  color: #9ca3af;
  font-size: 10px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.apc-col-item.open > .apc-col-header .apc-col-chevron { transform: rotate(90deg); }
.apc-col-icon {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.apc-col-name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apc-col-count {
  font-size: 10px;
  font-weight: 700;
  background: #e5e7eb;
  color: #6b7280;
  border-radius: 100px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.apc-col-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.apc-col-header:hover .apc-col-actions,
.apc-req-item:hover .apc-col-actions { opacity: 1; }

/* ── Request items ── */
.apc-req-list { padding: 2px 0 4px 16px; }
.apc-req-empty {
  font-size: 11px;
  color: #9ca3af;
  padding: 6px 12px;
  font-style: italic;
}
.apc-req-empty i { color: #d1d5db; }
.apc-req-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  margin: 1px 4px;
  transition: background 0.12s;
}
.apc-req-item:hover { background: #f3f4f6; }
.apc-req-item.active { background: #eef2ff; }
.apc-req-method {
  font-size: 10px;
  font-weight: 800;
  font-family: monospace;
  width: 42px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.apc-req-name {
  flex: 1;
  font-size: 12px;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Tree action buttons ── */
.apc-tree-btn {
  width: 22px; height: 22px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  transition: background 0.12s, color 0.12s;
}
.apc-tree-btn:hover { background: #e5e7eb; color: #374151; }
.apc-tree-del { color: #fca5a5; }
.apc-tree-del:hover { background: #fee2e2 !important; color: #ef4444 !important; }

/* ── Icon button (reusable) ── */
.apc-icon-btn {
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  white-space: nowrap;
}
.apc-icon-btn:hover { border-color: #6366f1; color: #6366f1; background: #eef2ff; }
.apc-danger-btn:hover { border-color: #ef4444 !important; color: #ef4444 !important; background: #fef2f2 !important; }

/* ── Editor panel ── */
.apc-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: #fff;
}

/* ── Empty state ── */
.apc-editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
}
.apc-empty-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: #eef2ff;
  color: #6366f1;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.apc-editor-empty h3 {
  font-size: 18px; font-weight: 700; color: #111827; margin-bottom: 8px;
}
.apc-editor-empty p {
  font-size: 13px; color: #6b7280; max-width: 360px; line-height: 1.6; margin-bottom: 20px;
}
.apc-empty-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  width: 100%;
  text-align: left;
}
.apc-empty-step {
  font-size: 12.5px;
  color: #6b7280;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #f3f4f6;
}
.apc-empty-step span {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.apc-empty-step code { background: #f3f4f6; border-radius: 4px; padding: 1px 5px; font-size: 11px; color: #7c3aed; }

/* ── Request pane ── */
.apc-request-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Request header ── */
.apc-req-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #f3f4f6;
  background: #f9fafb;
  flex-shrink: 0;
}
.apc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #9ca3af;
}
.apc-breadcrumb span:last-child { color: #374151; font-weight: 600; }
.apc-req-actions { display: flex; gap: 6px; }

/* ── URL Bar ── */
.apc-url-bar {
  padding: 10px 16px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.apc-req-name-input {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  border: none;
  outline: none;
  background: transparent;
  padding: 0;
  width: 100%;
}
.apc-req-name-input::placeholder { color: #d1d5db; }
.apc-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 4px 6px;
  transition: border-color 0.15s;
}
.apc-url-row:focus-within { border-color: #6366f1; background: #fff; }
.apc-method-sel {
  padding: 5px 10px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  color: #6366f1;
  cursor: pointer;
  outline: none;
  min-width: 72px;
}
.apc-url-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  overflow: hidden;
}
.apc-base-url-prefix {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.apc-path-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  color: #111827;
  outline: none;
  font-family: 'Fira Code', monospace;
  min-width: 60px;
}
.apc-send-btn {
  padding: 7px 16px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: background 0.15s;
}
.apc-send-btn:hover:not(:disabled) { background: #4f46e5; }
.apc-send-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Editor Tabs ── */
.apc-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 16px 0;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  overflow-x: auto;
}
.apc-tab {
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.apc-tab:hover { color: #374151; }
.apc-tab.active { color: #6366f1; border-bottom-color: #6366f1; font-weight: 600; }
.apc-tab-response.active { color: #10b981; border-bottom-color: #10b981; }
.apc-tab-ai.active { color: #7c3aed; border-bottom-color: #7c3aed; }

/* ── Tab panels ── */
.apc-tab-panels {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.apc-tab-panel {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── KV list ── */
.apc-kv-header {
  display: grid;
  grid-template-columns: 1fr 1fr 28px;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  padding: 0 2px 4px;
}
.apc-kv-list { display: flex; flex-direction: column; gap: 6px; }
.apc-kv-row {
  display: grid;
  grid-template-columns: 1fr 1fr 28px;
  gap: 8px;
  align-items: center;
}
.apc-add-kv-btn {
  padding: 6px 12px;
  border: 1px dashed #d1d5db;
  background: transparent;
  border-radius: 7px;
  font-size: 12px;
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  align-self: flex-start;
}
.apc-add-kv-btn:hover { border-color: #6366f1; color: #6366f1; background: #eef2ff; }

/* ── Shared inputs ── */
.apc-input {
  padding: 7px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  font-size: 12.5px;
  color: #111827;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.apc-input:focus { border-color: #6366f1; }
.apc-select {
  padding: 7px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  font-size: 12.5px;
  color: #111827;
  background: #fff;
  outline: none;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}
.apc-field { display: flex; flex-direction: column; gap: 5px; }
.apc-field label { font-size: 11.5px; font-weight: 600; color: #374151; }
.apc-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Hint text ── */
.apc-hint {
  font-size: 11.5px;
  color: #9ca3af;
  line-height: 1.5;
}
.apc-hint code { background: #f3f4f6; border-radius: 4px; padding: 1px 5px; font-size: 11px; color: #7c3aed; }

/* ── Body tab ── */
.apc-body-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.apc-body-label { font-size: 12px; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: 0.5px; }
.apc-code-area {
  font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
  font-size: 12.5px;
  line-height: 1.6;
  background: #0f172a;
  color: #a5f3fc;
  border: 1px solid #1e3a5f;
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 200px;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}
.apc-code-area:focus { border-color: #6366f1; }
.apc-code-area::placeholder { color: #334155; }

/* ── Auth tab ── */
.apc-auth-inherit { margin-bottom: 12px; }
.apc-auth-inherit-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #065f46;
}

/* ── Response panel ── */
.apc-response-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: #9ca3af;
  gap: 10px;
}
.apc-response-empty i { font-size: 28px; color: #d1d5db; }
.apc-response-empty p { font-size: 13px; line-height: 1.5; }
.apc-response-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.apc-status-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 100px;
}
.status-ok   { background: #dcfce7; color: #166534; }
.status-warn { background: #fef3c7; color: #92400e; }
.status-error{ background: #fee2e2; color: #991b1b; }
.apc-res-time, .apc-res-size { font-size: 11px; color: #9ca3af; font-weight: 500; }
.apc-response-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 10px;
  border-bottom: 1px solid #f3f4f6;
}
.apc-res-tab {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
}
.apc-res-tab:hover { color: #374151; }
.apc-res-tab.active { color: #6366f1; border-bottom-color: #6366f1; font-weight: 600; }
.apc-res-pre {
  font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.65;
  background: #0f172a;
  border-radius: 10px;
  padding: 14px 16px;
  max-height: 380px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: #94a3b8;
}
/* JSON syntax highlighting */
.apc-res-pre .json-key  { color: #38bdf8; }
.apc-res-pre .json-str  { color: #86efac; }
.apc-res-pre .json-num  { color: #fb923c; }
.apc-res-pre .json-bool { color: #c084fc; }
.apc-res-pre .json-null { color: #9ca3af; }
.apc-res-headers-list { display: flex; flex-direction: column; gap: 4px; }
.apc-res-hdr-row {
  display: flex;
  gap: 10px;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
}
.apc-res-hdr-key { color: #6366f1; font-weight: 600; font-family: monospace; flex-shrink: 0; }
.apc-res-hdr-val { color: #374151; word-break: break-all; }

/* ── AI & MCP tab ── */
.apc-ai-section {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.apc-ai-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.apc-ai-section-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.apc-ai-section-header p {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
  max-width: 500px;
}
.apc-ai-btn {
  padding: 7px 14px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.apc-ai-btn:hover:not(:disabled) { opacity: 0.88; }
.apc-ai-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.apc-purpose-area {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: #374151;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 120px;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}
.apc-purpose-area:focus { border-color: #6366f1; }
.apc-purpose-area::placeholder { color: #9ca3af; }

/* ── Outcome mapping ── */
.apc-outcome-map-list { display: flex; flex-direction: column; gap: 10px; }
.apc-outcome-empty {
  font-size: 12px;
  color: #9ca3af;
  padding: 14px;
  text-align: center;
  border: 1px dashed #e5e7eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.apc-outcome-rule {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.apc-or-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.apc-or-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.apc-or-node { width: 110px; flex-shrink: 0; font-weight: 700; }
.apc-or-label { flex: 1; min-width: 100px; }
.apc-or-conditions { padding-left: 4px; }
.apc-or-cond-header {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 28px;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  padding: 0 2px 4px;
}
.apc-cond-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 28px;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.apc-cond-field { font-family: monospace; }

/* ── MCP preview ── */
.apc-mcp-pre {
  font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
  font-size: 11.5px;
  line-height: 1.65;
  background: #0f172a;
  color: #94a3b8;
  border-radius: 10px;
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 280px;
  overflow-y: auto;
}

/* ── Save bar ── */
.apc-save-bar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid #f3f4f6;
  background: #f9fafb;
  flex-shrink: 0;
}
#apc-save-indicator { font-size: 12px; font-weight: 500; }

/* ── Collection modal ── */
.apc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.apc-modal {
  background: #fff;
  border-radius: 16px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
}
.apc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.apc-modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}
.apc-modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.apc-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Responsive ── */
@media (max-width: 800px) {
  .apc-layout { flex-direction: column; }
  .apc-sidebar { width: 100%; height: 200px; border-right: none; border-bottom: 1px solid #e5e7eb; }
  .apc-base-url-prefix { display: none; }
  .apc-kv-row, .apc-cond-row { grid-template-columns: 1fr 28px; }
  .apc-kv-row .apc-kv-val, .apc-cond-row .apc-cond-op, .apc-cond-row .apc-cond-val { display: none; }
  .apc-field-row { grid-template-columns: 1fr; }
}

/* ============================================================
   SETTINGS VIEW
   ============================================================ */

#view-settings {
  overflow-y: auto;
  background: var(--canvas-bg);
}

.settings-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 36px 32px 60px;
}

/* ── Page header ── */
.settings-header {
  margin-bottom: 32px;
}

.settings-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.settings-header h1 i {
  color: var(--primary);
  font-size: 20px;
}

.settings-header p {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0;
}

/* ── Section card ── */
.settings-section {
  background: white;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--card-shadow);
}

.settings-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 18px;
  border-bottom: 1px solid var(--panel-border);
  background: #fdfdff;
}

.settings-section-head h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.settings-section-head h2 i {
  color: var(--primary);
  font-size: 14px;
}

.settings-section-head p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
}

/* ── Category list inside settings ── */
.settings-cat-list {
  padding: 12px 0;
}

.settings-cat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 24px;
  color: var(--text-dim);
  text-align: center;
}

.settings-cat-empty i {
  font-size: 32px;
  opacity: 0.3;
}

.settings-cat-empty p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Individual category row ── */
.settings-cat-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.12s;
}

.settings-cat-row:last-child {
  border-bottom: none;
}

.settings-cat-row:hover {
  background: #fafbff;
}

.scr-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.scr-info {
  flex: 1;
  min-width: 0;
}

.scr-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scr-meta {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scr-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.settings-cat-row:hover .scr-actions {
  opacity: 1;
}

.scr-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--panel-border);
  background: white;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.scr-btn:hover {
  border-color: #c7d2fe;
  color: var(--primary);
  background: #eef2ff;
}

.scr-delete:hover {
  border-color: #fca5a5 !important;
  color: #dc2626 !important;
  background: #fef2f2 !important;
}

/* ============================================================
   SETTINGS — BOT ACCESS FORM
   ============================================================ */

/* URL row */
.sba-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sba-url-input {
  flex: 1;
  font-family: 'SFMono-Regular', Consolas, monospace !important;
  font-size: 12.5px !important;
  color: var(--text-muted) !important;
  background: #f9fafb !important;
  cursor: text;
}

.sba-copy-btn,
.sba-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
  text-decoration: none;
}

.sba-copy-btn {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}
.sba-copy-btn:hover { background: #ddd6fe; }
.sba-copy-btn.sba-copied { background: #dcfce7; color: #166534; border-color: #bbf7d0; }

.sba-open-btn {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
.sba-open-btn:hover { background: #e0f2fe; }

/* Toggle switch */
.sba-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sba-toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
  margin: 0;
}

.sba-toggle-switch input { opacity: 0; width: 0; height: 0; }

.sba-toggle-track {
  position: absolute;
  inset: 0;
  background: #e5e7eb;
  border-radius: 100px;
  transition: background 0.2s;
}

.sba-toggle-switch input:checked + .sba-toggle-track {
  background: var(--success, #10b981);
}

.sba-toggle-thumb {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.sba-toggle-switch input:checked + .sba-toggle-track .sba-toggle-thumb {
  transform: translateX(20px);
}

.sba-toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
}

.sba-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.5;
}

/* ============================================================
   CHAT MODAL  — floating popup simulator (dashboard flow cards)
   Triggered by the coral chat-bubble icon on each flow card.
   ============================================================ */

/* ── Overlay backdrop ── */
.chat-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  pointer-events: none;
}
.chat-modal-overlay.hidden { display: none; }
.chat-modal-overlay:not(.hidden) { pointer-events: all; }

/* ── Modal window ── */
.chat-modal {
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 80px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow:
    0 24px 48px rgba(0,0,0,0.18),
    0 8px 16px rgba(0,0,0,0.10),
    0 0 0 1px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cm-slide-up 0.28s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes cm-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Header ── */
.cm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--chat-accent, #6366f1);
  flex-shrink: 0;
}

.cm-avatar-wrap {
  flex-shrink: 0;
}

.cm-header .cm-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: #ffffff;
  flex-shrink: 0;
}

.cm-header-info {
  flex: 1;
  min-width: 0;
}

.cm-header-name {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.cm-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.8);
  margin-top: 2px;
}

.cm-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4ade80;
  animation: cm-pulse 2s infinite;
  flex-shrink: 0;
}
@keyframes cm-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.cm-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.cm-hdr-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.18);
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.cm-hdr-btn:hover { background: rgba(255,255,255,0.30); }

/* ── Messages area ── */
.cm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

/* Message rows */
.cm-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}
.cm-msg.bot  { flex-direction: row;  }
.cm-msg.user { flex-direction: row-reverse; }

/* Avatar inside messages (bot) */
.cm-msg.bot .cm-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--chat-accent, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
  align-self: flex-end;
}

/* Chat bubbles */
.cm-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.cm-msg.bot  .cm-bubble {
  background: #ffffff;
  color: #1e293b;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  border: 1px solid #e2e8f0;
}
.cm-msg.user .cm-bubble {
  background: var(--chat-accent, #6366f1);
  color: #ffffff;
  border-radius: 16px 4px 16px 16px;
}

/* Typing indicator */
.cm-bubble.cm-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}
.cm-bubble.cm-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: cm-bounce 1.2s infinite ease-in-out;
  display: inline-block;
}
.cm-bubble.cm-typing span:nth-child(2) { animation-delay: 0.2s; }
.cm-bubble.cm-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cm-bounce {
  0%,60%,100% { transform: translateY(0);    }
  30%          { transform: translateY(-6px); }
}

/* Choice buttons */
.cm-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 4px 36px;
}
.cm-choice-btn {
  background: #ffffff;
  border: 1.5px solid var(--chat-accent, #6366f1);
  color: var(--chat-accent, #6366f1);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.cm-choice-btn:hover:not(:disabled) {
  background: var(--chat-accent, #6366f1);
  color: #ffffff;
}
.cm-choice-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* End card */
.cm-end-card {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 14px;
  padding: 18px;
  margin: 4px 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cm-restart-btn {
  background: var(--chat-accent, #6366f1);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 7px 18px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.cm-restart-btn:hover { opacity: 0.85; }

/* ── Flow transition divider (goto_flow cross-flow jump) ── */
.cm-flow-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0 4px;
  gap: 0;
}
.cm-flow-divider span {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--chat-accent, #6366f1);
  background: color-mix(in srgb, var(--chat-accent, #6366f1) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--chat-accent, #6366f1) 28%, transparent);
  padding: 3px 11px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.2px;
  animation: cmBubbleIn 0.2s ease;
}

/* ── Text Input bar ── */
.cm-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  flex-shrink: 0;
}
.cm-input-bar.hidden { display: none; }

.cm-msg-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cm-msg-input:focus {
  border-color: var(--chat-accent, #6366f1);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
  background: #ffffff;
}
.cm-msg-input::placeholder { color: #94a3b8; }

.cm-send-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--chat-accent, #6366f1);
  border: none;
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}
.cm-send-btn:hover  { opacity: 0.88; }
.cm-send-btn:active { transform: scale(0.92); }

/* ── Flow path tracker ── */
.cm-tracker {
  flex-shrink: 0;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  font-size: 12px;
}

.cm-tracker-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  transition: color 0.15s;
}
.cm-tracker-toggle:hover { color: #374151; }
.cm-tracker-toggle i { font-size: 10px; color: #6366f1; }

.cm-tracker-chevron {
  margin-left: auto;
  font-size: 9px;
  color: #9ca3af;
  transition: transform 0.2s;
}
.cm-tracker-chevron.open { transform: rotate(180deg); }

.cm-tracker-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.cm-tracker-body.open { max-height: 180px; overflow-y: auto; }

#cm-tracker-steps {
  padding: 4px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ── Flow card chat button (the coral bubble icon) ── */
/* NOTE: This second .fc-chat-btn block overrides the one near line 679.
   We keep position:relative here so the ::after pulse ring (inset:-4px)
   stays contained and does NOT leak over neighbouring buttons (fc-edit). */
.fc-chat-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: #fee2e2;
  color: #ef4444;
  font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative;  /* REQUIRED: contains ::after pseudo overlay */
  transition: all 0.2s;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}
.fc-chat-btn:hover {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239,68,68,0.35);
  transform: scale(1.08);
}

/* ============================================================
   KB FULL-PAGE EDITOR  (#view-kb-editor)
   KB FULL-PAGE ARTICLE VIEW  (#view-kb-article)
   ============================================================ */

/* ── Shared: when active, use flex column layout ──
   NOTE: Do NOT set display:flex here — that would override
   .view { display:none } and make these always visible.
   The .view.active rule already sets display:flex.         */
#view-kb-editor.active,
#view-kb-article.active {
  flex-direction: column;
  overflow: hidden;
  background: #f8fafc;
}

.kbfp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  height: 54px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.kbfp-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.kbfp-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.kbfp-back-btn {
  font-size: 12.5px !important;
  padding: 6px 12px !important;
  gap: 6px !important;
  white-space: nowrap;
  flex-shrink: 0;
}

.kbfp-breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Editor layout: main + sidebar ── */
.kbfp-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.kbfp-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 28px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.kbfp-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid #e2e8f0;
  background: #ffffff;
  overflow-y: auto;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Field groups ── */
.kbfp-field-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.kbfp-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #374151;
  display: flex;
  align-items: baseline;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kbfp-hint {
  font-size: 11px;
  font-weight: 400;
  color: #94a3b8;
  letter-spacing: 0;
  text-transform: none;
}

/* Title input — extra large */
.kbfp-title-input {
  width: 100%;
  font-size: 22px !important;
  font-weight: 700 !important;
  color: #111827 !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 10px !important;
  padding: 12px 16px !important;
  background: #fff !important;
  transition: border-color 0.15s;
  box-sizing: border-box;
  line-height: 1.3;
}
.kbfp-title-input:focus {
  outline: none;
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.kbfp-title-input::placeholder { color: #cbd5e1; font-weight: 400; }

/* Excerpt input */
.kbfp-excerpt-input {
  width: 100%;
  font-size: 14px !important;
  color: #374151 !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  background: #fff !important;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.kbfp-excerpt-input:focus {
  outline: none;
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.kbfp-excerpt-input::placeholder { color: #cbd5e1; }

/* ── Content group with toolbar ── */
.kbfp-content-group { flex: 1; }

.kbfp-content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kbfp-content-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kbfp-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  background: white;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
}
.kbfp-toolbar-btn:hover { border-color: #6366f1; color: #6366f1; background: #eef2ff; }
.kbfp-toolbar-btn.active { background: #eef2ff; border-color: #6366f1; color: #6366f1; }

.kbfp-char-count {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}

/* Editor area: textarea + preview pane */
.kbfp-editor-area {
  display: flex;
  gap: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  min-height: 500px;
}

.kbfp-content-textarea {
  flex: 1;
  width: 100%;
  min-height: 500px;
  font-family: 'SFMono-Regular', 'Cascadia Code', 'Courier New', monospace !important;
  font-size: 13.5px !important;
  line-height: 1.75 !important;
  color: #1e293b !important;
  background: #fff !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 20px 22px !important;
  resize: none;
  outline: none;
  box-sizing: border-box;
  display: block;
}
.kbfp-content-textarea::placeholder { color: #94a3b8; }

/* Preview pane */
.kbfp-preview-pane {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  border-left: 1px solid #e2e8f0;
  background: #fafbfc;
}

.kbfp-preview-content {
  font-size: 14px;
  line-height: 1.75;
  color: #1e293b;
}
.kbfp-preview-content h1,
.kbfp-preview-content h2,
.kbfp-preview-content h3 {
  font-weight: 700;
  color: #111827;
  margin: 20px 0 8px;
  line-height: 1.3;
}
.kbfp-preview-content h1 { font-size: 20px; }
.kbfp-preview-content h2 { font-size: 17px; border-bottom: 1px solid #e5e7eb; padding-bottom: 6px; }
.kbfp-preview-content h3 { font-size: 15px; }
.kbfp-preview-content p  { margin: 0 0 12px; }
.kbfp-preview-content ul,
.kbfp-preview-content ol { padding-left: 22px; margin: 0 0 12px; }
.kbfp-preview-content li { margin-bottom: 4px; }
.kbfp-preview-content code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 12.5px;
  color: #7c3aed;
}
.kbfp-preview-content pre {
  background: #0f172a;
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin-bottom: 12px;
}
.kbfp-preview-content pre code {
  background: none;
  border: none;
  color: #a5f3fc;
  font-size: 12.5px;
}
.kbfp-preview-content strong { font-weight: 700; color: #111827; }
.kbfp-preview-content em     { font-style: italic; color: #4b5563; }
.kbfp-preview-content blockquote {
  border-left: 3px solid #6366f1;
  padding: 8px 14px;
  background: #f5f3ff;
  margin: 0 0 12px;
  border-radius: 0 6px 6px 0;
}
.kbfp-preview-content hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 20px 0;
}

/* ── Sidebar cards ── */
.kbfp-sidebar-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kbfp-sidebar-card-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.kbfp-vars-card { background: #faf5ff; border-color: #e9d5ff; }

/* ═══════════════════════════════════════════════════════
   KB ARTICLE VIEW  (#view-kb-article)  — blog-style read
   ═══════════════════════════════════════════════════════ */

.kbav-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Article body area */
.kbav-article {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 36px 48px 60px;
}

.kbav-article-header {
  max-width: 760px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
}

.kbav-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.kbav-category {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kbav-title {
  font-size: 28px;
  font-weight: 800;
  color: #111827;
  line-height: 1.3;
  margin: 0 0 12px;
  max-width: 760px;
}

.kbav-excerpt {
  font-size: 16px;
  color: #4b5563;
  line-height: 1.65;
  margin: 0 0 14px;
  max-width: 720px;
}

.kbav-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Article content — rich typography */
.kbav-content {
  max-width: 760px;
  font-size: 14.5px;
  line-height: 1.8;
  color: #1e293b;
}
.kbav-content h1,
.kbav-content h2,
.kbav-content h3,
.kbav-content h4 {
  font-weight: 700;
  color: #111827;
  margin: 28px 0 10px;
  line-height: 1.35;
}
.kbav-content h1 { font-size: 22px; }
.kbav-content h2 {
  font-size: 18px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 8px;
}
.kbav-content h3 { font-size: 16px; }
.kbav-content h4 { font-size: 14.5px; color: #374151; }
.kbav-content p  { margin: 0 0 14px; }
.kbav-content ul,
.kbav-content ol {
  padding-left: 26px;
  margin: 0 0 14px;
}
.kbav-content li { margin-bottom: 6px; }
.kbav-content code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 13px;
  color: #7c3aed;
}
.kbav-content pre {
  background: #0f172a;
  border-radius: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 0 0 16px;
}
.kbav-content pre code {
  background: none;
  border: none;
  color: #a5f3fc;
  font-size: 13px;
  padding: 0;
}
.kbav-content strong { font-weight: 700; color: #111827; }
.kbav-content em     { font-style: italic; color: #4b5563; }
.kbav-content blockquote {
  border-left: 4px solid #6366f1;
  padding: 10px 18px;
  background: #f5f3ff;
  margin: 0 0 16px;
  border-radius: 0 8px 8px 0;
  color: #374151;
}
.kbav-content hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 28px 0;
}
.kbav-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 13.5px;
}
.kbav-content th {
  background: #f8fafc;
  font-weight: 700;
  color: #374151;
  padding: 9px 14px;
  border: 1px solid #e2e8f0;
  text-align: left;
}
.kbav-content td {
  padding: 9px 14px;
  border: 1px solid #e2e8f0;
  color: #4b5563;
}

/* Article footer */
.kbav-footer {
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.kbav-helpful {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #6b7280;
}

.kbav-helpful-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  background: white;
  font-size: 12.5px;
  font-weight: 500;
  font-family: var(--font);
  color: #374151;
  cursor: pointer;
  transition: all 0.15s;
}
.kbav-helpful-btn:hover { border-color: #6366f1; color: #6366f1; background: #eef2ff; }
.kbav-helpful-btn.voted-yes { background: #dcfce7; border-color: #86efac; color: #166534; }
.kbav-helpful-btn.voted-no  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

.kbav-view-count {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #94a3b8;
}

/* Article side panel */
.kbav-sidebar {
  width: 260px;
  flex-shrink: 0;
  border-left: 1px solid #e2e8f0;
  background: #ffffff;
  overflow-y: auto;
  padding: 24px 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kbav-info-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kbav-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  padding: 5px 0;
  border-bottom: 1px solid #f1f5f9;
}
.kbav-info-row:last-child { border-bottom: none; }

.kbav-info-label {
  color: #6b7280;
  font-weight: 500;
}

.kbav-info-val {
  color: #1e293b;
  font-weight: 600;
  text-align: right;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .kbfp-layout,
  .kbav-layout { flex-direction: column; }

  .kbfp-sidebar,
  .kbav-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid #e2e8f0;
  }

  .kbfp-main,
  .kbav-article { padding: 20px 16px 40px; }

  .kbav-title { font-size: 22px; }
}

@media (max-width: 600px) {
  .kbfp-topbar { padding: 0 12px; }
  .kbfp-breadcrumb { display: none; }
  .kbfp-topbar-right .tbtn span { display: none; }
}

/* ============================================================
   SETTINGS — APPEARANCE FORM
   ============================================================ */

.settings-appearance-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Single field row ── */
.sa-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sa-field > label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.sa-field > label i { color: var(--primary); font-size: 11px; }

.sa-field-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
}

/* ── Text input ── */
.sa-input {
  width: 100%;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sa-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* ── Tagline wrapper (input + token bar stacked) ── */
.sa-tagline-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Token quick-insert bar ── */
.sa-token-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sa-token-bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.sa-token {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
  border-radius: 100px;
  font-size: 11.5px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.13s;
}

.sa-token:hover {
  background: #ddd6fe;
  border-color: #7c3aed;
  transform: translateY(-1px);
}

.sa-token-custom {
  background: #f3f4f6;
  color: var(--text-muted);
  border-color: #e5e7eb;
}

.sa-token-custom:hover {
  background: #e5e7eb;
  color: var(--text);
}

/* ── Live preview box ── */
.sa-preview {
  margin-top: 4px;
  border: 1.5px dashed #e5e7eb;
  border-radius: var(--r);
  overflow: hidden;
}

.sa-preview-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  padding: 6px 14px;
  background: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
}

.sa-preview-box {
  background: #0f0f13;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.sa-preview-hero-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 4px;
}

.sa-preview-h1 {
  font-size: 18px;
  font-weight: 700;
  color: #f1f1f5;
  line-height: 1.2;
}

.sa-preview-p {
  font-size: 12.5px;
  color: #8b8ba0;
  max-width: 280px;
  line-height: 1.5;
}

.sa-preview-tag {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  color: #8b8ba0;
  background: none;
  border: none;
  padding: 0;
  animation: sa-tag-in 0.3s ease;
}

@keyframes sa-tag-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Save button row ── */
.sa-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid #f3f4f6;
}

.sa-save-status {
  font-size: 13px;
  color: var(--text-dim);
  transition: color 0.2s;
}

.sa-save-status.sa-saved {
  color: var(--success);
  font-weight: 600;
}

/* Chatbot topbar button */
.tbtn-chatbot {
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 5px 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none !important;
  flex-shrink: 0;
}

.tbtn-chatbot:hover {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.4);
  color: #ffffff;
}
