:root {
  --bg: #0f1117;
  --panel: #171a22;
  --panel-border: #2a3040;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.15);
  --success: #3ecf8e;
  --error: #ff6b6b;
  --running: #f5a623;
  --node-input: #6c5ce7;
  --node-process: #4f8cff;
  --node-config: #a29bfe;
  --node-output: #3ecf8e;
  --grid: rgba(255, 255, 255, 0.04);
  --panel-left-w: 220px;
  --panel-right-w: 360px;
  --panel-collapsed-w: 38px;
  --scrollbar-size: 6px;
  --scrollbar-track: transparent;
  --scrollbar-thumb: rgba(139, 149, 168, 0.35);
  --scrollbar-thumb-hover: rgba(139, 149, 168, 0.55);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

body[data-mode="simple"] {
  overflow: hidden;
}

#view-simple {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

#view-expert.layout {
  flex: 1;
  min-height: 0;
  height: auto;
}

html,
body,
.scroll-pane,
.sidebar-body,
.sidebar,
.view-simple,
.simple-preview,
.simple-log,
.log-panel,
.param-panel,
.preview-panel,
.history-panel,
.settings-card,
.auth-card,
.modal-card {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.scroll-pane::-webkit-scrollbar,
.sidebar-body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.view-simple::-webkit-scrollbar,
.simple-preview::-webkit-scrollbar,
.simple-log::-webkit-scrollbar,
.log-panel::-webkit-scrollbar,
.param-panel::-webkit-scrollbar,
.preview-panel::-webkit-scrollbar,
.history-panel::-webkit-scrollbar,
.settings-card::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
.scroll-pane::-webkit-scrollbar-track,
.sidebar-body::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.view-simple::-webkit-scrollbar-track,
.simple-preview::-webkit-scrollbar-track,
.simple-log::-webkit-scrollbar-track,
.log-panel::-webkit-scrollbar-track,
.param-panel::-webkit-scrollbar-track,
.preview-panel::-webkit-scrollbar-track,
.history-panel::-webkit-scrollbar-track,
.settings-card::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
.scroll-pane::-webkit-scrollbar-thumb,
.sidebar-body::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.view-simple::-webkit-scrollbar-thumb,
.simple-preview::-webkit-scrollbar-thumb,
.simple-log::-webkit-scrollbar-thumb,
.log-panel::-webkit-scrollbar-thumb,
.param-panel::-webkit-scrollbar-thumb,
.preview-panel::-webkit-scrollbar-thumb,
.history-panel::-webkit-scrollbar-thumb,
.settings-card::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
.scroll-pane::-webkit-scrollbar-thumb:hover,
.sidebar-body::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.view-simple::-webkit-scrollbar-thumb:hover,
.simple-preview::-webkit-scrollbar-thumb:hover,
.simple-log::-webkit-scrollbar-thumb:hover,
.log-panel::-webkit-scrollbar-thumb:hover,
.param-panel::-webkit-scrollbar-thumb:hover,
.preview-panel::-webkit-scrollbar-thumb:hover,
.history-panel::-webkit-scrollbar-thumb:hover,
.settings-card::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}

html::-webkit-scrollbar-corner,
body::-webkit-scrollbar-corner,
.scroll-pane::-webkit-scrollbar-corner {
  background: transparent;
}

.topbar,
.app-header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, rgba(26, 30, 40, 0.98) 0%, rgba(23, 26, 34, 0.96) 100%);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  min-height: 58px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #6b5cff);
  box-shadow: 0 6px 18px rgba(79, 140, 255, 0.28);
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

.topbar-spacer {
  flex: 1;
  min-width: 8px;
}

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  max-width: 300px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.user-chip:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

.user-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.user-email {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary, #e8eaed);
}

.user-center-link {
  flex-shrink: 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.52);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.user-chip:hover .user-center-link {
  color: rgba(255, 255, 255, 0.82);
}

.user-center-link.hidden {
  display: none;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #3ecf8e, #2aa86a);
  flex-shrink: 0;
}

.user-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-email {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 168px;
}

.quota-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quota-track {
  flex: 1;
  height: 4px;
  min-width: 56px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.35s ease;
}

.quota-label {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #6b5cff);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-accent:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.btn-ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--panel-border);
}

.toolbar { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

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

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.secondary { background: #1f2430; }
.btn.danger {
  background: rgba(255, 107, 107, 0.15);
  color: #ff8a8a;
  border: 1px solid rgba(255, 107, 107, 0.35);
}
.btn.danger:hover { background: rgba(255, 107, 107, 0.28); }

.layout {
  display: grid;
  grid-template-columns: var(--panel-left-w) 1fr var(--panel-right-w);
  height: 100%;
  transition: grid-template-columns 0.24s ease;
}

.layout.panel-left-collapsed {
  --panel-left-w: var(--panel-collapsed-w);
}

.layout.panel-right-collapsed {
  --panel-right-w: var(--panel-collapsed-w);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.sidebar.right {
  border-right: none;
  border-left: 1px solid var(--panel-border);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px 8px;
  flex-shrink: 0;
}

.sidebar-head-right {
  flex-direction: row;
  align-items: flex-start;
  padding-bottom: 0;
}

.sidebar-head-right .side-tabs {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.sidebar-label,
.sidebar-section {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-section {
  margin-top: 20px;
}

.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0 10px 12px;
}

.sidebar.right .sidebar-body {
  padding: 0 10px 12px;
}

.sidebar.right .sidebar-head-right {
  padding-bottom: 8px;
}

.sidebar.left .sidebar-body {
  overflow-y: auto;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #1a1f2a;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.sidebar-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.layout.panel-left-collapsed .sidebar.left .sidebar-label,
.layout.panel-left-collapsed .sidebar.left .sidebar-body {
  display: none;
}

.layout.panel-left-collapsed .sidebar.left .sidebar-head {
  justify-content: center;
  padding: 12px 4px;
}

.layout.panel-right-collapsed .sidebar.right .sidebar-body,
.layout.panel-right-collapsed .sidebar.right .side-tabs {
  display: none;
}

.layout.panel-right-collapsed .sidebar.right .sidebar-head {
  justify-content: center;
  padding: 12px 4px;
}

.layout.panel-left-collapsed .sidebar.left {
  border-right-color: transparent;
}

.layout.panel-right-collapsed .sidebar.right {
  border-left-color: transparent;
}

.sidebar h2 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.palette-item {
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: grab;
  font-size: 13px;
  background: #1a1f2a;
}

.palette-item:hover { border-color: var(--accent); }

.canvas-wrap {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, var(--grid) 1px, transparent 0);
  background-size: 24px 24px;
  transition: opacity 0.12s ease;
}

#view-expert.canvas-init .canvas-wrap {
  opacity: 0;
  pointer-events: none;
}

.canvas {
  width: 100%;
  height: 100%;
  position: relative;
  cursor: grab;
}

.canvas.panning { cursor: grabbing; }

.edges-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 4000px;
  height: 4000px;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.nodes-layer .node {
  z-index: 1;
}

.connect-help {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
}

.connect-help ul {
  margin: 6px 0;
  padding-left: 18px;
}

.connect-panel.hidden { display: none; }

.side-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.side-tab {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid var(--panel-border);
  background: #11151d;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.side-tab.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tab-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.tab-pane.active {
  display: flex;
}

.tab-pane h2 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.panel-hint {
  margin: 0 0 10px;
  font-size: 12px;
  flex-shrink: 0;
}

.scroll-pane {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.connect-panel {
  padding: 10px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #11151d;
  font-size: 12px;
}

.connect-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--panel-border);
}

.connect-item:last-child { border-bottom: none; }

.connect-item button {
  padding: 2px 8px;
  font-size: 11px;
}

.edge-path {
  fill: none;
  stroke: #5b6b85;
  stroke-width: 2;
  pointer-events: stroke;
  cursor: pointer;
}

.edge-path.temp {
  stroke: var(--accent);
  stroke-dasharray: 6 4;
  pointer-events: none;
}

.edge-path:hover { stroke: var(--accent); }

.edge-path.selected { stroke: var(--accent); stroke-width: 2.5; }

.nodes-layer {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.canvas-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}

.node {
  position: absolute;
  width: 280px;
  background: #1a1f2a;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  user-select: none;
  cursor: move;
}

.node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.node.status-running { border-color: var(--running); }
.node.status-success { border-color: var(--success); }
.node.status-cached { border-color: #5bc0de; box-shadow: 0 0 0 1px rgba(91, 192, 222, 0.25); }
.node.status-error { border-color: var(--error); }
.node.run-out-of-scope { opacity: 0.62; filter: saturate(0.75); }
.node.run-out-of-scope.status-running { opacity: 1; filter: none; }

.node-run-idle-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.15);
  vertical-align: middle;
}

.node-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
}

.node-type-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.node-title { font-size: 13px; font-weight: 600; }

.node-ports {
  padding: 8px 0;
  font-size: 12px;
}

.port-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  min-height: 24px;
}

.port {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--bg);
  cursor: crosshair;
  flex-shrink: 0;
}

.port.input { margin-right: 8px; }
.port.output { margin-left: 8px; }

.port.connecting { background: var(--accent); }

.node-params {
  padding: 8px 10px 10px;
  border-top: 1px solid var(--panel-border);
  background: #151922;
  border-radius: 0 0 10px 10px;
}

.node-params-title {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.node-params .field {
  margin-bottom: 8px;
}

.node-params .field:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

.field-input,
.param-panel input,
.param-panel textarea,
.param-panel select,
.node-params input,
.node-params textarea,
.node-params select {
  width: 100%;
  background: #11151d;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  user-select: text;
  cursor: text;
}

.param-panel select.field-input,
.node-params select.field-input {
  cursor: pointer;
}

.node-params textarea,
.param-panel textarea {
  min-height: 56px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}

.param-panel label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 4px;
}

.param-panel textarea { min-height: 120px; }

.param-group-title {
  font-size: 12px;
  color: var(--accent);
  margin: 14px 0 8px;
  padding-top: 8px;
  border-top: 1px solid var(--panel-border);
}

.param-group-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.param-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.field-hint {
  font-size: 11px;
  color: var(--success);
  margin-top: 3px;
}

.param-empty {
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.log-panel {
  background: #11151d;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #c8d0df;
  margin: 0;
}

.muted { color: var(--muted); font-size: 13px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-card {
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
}

.modal-card h3 { margin: 0 0 12px; }

.modal-card select {
  width: 100%;
  padding: 8px;
  background: #11151d;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.password-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.password-row .field-input {
  flex: 1;
}

.password-toggle {
  padding: 6px 10px;
  min-width: 36px;
}

.preview-actions {
  margin-bottom: 10px;
}

.preview-panel {
  min-height: 200px;
}

.wechat-preview-frame {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  max-width: 375px;
  width: 100%;
  margin: 0 auto;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.wechat-preview-inner {
  color: #333;
  font-size: 16px;
  line-height: 1.75;
}

.preview-path {
  margin-top: 12px;
  font-size: 12px;
  word-break: break-all;
}

.node-run-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.node-run-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.node-run-buttons .btn {
  width: 100%;
  justify-content: center;
}

.node-run-actions.hidden {
  display: none;
}

.run-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
}

.node-output-preview {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
}

.output-snippet {
  background: #11151d;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px;
  font-size: 11px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  color: #c8d0df;
}

.restore-banner {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: rgba(62, 207, 142, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

.restore-banner.hidden { display: none; }

.app-header { position: relative; }

.node-header-main { flex: 1; min-width: 0; }

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

.node-action-btn {
  border: 1px solid var(--panel-border);
  background: #1f2430;
  color: var(--text);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 0;
}

.node-action-btn:hover { border-color: var(--accent); color: var(--accent); }

.node-action-btn.run { color: var(--success); }

.node-delete {
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.node-qa-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(62, 207, 142, 0.2);
  color: var(--success);
}

.node-qa-badge.fail {
  background: rgba(255, 107, 107, 0.2);
  color: var(--error);
}

.node-wechat-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(62, 207, 142, 0.15);
  color: var(--success);
  font-weight: 500;
}

.node-wechat-badge.unset {
  background: rgba(255, 180, 80, 0.15);
  color: #e6a23c;
}

.node-llm-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.15);
  color: var(--accent);
  font-weight: 500;
}

.node-llm-badge.unset {
  background: rgba(255, 180, 80, 0.15);
  color: #e6a23c;
}

.llm-cred-banner {
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  background: rgba(255, 180, 80, 0.1);
  border: 1px solid rgba(255, 180, 80, 0.25);
  color: #e6c080;
}

.llm-cred-banner.ok {
  background: rgba(79, 140, 255, 0.08);
  border-color: rgba(79, 140, 255, 0.25);
  color: #9ec0ff;
}

.llm-cred-banner a {
  color: var(--accent);
}

.wechat-cred-banner {
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.wechat-cred-banner.ok {
  background: rgba(62, 207, 142, 0.12);
  color: var(--success);
  border: 1px solid rgba(62, 207, 142, 0.25);
}

.wechat-cred-banner.warn {
  background: rgba(255, 180, 80, 0.1);
  color: #e6a23c;
  border: 1px solid rgba(255, 180, 80, 0.25);
}

.wechat-cred-banner a {
  color: inherit;
  text-decoration: underline;
}

.wechat-ip-whitelist {
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  border: 1px solid rgba(96, 165, 250, 0.25);
  background: rgba(59, 130, 246, 0.08);
  color: var(--text);
}

.wechat-ip-whitelist-title {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: #93c5fd;
}

.wechat-ip-whitelist-desc {
  margin: 0 0 6px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

.wechat-ip-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.wechat-ip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wechat-ip-row-label {
  flex: 0 0 58px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.wechat-ip-chip {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 5px 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.wechat-ip-chip code {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 0;
  border-radius: 0;
  background: none;
  word-break: break-all;
}

.wechat-ip-chip .btn-copy-ip {
  flex-shrink: 0;
  padding: 1px 8px;
  min-height: 22px;
  font-size: 10px;
  line-height: 1.2;
}

.wechat-ip-whitelist-foot {
  margin-top: 6px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted);
}

.simple-wechat-hint {
  font-size: 12px;
  margin: 4px 0 0;
}

.simple-wechat-hint.ok {
  color: var(--success);
}

.wechat-node-summary.ok {
  color: var(--success);
}

.wechat-node-summary.warn {
  color: #e6a23c;
}

.file-picker-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.file-picker-row .file-picker-select {
  flex: 1 1 140px;
  min-width: 0;
  max-width: 100%;
}

.file-picker-row .file-picker-btn {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 12px;
}

.node .file-picker-row .file-picker-btn {
  padding: 4px 8px;
  font-size: 11px;
}

.param-error-banner,
.simple-error-panel {
  margin: 0 0 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: #fff;
  background: rgba(255, 107, 107, 0.18);
  border: 1px solid rgba(255, 107, 107, 0.55);
  border-radius: 8px;
  word-break: break-word;
}

.simple-error-panel strong {
  display: block;
  margin-bottom: 6px;
  color: var(--error);
}

.node-error-bar {
  margin: 0;
  padding: 6px 10px;
  font-size: 11px;
  color: #fff;
  background: rgba(255, 107, 107, 0.85);
  border-radius: 0;
  word-break: break-all;
  max-height: 48px;
  overflow: hidden;
}

.node-preview {
  padding: 8px 10px;
  border-top: 1px solid var(--panel-border);
  background: #12161f;
}

.node-preview-title {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.node-preview-img {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
  border: 1px solid var(--panel-border);
}

.node-preview-img.thumb {
  max-height: 72px;
}

.node-preview-img-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.node-preview-img-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.node-preview-figure {
  margin: 0;
  min-width: 0;
}

.node-preview-figure figcaption {
  margin-top: 2px;
  font-size: 9px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-preview-img-more {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px dashed var(--panel-border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.node-preview-count {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 4px;
}

.node-output-dir {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0 8px;
  word-break: break-all;
  line-height: 1.45;
}

.node-output-dir.compact {
  margin: 2px 0 6px;
  font-size: 10px;
}

.node-output-dir code,
.node-save-dir-hint code {
  color: #9eb4ff;
  font-size: inherit;
  background: rgba(79, 140, 255, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
}

.node-save-dir-hint {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--panel-border);
  font-size: 10px;
  color: var(--muted);
  word-break: break-all;
}

.param-panel-dir {
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(79, 140, 255, 0.08);
  border: 1px solid rgba(79, 140, 255, 0.2);
  margin-bottom: 10px;
}

.node-output-dir-row-wrap,
.node-output-dir-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.node-output-dir-text {
  flex: 1;
  min-width: 0;
  word-break: break-all;
  line-height: 1.45;
}

.node-output-dir-row .btn-copy-dir,
.node-output-dir-row-wrap .btn-copy-dir {
  flex-shrink: 0;
  margin-top: 1px;
}

.param-panel-dir .muted {
  margin-top: 6px;
}

.node-preview-md {
  font-size: 12px;
  line-height: 1.55;
  color: #c8d0df;
  max-height: 120px;
  overflow: hidden;
}

.node-preview-md h2,
.node-preview-md h3,
.node-preview-md h4 {
  font-size: 13px;
  margin: 6px 0 4px;
  color: var(--text);
}

.node-preview-html {
  background: #fff;
  color: #333;
  border-radius: 6px;
  padding: 8px;
  max-height: 120px;
  overflow: hidden;
  font-size: 13px;
  transform: scale(0.92);
  transform-origin: top left;
  width: 108%;
}

.node-preview-meta {
  font-size: 11px;
  line-height: 1.45;
  margin-top: 6px;
  word-break: break-all;
}

.node-preview-meta a {
  color: var(--accent);
}

.node-preview-path {
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

.node.status-running .node-title::after {
  content: " …";
  color: var(--running);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% { opacity: 0.4; }
}

.port.invalid { border-color: var(--error); background: rgba(255, 107, 107, 0.3); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden { display: none; }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
}

.lightbox img {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.preview-md-content {
  background: #11151d;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.65;
  color: #c8d0df;
  max-height: 480px;
  overflow: auto;
}

.preview-md-content h2,
.preview-md-content h3 { color: var(--text); margin: 12px 0 8px; }

.toolbar .hidden { display: none; }

.node.bypassed {
  opacity: 1;
  border: 2px dashed #e6a23c !important;
  background-color: #1c1810;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(230, 162, 60, 0.11) 0,
    rgba(230, 162, 60, 0.11) 8px,
    transparent 8px,
    transparent 16px
  );
  box-shadow:
    0 0 0 2px rgba(230, 162, 60, 0.22),
    inset 0 1px 0 rgba(255, 200, 100, 0.08);
}

.node.bypassed .node-header {
  background: rgba(230, 162, 60, 0.14);
  border-bottom-color: rgba(230, 162, 60, 0.35);
}

.node.bypassed .node-action-btn.bypass {
  background: rgba(230, 162, 60, 0.35);
  border-color: #e6a23c;
  color: #ffd28a;
  font-weight: 700;
}

.node-bypass-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  background: rgba(230, 162, 60, 0.28);
  color: #ffc866;
  border: 1px solid rgba(230, 162, 60, 0.65);
  vertical-align: middle;
}

.node.ctx-dimmed.bypassed {
  opacity: 0.88;
  filter: saturate(1);
}

.node-preview-video {
  width: 100%;
  max-height: 120px;
  border-radius: 6px;
  background: #000;
}

.history-panel { min-height: 200px; }

.history-item {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.status-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
}

.status-tag.status-success { background: rgba(62,207,142,0.2); color: var(--success); }
.status-tag.status-error { background: rgba(255,107,107,0.2); color: var(--error); }
.status-tag.status-cancelled { background: rgba(139,149,168,0.2); color: var(--muted); }

.history-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.history-actions .btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.connect-drop-menu {
  position: absolute;
  z-index: 120;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.connect-drop-title {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 8px;
}

.connect-drop-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.connect-drop-item:hover { background: var(--accent-soft); }

.node.status-bypassed {
  border-color: #e6a23c !important;
  border-style: dashed;
}

/* === Commercial UI === */
.mode-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.22);
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(79, 140, 255, 0.35);
}

.mode-tab.disabled,
.mode-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.global-progress {
  padding: 0 18px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.progress-track {
  height: 6px;
  background: #1f2430;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  width: 0%;
  transition: width 0.4s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  justify-content: flex-end;
}

.progress-step {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #1f2430;
  color: var(--muted);
}

.progress-step.status-success,
.progress-step.status-cached { background: rgba(62,207,142,0.2); color: var(--success); }
.progress-step.status-running { background: rgba(245,166,35,0.2); color: var(--running); }
.progress-step.status-error { background: rgba(255,107,107,0.2); color: var(--error); }
.progress-step.status-unchanged,
.progress-step.out-of-scope {
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
  opacity: 0.55;
}

.view-simple {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.simple-hero h2 { margin: 0 0 8px; font-size: 22px; }

.simple-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.simple-input-mode {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.simple-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.simple-input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.simple-input-row .simple-input {
  flex: 1 1 240px;
}

#simple-local-info {
  flex: 1 1 180px;
  min-width: 120px;
}

.local-video-info {
  flex: 1 1 160px;
  min-width: 100px;
  font-size: 13px;
  word-break: break-all;
}

.simple-input, .simple-select, .field-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
}

.simple-check {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-lg { padding: 12px 24px; font-size: 15px; }

.simple-actions-row { display: flex; gap: 8px; flex-wrap: wrap; }

.simple-log {
  font-size: 11px;
  max-height: 80px;
  overflow: auto;
  margin-top: 12px;
}

.simple-result { margin-top: 32px; }

.simple-preview {
  min-height: 200px;
  max-height: min(72vh, 760px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
}

.simple-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.manifest-list {
  margin: 8px 0 16px;
  padding-left: 20px;
  font-size: 13px;
  color: var(--muted);
}

.expert-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
  flex-wrap: wrap;
}

#view-expert.layout {
  height: 100%;
}

.toast-host {
  position: fixed;
  top: 68px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  font-size: 13px;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.25s ease;
}

.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--error); }
.toast-warning { border-color: var(--running); }

.onboarding {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  margin: 16px;
}

.modal-wide { max-width: 520px; width: 90vw; }

/* ── Auth modal ── */
.auth-modal {
  backdrop-filter: blur(8px);
  background: rgba(8, 10, 16, 0.72);
}

.auth-card {
  position: relative;
  width: min(820px, 94vw);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.auth-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 420px;
}

.auth-brand {
  padding: 40px 36px;
  background: linear-gradient(145deg, #1a2744 0%, #12182a 50%, #171a22 100%);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(79, 140, 255, 0.35);
}

.auth-brand h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-brand > p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-features {
  margin: 0;
  padding: 0;
  list-style: none;
}

.auth-features li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #b8c4d8;
  line-height: 1.4;
}

.auth-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--success);
  font-size: 12px;
}

.auth-form-wrap {
  padding: 40px 36px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #11151d;
  border-radius: 10px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.auth-tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-field .field-input {
  width: 100%;
  padding: 12px 14px;
  background: #11151d;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-field .field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-radius: 8px;
  color: var(--error);
  font-size: 13px;
}

.auth-error.hidden { display: none; }

.auth-field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.auth-support-box {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.15);
}
.auth-support-box.hidden { display: none; }
.auth-support-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.auth-support-lines {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.auth-support-lines div + div { margin-top: 2px; }

.auth-submit-btn {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  margin-top: 4px;
}

#btn-login {
  background: linear-gradient(135deg, var(--accent), #6b5cff);
  border-color: transparent;
  color: #fff;
}

#btn-login:hover {
  filter: brightness(1.08);
  border-color: transparent;
}

@media (max-width: 680px) {
  .auth-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .auth-brand {
    padding: 28px 24px 20px;
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
  }
  .auth-features { display: none; }
  .auth-form-wrap { padding: 24px; }
}

.config-group { margin-bottom: 16px; }
.config-group h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.config-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--panel-border);
  font-size: 13px;
}
.config-item.ok .config-badge { color: var(--success); }
.config-item.missing .config-badge { color: var(--error); }

.settings-card { max-width: 640px; max-height: 85vh; overflow-y: auto; }
.settings-tabs { display: flex; gap: 4px; margin: 12px 0 16px; border-bottom: 1px solid var(--panel-border); }
.settings-tab {
  border: none; background: transparent; padding: 8px 14px; cursor: pointer;
  font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }
.settings-hr { border: none; border-top: 1px solid var(--panel-border); margin: 16px 0; }
.settings-key-row { margin-bottom: 12px; }
.settings-key-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 13px; }
.settings-wh-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

.node-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  border: 2px solid var(--running);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

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

.node.is-running { box-shadow: 0 0 0 2px rgba(245,166,35,0.35); }

.history-sub { font-size: 11px; margin: 4px 0; }
.history-url { font-size: 11px; margin-bottom: 8px; word-break: break-all; }

.template-gallery { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.template-card {
  border: 1px solid var(--panel-border); background: var(--panel); border-radius: 8px;
  padding: 10px 14px; cursor: pointer; text-align: left; max-width: 200px;
}
.template-card strong { display: block; font-size: 13px; }
.template-card span { font-size: 11px; color: var(--muted); }

.simple-editor-wrap { margin: 16px 0; }
.simple-editor { width: 100%; border-radius: 8px; border: 1px solid var(--panel-border); background: var(--panel); color: var(--text); padding: 12px; font-family: inherit; }

.comfy-queue {
  position: absolute; bottom: 12px; left: 12px; width: 220px; background: var(--panel);
  border: 1px solid var(--panel-border); border-radius: 8px; z-index: 20; font-size: 11px;
}
.comfy-queue-header { padding: 8px 10px; border-bottom: 1px solid var(--panel-border); font-weight: 600; }
.comfy-queue-list { max-height: 120px; overflow: auto; padding: 6px; }
.queue-item { padding: 4px 6px; border-radius: 4px; margin-bottom: 2px; background: #1a1f2a; }
.queue-item.status-success { color: var(--success); }
.queue-item.status-error { color: var(--error); }

.comfy-minimap {
  position: absolute; bottom: 12px; right: 12px; border: 1px solid var(--panel-border);
  border-radius: 6px; z-index: 20; opacity: 0.85;
}

.ctx-menu {
  position: fixed; z-index: 200; background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 4px; min-width: 140px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.ctx-menu button {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  color: var(--text); padding: 8px 12px; border-radius: 4px; cursor: pointer; font-size: 13px;
}
.ctx-menu button:hover { background: var(--accent-soft); }

.box-select-rect {
  position: absolute; border: 1px dashed var(--accent); background: rgba(79,140,255,0.1); pointer-events: none; z-index: 5;
}

.canvas-wrap { position: relative; }

.hidden { display: none !important; }

@media (max-width: 900px) {
  .topbar-main {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 10px;
  }

  .topbar-spacer {
    display: none;
  }

  .mode-switch {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .user-chip {
    max-width: 180px;
  }

  .user-email {
    max-width: 120px;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: 100%;
  }

  .layout.panel-left-collapsed,
  .layout.panel-right-collapsed {
    --panel-left-w: 1fr;
    --panel-right-w: 1fr;
  }

  .sidebar.left {
    order: 1;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
  }

  .canvas-wrap {
    order: 2;
    min-height: 50vh;
  }

  .sidebar.right {
    order: 3;
    border-left: none;
    border-top: 1px solid var(--panel-border);
    max-height: 42vh;
  }

  .layout.panel-left-collapsed .sidebar.left .sidebar-body,
  .layout.panel-right-collapsed .sidebar.right .sidebar-body {
    display: none;
  }

  .layout.panel-left-collapsed .sidebar.left .sidebar-label,
  .layout.panel-right-collapsed .sidebar.right .side-tabs {
    display: none;
  }

  .mode-switch { margin-left: 0; }
  .brand { flex-wrap: wrap; }
}

@media (max-width: 600px) {
  .brand-sub { display: none; }
  .quota-label { display: none; }
  .btn-logout { padding: 8px; }
  .view-simple { padding: 16px 12px; }
}

/* ── Workflow run FX ── */
#btn-fx-level.fx-off {
  opacity: 0.65;
}

.edge-path.edge-state-active { stroke: rgba(79, 200, 255, 0.55); }
.edge-path.edge-state-success { stroke: rgba(62, 207, 142, 0.45); }
.edge-path.edge-state-error { stroke: rgba(255, 107, 107, 0.75); }
.edge-path.edge-state-blocked {
  stroke: rgba(139, 149, 168, 0.35);
  stroke-dasharray: 6 8;
}
.edge-path.edge-state-bypass {
  stroke: rgba(230, 162, 60, 0.75);
  stroke-dasharray: 8 6;
  stroke-width: 2.5;
}
.edge-path.edge-state-skipped {
  stroke: rgba(139, 149, 168, 0.25);
  stroke-dasharray: 3 8;
  opacity: 0.6;
}
.edge-path.edge-state-cached { stroke: rgba(91, 192, 222, 0.55); }

.edge-flow-track {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.85;
}

.edge-fx-active .edge-flow-track {
  stroke: rgba(64, 196, 255, 0.55);
  stroke-dasharray: 10 16;
  animation: edge-flow-march 1.1s linear infinite;
  filter: url(#wf-glow-blue);
}

.edge-fx-error .edge-flow-track {
  stroke: rgba(255, 90, 90, 0.85);
  stroke-dasharray: 8 10;
  animation: edge-flow-march 0.55s linear infinite, edge-flow-blink 1s ease-in-out infinite;
}

.edge-fx-bypass .edge-flow-track {
  stroke: rgba(230, 162, 60, 0.65);
  stroke-dasharray: 8 12;
  animation: edge-flow-march 2s linear infinite;
  opacity: 0.75;
}

.edge-fx-success .edge-flow-track {
  stroke: rgba(62, 207, 142, 0.35);
  stroke-dasharray: none;
  opacity: 0.5;
  animation: edge-fx-fadeout 2.8s ease forwards;
}

.edge-fx-blocked .edge-flow-track,
.edge-fx-skipped .edge-flow-track {
  display: none;
}

.edge-fx-cached-flash .edge-flow-track {
  stroke: rgba(91, 192, 222, 0.7);
  animation: edge-cached-flash 0.8s ease-out 1;
}

.edge-particle { fill: #5fd4ff; opacity: 0.95; }
.edge-fx-error .edge-particle { fill: #ff6b6b; }
.edge-fx-bypass .edge-particle { fill: #ffc866; opacity: 0.85; }

@keyframes edge-flow-march {
  to { stroke-dashoffset: -26; }
}

@keyframes edge-flow-blink {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.35; }
}

@keyframes edge-fx-fadeout {
  0% { opacity: 0.7; }
  100% { opacity: 0; }
}

@keyframes edge-cached-flash {
  0% { opacity: 0.9; stroke-width: 5; }
  100% { opacity: 0; stroke-width: 3; }
}

@keyframes fx-breathe {
  0%, 100% {
    box-shadow: 0 0 0 2px rgba(79, 180, 255, 0.3), 0 0 14px rgba(79, 180, 255, 0.12);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(79, 180, 255, 0.55), 0 0 24px rgba(79, 180, 255, 0.22);
  }
}

@keyframes fx-error-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.45); }
  50% { box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.75), 0 0 16px rgba(255, 107, 107, 0.25); }
}

@keyframes port-ripple-anim {
  0% { transform: scale(0.6); opacity: 0.75; }
  100% { transform: scale(2.8); opacity: 0; }
}

.node.fx-running {
  border-color: #4fb4ff !important;
  animation: fx-breathe 2s ease-in-out infinite;
}

.node.fx-success:not(.fx-bypass):not(.bypassed) {
  border-color: var(--success) !important;
  box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.35);
}

.node.fx-error {
  border-color: var(--error) !important;
  animation: fx-error-pulse 1.6s ease-in-out infinite;
}

.node.fx-cached {
  border-color: #5bc0de !important;
  box-shadow: 0 0 0 2px rgba(91, 192, 222, 0.3);
}

.node.fx-skipped {
  opacity: 0.45;
  filter: grayscale(0.35);
}

.node.fx-bypass,
.node.fx-bypass.bypassed {
  border-color: #e6a23c !important;
  box-shadow: 0 0 0 2px rgba(230, 162, 60, 0.28);
}

.node.fx-cancelled {
  opacity: 0.7;
  animation: none;
  transition: opacity 0.4s ease, box-shadow 0.4s ease;
}

.node.fx-simple.fx-running {
  animation: none;
  box-shadow: 0 0 0 2px rgba(79, 180, 255, 0.45);
}

.node.fx-simple.fx-error {
  animation: none;
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.6);
}

.port {
  position: relative;
  overflow: visible;
}

.port.port-pulse::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(79, 200, 255, 0.75);
  animation: port-ripple-anim 0.65s ease-out forwards;
  pointer-events: none;
}

.port.output.port-pulse::after {
  border-color: rgba(62, 207, 142, 0.75);
}

.port.input.port-pulse::after {
  border-color: rgba(79, 200, 255, 0.75);
}

body[data-fx-level="off"] .edge-fx-layer,
body[data-fx-level="off"] .node[class*="fx-"] {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .edge-fx-layer,
  .node.fx-running,
  .node.fx-error,
  .port.port-pulse::after {
    animation: none !important;
  }
  .edge-particle animateMotion,
  .edge-particle > animateMotion {
    display: none;
  }
}

/* ── Selection context (neighbor highlight) ── */
.node.ctx-focused {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 20px rgba(79, 140, 255, 0.18);
  z-index: 3;
}

.node.ctx-upstream {
  box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.28), inset 3px 0 0 rgba(62, 207, 142, 0.75);
  border-color: rgba(62, 207, 142, 0.45) !important;
  z-index: 2;
}

.node.ctx-downstream {
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.25), inset -3px 0 0 rgba(108, 92, 231, 0.7);
  border-color: rgba(108, 92, 231, 0.45) !important;
  z-index: 2;
}

.node.ctx-dimmed {
  opacity: 0.42;
  filter: saturate(0.65);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.node.ctx-dimmed.fx-running,
.node.ctx-dimmed.fx-error {
  opacity: 0.78;
  filter: saturate(0.85);
}

.edge-path.edge-ctx-active {
  stroke: var(--accent) !important;
  stroke-width: 2.5;
  opacity: 1;
  filter: drop-shadow(0 0 4px rgba(79, 140, 255, 0.45));
}

.edge-path.edge-ctx-dimmed {
  opacity: 0.18;
  stroke-width: 1.5;
}
