/* ============================================================
   Workflox — workflow builder
   ============================================================ */

.app.studio-mode .sidebar,
.app.studio-mode .topbar { display: none; }
.app.studio-mode .app-main { height: 100vh; }
.app.studio-mode .view { overflow: hidden; }

.builder {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- builder header ---------- */
.builder-top {
  flex: none;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.bt-left, .bt-right { display: flex; align-items: center; gap: 9px; min-width: 0; }
.builder-back {
  width: 33px; height: 33px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: background .18s, border-color .18s;
}
.builder-back:hover { background: #fbf6f7; border-color: var(--line-2); }
.builder-back svg { width: 16px; height: 16px; }
.builder-app-icon {
  width: 35px; height: 35px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--c);
  background: var(--t);
  flex: none;
  margin-left: 2px;
}
.builder-app-icon svg { width: 17px; height: 17px; }
.builder-title-wrap { min-width: 0; }
.builder-name-input {
  border: 0;
  background: transparent;
  outline: none;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  width: 250px;
  padding: 1px 4px;
  margin-left: -4px;
  border-radius: 5px;
}
.builder-name-input:hover { background: #fbf6f7; }
.builder-name-input:focus { background: #fff; box-shadow: 0 0 0 2px rgba(125,31,46,.16); }
.builder-meta { display: flex; align-items: center; gap: 6px; font-size: 9px; color: var(--muted); margin-top: 1px; padding-left: 1px; white-space: nowrap; }
.builder-meta .dot-sep { width: 3px; height: 3px; border-radius: 50%; background: #c9cfde; }
.builder-meta .status { height: 18px; font-size: 8.5px; padding: 0 6px; }
.bt-divider { width: 1px; height: 24px; background: var(--line); margin: 0 3px; }
.bt-autosave { display: flex; align-items: center; gap: 5px; font-size: 9px; color: var(--muted-2); margin-right: 3px; white-space: nowrap; }
.bt-autosave svg { width: 12px; height: 12px; color: #10b981; }
.builder-tabsbar {
  flex: none;
  height: 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 19;
}
.builder-tabs { display: flex; align-items: center; gap: 2px; height: 100%; }
.builder-tab {
  height: 100%;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.builder-tab svg { width: 14px; height: 14px; }
.builder-tab:hover { color: var(--ink-2); }
.builder-tab.active { color: var(--primary-ink); border-bottom-color: var(--primary); }
.builder-tab .tab-count { font-size: 8px; background: #f1e6e8; color: var(--muted); border-radius: 20px; padding: 1px 5px; font-weight: 700; }
.builder-tab.active .tab-count { background: var(--primary-soft); color: var(--primary); }
.builder-tabsbar-right { display: flex; align-items: center; gap: 9px; }
.async-pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px; border-radius: 5px; background: #f9e9ed; color: #8b2336; font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.async-pill svg { width: 10px; height: 10px; }
.deploy-state { display: flex; align-items: center; gap: 5px; font-size: 9px; color: var(--muted); }
.deploy-state .dot { background: #22c55e; width: 6px; height: 6px; box-shadow: 0 0 0 3px rgba(34,197,94,.12); }

.builder-main { flex: 1; min-height: 0; position: relative; }
.builder-layout {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 338px;
  min-height: 0;
}

/* ---------- node palette ---------- */
.palette {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 8;
}
.palette-head { padding: 14px 13px 11px; border-bottom: 1px solid var(--line); flex: none; }
.palette-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.palette-title h3 { font-size: 11px; font-weight: 700; }
.palette-title span { font-size: 8px; color: var(--muted-2); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.palette-search { position: relative; }
.palette-search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 13px; height: 13px; color: var(--muted-2); }
.palette-search input {
  width: 100%; height: 31px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf6f7;
  padding: 0 9px 0 28px;
  font-size: 10.5px;
  outline: none;
}
.palette-search input:focus { border-color: rgba(125,31,46,.45); background: #fff; box-shadow: 0 0 0 3px rgba(125,31,46,.09); }
.palette-scroll { flex: 1; overflow: auto; padding: 10px 9px 14px; }
.palette-group { margin-bottom: 13px; }
.palette-group-head { display: flex; align-items: center; justify-content: space-between; padding: 3px 5px 5px; }
.palette-group-head span { font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .11em; color: var(--muted-2); }
.palette-group-head small { font-size: 8px; color: #b5bccd; }
.palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  cursor: grab;
  transition: background .15s, border-color .15s;
  position: relative;
}
.palette-item:hover { background: #fbf6f7; border-color: #f1e6e8; }
.palette-item:active { cursor: grabbing; }
.palette-item.dragging { opacity: .45; }
.palette-item-icon { width: 27px; height: 27px; border-radius: 7px; display: grid; place-items: center; color: var(--c); background: var(--t); flex: none; }
.palette-item-icon svg { width: 14px; height: 14px; }
.palette-item-copy { flex: 1; min-width: 0; }
.palette-item-copy strong { display: block; font-size: 10.5px; font-weight: 600; color: var(--ink-2); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item-copy span { display: block; font-size: 8px; color: var(--muted-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-add { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; color: var(--muted-2); opacity: 0; transition: opacity .15s, background .15s; flex: none; }
.palette-add svg { width: 11px; height: 11px; }
.palette-item:hover .palette-add { opacity: 1; }
.palette-add:hover { background: var(--t); color: var(--c); }
.palette-empty { padding: 22px 10px; text-align: center; font-size: 9.5px; color: var(--muted); }
.palette-foot {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 8.5px;
  color: var(--muted);
  line-height: 1.5;
  display: flex;
  gap: 7px;
}
.palette-foot svg { width: 12px; height: 12px; flex: none; color: var(--primary); margin-top: 1px; }
.palette-foot strong { color: var(--ink-2); font-weight: 600; }

/* ---------- canvas ---------- */
.canvas-shell { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #f8f1f2; }
.canvas-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: #f8f1f2;
  background-image: radial-gradient(circle, #d8ddec 1.15px, transparent 1.15px);
  background-size: 19px 19px;
  cursor: default;
  touch-action: none;
}
.canvas-stage.panning { cursor: grabbing; }
.canvas-stage.connecting { cursor: crosshair; }
.canvas-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 80% at 50% 0%, rgba(255,255,255,.5), transparent 60%);
  pointer-events: none;
}
.canvas-world {
  position: absolute;
  left: 0; top: 0;
  width: 4000px;
  height: 2600px;
  transform-origin: 0 0;
  will-change: transform;
}
.edges-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.edge-path { fill: none; stroke-width: 2; stroke-linecap: round; opacity: .9; transition: stroke-width .15s, opacity .15s; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.edge-group:hover .edge-path { stroke-width: 2.6; opacity: 1; }
.edge-group.selected .edge-path { stroke-width: 3.2; stroke-dasharray: none; filter: drop-shadow(0 1px 2px rgba(58,20,28,.18)); }
.edge-label { font-family: var(--font-body); font-size: 8px; font-weight: 700; letter-spacing: .03em; }
.edge-label-bg { fill: #fff; stroke: #e7eaf3; stroke-width: 1; }
.edge-del { cursor: pointer; pointer-events: auto; }
.edge-del circle { fill: #fff; stroke: #e2e6f1; stroke-width: 1; filter: drop-shadow(0 2px 4px rgba(58,20,28,.12)); }
.edge-del path { stroke: #64748b; stroke-width: 1.5; stroke-linecap: round; }
.edge-del:hover circle { fill: #fff1f2; stroke: #fecdd3; }
.edge-del:hover path { stroke: #e11d48; }
.edge-draft { fill: none; stroke-width: 2; stroke-dasharray: 6 5; opacity: .9; }

/* overlay chrome */
.canvas-floating {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  pointer-events: none; z-index: 6;
}
.canvas-floating .left, .canvas-floating .right { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.canvas-chip {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 9px;
  background: rgba(255,255,255,.9);
  border: 1px solid #e5e8f2;
  border-radius: 7px;
  box-shadow: var(--shadow-xs);
  font-size: 9px; font-weight: 550; color: var(--ink-2);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.canvas-chip svg { width: 12px; height: 12px; color: var(--muted); }
.canvas-chip strong { font-weight: 650; }
.canvas-chip.live { color: #047857; }
.canvas-chip.live .dot { width: 6px; height: 6px; background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.14); }
.canvas-chip.btn-chip { cursor: pointer; transition: background .16s, border-color .16s; }
.canvas-chip.btn-chip:hover { background: #fff; border-color: #d5daea; }
.canvas-chip.variables { color: var(--primary-ink); }
.canvas-chip.variables svg { color: var(--primary); }

.canvas-controls {
  position: absolute; left: 14px; bottom: 14px; z-index: 7;
  display: flex; align-items: center; gap: 1px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  box-shadow: var(--shadow-sm);
}
.canvas-controls button {
  width: 26px; height: 26px;
  border: 0; background: none; border-radius: 6px;
  display: grid; place-items: center; color: var(--muted);
}
.canvas-controls button:hover { background: #f8f1f2; color: var(--ink); }
.canvas-controls button svg { width: 14px; height: 14px; }
.canvas-controls .zoom-label { font-size: 9px; font-weight: 650; color: var(--ink-2); min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; }
.canvas-controls .divider-v { width: 1px; height: 17px; background: var(--line); margin: 0 2px; }
.canvas-help {
  position: absolute; right: 14px; bottom: 14px; z-index: 7;
  font-size: 8.5px; color: var(--muted);
  background: rgba(255,255,255,.85);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  border-radius: 7px;
  padding: 6px 9px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-xs);
}
.canvas-help span { display: inline-flex; align-items: center; gap: 4px; }
.canvas-help svg { width: 11px; height: 11px; }
.canvas-help kbd { font-size: 8px; }
.canvas-empty {
  position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%);
  z-index: 5; text-align: center; pointer-events: none;
}
.canvas-empty .empty-icon { background: #fff; box-shadow: var(--shadow-sm); }
.canvas-empty h3 { font-size: 14px; }
.canvas-empty p { font-size: 10px; }

/* ---------- nodes ---------- */
.canvas-nodes { position: relative; z-index: 2; }
.node {
  position: absolute;
  width: 242px;
  background: #fff;
  border: 1px solid #eadfe1;
  border-radius: 13px;
  box-shadow: 0 1px 2px rgba(58,20,28,.04), 0 10px 26px -20px rgba(58,20,28,.3);
  transition: border-color .16s, box-shadow .16s;
  user-select: none;
}
.node:hover { border-color: #d6dcec; box-shadow: 0 1px 2px rgba(58,20,28,.04), 0 14px 30px -20px rgba(58,20,28,.32); }
.node.selected { border-color: var(--c); box-shadow: 0 0 0 3px var(--t), 0 14px 30px -18px rgba(58,20,28,.3); }
.node.trigger-node { border-top: 2px solid var(--c); }
.node.trigger-node::after {
  content: "TRIGGER";
  position: absolute; top: -8px; right: 11px;
  background: var(--c);
  color: #fff;
  font-size: 6.5px; font-weight: 800; letter-spacing: .1em;
  border-radius: 4px; padding: 2px 5px;
  box-shadow: 0 2px 5px var(--t);
}
.node-head { display: flex; align-items: flex-start; gap: 9px; padding: 11px 11px 8px; cursor: grab; }
.node-head:active { cursor: grabbing; }
.node-icon { width: 31px; height: 31px; border-radius: 8px; display: grid; place-items: center; color: var(--c); background: var(--t); flex: none; }
.node-icon svg { width: 15px; height: 15px; }
.node-title { flex: 1; min-width: 0; padding-top: 1px; }
.node-title strong { display: block; font-size: 11px; font-weight: 650; color: var(--ink); line-height: 1.28; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.005em; }
.node-type { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 7.5px; font-weight: 700; color: var(--c); text-transform: uppercase; letter-spacing: .06em; }
.node-type .node-state-dot { width: 4px; height: 4px; border-radius: 50%; background: #cbd5e1; margin-left: 2px; }
.node-menu { border: 0; background: none; color: #b3bacb; border-radius: 4px; padding: 2px; opacity: 0; transition: opacity .15s, background .15s; flex: none; margin: -2px -2px 0 0; }
.node-menu svg { width: 13px; height: 13px; }
.node:hover .node-menu, .node.selected .node-menu { opacity: 1; }
.node-menu:hover { background: #f4f6fb; color: var(--ink-2); }
.node-body { padding: 0 11px 9px; }
.node-summary {
  font-size: 8.5px;
  color: #6b7590;
  background: #fbf6f7;
  border: 1px solid #f1e6e8;
  border-radius: 6px;
  padding: 5px 7px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-summary .method { font-family: var(--font-mono); font-size: 7.5px; font-weight: 700; color: var(--c); background: var(--t); border-radius: 3px; padding: 1px 4px; margin-right: 3px; }
.node-summary code { font-family: var(--font-mono); font-size: 8px; color: #4d5875; }
.node-badges { display: flex; align-items: center; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.node-badge { font-size: 7px; font-weight: 650; color: var(--muted); background: #faf4f5; border-radius: 4px; padding: 1px 5px; display: inline-flex; align-items: center; gap: 3px; }
.node-badge svg { width: 8px; height: 8px; }
.node-badge.var { color: #732032; background: #f9e9ed; }
.node-badge.async { color: #8b2336; background: #f9e9ed; }
.node-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 11px; border-top: 1px solid #f2f4f9; font-size: 7.5px; color: var(--muted-2); }
.node-foot .left { display: flex; align-items: center; gap: 4px; }
.node-foot svg { width: 10px; height: 10px; }
.node-foot .run-meta { font-family: var(--font-mono); font-size: 7.5px; }
.node-branch-list { border-top: 1px solid #f2f4f9; }
.node-branch {
  display: flex; align-items: center; gap: 6px;
  height: 25px;
  padding: 0 11px;
  font-size: 8px;
  font-weight: 650;
  color: var(--ink-2);
  position: relative;
}
.node-branch + .node-branch { border-top: 1px dashed #f2e7e9; }
.node-branch .branch-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--bc); box-shadow: 0 0 0 3px var(--bt); }
.node-branch .branch-label { color: var(--bc); }
.node-branch .branch-sub { margin-left: auto; padding-right: 15px; font-size: 7px; font-weight: 500; color: var(--muted-2); }
.node-branch.tone-yes { --bc: #16a34a; --bt: rgba(22,163,74,.12); }
.node-branch.tone-no { --bc: #dc2626; --bt: rgba(220,38,38,.1); }
.node-branch.tone-muted { --bc: #94a3b8; --bt: rgba(148,163,184,.12); }
.node-branch.tone-default { --bc: var(--c); --bt: var(--t); }
.node-branch .port.out { position: absolute; right: -7px; top: 50%; margin-top: -6px; }

/* node execution states */
.node.is-running { border-color: #ce9aa5; box-shadow: 0 0 0 3px rgba(125,31,46,.13), 0 14px 30px -18px rgba(58,20,28,.3); }
.node.is-running .node-icon { animation: nodePulse 1s ease-in-out infinite; }
.node.is-running .node-menu { opacity: 1; }
@keyframes nodePulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.node.is-done .node-icon { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(16,185,129,.22); }
.node.is-failed { border-color: #fca5a5; box-shadow: 0 0 0 3px rgba(239,68,68,.1); }
.node.is-failed .node-icon { color: #dc2626; background: #fef2f2; }
.node.is-disabled { opacity: .55; filter: grayscale(.4); }

/* ports */
.port {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--pc, var(--c));
  z-index: 5;
  padding: 0;
  transition: transform .14s var(--ease), box-shadow .14s, background .14s;
}
.port:hover { transform: scale(1.28); background: var(--pc, var(--c)); box-shadow: 0 0 0 4px var(--pt, var(--t)); }
.port.in { left: -7px; top: 27px; }
.port.out { right: -7px; top: 50%; margin-top: -6px; }
.port.out.branch-port { right: -7px; top: 50%; margin-top: -6px; }
.port.tone-yes { --pc: #16a34a; --pt: rgba(22,163,74,.15); }
.port.tone-no { --pc: #dc2626; --pt: rgba(220,38,38,.13); }
.port.tone-muted { --pc: #94a3b8; --pt: rgba(148,163,184,.15); }
.port.drag-target { transform: scale(1.4); background: var(--pc, var(--c)); box-shadow: 0 0 0 5px var(--pt, var(--t)); }
.port-dot-label { font-size: 7px; font-weight: 700; color: var(--muted-2); position: absolute; left: -3px; top: -14px; }

.node-drop-target { outline: 2px dashed rgba(125,31,46,.45); outline-offset: 4px; border-radius: 14px; }

/* ---------- inspector ---------- */
.inspector {
  background: #fff;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 8;
}
.inspector-scroll { flex: 1; overflow: auto; min-height: 0; }
.inspector-head {
  flex: none;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fdf8f9, #fff);
}
.inspector-title-row { display: flex; align-items: flex-start; gap: 9px; }
.inspector-node-icon { width: 35px; height: 35px; border-radius: 9px; display: grid; place-items: center; color: var(--c); background: var(--t); flex: none; }
.inspector-node-icon svg { width: 17px; height: 17px; }
.inspector-title-copy { flex: 1; min-width: 0; }
.inspector-kicker { display: flex; align-items: center; gap: 5px; font-size: 7.5px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; color: var(--c); margin-bottom: 1px; }
.inspector-kicker .dot { width: 4px; height: 4px; background: var(--c); }
.inspector-title-copy h2 { font-size: 12.5px; font-weight: 700; line-height: 1.3; }
.inspector-title-copy p { font-size: 9px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.inspector-head-actions { display: flex; align-items: center; gap: 4px; margin-top: -2px; margin-right: -3px; }
.mini-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 8px; font-weight: 650; color: var(--muted); background: #faf4f5; border-radius: 5px; padding: 2px 6px; white-space: nowrap; line-height: 1.35; }
.mini-tag svg { width: 10px; height: 10px; flex: none; }
.inspector-head-actions .mini-tag { color: var(--muted-2); background: #faf4f5; }
.inspector-name-edit { margin-top: 11px; position: relative; }
.inspector-name-edit input {
  width: 100%; height: 31px;
  border: 1px solid transparent; background: #fbf6f7;
  border-radius: 7px; padding: 0 8px;
  font-size: 11px; font-weight: 600; color: var(--ink);
  outline: none;
  transition: border-color .15s, background .15s;
}
.inspector-name-edit input:hover { border-color: #ede1e3; }
.inspector-name-edit input:focus { background: #fff; border-color: rgba(125,31,46,.45); box-shadow: 0 0 0 3px rgba(125,31,46,.08); }
.inspector-name-edit .name-tag { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); font-size: 7px; font-weight: 600; color: var(--muted-2); pointer-events: none; }
.inspector-meta-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.inspector-meta-row .type-badge { height: 17px; font-size: 7.5px; }
.inspector-meta-row .mini-tag { font-size: 8px; color: var(--muted); background: #faf4f5; border-radius: 4px; padding: 1px 5px; display: inline-flex; align-items: center; gap: 3px; }
.inspector-meta-row .mini-tag svg { width: 9px; height: 9px; }
.inspector-section { padding: 13px 14px; border-bottom: 1px solid #f5ecee; }
.inspector-section:last-child { border-bottom: 0; }
.inspector-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.inspector-section-head h4 { font-size: 8px; font-weight: 750; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-2); display: flex; align-items: center; gap: 5px; }
.inspector-section-head h4 svg { width: 11px; height: 11px; }
.inspector-section-head .link-btn { font-size: 8.5px; }
.inspector .field + .field { margin-top: 10px; }
.inspector .field > label { font-size: 10px; font-weight: 600; color: var(--ink-2); }
.inspector .field-hint { font-size: 9px; }
.inspector .field-row { gap: 6px; }
.inspector .input, .inspector .select { height: 32px; font-size: 10.5px; border-radius: 7px; padding-left: 9px; }
.inspector .select { padding-right: 27px; background-position: right 8px center; }
.inspector .input::placeholder { font-size: 10px; }
.inspector textarea.input { min-height: 62px; font-size: 10.5px; }
.inspector .switch-row { padding: 3px 0; }
.inspector .switch-copy strong { font-size: 10px; }
.inspector .switch-copy small { font-size: 8.5px; }
.inspector .switch { width: 31px; height: 18px; }
.inspector .switch .switch-thumb { width: 12px; height: 12px; }
.inspector .switch input:checked + .switch-track .switch-thumb { transform: translateX(13px); }
.inspector .field-info {
  display: flex; gap: 6px;
  background: #fbf6f7; border: 1px solid #f1e6e8;
  border-radius: 7px; padding: 7px 8px;
  font-size: 8.5px; color: var(--muted); line-height: 1.5;
}
.inspector .field-info svg { width: 11px; height: 11px; flex: none; margin-top: 1px; color: var(--primary); }
.inspector .field-info.amber { background: #fffbf0; border-color: #fdf0d5; }
.inspector .field-info.amber svg { color: #d97706; }

/* range */
.range-control { display: flex; align-items: center; gap: 9px; }
.range-control input[type="range"] { flex: 1; appearance: none; height: 4px; border-radius: 99px; background: linear-gradient(90deg, var(--primary) var(--pct, 30%), #ede1e3 var(--pct, 30%)); outline: none; }
.range-control input[type="range"]::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; background: #fff; border: 3px solid var(--primary); border-radius: 50%; box-shadow: 0 1px 3px rgba(58,20,28,.2); cursor: pointer; }
.range-value { min-width: 38px; text-align: center; height: 24px; border: 1px solid var(--line); border-radius: 5px; font-size: 9.5px; font-weight: 650; display: grid; place-items: center; color: var(--ink-2); background: #fdf8f9; }

/* kv editor */
.kv-list { display: flex; flex-direction: column; gap: 5px; }
.kv-row { display: grid; grid-template-columns: 1fr 1fr 22px; gap: 4px; align-items: center; }
.kv-row input {
  height: 29px; border: 1px solid var(--line-2); border-radius: 6px;
  background: #fff; padding: 0 7px;
  font-family: var(--font-mono); font-size: 9px; color: var(--ink-2);
  outline: none; min-width: 0;
}
.kv-row input:focus { border-color: rgba(125,31,46,.45); box-shadow: 0 0 0 2px rgba(125,31,46,.08); }
.kv-row input::placeholder { font-family: var(--font-body); color: var(--muted-2); }
.kv-del { width: 22px; height: 22px; border: 0; background: none; border-radius: 5px; display: grid; place-items: center; color: var(--muted-2); }
.kv-del:hover { background: #fef2f2; color: #dc2626; }
.kv-del svg { width: 11px; height: 11px; }
.kv-add { display: inline-flex; align-items: center; gap: 4px; background: none; border: 1px dashed #d9dfef; border-radius: 6px; padding: 4px 7px; color: var(--muted); font-size: 8.5px; font-weight: 600; margin-top: 1px; align-self: flex-start; }
.kv-add:hover { border-color: #cbb0b6; color: var(--primary-ink); background: #fdf8f9; }
.kv-add svg { width: 10px; height: 10px; }

/* code editor */
.code-shell { border-radius: 9px; overflow: hidden; border: 1px solid #1b2944; background: #0f172a; }
.code-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px; height: 30px; background: #111c33; border-bottom: 1px solid #1e2b47; }
.code-lang { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 8px; color: #94a3b8; }
.code-lang .lang-dot { width: 5px; height: 5px; border-radius: 50%; background: #facc15; }
.code-lang.prompt .lang-dot { background: #d1929f; }
.code-lang.json .lang-dot { background: #38bdf8; }
.code-lang.sql .lang-dot { background: #34d399; }
.code-toolbar-actions { display: flex; align-items: center; gap: 3px; }
.code-tool {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: none; color: #94a3b8;
  font-size: 8px; font-weight: 550;
  border-radius: 4px; padding: 3px 5px;
}
.code-tool:hover { background: #1e2b47; color: #e2e8f0; }
.code-tool svg { width: 10px; height: 10px; }
.code-shell textarea {
  display: block; width: 100%;
  border: 0; outline: none; resize: vertical;
  background: transparent; color: #dbe6f7;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.7;
  tab-size: 2;
  min-height: 80px;
}
.code-shell textarea::selection { background: rgba(125,31,46,.4); }
.code-shell .code-var-row { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 8px 8px; }
.code-var-chip {
  border: 1px solid #263550;
  background: #16233a;
  color: #ce9aa5;
  font-family: var(--font-mono);
  font-size: 7.5px;
  border-radius: 3px;
  padding: 2px 4px;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.code-var-chip:hover { background: #1e2f4d; color: #c7d2fe; }
.code-wrap { position: relative; }
.code-suggest {
  position: absolute;
  left: 7px; right: 7px; top: 37px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 20;
  max-height: 190px;
  overflow: auto;
  padding: 4px;
}
.code-suggest-head { font-size: 7px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); font-weight: 700; padding: 5px 7px 3px; }
.code-suggest-item { display: flex; align-items: center; gap: 7px; width: 100%; padding: 5px 7px; border: 0; background: none; border-radius: 5px; text-align: left; }
.code-suggest-item:hover, .code-suggest-item.active { background: #f5f6fd; }
.code-suggest-item .sym { font-family: var(--font-mono); color: #8b2336; font-size: 10px; }
.code-suggest-item code { flex: 1; font-family: var(--font-mono); font-size: 8.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-suggest-item small { font-size: 7.5px; color: var(--muted-2); }
.code-suggest-empty { padding: 10px; text-align: center; font-size: 8.5px; color: var(--muted); }

/* variables */
.inspector-vars { display: flex; flex-direction: column; gap: 4px; }
.inspector-var { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 6px; border: 1px solid #f2e7e9; background: #fdf8f9; }
.inspector-var svg { width: 11px; height: 11px; color: #9b3145; flex: none; }
.inspector-var code { flex: 1; font-family: var(--font-mono); font-size: 8px; color: #5b6580; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inspector-var .var-type { font-size: 7px; color: var(--muted-2); background: #f5ecee; border-radius: 3px; padding: 1px 3px; }
.inspector-var .copy-var { border: 0; background: none; color: var(--muted-2); padding: 1px; border-radius: 3px; }
.inspector-var .copy-var:hover { color: var(--primary-ink); background: var(--primary-soft); }
.inspector-var .copy-var svg { width: 9px; height: 9px; color: inherit; }
.trigger-var-group { margin-bottom: 6px; border: 1px solid #f1e6e8; border-radius: 8px; background: #fdf8f9; overflow: hidden; }
.trigger-var-group summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 7px 8px; font-size: 8.5px; font-weight: 650; color: var(--ink-2); }
.trigger-var-group summary::-webkit-details-marker { display: none; }
.trigger-var-group summary svg { width: 11px; height: 11px; color: var(--muted); }
.trigger-var-group summary .pill { margin-left: auto; height: 17px; font-size: 7px; }
.trigger-var-group summary:after { content: '›'; color: var(--muted-2); font-size: 13px; line-height: 1; margin-left: 3px; transform: rotate(90deg); transition: transform .16s; }
.trigger-var-group[open] summary:after { transform: rotate(-90deg); }
.trigger-var-group .inspector-vars { padding: 0 6px 6px; }
.trigger-var-group .inspector-var { background: #fff; }
.trigger-var-note { font-size: 7.5px; line-height: 1.45; color: var(--muted); padding: 3px 8px 7px; }
.var-add-row { display: grid; grid-template-columns: 1fr 80px 24px; gap: 4px; margin-top: 5px; }
.var-add-row input, .var-add-row select { height: 28px; border: 1px solid var(--line-2); border-radius: 6px; padding: 0 6px; font-size: 9px; outline: none; min-width: 0; }
.var-add-row button { border: 1px solid var(--line); background: #fff; border-radius: 6px; display: grid; place-items: center; color: var(--primary-ink); }
.var-add-row button:hover { background: var(--primary-soft); }
.var-add-row button svg { width: 12px; height: 12px; }

/* execution card */
.exec-card { background: #fbf6f7; border: 1px solid #f1e6e8; border-radius: 9px; padding: 9px 10px; }
.exec-top { display: flex; align-items: center; gap: 6px; font-size: 8.5px; font-weight: 650; color: var(--ink-2); }
.exec-top .status { height: 18px; font-size: 8px; padding: 0 5px; margin-left: auto; }
.exec-top svg { width: 12px; height: 12px; color: var(--muted); }
.exec-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 8px; }
.exec-stat { background: #fff; border-radius: 6px; padding: 5px 7px; border: 1px solid #f1e6e8; }
.exec-stat span { display: block; font-size: 7px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .04em; }
.exec-stat strong { display: block; font-size: 10px; font-weight: 700; margin-top: 1px; font-family: var(--font-mono); }
.exec-log-line { font-family: var(--font-mono); font-size: 7.5px; color: var(--muted); margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exec-log-line.success { color: #059669; }
.exec-link { display: inline-flex; align-items: center; gap: 3px; margin-top: 6px; font-size: 8px; font-weight: 600; color: var(--primary-ink); background: none; border: 0; padding: 0; }
.exec-link svg { width: 10px; height: 10px; }

/* trigger history mini */
.trigger-hist { display: flex; flex-direction: column; }
.trigger-hist-row { display: flex; align-items: flex-start; gap: 7px; padding: 6px 0; }
.trigger-hist-row + .trigger-hist-row { border-top: 1px dashed #f2e7e9; }
.trigger-hist-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--green-soft); color: #059669; display: grid; place-items: center; flex: none; margin-top: 1px; }
.trigger-hist-dot svg { width: 8px; height: 8px; }
.trigger-hist-copy { flex: 1; min-width: 0; font-size: 8.5px; color: var(--ink-2); }
.trigger-hist-copy strong { font-weight: 600; }
.trigger-hist-copy span { display: block; color: var(--muted); font-size: 7.5px; margin-top: 1px; }
.trigger-hist-time { font-family: var(--font-mono); font-size: 7px; color: var(--muted-2); white-space: nowrap; margin-top: 2px; }

/* empty inspector */
.inspector-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px 24px; }
.inspector-empty .empty-visual { width: 62px; height: 62px; border-radius: 18px; background: linear-gradient(145deg, #faedf0, #faf5ff); display: grid; place-items: center; color: var(--primary); margin-bottom: 13px; position: relative; }
.inspector-empty .empty-visual::after { content: ""; position: absolute; inset: -7px; border: 1px dashed #e0e4f5; border-radius: 23px; }
.inspector-empty .empty-visual svg { width: 27px; height: 27px; }
.inspector-empty h3 { font-size: 13px; font-weight: 700; }
.inspector-empty p { font-size: 9.5px; color: var(--muted); line-height: 1.55; max-width: 210px; margin: 4px 0 13px; }
.inspector-empty .mini-node-list { display: flex; align-items: center; gap: 4px; }
.inspector-empty .mini-node-list span { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--c); background: var(--t); }
.inspector-empty .mini-node-list svg { width: 12px; height: 12px; }
.inspector-empty .mini-node-list .link { width: 10px; height: 1.5px; background: #e1e5f0; }
.inspector-tip { margin-top: 16px; font-size: 8px; color: var(--muted-2); display: flex; align-items: center; gap: 4px; }
.inspector-tip svg { width: 10px; height: 10px; }

/* edge selection panel in inspector (optional fallback) */
.inspector-edge .inspector-head { border-bottom: 0; }

/* ---------- builder panes (runs / settings) ---------- */
.builder-pane { height: 100%; overflow: auto; background: var(--bg); }
.pane-inner { max-width: 1180px; margin: 0 auto; padding: 24px 28px 40px; }
.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.pane-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -.025em; }
.pane-head p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.pane-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.pane-stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.pane-stat span { font-size: 8.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.pane-stat span svg { width: 10px; height: 10px; }
.pane-stat strong { display: block; font-size: 18px; font-weight: 750; margin-top: 4px; letter-spacing: -.02em; }
.pane-stat strong small { font-size: 9px; color: var(--muted); font-weight: 500; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.settings-card { background: #fff; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.settings-card + .settings-card { margin-top: 14px; }
.settings-card-head { padding: 15px 18px 0; }
.settings-card-head h3 { font-size: 13px; font-weight: 700; }
.settings-card-head p { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.settings-card-body { padding: 15px 18px 18px; }
.settings-card-body .field + .field { margin-top: 12px; }
.settings-toggle-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 12px 0; }
.settings-toggle-row + .settings-toggle-row { border-top: 1px solid #f2f4f9; }
.settings-toggle-copy strong { display: block; font-size: 11px; font-weight: 600; }
.settings-toggle-copy p { font-size: 9.5px; color: var(--muted); margin-top: 2px; line-height: 1.5; max-width: 430px; }
.settings-toggle-row .switch { margin-top: 2px; }
.settings-side { position: sticky; top: 0; }
.trigger-summary-card {
  background: linear-gradient(150deg, #fdf7f8, #f4f1ff);
  border: 1px solid #eae5fb;
  border-radius: 15px;
  padding: 16px;
}
.trigger-summary-card .kicker { font-size: 8px; font-weight: 750; text-transform: uppercase; letter-spacing: .1em; color: #8b2336; display: flex; align-items: center; gap: 5px; }
.trigger-summary-card .kicker svg { width: 11px; height: 11px; }
.trigger-summary-node { display: flex; align-items: center; gap: 9px; margin-top: 12px; }
.trigger-summary-icon { width: 34px; height: 34px; border-radius: 9px; background: #fff; display: grid; place-items: center; color: var(--c); box-shadow: var(--shadow-xs); flex: none; }
.trigger-summary-icon svg { width: 16px; height: 16px; }
.trigger-summary-node strong { display: block; font-size: 11px; font-weight: 650; }
.trigger-summary-node span { display: block; font-size: 8.5px; color: var(--muted); margin-top: 1px; }
.trigger-summary-rows { margin-top: 13px; border-top: 1px dashed #e3ddf7; padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.trigger-summary-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 9px; }
.trigger-summary-row span { color: var(--muted); }
.trigger-summary-row strong { font-weight: 600; color: var(--ink-2); }
.settings-var-list { display: flex; flex-direction: column; }
.settings-var-item { display: flex; align-items: center; gap: 9px; padding: 9px 0; }
.settings-var-item + .settings-var-item { border-top: 1px solid #f2f4f9; }
.settings-var-item code { font-family: var(--font-mono); font-size: 9.5px; color: #651624; background: #fbf0f2; border-radius: 4px; padding: 2px 5px; }
.settings-var-item .value { flex: 1; font-size: 9px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-var-item .actions { display: flex; gap: 2px; }
.danger-zone { border: 1px solid #fee2e2; border-radius: 12px; padding: 14px; margin-top: 14px; }
.danger-zone h4 { font-size: 11px; font-weight: 650; color: #b91c1c; }
.danger-zone p { font-size: 9.5px; color: var(--muted); margin: 2px 0 10px; line-height: 1.5; }
.builder-runs-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.builder-runs-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.config-note { font-size: 8.5px; color: var(--muted); background: #fdf8f9; border: 1px dashed var(--line-2); border-radius: 7px; padding: 7px 8px; line-height: 1.5; }

/* ---------- responsive ---------- */
@media (max-width: 1320px) {
  .builder-layout { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 1160px) {
  .builder-layout { grid-template-columns: minmax(0, 1fr) 306px; }
  .builder-name-input { width: 200px; }
}
@media (max-width: 1000px) {
  .builder-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .palette { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-side { position: static; }
}
@media (max-width: 780px) {
  .builder-layout { grid-template-columns: minmax(0, 1fr); }
  .inspector { display: none; }
  .builder-name-input { width: 150px; }
  .bt-autosave, .bt-divider { display: none; }
  .pane-stats { grid-template-columns: repeat(2, 1fr); }
  .pane-inner { padding: 18px 14px 30px; }
}

/* ---------- inspector field grid ---------- */
.inspector-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 7px;
  align-items: start;
}
.inspector-fields > .field { margin-top: 0 !important; min-width: 0; }
.inspector-fields > .field.full { grid-column: 1 / -1; }
.inspector-fields > .field.hidden { display: none !important; }
.inspector-fields > .field .field-hint { margin-top: 1px; }
.inspector-fields > .field > label { min-height: 15px; }
.inspector-fields .optional { font-size: 8px; font-weight: 500; color: var(--muted-2); text-transform: lowercase; letter-spacing: .02em; }
.inspector-section.hidden { display: none !important; }

/* ---------- variable explorer ---------- */
.var-modal-list { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; max-height: 54vh; overflow: auto; padding-right: 3px; }
.var-modal-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.var-modal-group-icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--c); background: var(--t); flex: none; }
.var-modal-group-icon svg { width: 13px; height: 13px; }
.var-modal-group-head > div { flex: 1; min-width: 0; }
.var-modal-group-head strong { display: block; font-size: 10px; font-weight: 650; }
.var-modal-group-head span:not(.pill) { display: block; font-size: 8.5px; color: var(--muted); margin-top: 1px; }
.var-modal-group-head .pill { height: 18px; font-size: 8px; }
.var-modal-rows { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.var-modal-row {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 7px 9px; border: 0; background: #fff; text-align: left;
  border-bottom: 1px solid #f3f5fa;
}
.var-modal-row:last-child { border-bottom: 0; }
.var-modal-row:hover { background: #fdf8f9; }
.var-modal-row .sym { font-family: var(--font-mono); font-size: 9px; color: #c4b5fd; }
.var-modal-row code { font-family: var(--font-mono); font-size: 9px; color: #651624; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.var-modal-type { font-size: 7.5px; color: var(--muted-2); background: #faf4f5; border-radius: 4px; padding: 1px 4px; }
.var-modal-copy { color: var(--muted-2); display: grid; place-items: center; }
.var-modal-copy svg { width: 11px; height: 11px; }
.var-modal-row:hover .var-modal-copy { color: var(--primary-ink); }

/* ---------- extra polish ---------- */
.node.dragging { z-index: 20; box-shadow: 0 22px 44px -16px rgba(58,20,28,.35); cursor: grabbing; }
.node.selected { z-index: 6; }
.node.is-running { z-index: 7; }
.canvas-help kbd { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 0 3px; font-size: 7.5px; }
.code-wrap { position: relative; }
.inspector .code-shell textarea { scrollbar-width: thin; }
.inspector .field.hidden { display: none !important; }
.pop-item { transition: background .15s; }
.pop-item:hover { background: #fbf6f7; }
.field-btn > svg { width: 12px; height: 12px; color: var(--muted-2); }
.form-stage .field-btn > svg { width: 12px; height: 12px; color: var(--muted-2); }
.preview-input svg { width: 13px; height: 13px; display: inline-block; vertical-align: middle; }

/* ---------- flow direction ---------- */
.flow-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 24px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbf6f7;
}
.flow-switch > span {
  font-size: 7.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted-2);
  padding: 0 5px 0 4px;
}
.flow-switch button {
  width: 22px;
  height: 18px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.flow-switch button svg { width: 12px; height: 12px; }
.flow-switch button:hover { color: var(--ink-2); }
.flow-switch button.active { background: #fff; color: var(--primary-ink); box-shadow: 0 1px 3px rgba(58, 20, 28, .14); }

/* vertical flow: ports move to top/bottom, IF branches split across the node foot */
.canvas-stage.flow-vertical .port.in {
  left: 50%;
  top: -7px;
  transform: translateX(-50%);
}
.canvas-stage.flow-vertical .port.out {
  left: 50%;
  right: auto;
  top: auto;
  bottom: -7px;
  margin: 0;
  transform: translateX(-50%);
}
.canvas-stage.flow-vertical .port.in:hover,
.canvas-stage.flow-vertical .port.out:hover { transform: translateX(-50%) scale(1.28); }
.canvas-stage.flow-vertical .node-branch-list { display: flex; }
.canvas-stage.flow-vertical .node-branch {
  flex: 1;
  min-width: 0;
  height: 27px;
  border-top: 1px solid #f2f4f9;
}
.canvas-stage.flow-vertical .node-branch + .node-branch {
  border-top: 1px solid #f2f4f9;
  border-left: 1px dashed #f2e7e9;
}
.canvas-stage.flow-vertical .node-branch .branch-sub { display: none; }
.canvas-stage.flow-vertical .node-branch .branch-dot { margin-left: 2px; }
.canvas-stage.flow-vertical .node-branch .port.out {
  left: 50%;
  right: auto;
  top: auto;
  bottom: -7px;
  margin: 0;
  transform: translateX(-50%);
}
.canvas-stage.flow-vertical .node-branch .port.out:hover { transform: translateX(-50%) scale(1.28); }
@media (max-width: 1200px) {
  .builder-tabsbar-right .deploy-state { display: none; }
}
@media (max-width: 1000px) {
  .builder-tabsbar-right .bt-autosave { display: none; }
}



/* trigger picker + trigger variable groups */
.trigger-picker .type-option { align-items: flex-start; text-align: left; }
.trigger-picker .type-option > span:first-child { margin-top: 1px; }
.trigger-picker .type-option strong { font-weight: 650; }

/* field tooltips */
.field-label-copy { display: inline-flex; align-items: center; min-width: 0; gap: 2px; }
.field-tooltip { display: inline-flex; align-items: center; justify-content: center; margin-left: 4px; color: var(--muted-2); cursor: help; outline: none; vertical-align: middle; }
.field-tooltip svg { width: 10px; height: 10px; }
.field-tooltip:hover, .field-tooltip:focus { color: var(--primary-ink); }
.wf-tooltip { position: fixed; z-index: 3000; display: none; max-width: 270px; padding: 7px 9px; border-radius: 7px; background: #29161a; color: #f3e7e9; font-size: 9px; line-height: 1.55; box-shadow: 0 12px 30px -12px rgba(58,20,28,.7); pointer-events: none; }
.wf-tooltip.show { display: block; }

/* code editor line numbers */
.code-editor-body { display: flex; align-items: stretch; }
.code-gutter { flex: none; width: 30px; overflow: hidden; background: #0c1424; border-right: 1px solid #1e2b47; padding-top: 10px; }
.code-gutter-inner { color: #475569; font-family: var(--font-mono); font-size: 9px; line-height: 1.7; text-align: right; padding: 0 7px 10px 0; white-space: pre; will-change: transform; }
.code-editor-body textarea { flex: 1; min-width: 0; white-space: pre; overflow: auto; }


/* add node affordance + picker */
.node-add {
  position: absolute; z-index: 6;
  left: 50%; bottom: -42px; transform: translateX(-50%);
  width: 27px; height: 27px; border-radius: 9px;
  border: 1px solid #cfd6ea; background: #fff; color: var(--primary-ink);
  display: grid; place-items: center;
  box-shadow: 0 8px 18px -10px rgba(58,20,28,.45);
  transition: transform .16s, box-shadow .16s, background .16s;
}
.node-add svg { width: 13px; height: 13px; }
.node-add:hover { background: var(--primary-ink); color: #fff; border-color: var(--primary-ink); transform: translateX(-50%) translateY(-1px); box-shadow: 0 10px 20px -8px rgba(79,70,229,.55); }
.canvas-stage.flow-horizontal .node-add { left: auto; right: -42px; top: 50%; bottom: auto; transform: translateY(-50%); }
.canvas-stage.flow-horizontal .node-add:hover { transform: translateY(-50%) translateX(1px); }
.node-picker-groups { display: flex; flex-direction: column; gap: 13px; max-height: 50vh; overflow: auto; padding: 2px 2px 4px; }
.node-picker-label { font-size: 8px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 5px; }
.node-picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.node-pick { display: flex; align-items: flex-start; gap: 8px; text-align: left; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: #fff; transition: border-color .15s, background .15s, transform .15s; }
.node-pick:hover { border-color: #c7cdf5; background: #fdf8f9; transform: translateY(-1px); }
.node-pick-icon { width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center; flex: none; color: var(--c); background: var(--t); }
.node-pick-icon svg { width: 14px; height: 14px; }
.node-pick strong { display: block; font-size: 10px; font-weight: 650; color: var(--ink); }
.node-pick small { display: block; margin-top: 2px; font-size: 8px; line-height: 1.35; color: var(--muted); }
.node-picker-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 10px; }

/* ---------- loop container ---------- */
.node.loop-container {
  z-index: 1;
  width: 360px;
  min-height: 320px;
  border: 1.5px solid #e2d3d6;
  border-radius: 17px;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.node.loop-container:hover { border-color: #cbb0b6; }
.node.loop-container.selected { border-color: var(--c); box-shadow: 0 0 0 3px var(--t); }
.loop-container-head { display: flex; align-items: center; gap: 8px; padding: 13px 14px 7px; }
.loop-container-head .node-icon { width: 27px; height: 27px; border-radius: 8px; }
.loop-container-head .node-title { min-width: 0; flex: 1; }
.loop-container-head .node-title strong { display: block; font-size: 11px; font-weight: 750; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loop-container-head .node-title .node-type { font-size: 8px; color: var(--muted); }
.loop-count { display: inline-flex; align-items: center; gap: 4px; flex: none; height: 19px; padding: 0 7px; border-radius: 6px; background: #f7f0f1; color: var(--primary-ink); font-size: 7.5px; font-weight: 700; }
.loop-count svg { width: 10px; height: 10px; }
.loop-add-step { display: inline-flex; align-items: center; gap: 3px; flex: none; height: 22px; padding: 0 7px; border-radius: 7px; border: 1px solid #e2d3d6; background: transparent; color: var(--primary-ink); font-size: 7.5px; font-weight: 700; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.loop-add-step svg { width: 9px; height: 9px; }
.loop-add-step:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.loop-container-summary { display: flex; align-items: center; gap: 8px; padding: 0 15px 9px; min-width: 0; }
.loop-container-summary code { font-family: var(--mono); font-size: 8px; color: var(--primary-ink); background: #f7f0f1; border-radius: 5px; padding: 2px 5px; max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loop-container-summary span { font-size: 7.5px; color: var(--muted-2); font-weight: 600; }
.loop-container-body { position: absolute; left: 11px; right: 11px; top: 87px; bottom: 13px; border: 1.5px dashed #e4d5d8; border-radius: 12px; background: transparent; pointer-events: none; }
.loop-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; color: var(--muted); padding: 16px; }
.loop-empty svg { width: 21px; height: 21px; opacity: .65; }
.loop-empty strong { font-size: 9px; }
.loop-empty span { font-size: 7.5px; max-width: 210px; line-height: 1.5; color: var(--muted-2); }
.container-dot { position: absolute; left: 50%; width: 11px; height: 11px; border-radius: 50%; transform: translateX(-50%); background: var(--surface); border: 2px solid var(--c); box-shadow: 0 0 0 3px var(--t); z-index: 2; }
.container-dot.start { top: 8px; }
.container-dot.end { bottom: 8px; }
.node.inside-loop { z-index: 4; }

/* ---------- parallel container ---------- */
.node.parallel-container {
  border-color: #e8d3bd;
  background: transparent;
  box-shadow: none;
}
.node.parallel-container:hover { border-color: #d9b995; }
.node.parallel-container.selected { border-color: var(--c); box-shadow: 0 0 0 3px var(--t); }
.node.parallel-container .loop-count { background: #fff7ed; color: #b45309; }
.node.parallel-container .loop-container-summary code { background: #fff7ed; color: #b45309; }
.node.parallel-container .loop-add-step { border-color: #e8d3bd; color: #b45309; }
.node.parallel-container .loop-add-step:hover { background: #b45309; border-color: #b45309; }
.node.parallel-container .loop-container-body { border-color: #ead8c2; background: transparent; }
.node.parallel-container .loop-empty { color: #a16207; }
.edge-guide { fill: none; stroke-width: 1.4; stroke-dasharray: 4 5; opacity: .55; pointer-events: none; }

/* horizontal flow: container ports and internal anchors */
.canvas-stage.flow-horizontal .loop-container > .port.in {
  left: -7px; right: auto; top: 50%; bottom: auto; margin-top: -6px; transform: none;
}
.canvas-stage.flow-horizontal .loop-container > .port.out {
  left: auto; right: -7px; top: 50%; bottom: auto; margin-top: -6px; transform: none;
}
.canvas-stage.flow-horizontal .loop-container > .port.in:hover,
.canvas-stage.flow-horizontal .loop-container > .port.out:hover { transform: scale(1.28); }
.canvas-stage.flow-horizontal .container-dot.start {
  left: 8px; right: auto; top: 50%; bottom: auto; transform: translateY(-50%);
}
.canvas-stage.flow-horizontal .container-dot.end {
  left: auto; right: 8px; top: 50%; bottom: auto; transform: translateY(-50%);
}
