/* ── Workflow Page Layout ──────────────────────────── */

.app--workflow {
  max-width: none !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  height: calc(100vh);
  overflow: hidden;
}

/* ── Toolbar ──────────────────────────────────────── */

.wf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  min-height: 48px;
  gap: 12px;
  flex-shrink: 0;
}

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

.wf-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.wf-back-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-bright);
  border-color: var(--border);
}
.wf-back-btn:focus-visible {
  outline: none;
  border-color: var(--border-focus);
}
.wf-back-btn svg { display: block; }

.wf-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.wf-name-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-bright);
  font-size: 15px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  width: 240px;
}
.wf-name-input:focus {
  border-color: var(--border-focus);
  outline: none;
  background: var(--bg-input);
}

.wf-zoom-label {
  color: var(--text-dim);
  font-size: 12px;
  min-width: 40px;
  text-align: center;
}

/* ── Body (palette + canvas) ─────────────────────── */

.wf-body {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* ── Node Palette ─────────────────────────────────── */

.wf-palette {
  width: 200px;
  min-width: 200px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.wf-palette-header {
  padding: 12px 14px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.wf-palette-category {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.wf-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: grab;
  font-size: 13px;
  color: var(--text);
  transition: background var(--transition);
  user-select: none;
}
.wf-palette-item:hover {
  background: var(--bg-card-hover);
}
.wf-palette-item:active {
  cursor: grabbing;
}
.wf-palette-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
}

/* ── Drawflow Canvas ──────────────────────────────── */

#drawflow {
  flex: 1;
  background: var(--bg);
  background-image: radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}
.drawflow { background: transparent !important; }
.drawflow .connection .main-path {
  stroke: var(--accent);
  stroke-width: 2;
  color: var(--accent);
  marker-end: url(#wf-arrow);
}
.drawflow .connection .main-path:hover {
  stroke: var(--text-bright);
  stroke-width: 3;
  color: var(--text-bright);
}
.drawflow .drawflow-node {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow);
  min-width: 170px;
  padding: 0;
}
.drawflow .drawflow-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.drawflow .drawflow-node .input,
.drawflow .drawflow-node .output {
  width: 12px;
  height: 12px;
  background: var(--bg);
  border: 2px solid var(--accent);
  border-radius: 50%;
}
.drawflow .drawflow-node .input:hover,
.drawflow .drawflow-node .output:hover {
  background: var(--accent);
}
.drawflow .drawflow-delete {
  display: none;
}

/* ── Node HTML inside Drawflow ────────────────────── */

.wf-node {
  padding: 10px 14px;
}
.wf-node-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.wf-node-icon { font-size: 14px; }
.wf-node-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wf-node-type {
  font-size: 10px;
  color: var(--text-dim);
}

.wf-node-next-run {
  margin-top: 8px;
  padding: 6px 8px;
  border-top: 1px dashed var(--border);
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--accent);
  background: rgba(124, 154, 142, 0.06);
  border-radius: 0 0 var(--radius) var(--radius);
}
.wf-node-next-run-primary { font-weight: 600; }
.wf-node-next-run-sub { color: var(--text-dim); font-size: 10px; margin-top: 2px; }
.wf-node-next-run--draft { color: var(--text-dim); font-style: italic; background: transparent; }
.wf-node-next-run--draft .wf-node-next-run-primary { font-weight: 500; }

.wf-node--trigger { border-left: 3px solid var(--accent); }
.wf-node--ai { border-left: 3px solid var(--green); }
.wf-node--tool { border-left: 3px solid var(--sage-300); }
.wf-node--render { border-left: 3px solid var(--yellow); }
.wf-node--factory { border-left: 3px solid var(--yellow); }
.wf-node--control { border-left: 3px solid var(--text-dim); }

/* Execution status on nodes */
.wf-node-status {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
}
.wf-node-status.show { display: block; }
.wf-node-status.pending { background: var(--text-dim); }
.wf-node-status.running { background: var(--yellow); animation: wfPulse 1s ease-in-out infinite; }
.wf-node-status.completed { background: var(--green); }
.wf-node-status.failed { background: var(--red); }
.wf-node-status.skipped { background: var(--text-dim); opacity: 0.4; }

@keyframes wfPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234,179,8,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(234,179,8,0); }
}

.wf-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  margin-right: 4px;
  animation: wfSpin 0.7s linear infinite;
}
@keyframes wfSpin {
  to { transform: rotate(360deg); }
}

/* Publish / Live status toggle in toolbar */
.btn.wf-status-draft {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.wf-status-draft:hover:not(:disabled) {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--text-bright);
}
.btn.wf-status-live {
  background: rgba(34,197,94,0.12);
  color: var(--green);
  border: 1px solid var(--green);
}
.btn.wf-status-live:hover:not(:disabled) {
  background: rgba(34,197,94,0.2);
}
.wf-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
  vertical-align: 1px;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.5);
  animation: wfLivePulse 1.6s ease-in-out infinite;
}
@keyframes wfLivePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50% { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

.drawflow .drawflow-node.wf-status-running {
  border-color: var(--yellow);
  box-shadow: 0 0 8px rgba(234,179,8,0.3);
}
.drawflow .drawflow-node.wf-status-current {
  box-shadow: 0 0 0 3px var(--yellow), 0 0 20px rgba(234,179,8,0.55);
  transform: scale(1.02);
  transition: box-shadow 180ms ease, transform 180ms ease;
}
.drawflow .drawflow-node.wf-status-completed { border-color: var(--green); }
.drawflow .drawflow-node.wf-status-failed { border-color: var(--red); }
.drawflow .drawflow-node.wf-status-skipped { opacity: 0.5; }

/* ══════════════════════════════════════════════════════
   Node Modal — 3-column full-screen overlay (n8n-style)
   ══════════════════════════════════════════════════════ */

.wf-node-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: wfModalFadeIn 0.15s ease;
}

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

.wf-nm-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 94vw;
  max-width: 1200px;
  height: 80vh;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ── Modal Header ── */

.wf-nm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.wf-nm-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wf-nm-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wf-nm-icon { font-size: 18px; }

.wf-nm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
}

.wf-nm-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.wf-nm-dur {
  font-size: 12px;
  color: var(--text-dim);
}

.wf-nm-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.wf-nm-close:hover { color: var(--text-bright); }

.wf-nm-exec-btn {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.wf-nm-exec-btn:hover { background: var(--accent-hover); }

/* ── Modal Body (3 columns) ── */

.wf-nm-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.wf-nm-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wf-nm-col-input {
  width: 28%;
  min-width: 200px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.wf-nm-col-params {
  flex: 1;
  min-width: 0;
}

.wf-nm-col-output {
  width: 28%;
  min-width: 200px;
  border-left: 1px solid var(--border);
  background: var(--bg);
}

.wf-nm-col-label {
  padding: 10px 16px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wf-nm-copy-btn {
  font-size: 10px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}

.wf-nm-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wf-nm-col-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ── Modal: JSON display ── */

.wf-nm-json {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 8px;
  line-height: 1.5;
}

.wf-nm-port-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
  margin-top: 8px;
}
.wf-nm-port-label:first-child { margin-top: 0; }

.wf-nm-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

/* ── Modal: Empty states ── */

.wf-nm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
  font-size: 13px;
  min-height: 120px;
}

.wf-nm-empty-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.4;
}

.wf-nm-empty-sub {
  font-size: 12px;
  margin-top: 4px;
  opacity: 0.6;
}

/* ── Modal: Mock data editor ── */

.wf-nm-mock-editor {
  margin-bottom: 12px;
}

.wf-nm-mock-ta {
  width: 100%;
  min-height: 100px;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
}
.wf-nm-mock-ta:focus {
  border-color: var(--border-focus);
  outline: none;
}

.wf-nm-input-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wf-nm-mock-btn {
  background: var(--bg-card-hover);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.wf-nm-mock-btn:hover { border-color: var(--accent); }

/* ── Output pane layout ── */
.wf-output-pane { display: flex; flex-direction: column; height: 100%; }
.wf-output-content { flex: 1; overflow-y: auto; }
.wf-output-exec-btn { margin-top: 12px; width: 100%; flex-shrink: 0; }

/* ── Output view toggle ── */
.wf-output-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.wf-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wf-tab-btn:hover { color: var(--text); }
.wf-tab-btn.active { background: var(--bg-card-hover); color: var(--text-bright); border-color: var(--border); }

/* ── Media renderers (image/video/audio) ── */
.wf-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.wf-media-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.wf-media-card img,
.wf-media-card video {
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: cover;
  display: block;
  background: #000;
}
.wf-media-caption {
  font-size: 10px;
  color: var(--text-dim);
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--border);
}

.wf-media-list { display: flex; flex-direction: column; gap: 8px; }
.wf-audio-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.wf-audio-caption {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wf-audio-item audio { width: 100%; height: 32px; }

/* ── Per-iteration error card ── */
.wf-media-card.wf-media-error {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
}
.wf-media-error-body { padding: 10px; }
.wf-media-error-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.wf-media-error-msg {
  font-size: 11px;
  color: var(--red);
  word-break: break-word;
  line-height: 1.4;
}
.wf-media-error-stack summary {
  font-size: 10px;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 6px;
}
.wf-media-error-stack pre {
  font-size: 9px;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 4px;
  max-height: 120px;
  overflow-y: auto;
}

/* Audio error variant inherits from card styling naturally */
.wf-media-list .wf-media-card.wf-media-error { padding: 0; }

/* ── Modal: Error display ── */

.wf-nm-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}

.wf-nm-error-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.wf-nm-error-msg {
  font-size: 13px;
  color: var(--red);
  word-break: break-word;
}

.wf-nm-error-stack summary {
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 8px;
}

.wf-nm-error-stack pre {
  font-size: 10px;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 4px;
  max-height: 150px;
  overflow-y: auto;
}

/* ── Modal: Spinner ── */

.wf-nm-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: wfSpin 0.8s linear infinite;
  margin-bottom: 8px;
}

@keyframes wfSpin {
  to { transform: rotate(360deg); }
}

/* ── Config fields (shared: used in both modal params and old panel) ── */

.wf-config-field {
  margin-bottom: 14px;
}
.wf-config-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.wf-config-field input,
.wf-config-field select,
.wf-config-field textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  box-sizing: border-box;
}
.wf-config-field textarea {
  min-height: 80px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
}
.wf-config-field input:focus,
.wf-config-field select:focus,
.wf-config-field textarea:focus {
  border-color: var(--border-focus);
  outline: none;
}

/* ── Tool Checkbox List ── */
.wf-tools-search {
  width: 100%; padding: 5px 8px; margin-bottom: 4px;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text);
}
.wf-tools-list { display: flex; flex-direction: column; gap: 2px; max-height: 180px; overflow-y: auto; }
.wf-tools-empty { font-size: 11px; color: var(--text-dim); font-style: italic; padding: 4px 0; }
label.wf-tool-item {
  display: flex !important; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.1s;
  text-transform: none !important; font-size: 12px !important;
  letter-spacing: normal !important; color: var(--text) !important;
  margin-bottom: 0 !important; font-weight: normal !important;
}
label.wf-tool-item:hover { background: rgba(255,255,255,0.05); }
label.wf-tool-active { background: rgba(124,154,142,0.12); }
.wf-tool-item input[type="checkbox"] {
  flex-shrink: 0; cursor: pointer;
  accent-color: var(--sage); width: 14px; height: 14px;
  padding: 0 !important; margin: 0;
}
.wf-tool-info { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.wf-tool-name { font-size: 12px; font-weight: 500; color: var(--text); }
.wf-tool-desc { font-size: 10px; color: var(--text-dim); line-height: 1.3; }

/* ── JSON Tree Viewer ── */
.jt-root { font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--text); overflow-x: auto; }
.jt-children { padding-left: 16px; border-left: 1px solid var(--border); margin-left: 4px; }
.jt-row { white-space: nowrap; }
.jt-key { color: var(--sage-700); }
.jt-str { color: var(--green); word-break: break-all; white-space: pre-wrap; }
.jt-num { color: var(--yellow); }
.jt-bool { color: var(--coral); }
.jt-null { color: var(--text-dim); font-style: italic; }
.jt-dim { color: var(--text-dim); }
.jt-toggle { cursor: pointer; display: inline-block; width: 14px; font-size: 9px; color: var(--text-dim); user-select: none; }
.jt-toggle:hover { color: var(--text); }

/* ── JSONEditor dark theme overrides ── */
.jsoneditor { border: 1px solid var(--border) !important; }
.jsoneditor-menu { background: var(--surface-2) !important; border-bottom-color: var(--border) !important; }
.jsoneditor-contextmenu .jsoneditor-menu { background: var(--surface) !important; }
.jsoneditor-tree, .jsoneditor textarea.jsoneditor-text { background: var(--surface) !important; color: var(--text) !important; }
.jsoneditor-field, .jsoneditor-value { color: var(--text) !important; }
.jsoneditor-value.jsoneditor-string { color: var(--green) !important; }
.jsoneditor-value.jsoneditor-number { color: var(--yellow) !important; }
.jsoneditor-value.jsoneditor-boolean { color: var(--coral) !important; }
.jsoneditor-value.jsoneditor-null { color: var(--text-dim) !important; }
.jsoneditor-readonly { color: var(--text-dim) !important; }
.jsoneditor td, .jsoneditor th { border-color: var(--border) !important; }
.jsoneditor-treepath { background: var(--surface-2) !important; color: var(--text-dim) !important; }
.jsoneditor-navigation-bar { background: var(--surface-2) !important; border-color: var(--border) !important; }
div.jsoneditor-search input { background: var(--surface) !important; color: var(--text) !important; }
.jsoneditor-frame { background: var(--surface) !important; }
.jsoneditor-statusbar { background: var(--surface-2) !important; border-color: var(--border) !important; color: var(--text-dim) !important; }
.jsoneditor-poweredBy { display: none !important; }

/* ── Old config panel (hidden, kept for HTML compat) ── */

.wf-config-panel {
  width: 0;
  overflow: hidden;
  flex-shrink: 0;
}

.wf-config-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}
.wf-config-close:hover { color: var(--text); }

/* ── Run History Panel ────────────────────────────── */

.wf-run-history {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.wf-run-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.wf-run-history-header:hover { background: var(--bg-card-hover); }
.wf-run-history-toggle { transition: transform 0.2s; }
.wf-run-history.collapsed .wf-run-history-toggle { transform: rotate(180deg); }
.wf-run-history.collapsed .wf-run-history-body { display: none; }

.wf-run-history-body {
  max-height: 180px;
  overflow-y: auto;
  padding: 0 16px 8px;
}

.wf-run-item {
  border-bottom: 1px solid var(--border);
}
.wf-run-item:last-child { border-bottom: none; }

.wf-run-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}
.wf-run-row:hover { color: var(--text); }
.wf-run-row.expanded { color: var(--text-bright); }

.wf-run-chevron {
  display: inline-block;
  width: 10px;
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color var(--transition);
}
.wf-run-row.expanded .wf-run-chevron { color: var(--accent); }

.wf-run-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wf-rerun-btn {
  margin-left: 8px;
  font-size: 10.5px;
  padding: 2px 8px;
  line-height: 1.4;
}

/* ── Run Row Details (expanded) ── */

.wf-run-details {
  padding: 8px 0 12px 22px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.wf-run-details-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 0;
}

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

.wf-run-node-item {
  display: grid;
  grid-template-columns: 16px auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
}
.wf-run-node-item:hover { background: var(--bg-card-hover); }

.wf-run-node-icon {
  width: 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.wf-run-node-icon.status-completed { color: var(--green); }
.wf-run-node-icon.status-failed    { color: var(--red); }
.wf-run-node-icon.status-running   { color: var(--yellow); }
.wf-run-node-icon.status-skipped,
.wf-run-node-icon.status-pending   { color: var(--text-dim); }

.wf-run-node-type-icon {
  font-size: 13px;
  opacity: 0.8;
}

.wf-run-node-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wf-run-node-dur {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.wf-run-node-error {
  grid-column: 2 / -1;
  font-size: 11px;
  color: var(--red);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wf-run-final-output {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}
.wf-run-final-output > summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  list-style: none;
  padding: 4px 0;
}
.wf-run-final-output > summary::-webkit-details-marker { display: none; }
.wf-run-final-output > summary::before {
  content: "\25b8";
  display: inline-block;
  width: 12px;
  color: var(--text-dim);
}
.wf-run-final-output[open] > summary::before { content: "\25be"; }
.wf-run-final-output > summary:hover { color: var(--text); }
.wf-run-final-output-body {
  max-height: 220px;
  overflow-y: auto;
  padding: 6px 0 2px;
}

/* ── Run View Banner ─────────────────────────────── */

.wf-run-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  flex-shrink: 0;
}
.wf-run-banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── List View ────────────────────────────────────── */

.wf-list-view {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.wf-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.wf-list-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
}
.wf-list-actions { display: flex; gap: 8px; }

.wf-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.wf-list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.wf-list-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}
.wf-list-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 4px;
}
.wf-list-card-desc { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.wf-list-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.wf-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.wf-status-badge.draft { background: var(--border); color: var(--text-dim); }
.wf-status-badge.active { background: var(--green-soft); color: var(--green); }
.wf-status-badge.archived { background: var(--red-soft); color: var(--red); }

/* ── Template Modal ───────────────────────────────── */

.wf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wf-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.wf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.wf-modal-header h3 { font-size: 16px; font-weight: 600; }
.wf-modal-body {
  padding: 20px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.wf-template-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: border-color var(--transition);
}
.wf-template-card:hover { border-color: var(--accent); }
.wf-template-card-name { font-size: 14px; font-weight: 600; color: var(--text-bright); margin-bottom: 4px; }
.wf-template-card-desc { font-size: 12px; color: var(--text-dim); }
.wf-template-card-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Chat FAB & Panel ────────────────────────────── */

.wf-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent, #7C9A8E);
  color: #fff;
  border: none;
  font-size: 22px;
  cursor: pointer;
  z-index: 400;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
.wf-chat-fab:hover { transform: scale(1.08); background: var(--accent-hover, #6a877b); }

.wf-chat-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 400px;
  height: 540px;
  background: var(--bg-card, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: 16px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  overflow: hidden;
}

.wf-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #333);
  font-weight: 600;
  font-size: 14px;
}

.wf-chat-close {
  background: none;
  border: none;
  color: var(--text-dim, #888);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}
.wf-chat-close:hover { color: var(--text, #fff); }

.wf-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wf-chat-empty {
  color: var(--text-dim, #888);
  text-align: center;
  margin-top: 60px;
  font-size: 13px;
  line-height: 1.5;
}

.wf-chat-msg { display: flex; }
.wf-chat-msg-user { justify-content: flex-end; }
.wf-chat-msg-ai { justify-content: flex-start; }

.wf-chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.wf-chat-bubble-user {
  background: var(--accent, #7C9A8E);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.wf-chat-bubble-ai {
  background: var(--bg-input, #2a2a3e);
  color: var(--text, #e0e0e0);
  border-bottom-left-radius: 4px;
}

.wf-chat-tools {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.wf-chat-tool {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(124,154,142,0.2);
  color: var(--accent, #7C9A8E);
}

.wf-chat-error {
  margin-top: 6px;
  color: var(--red, #C97D70);
  font-size: 12px;
}

.wf-chat-typing {
  display: flex;
  gap: 4px;
  padding: 8px 14px;
}
.wf-chat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim, #888);
  animation: wf-chat-bounce 1.2s infinite;
}
.wf-chat-dot:nth-child(2) { animation-delay: 0.2s; }
.wf-chat-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes wf-chat-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

.wf-chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border, #333);
}
.wf-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border, #333);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg-input, #2a2a3e);
  color: var(--text, #e0e0e0);
  max-height: 80px;
  overflow-y: auto;
  font-family: inherit;
}
.wf-chat-input:focus { outline: none; border-color: var(--accent, #7C9A8E); }
.wf-chat-input::placeholder { color: var(--text-dim, #888); }

.wf-chat-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #7C9A8E);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wf-chat-send:disabled { opacity: 0.4; cursor: default; }
.wf-chat-send:not(:disabled):hover { background: var(--accent-hover, #6a877b); }
