:root {
  --bg: #121316;
  --panel: #191a1f;
  --panel-soft: #222329;
  --panel-strong: #2b2d33;
  --rail: #2f3033;
  --border: #30323a;
  --border-strong: #41444d;
  --text: #e5e7eb;
  --muted: #a1a1aa;
  --muted-soft: #71717a;
  --primary: #4aa3ff;
  --primary-soft: rgba(74, 163, 255, 0.16);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --node-blue: #60a5fa;
  --node-violet: #a78bfa;
  --node-green: #34d399;
  --node-amber: #fbbf24;
  --node-slate: #94a3b8;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  --ui-scale: 0.8;
  --ui-scale-inverse: 1.25;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.42) rgba(15, 16, 20, 0.24);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: rgba(15, 16, 20, 0.24);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid rgba(15, 16, 20, 0.24);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.42);
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(180, 190, 205, 0.68);
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

.studio-shell {
  width: calc(100vw * var(--ui-scale-inverse));
  height: calc(100vh * var(--ui-scale-inverse));
  overflow: hidden;
  transform: scale(var(--ui-scale));
  transform-origin: 0 0;
}

.studio-main {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.studio-main {
  position: relative;
}

.canvas-shell {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: var(--bg);
}

.canvas-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: #212121;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.46) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.46) 1px, transparent 1px);
  background-size: 28px 28px;
}

.module-card-shadow {
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.22));
}

#workflow-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.annotation-layer,
.node-widget-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.annotation-layer {
  z-index: 2;
  overflow: visible;
}

.node-widget-layer {
  z-index: 3;
}

.top-progress-bar {
  position: fixed;
  left: 0;
  right: 0;
  top: 48px;
  z-index: 50;
  height: 22px;
  background: rgba(8, 14, 11, 0.92);
  overflow: hidden;
}

.run-progress {
  height: 100%;
  width: 0%;
  border-radius: 0;
  background: #0f7a2f;
  box-shadow: 0 0 12px rgba(15, 122, 47, 0.62);
  transition: width 0.18s ease;
}

.run-progress.awaiting-confirmation {
  background: #eab308;
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.72);
}

.run-progress-meta {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 14px;
  color: #ecfdf5;
  font-size: 11px;
  font-weight: 820;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.progress-follow-toggle.active {
  border-color: rgba(34, 197, 94, 0.9);
  background: rgba(34, 197, 94, 0.24);
  color: #ecfdf5;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.28);
}

#run-progress-percent {
  min-width: 34px;
  text-align: right;
}

#run-progress-detail {
  max-width: min(58vw, 560px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-command-dock {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: rgba(25, 26, 31, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
}

.workflow-title-block,
.command-actions,
.canvas-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workflow-title-block {
  flex: 1 1 auto;
  justify-content: flex-start;
  min-width: 0;
}

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

.top-icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #101114;
  color: var(--text);
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.top-icon-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.top-icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--panel-soft);
}

.top-icon-button.primary {
  color: #bfdbfe;
  border-color: rgba(37, 99, 235, 0.48);
  background: rgba(37, 99, 235, 0.13);
}

.top-icon-button.danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.38);
  background: rgba(239, 68, 68, 0.08);
}

.top-icon-button.api-doc-trigger {
  color: #bfdbfe;
  border-color: rgba(74, 163, 255, 0.48);
  background: rgba(74, 163, 255, 0.12);
}

.top-icon-button.api-doc-trigger:hover {
  border-color: rgba(74, 163, 255, 0.82);
  background: rgba(74, 163, 255, 0.2);
}

.canvas-stats {
  color: var(--muted);
  font-size: 12px;
  padding: 0 6px;
}

.workflow-name-input {
  width: min(360px, 34vw);
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #101114;
  color: var(--text);
  outline: none;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.workflow-name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.save-state {
  height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.save-state.saved {
  color: #86efac;
  background: rgba(34, 197, 94, 0.14);
}

.save-state.dirty,
.save-state.saving {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.14);
}

.save-state.error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
}

.left-panel {
  position: fixed;
  left: 8px;
  top: 84px;
  bottom: 8px;
  z-index: 20;
  width: 398px;
  display: grid;
  grid-template-columns: 66px 1fr;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: width 0.18s ease;
}

.left-panel:not(.collapsed) {
  z-index: 30;
}

.left-panel.collapsed {
  width: 66px;
}

.left-panel.collapsed .sidebar-content {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.left-panel.is-transitioning .sidebar-content,
.right-panel.is-transitioning .inspector-body {
  overflow: hidden;
}

.nav-rail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 8px 6px;
  background: var(--rail);
  border-right: 1px solid var(--border);
}

.panel-tab {
  position: relative;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  gap: 2px;
  background: transparent;
  color: #b8bac2;
}

.panel-tab:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.panel-tab.active {
  background: #3a3b40;
  color: #fff;
}

.panel-tab.active::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
}

.nav-icon {
  font-size: 23px;
  line-height: 1;
}

.nav-text {
  max-width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  line-height: 1.1;
}

.sidebar-content {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.12s ease;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: #17181d;
}

.brand-title {
  font-size: 15px;
  font-weight: 820;
  line-height: 1.1;
}

.brand-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.left-section {
  display: none;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  scrollbar-gutter: stable;
}

.left-section.active {
  display: block;
}

.section-toolbar {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.tool-icon,
.icon-action {
  min-width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101114;
  color: var(--text);
  font-weight: 820;
  padding: 0;
}

.icon-action:hover,
.tool-icon:hover {
  border-color: var(--border-strong);
  background: var(--panel-soft);
}

.icon-action svg {
  width: 16px;
  height: 16px;
  display: block;
}

.progress-follow-toggle svg {
  transform: translate(1px, 1px);
}

.icon-action.wide {
  flex: 1;
  padding: 0 10px;
}

.node-search {
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #090a0c;
  color: var(--text);
  outline: none;
  padding: 0 12px;
  font-size: 13px;
}

.node-search::placeholder {
  color: var(--muted-soft);
}

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

.node-category {
  color: var(--text);
}

.node-category summary {
  min-height: 36px;
  display: grid;
  grid-template-columns: 18px 20px 1fr auto;
  align-items: center;
  gap: 6px;
  list-style: none;
  border-radius: 8px;
  padding: 0 8px;
  color: #e2e8f0;
  font-size: 14px;
  user-select: none;
}

.node-category summary::-webkit-details-marker {
  display: none;
}

.node-category summary:hover {
  background: rgba(255, 255, 255, 0.06);
}

.node-category[open] .category-arrow {
  transform: rotate(90deg);
}

.category-arrow {
  display: inline-flex;
  justify-content: center;
  color: #f8fafc;
  font-size: 24px;
  line-height: 1;
  transition: transform 0.12s ease;
}

.category-folder {
  color: #a5b4fc;
}

.node-category b {
  min-width: 24px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--panel-strong);
  color: #d4d4d8;
  font-size: 11px;
  font-weight: 800;
}

.module-library {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 8px 34px;
}

.module-preset,
.workflow-item {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #dbe4ef;
  padding: 8px 10px;
  text-align: left;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.module-preset:hover,
.workflow-item:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}

.module-preset {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 740;
  cursor: grab;
  user-select: none;
}

.module-preset:active,
.module-preset.dragging {
  cursor: grabbing;
}

.module-preset.dragging {
  border-color: rgba(74, 163, 255, 0.55);
  background: rgba(74, 163, 255, 0.12);
  opacity: 0.72;
}

.workflow-item.active {
  border-color: rgba(74, 163, 255, 0.5);
  background: var(--primary-soft);
}

.workflow-item-title {
  font-size: 13px;
  font-weight: 820;
  color: var(--text);
}

.workflow-item-meta {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
}

.placeholder-list {
  display: grid;
  gap: 6px;
  padding: 4px 0 10px 44px;
  color: var(--muted);
  font-size: 12px;
}

.preset-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.preset-dot.blue { background: var(--node-blue); }
.preset-dot.violet { background: var(--node-violet); }
.preset-dot.green { background: var(--node-green); }
.preset-dot.amber { background: var(--node-amber); }
.preset-dot.slate { background: var(--node-slate); }
.preset-dot.red { background: #dc2626; }

.utility-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111216;
  padding: 12px;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 13px;
}

.muted-card {
  color: var(--muted);
  line-height: 1.6;
}

.canvas-mini-panel {
  position: fixed;
  z-index: 25;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(25, 26, 31, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.canvas-mini-panel {
  left: 82px;
  bottom: 14px;
  padding: 10px 12px;
}

.canvas-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.canvas-actions #zoom-label {
  min-width: 48px;
  text-align: center;
  color: var(--text);
}

.right-panel {
  position: fixed;
  top: 84px;
  right: 8px;
  bottom: 8px;
  z-index: 22;
  width: 344px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: width 0.18s ease;
}

.right-panel.collapsed {
  width: 46px;
}

.right-panel.collapsed .right-header {
  height: 100%;
  padding: 8px 6px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.right-panel.collapsed .right-header > div {
  display: none;
}

.right-panel.collapsed .inspector-body,
.right-panel.collapsed .inspector-footer {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.right-panel.collapsed .inspector-toggle {
  margin: 0;
}

.right-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: #17181d;
}

.right-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 820;
}

.right-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.inspector-body {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  scrollbar-gutter: stable;
}

.right-panel.has-footer-action .inspector-body {
  padding-bottom: 84px;
}

.inspector-footer {
  display: none;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: rgba(23, 24, 29, 0.96);
  box-shadow: 0 -14px 24px rgba(0, 0, 0, 0.2);
}

.right-panel.has-footer-action .inspector-footer {
  display: block;
}

.inspector-toggle {
  flex: 0 0 auto;
}

.btn {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 12px;
  color: var(--text);
  background: #101114;
  font-weight: 720;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--panel-soft);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn.primary {
  color: #fff;
  border-color: #2563eb;
  background: #2563eb;
}

.btn.run {
  color: #07110b;
  border-color: #22c55e;
  background: #22c55e;
}

.btn.danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.38);
  background: rgba(239, 68, 68, 0.08);
}

.btn.ghost {
  background: #101114;
}

.btn.small {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.form-control,
textarea.form-control,
select.form-control {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #101114;
  color: var(--text);
  outline: none;
  padding: 9px 10px;
  font-size: 13px;
}

textarea.form-control {
  min-height: 76px;
  resize: vertical;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.inline-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.inspector-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111216;
  padding: 10px;
  margin-bottom: 10px;
}

.inspector-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 820;
}

.port-row,
.field-row {
  display: grid;
  grid-template-columns: 1fr 74px 30px;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.field-row {
  grid-template-columns: 1fr 84px 30px;
}

.field-value-row {
  margin: -2px 0 10px;
}

.mini-btn {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101114;
  color: var(--text);
  font-weight: 760;
}

.mini-btn.danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.38);
  background: rgba(239, 68, 68, 0.08);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111216;
  padding: 12px;
}

.stat-value {
  font-size: 22px;
  font-weight: 860;
}

.stat-label {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.empty-state {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.empty-state.visible {
  display: flex;
}

.empty-card {
  width: 340px;
  padding: 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  background: rgba(25, 26, 31, 0.82);
  text-align: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.empty-icon {
  width: 50px;
  height: 50px;
  margin: 0 auto 14px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #08111f;
  background: var(--primary);
  font-size: 28px;
  font-weight: 760;
}

.empty-card h3 {
  margin: 0;
  font-size: 16px;
}

.empty-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  min-width: 240px;
  max-width: 520px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #0b0c0f;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
  font-size: 13px;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1180px) {
  .right-panel {
    width: 320px;
  }
}

@media (max-width: 980px) {
  .right-panel {
    display: none;
  }

  .top-command-dock {
    right: 8px;
  }
}

@media (max-width: 760px) {
  .left-panel {
    width: min(398px, calc(100vw - 16px));
  }

  .top-command-dock {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 8px;
    justify-content: space-between;
  }

  .workflow-name-input,
  .canvas-stats {
    display: none;
  }

  .canvas-mini-panel,
  .run-status-panel {
    display: none;
  }
}

/* annotation region styles */
.annotation-region {
  position: absolute;
  pointer-events: auto;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--annotation-color) 64%, transparent);
  border-radius: 14px;
  background: var(--annotation-fill);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 16px 34px rgba(0, 0, 0, 0.18);
  cursor: move;
  user-select: none;
}

.annotation-region.selected {
  border-color: var(--annotation-color);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--annotation-color) 52%, transparent), 0 0 0 2px color-mix(in srgb, var(--annotation-color) 28%, transparent), 0 18px 38px rgba(0, 0, 0, 0.24);
}

.annotation-title {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: #f8fafc;
  background: color-mix(in srgb, var(--annotation-color) 32%, rgba(15, 23, 42, 0.68));
  font-size: 30px;
  font-weight: 860;
  letter-spacing: 0.01em;
}

.annotation-note {
  padding: 12px 14px;
  color: rgba(248, 250, 252, 0.78);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.annotation-resize-handle {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  border-right: 2px solid rgba(248, 250, 252, 0.52);
  border-bottom: 2px solid rgba(248, 250, 252, 0.52);
  border-radius: 0 0 8px 0;
}

.annotation-tools {
  display: grid;
  gap: 10px;
}

/* node-widget styles */
.node-widget-card {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  overflow: visible;
  border: 1px solid #2c3038;
  border-radius: 10px;
  background: #3a3a3a;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.22);
}

.node-widget-card.palette-drag-preview {
  pointer-events: none;
  opacity: 0.62;
  filter: saturate(1.08) brightness(1.08);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.12);
  z-index: 9999;
}

.node-widget-card.palette-drag-preview .node-card-header {
  cursor: grabbing;
}

.node-widget-card.selected {
  border-color: var(--node-color);
  box-shadow: 0 16px 28px color-mix(in srgb, var(--node-color) 24%, transparent);
}

.node-widget-card.running {
  border-color: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.5), 0 0 30px rgba(34, 197, 94, 0.34), 0 16px 32px rgba(0, 0, 0, 0.32);
  animation: nodeRunningPulse 1.05s ease-in-out infinite;
}

.node-widget-card.waiting {
  border-color: #eab308;
  box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.56), 0 0 30px rgba(234, 179, 8, 0.32), 0 16px 32px rgba(0, 0, 0, 0.32);
}

.node-widget-card.waiting .node-card-signal {
  background: #facc15;
  box-shadow: 0 0 0 6px rgba(234, 179, 8, 0.16), 0 0 16px rgba(250, 204, 21, 0.9);
  animation: nodeSignalPulse 1.1s ease-in-out infinite;
}

.node-widget-card.completed {
  border-color: rgba(34, 197, 94, 0.72);
}

.node-widget-card.completed .node-card-signal {
  background: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.72);
}

.node-widget-card.running .node-card-signal {
  background: #86efac;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.16), 0 0 16px rgba(134, 239, 172, 0.9);
  animation: nodeSignalPulse 0.72s ease-in-out infinite;
}

@keyframes nodeRunningPulse {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.12);
  }
}

@keyframes nodeSignalPulse {
  0%, 100% {
    transform: scale(0.88);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.14);
    opacity: 1;
  }
}

.node-card-header {
  height: 40px;
  flex: 0 0 40px;
  border-radius: 9px 9px 0 0;
  background: var(--node-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 14px;
  cursor: grab;
}

.node-card-header:active {
  cursor: grabbing;
}

.node-card-title {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-card-signal {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #475569;
  border: 1px solid rgba(255, 255, 255, 0.28);
  flex: 0 0 auto;
}

.node-card-body {
  padding: 12px 14px 10px;
}

.node-card-desc {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.35;
  min-height: 18px;
  margin-bottom: 10px;
}

.node-port-zone {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.node-port-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.node-port-column.output {
  align-items: flex-end;
}

.node-port-row {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1;
  max-width: 100%;
  cursor: crosshair;
  user-select: none;
}

.node-port-row.output {
  flex-direction: row-reverse;
  text-align: right;
}

.node-port-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--port-color);
  border: 2px solid var(--port-color);
  flex: 0 0 auto;
}

.node-port-row.input .node-port-dot {
  background: #ffffff;
}

.node-port-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-port-row.link-source .node-port-dot,
.node-port-row.link-compatible .node-port-dot {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--port-color) 24%, transparent), 0 0 16px color-mix(in srgb, var(--port-color) 54%, transparent);
}

.node-port-row.link-compatible {
  color: #f8fafc;
}

.node-port-row.link-incompatible {
  color: #64748b;
  cursor: not-allowed;
}

.node-port-row.link-incompatible .node-port-dot {
  background: #475569;
  border-color: #64748b;
  box-shadow: none;
  filter: grayscale(1);
  opacity: 0.46;
}

.node-port-row.link-snap-target {
  color: #bbf7d0;
  transform: translateX(-2px);
}

.node-port-row.link-snap-target .node-port-dot {
  transform: scale(1.38);
  border-color: #22c55e;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.2), 0 0 22px rgba(34, 197, 94, 0.78);
}

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

.node-card-footer {
  margin-top: auto;
  padding: 0 14px 12px;
  color: #94a3b8;
  font-size: 11px;
}

.node-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 2px;
}

.node-field-label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}

.node-field-input {
  background-color: #1e293b;
  border: 1px solid #334155;
  color: #f8fafc;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
  height: 28px;
}

.node-field-input:focus {
  border-color: #4f46e5;
}

.camera3d-control {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(147, 51, 234, 0.38);
  border-radius: 12px;
  background: radial-gradient(circle at 50% 0%, rgba(147, 51, 234, 0.22), rgba(15, 23, 42, 0.94) 52%, rgba(2, 6, 23, 0.98));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 14px 30px rgba(0, 0, 0, 0.28);
}

.camera3d-stage {
  position: relative;
  height: 160px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.78), rgba(2, 6, 23, 0.96));
  perspective: 620px;
}

.camera3d-stage.sliding .camera3d-orbit {
  transition: transform 0.68s cubic-bezier(0.22, 1, 0.36, 1);
}

.camera3d-stage.sliding .camera3d-camera,
.camera3d-stage.sliding .camera3d-person-shell {
  transition: transform 0.68s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease;
}

.camera3d-grid {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 12px;
  height: 78px;
  transform: rotateX(68deg);
  transform-origin: center bottom;
  background-image: linear-gradient(rgba(148, 163, 184, 0.26) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, 0.26) 1px, transparent 1px);
  background-size: 18px 18px;
  border-radius: 999px;
  opacity: 0.62;
}

.camera3d-orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 118px;
  height: 118px;
  transform-style: preserve-3d;
  transform: translate(calc(-50% + var(--camera-x, 0px)), calc(-50% + var(--camera-y, 0px))) rotateX(var(--camera-pitch, 0deg)) rotateY(var(--camera-yaw, 0deg)) rotateZ(var(--camera-roll, 0deg));
}

.camera3d-orbit::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(196, 181, 253, 0.58);
  border-radius: 50%;
  transform: rotateX(68deg);
}

.camera3d-person-shell {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 76px;
  height: 110px;
  transform: translate(-50%, -50%);
  transform-style: preserve-3d;
}

.camera3d-person-shadow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 72px;
  height: 22px;
  transform: translateX(-50%) rotateX(68deg);
  border-radius: 50%;
  background: rgba(96, 165, 250, 0.18);
  filter: blur(1px);
}

.camera3d-person-body {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38px;
  height: 82px;
  transform: translate(-50%, -50%) translateZ(2px);
  border-radius: 18px 18px 10px 10px;
  background: linear-gradient(180deg, #f8fafc 0 20%, #60a5fa 21% 58%, #1d4ed8 59% 100%);
  box-shadow: 0 14px 28px rgba(96, 165, 250, 0.24);
}

.camera3d-person-body::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 9px;
  width: 4px;
  height: 58px;
  transform: translateX(-50%) translateZ(4px);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.86);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.camera3d-person-body span {
  position: absolute;
  left: 50%;
  top: -18px;
  width: 28px;
  height: 28px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #f8fafc;
}

.camera3d-person-billboard {
  position: absolute;
  left: 50%;
  top: 4px;
  transform: translateX(-50%) rotateY(var(--camera-counter-yaw, 0deg)) translateZ(32px);
  padding: 3px 7px;
  border: 1px solid rgba(191, 219, 254, 0.72);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #dbeafe;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.72);
}

.camera3d-facing-badge {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%) rotateY(var(--camera-counter-yaw, 0deg)) translateZ(34px);
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(96, 165, 250, 0.9);
  color: #020617;
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: 0 0 14px rgba(96, 165, 250, 0.42);
}

.camera3d-camera {
  position: absolute;
  left: 50%;
  top: -4px;
  width: 44px;
  height: 22px;
  transform: translateX(-50%) translateZ(calc(72px + var(--camera-z, 0px)));
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #a855f7;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.72);
}

.camera3d-axis {
  position: absolute;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: #020617;
  font-size: 11px;
  font-weight: 900;
}

.camera3d-axis.x { right: 18px; bottom: 28px; background: #f87171; }
.camera3d-axis.y { left: 18px; top: 20px; background: #4ade80; }
.camera3d-axis.z { right: 48px; top: 26px; background: #60a5fa; }

.camera3d-view-label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  color: #e9d5ff;
  font-size: 12px;
  font-weight: 900;
}

.camera3d-view-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.camera3d-view-tab {
  height: 28px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.82);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 800;
}

.camera3d-view-tab.active {
  border-color: rgba(168, 85, 247, 0.9);
  background: rgba(147, 51, 234, 0.42);
  color: #f5f3ff;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.26);
}

.camera3d-sliders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.camera3d-slider-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  font-size: 11px;
}

.camera3d-slider-row input {
  min-width: 0;
  accent-color: #a855f7;
}

.camera3d-slider-row output {
  color: #e9d5ff;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

textarea.node-field-input {
  resize: vertical;
  min-height: 72px;
  height: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 19px;
  white-space: pre;
  overflow: auto;
}

.node-code-editor {
  position: relative;
  min-height: var(--code-height, 72px);
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0f172a;
  overflow: hidden;
}

.node-code-editor:focus-within {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.22);
}

.node-code-highlight,
.node-code-input {
  min-height: var(--code-height, 72px);
  height: var(--code-height, 72px);
  margin: 0;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 19px;
  white-space: pre;
  tab-size: 2;
  box-sizing: border-box;
}

.node-code-highlight {
  position: absolute;
  inset: 0;
  color: #cbd5e1;
  pointer-events: none;
  overflow: hidden;
}

.node-code-input {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: #f8fafc;
  resize: vertical;
  outline: none;
}

.node-code-input::selection {
  color: transparent;
  background: rgba(96, 165, 250, 0.32);
}

.code-token.keyword {
  color: #93c5fd;
  font-weight: 700;
}

.code-token.string {
  color: #86efac;
}

.code-token.number {
  color: #fbbf24;
}

.code-token.punctuation {
  color: #c084fc;
}

.node-toggle-control,
.inspector-toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #cbd5e1;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.node-toggle-control input,
.inspector-toggle-field input {
  width: 16px;
  height: 16px;
  accent-color: #4f46e5;
}

.node-toggle-control .node-field-input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.node-field-image,
.node-field-video {
  width: 100%;
  min-height: 120px;
  background-color: #1e293b;
  border: 1px dashed #334155;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.node-field-image:hover,
.node-field-video:hover {
  border-color: #4f46e5;
}

.node-field-image.has-image,
.node-field-video.has-video {
  display: block;
  min-height: 0;
  border-style: solid;
  background-color: #0f172a;
}

.node-field-image img,
.inspector-image-upload img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.node-field-video video,
.inspector-video-upload video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
  min-height: 160px;
  object-fit: contain;
  background: #020617;
}

.inspector-image-upload,
.inspector-video-upload {
  width: 100%;
  min-height: 180px;
  background-color: #1e293b;
  border: 1px dashed #334155;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.inspector-image-upload:hover,
.inspector-video-upload:hover {
  border-color: #4f46e5;
}

.inspector-image-upload.has-image,
.inspector-video-upload.has-video {
  display: block;
  min-height: 0;
  border-style: solid;
  background-color: #0f172a;
}

.image-sequence-editor {
  display: grid;
  gap: 10px;
}

.image-sequence-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 800;
}

.image-sequence-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.image-sequence-item {
  position: relative;
  min-height: 104px;
  overflow: hidden;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
}

.image-sequence-item.active {
  border-color: #22c55e;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.3);
}

.image-sequence-item img {
  display: block;
  width: 100%;
  height: 104px;
  object-fit: cover;
}

.image-sequence-item span {
  position: absolute;
  left: 6px;
  bottom: 6px;
  min-width: 18px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #e5e7eb;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}

.image-sequence-empty {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border: 1px dashed #334155;
  border-radius: 8px;
  color: #64748b;
  font-size: 12px;
  text-align: center;
  background: #1e293b;
}

.local-upload-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #d1fae5;
  font-size: 10px;
  font-weight: 800;
  pointer-events: none;
}

.upload-placeholder {
  font-size: 12px;
  color: #64748b;
}

.remove-image-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.remove-image-btn:hover {
  background: #ef4444;
}

.api-doc-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.api-doc-modal.visible {
  display: flex;
}

.api-doc-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(10px);
}

.api-doc-panel {
  position: relative;
  z-index: 1;
  width: min(1040px, calc(100vw - 48px));
  max-height: min(820px, calc(100vh - 56px));
  transform: scale(var(--ui-scale));
  transform-origin: center center;
  border: 1px solid rgba(74, 163, 255, 0.26);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(25, 26, 31, 0.98), rgba(15, 17, 23, 0.98));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.52);
  overflow: hidden;
}

.api-doc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}

.api-doc-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.api-doc-kicker {
  margin-bottom: 4px;
  color: #93c5fd;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.api-doc-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.api-doc-body {
  max-height: calc(min(820px, 100vh - 56px) - 82px);
  overflow: auto;
  padding: 18px 22px 24px;
}

.api-doc-section {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.42);
}

.api-doc-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.api-doc-section p,
.api-doc-section li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.api-doc-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.api-doc-meta-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.28);
}

.api-doc-meta-label {
  margin-bottom: 5px;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 800;
}

.api-doc-meta-value {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  word-break: break-all;
}

.api-code-block {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  background: #050816;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow: auto;
}

.api-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.api-copy-button,
.api-download-button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(74, 163, 255, 0.35);
  border-radius: 8px;
  background: rgba(74, 163, 255, 0.1);
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 800;
}

.api-download-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  white-space: nowrap;
}

.api-copy-button:hover,
.api-download-button:hover {
  border-color: rgba(74, 163, 255, 0.72);
  background: rgba(74, 163, 255, 0.18);
}

@media (max-width: 720px) {
  .api-doc-meta {
    grid-template-columns: 1fr;
  }

  .api-doc-modal {
    padding: 12px;
  }
}
