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

*, *::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;
  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;
}

#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;
  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); }

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

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

.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(280px, 1fr));
  gap: 16px;
  padding: 0 32px 32px;
  overflow-y: auto;
  flex: 1;
  align-content: start;
}

/* Flow cards */
.flow-card {
  background: white;
  border: 1px solid var(--panel-border);
  border-radius: var(--r);
  overflow: hidden;
  transition: all 0.2s;
  cursor: default;
  display: flex;
  flex-direction: column;
}

.flow-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
  border-color: #d1d5db;
}

.fc-top-strip { height: 4px; }

.fc-body {
  padding: 16px 16px 12px;
  flex: 1;
  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;
}

.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 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; }

/* 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;
}

/* 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; }

/* 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: 300px;
  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: 16px;
  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; }

/* ── 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; }
.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: 300px;
}

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

.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;
}

.nap-path { color: #0369a1; font-family: monospace; }
.nap-var  { color: #7c3aed; font-family: monospace; background: #ede9fe; padding: 1px 4px; border-radius: 3px; }

/* 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: 90px 1fr;
  gap: 8px;
  align-items: start;
}

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

.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;
}

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

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

.api-map-field label {
  font-size: 9.5px;
  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; }

/* 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); }

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

/* ── 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; }

/* ============================================================
   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; }
.conv-row-flow {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 3px;
  flex-wrap: wrap;
}
.conv-sim-badge {
  background: #f3f4f6;
  color: #6b7280;
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
}

.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 DETAIL MODAL ── */
.modal-conv {
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.conv-detail-body {
  overflow-y: auto;
  flex: 1;
  padding: 20px 24px;
}
.conv-detail-summary { margin-bottom: 20px; }
.conv-detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.conv-dmeta {
  background: #f9fafb;
  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-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;
}
.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;
  min-width: 0;
}

/* ── 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: 16px 24px 32px;
}
.dash-main .dash-toolbar {
  padding: 12px 24px;
}

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

@media (max-width: 1100px) {
  .right-panel { width: 280px; }
  .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 grid ── */
.kb-articles-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.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;
}

/* ============================================================
   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;
}
