/*
 * Workflow visual system: a graphite workbench, quiet paper consoles and warm
 * signal lines. Kept last in the cascade so legacy CSS can be retired safely.
 */
:root {
  --workbench-canvas: #eef2f1;
  --workbench-dot: rgba(66, 91, 84, .34);
  --workbench-surface: #fcfbf5;
  --workbench-surface-muted: #f1f2eb;
  --workbench-ink: #1b2a27;
  --workbench-muted: #667772;
  --workbench-line: #ccd6d0;
  --workbench-spruce: #245c4c;
  --workbench-moss: #6f967d;
  --workbench-amber: #d8a842;
  --workbench-amber-soft: #f6dfac;
  --workbench-danger: #9d574b;
  --workbench-shadow: 0 18px 38px rgba(28, 45, 40, .14);
  --workbench-ease: cubic-bezier(.16, 1, .3, 1);
}

/* The app is a tool, not a document viewer. Inputs remain selectable. */
body { color: var(--workbench-ink); background: var(--workbench-canvas); user-select: none; -webkit-user-select: none; }
input, textarea, select, [contenteditable="true"], [contenteditable=""] { user-select: text; -webkit-user-select: text; }

header {
  background: color-mix(in srgb, var(--workbench-surface) 92%, transparent);
  border-color: var(--workbench-line);
}

.workflow-canvas-shell { border-color: var(--workbench-line); background: var(--workbench-surface); }
.workflow-canvas-toolbar { background: color-mix(in srgb, var(--workbench-surface) 94%, var(--workbench-surface-muted)); border-color: var(--workbench-line); }
.workflow-canvas {
  background-color: var(--workbench-canvas);
  background-image: radial-gradient(circle, var(--workbench-dot) 1px, transparent 1.3px);
}

.flow-node { contain: layout paint style; }
.flow-node input, .flow-node select, .flow-node textarea, .flow-node output { color: var(--workbench-ink); }

/* Page-level header chrome must not leak into headers rendered inside nodes. */
#workflow-nodes > .flow-node > header {
  z-index: auto !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
#workflow-nodes > .normal-image-generation-node > header.generated-content-title {
  display: none !important;
}

/* Bare image nodes: the asset remains the node; chrome only appears for state. */
.image-result-node {
  width: fit-content !important;
  height: fit-content !important;
  display: inline-block !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  overflow: visible !important;
}

.image-result-node .result-node-image {
  display: block;
  width: min(206px, 26vw);
  /* The parent is fit-content. A percentage max-width makes the child's
     width depend on the parent while the parent also depends on the child;
     repeated drag/link layout then progressively collapses tall images. */
  max-width: none !important;
  height: auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: 0 12px 24px rgba(31, 44, 39, .12);
  image-rendering: pixelated;
  transform: translateZ(0);
}

.image-result-node.normal-image-node .result-node-image {
  width: min(340px, 42vw);
  max-width: none !important;
  image-rendering: auto;
}
/* Override the legacy square 228px normal-image rule. Generated photographs
   keep their real aspect ratio and use a stable, viewport-independent parent
   size, so link layout cannot repeatedly squeeze them while they are moved. */
body.normal-image-workbench #workflow-nodes > .image-result-node.normal-image-node .result-node-image {
  width: min(340px, 42vw) !important;
  max-width: none !important;
  height: auto !important;
  aspect-ratio: auto !important;
  object-fit: initial !important;
}
.image-result-node .image-node-drag-hit {
  position: absolute;
  z-index: 2;
  inset: -10px;
  display: block;
  width: calc(100% + 20px);
  height: calc(100% + 20px);
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none !important;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  color: transparent;
  font-size: 0;
  line-height: 0;
  cursor: grab;
  touch-action: none;
}
.image-result-node .image-node-drag-hit:active { cursor: grabbing; }
.image-result-node .result-node-image { position: relative; z-index: 1; pointer-events: none; }
.image-result-node .node-port { z-index: 4; }
.image-result-node.selected .result-node-image { outline: 2px solid var(--workbench-amber); outline-offset: 7px; box-shadow: 0 0 0 7px rgba(216, 168, 66, .14), 0 16px 28px rgba(31, 44, 39, .18); }
.image-result-node .node-port { opacity: 0; transition: opacity 150ms ease, transform 150ms ease; }
.image-result-node:hover .node-port, .image-result-node.selected .node-port { opacity: 1; }

/* Reference image becomes a bare source image until it is selected. */
.reference-image-node.is-collapsed {
  width: fit-content !important;
  height: auto !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  overflow: visible !important;
}

.reference-image-node.is-collapsed .image-edit-hero {
  display: block;
  width: min(280px, 34vw) !important;
  height: auto;
  line-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.reference-image-node.is-collapsed .image-edit-source {
  display: block;
  width: min(280px, 34vw);
  height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: 0 12px 24px rgba(31, 44, 39, .12);
  pointer-events: none;
}

.reference-image-node.is-collapsed.selected .image-edit-source { outline: 2px solid var(--workbench-amber); outline-offset: 7px; box-shadow: 0 0 0 7px rgba(216, 168, 66, .14), 0 16px 28px rgba(31, 44, 39, .18); }
.reference-image-node.is-collapsed .node-port { opacity: 0; }
.reference-image-node.is-collapsed:hover .node-port, .reference-image-node.is-collapsed.selected .node-port { opacity: 1; }
.reference-image-node.is-collapsed .node-drag-strip { display: none; }

/* Expanded prompt editor: source image floats above a calm control console. */
.reference-image-node:not(.is-collapsed) {
  width: 420px;
  padding: 0 !important;
  overflow: visible !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.reference-image-node:not(.is-collapsed) .image-edit-hero {
  display: block;
  width: 236px;
  margin: 0 auto -18px;
  padding: 0;
  position: relative;
  z-index: 3;
  border: 3px solid var(--workbench-amber);
  border-radius: 20px 20px 8px 8px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 18px 30px rgba(31, 44, 39, .18);
}

.reference-image-node:not(.is-collapsed) .image-edit-source { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: contain; }
.image-edit-details { position: relative; z-index: 2; }
.node-drag-strip {
  position: absolute;
  z-index: 8;
  top: 8px;
  left: 50%;
  width: 54px;
  height: 8px;
  border-radius: 99px;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--workbench-moss) 34%, transparent);
  cursor: grab;
  touch-action: none;
}
.node-drag-strip:active { cursor: grabbing; }
.node-prompt-console {
  display: grid;
  gap: 12px;
  padding: 42px 16px 16px;
  background: var(--workbench-surface);
  border: 2px solid var(--workbench-line);
  border-radius: 20px;
  box-shadow: var(--workbench-shadow);
}

.node-reference-deck { position: relative; z-index: 4; }
.reference-image-node:not(.is-collapsed) .node-reference-deck { margin: 0 34px -26px; }
.normal-image-generation-node .node-reference-deck { margin: 0 12px -24px; position: relative; z-index: 2; }
.node-reference-deck .node-reference-panel {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}
.node-reference-deck .node-reference-panel > strong { display: none; }
.node-reference-deck .node-reference-grid { display: flex; gap: 8px; justify-content: center; }
.node-reference-deck .reference-tile { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 7px; background: var(--workbench-surface); box-shadow: 0 8px 16px rgba(31, 44, 39, .14); }
.node-reference-deck .reference-add { border: 1px dashed var(--workbench-moss); color: var(--workbench-spruce); }

.normal-image-generation-node {
  width: 420px;
  padding: 0 !important;
  overflow: visible !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.normal-image-generation-node > header { display: none; }
.normal-image-generation-node .node-prompt-console { padding-top: 44px; }
.normal-image-generation-node .node-prompt-console:before {
  content: "新图像";
  display: block;
  margin: -24px 0 2px;
  color: var(--workbench-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
}

.node-prompt { position: relative; gap: 7px; }
.node-prompt textarea { min-height: 126px; padding: 13px 82px 13px 13px; border-color: var(--workbench-line); border-radius: 10px; background: var(--workbench-surface-muted); }
.node-prompt textarea:focus { border-color: var(--workbench-moss); box-shadow: 0 0 0 3px rgba(111, 150, 125, .16); outline: 0; }
.node-prompt .polish-node { position: absolute; right: 9px; top: 31px; padding: 7px 9px; border-radius: 7px; font-size: 12px; }
.image-edit-options { grid-template-columns: 1.1fr 1fr .8fr !important; gap: 8px; }
.image-edit-options label { gap: 4px; color: var(--workbench-muted); font-size: 11px; }
.image-edit-options output, .image-edit-options select { min-height: 34px; padding: 7px 8px; border-color: var(--workbench-line); border-radius: 7px; background: var(--workbench-surface-muted); }
.node-prompt-console .generate-node { min-height: 42px; border-radius: 8px; }

/* Normal-image editor: keep the source asset clear and place its controls in
   one compact horizontal console beneath it, never beside or over the image. */
.reference-image-node:not(.is-collapsed) { width: 580px; }
.reference-image-node:not(.is-collapsed) {
  display: block !important;
  grid-template-columns: none !important;
  column-gap: 0 !important;
}
.reference-image-node:not(.is-collapsed) .image-edit-hero,
.reference-image-node:not(.is-collapsed) .image-edit-details {
  grid-column: auto !important;
  grid-row: auto !important;
}
.reference-image-node:not(.is-collapsed) .image-edit-details { display: block !important; min-width: 0; }
.reference-image-node:not(.is-collapsed) .node-prompt-console {
  grid-template-columns: minmax(0, 1fr) 164px;
  grid-template-areas:
    "prompt prompt"
    "options action";
  align-items: end;
  padding: 40px 18px 16px;
}
.reference-image-node:not(.is-collapsed) .image-edit-prompt { grid-area: prompt; }
.reference-image-node:not(.is-collapsed) .image-edit-options { grid-area: options; }
.reference-image-node:not(.is-collapsed) .generate-node {
  grid-area: action;
  width: 100%;
  min-height: 38px;
  margin: 0;
}
.reference-image-node:not(.is-collapsed) .node-prompt textarea { min-height: 88px; }

/* Structural reset for the normal-image reference editor. Earlier canvas
   styles used a two-column grid; this explicit flex stack prevents its
   reference slots and prompt controls being laid out as detached islands. */
#workflow-nodes > .reference-image-node:not(.is-collapsed) {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  width: 580px !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-details {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  position: relative !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-deck {
  width: calc(100% - 68px) !important;
  margin: 0 34px -26px !important;
  position: relative !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-prompt-console {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Ports are part of the node contract, not hover-only decoration.  They remain
   fully visible and sit above transparent image hit areas. */
.image-result-node .node-port,
.reference-image-node .node-port {
  opacity: 1 !important;
  z-index: 10 !important;
}
.image-result-node .node-port-in,
.reference-image-node .node-port-in { left: -15px !important; }
.image-result-node .node-port-out,
.reference-image-node .node-port-out { right: -15px !important; }

.reference-image-node.will-expand .image-edit-hero { animation: prompt-hero-rise 320ms var(--workbench-ease) both; }
.reference-image-node.will-expand .image-edit-details { animation: prompt-console-unfold 340ms var(--workbench-ease) both; transform-origin: top center; }
@keyframes prompt-hero-rise { from { opacity: .35; transform: translateY(16px) scale(.92); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes prompt-console-unfold { from { opacity: 0; transform: translateY(-14px) scaleY(.88); } to { opacity: 1; transform: translateY(0) scaleY(1); } }

/* One floating cut action is reliable and cheap even on a dense graph. */
.workflow-link-hit { stroke: transparent; stroke-width: 26px; fill: none; pointer-events: stroke; cursor: crosshair; }
.connection-cut-control { display: none; }
.connection-cut-float {
  position: absolute;
  z-index: 18;
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 1px solid var(--workbench-amber);
  border-radius: 50%;
  background: var(--workbench-surface);
  color: var(--workbench-spruce);
  box-shadow: 0 8px 18px rgba(31, 44, 39, .22);
  cursor: pointer;
  touch-action: manipulation;
}
.connection-cut-float:hover,
.connection-cut-float:focus-visible {
  outline: none;
  border-color: var(--workbench-danger);
  background: var(--workbench-danger);
  color: #fff;
  transform: translate(-50%, -50%) scale(1.08);
}

body.workflow-dark-mode {
  --workbench-canvas: #111618;
  --workbench-dot: rgba(214, 228, 220, .20);
  --workbench-surface: #20282a;
  --workbench-surface-muted: #171e20;
  --workbench-ink: #edf3ef;
  --workbench-muted: #a7b6af;
  --workbench-line: #40504c;
  --workbench-spruce: #95c3a1;
  --workbench-moss: #6f967d;
  --workbench-amber: #dcb65d;
  --workbench-amber-soft: #493d24;
  --workbench-danger: #e09a8e;
  --workbench-shadow: 0 20px 42px rgba(0, 0, 0, .36);
  background: #0d1112 !important;
  color: var(--workbench-ink);
}

body.workflow-dark-mode header,
body.workflow-dark-mode .workflow-canvas-toolbar,
body.workflow-dark-mode .workbench-menu,
body.workflow-dark-mode .panel,
body.workflow-dark-mode dialog { background: #151b1d !important; border-color: var(--workbench-line) !important; }
body.workflow-dark-mode .wide,
body.workflow-dark-mode .workflow-canvas-shell { background: #0d1112 !important; }
body.workflow-dark-mode .workflow-canvas {
  background-color: var(--workbench-canvas) !important;
  background-image: radial-gradient(circle, var(--workbench-dot) .85px, transparent 1.18px) !important;
}
body.workflow-dark-mode .flow-node,
body.workflow-dark-mode .node-prompt-console { color: var(--workbench-ink) !important; }
body.workflow-dark-mode .node-prompt-console,
body.workflow-dark-mode .node-reference-deck .reference-tile,
body.workflow-dark-mode .connection-cut-float { background: var(--workbench-surface) !important; border-color: var(--workbench-line) !important; }
body.workflow-dark-mode .flow-node input,
body.workflow-dark-mode .flow-node select,
body.workflow-dark-mode .flow-node textarea,
body.workflow-dark-mode .flow-node output,
body.workflow-dark-mode .image-edit-options output,
body.workflow-dark-mode .image-edit-options select { background: var(--workbench-surface-muted) !important; color: var(--workbench-ink) !important; border-color: var(--workbench-line) !important; }
body.workflow-dark-mode .image-result-node { background: transparent !important; }
body.workflow-dark-mode .workflow-link { stroke: #d6b46d !important; }
body.workflow-dark-mode .workflow-link-bubble { fill: #f5df9f !important; }
body.workflow-dark-mode .connection-cut-float { color: var(--workbench-amber); }

/* The prompt console deliberately has no redundant title chrome. */
.normal-image-generation-node .node-prompt-console::before { content: none !important; display: none !important; }

.generation-node > header.generated-content-title {
  min-height: 42px !important;
  padding: 11px 14px !important;
  border-bottom: 1px solid var(--workbench-line) !important;
  color: var(--workbench-ink) !important;
}
.generation-node > header.generated-content-title strong {
  overflow: hidden;
  font-size: 14px !important;
  font-weight: 760 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Light mode keeps the navigation as a readable paper rail, not faded chrome. */
body:not(.workflow-dark-mode) > header {
  background: linear-gradient(180deg, #fbfaf5 0%, #f2f3ed 100%) !important;
  border-right: 1px solid #d5ddd6 !important;
  box-shadow: 10px 0 26px rgba(42, 61, 53, .08) !important;
  color: var(--workbench-ink) !important;
}
body:not(.workflow-dark-mode) > header .workbench-switch {
  background: #f5f6ef !important;
  border: 1px solid #cbd7cf !important;
  box-shadow: none !important;
}
body:not(.workflow-dark-mode) > header .workbench-switch-copy small,
body:not(.workflow-dark-mode) > header .workbench-switch-copy em { color: #74837b !important; opacity: 1 !important; }
body:not(.workflow-dark-mode) > header .workbench-switch-copy b { color: #1e4035 !important; opacity: 1 !important; }
body:not(.workflow-dark-mode) > header .workbench-switch-mark { color: #4d7461 !important; }
body:not(.workflow-dark-mode) > header .nav { color: #456256 !important; opacity: 1 !important; }
body:not(.workflow-dark-mode) > header .nav::before { background: #8fa497 !important; opacity: 1 !important; }
body:not(.workflow-dark-mode) > header .nav:hover { background: #e8f0e8 !important; color: #1f4e3c !important; }
body:not(.workflow-dark-mode) > header .nav.active { background: #ffffff !important; color: #1a4536 !important; box-shadow: 0 8px 18px rgba(47, 73, 60, .12) !important; }
body:not(.workflow-dark-mode) > header .nav.active::before { background: var(--workbench-amber) !important; }

body.workflow-dark-mode > header { background: linear-gradient(180deg, #0d1414 0%, #121c1b 100%) !important; border-right-color: #2c3d38 !important; }
body.workflow-dark-mode > header .workbench-switch { background: #172120 !important; border-color: #394c45 !important; }
body.workflow-dark-mode > header .workbench-switch-copy b { color: #f0f4f0 !important; }
body.workflow-dark-mode > header .workbench-switch-copy small,
body.workflow-dark-mode > header .workbench-switch-copy em { color: #9db3a7 !important; opacity: 1 !important; }
body.workflow-dark-mode > header .nav { color: #afc3b8 !important; opacity: 1 !important; }
body.workflow-dark-mode > header .nav:hover { background: #1e2c29 !important; color: #f4f8f3 !important; }
body.workflow-dark-mode > header .nav.active { background: #e8eee7 !important; color: #173b2f !important; }
header, header * { user-select: none; -webkit-user-select: none; }

/* A result image is the node itself; source card paint never leaks through. */
#workflow-nodes > .flow-node.image-result-node,
#workflow-nodes > .flow-node.eightway-node {
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  box-shadow: none !important;
}
.flow-node.image-result-node .node-port,
.flow-node.eightway-node .node-port,
.reference-image-node.is-collapsed .node-port {
  width: 30px !important;
  height: 30px !important;
}
.flow-node.image-result-node .node-port-in,
.flow-node.eightway-node .node-port-in,
.reference-image-node.is-collapsed .node-port-in { left: -36px !important; }
.flow-node.image-result-node .node-port-out,
.flow-node.eightway-node .node-port-out,
.reference-image-node.is-collapsed .node-port-out { right: -36px !important; }

@media (max-width: 820px) {
  .normal-image-generation-node, .reference-image-node:not(.is-collapsed) { width: 340px; }
  .image-result-node .result-node-image, .reference-image-node.is-collapsed .image-edit-source { width: min(228px, 62vw); }
  body.normal-image-workbench #workflow-nodes > .image-result-node.normal-image-node .result-node-image { width: min(300px, 74vw) !important; }
}

/* Batch image editing keeps one quiet command card between many sources and
   their one-to-one outputs. The connected-image stack is the visual anchor. */
#workflow-nodes > .batch-image-edit-node {
  box-sizing: border-box;
  width: 440px;
  padding: 18px !important;
  overflow: visible !important;
  contain: none !important;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 88%, transparent) !important;
  border-radius: 22px !important;
  background: var(--workbench-surface) !important;
  box-shadow: var(--workbench-shadow) !important;
}
#workflow-nodes > .batch-image-edit-node.selected {
  border-color: var(--workbench-amber) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--workbench-amber) 24%, transparent), var(--workbench-shadow) !important;
}
#workflow-nodes > .batch-image-edit-node > header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin: 8px 0 16px;
  padding: 0;
  background: transparent !important;
}
#workflow-nodes > .batch-image-edit-node > header > div { display: grid; gap: 3px; }
#workflow-nodes > .batch-image-edit-node > header span {
  color: var(--workbench-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}
#workflow-nodes > .batch-image-edit-node > header strong { color: var(--workbench-ink); font-size: 18px; line-height: 1.25; }
#workflow-nodes > .batch-image-edit-node .remove-node {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  color: var(--workbench-muted);
  place-items: center;
}
#workflow-nodes > .batch-image-edit-node .remove-node:hover { background: color-mix(in srgb, var(--workbench-danger) 9%, transparent); color: var(--workbench-danger); }
#workflow-nodes > .batch-image-edit-node .batch-source-summary {
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 82%, var(--workbench-surface));
}
#workflow-nodes > .batch-image-edit-node .batch-source-summary > div { display: grid; gap: 4px; min-width: 0; }
#workflow-nodes > .batch-image-edit-node .batch-source-summary strong { color: var(--workbench-ink); font-size: 13px; }
#workflow-nodes > .batch-image-edit-node .batch-source-summary small { color: var(--workbench-muted); font-size: 11px; }
#workflow-nodes > .batch-image-edit-node .batch-source-stack { position: relative; width: 74px; height: 52px; flex: 0 0 74px; }
#workflow-nodes > .batch-image-edit-node .batch-source-stack:empty::after {
  content: '＋';
  display: grid;
  width: 52px;
  height: 52px;
  border: 1px dashed var(--workbench-moss);
  border-radius: 12px;
  color: var(--workbench-spruce);
  place-items: center;
}
#workflow-nodes > .batch-image-edit-node .batch-source-stack img {
  position: absolute;
  top: 0;
  left: calc(var(--stack-index) * 10px);
  width: 52px;
  height: 52px;
  object-fit: cover;
  border: 2px solid var(--workbench-surface);
  border-radius: 12px;
  background: var(--workbench-surface-muted);
  box-shadow: 0 6px 14px rgba(31, 44, 39, .14);
}
#workflow-nodes > .batch-image-edit-node .batch-image-prompt { margin: 16px 0 12px; color: var(--workbench-muted); }
#workflow-nodes > .batch-image-edit-node .batch-image-prompt textarea { min-height: 112px; resize: vertical; }
#workflow-nodes > .batch-image-edit-node .batch-image-options { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
#workflow-nodes > .batch-image-edit-node .batch-image-options label { display: grid; gap: 5px; color: var(--workbench-muted); font-size: 10px; }
#workflow-nodes > .batch-image-edit-node .batch-image-options select,
#workflow-nodes > .batch-image-edit-node .batch-image-options output {
  box-sizing: border-box;
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  margin: 0;
  padding: 8px 9px;
  border: 1px solid var(--workbench-line);
  border-radius: 10px;
  background: var(--workbench-surface-muted);
  color: var(--workbench-ink);
  font: 600 11px/1 inherit;
}
#workflow-nodes > .batch-image-edit-node .batch-progress {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  color: var(--workbench-spruce);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
#workflow-nodes > .batch-image-edit-node .batch-progress.is-empty { justify-content: flex-start; color: var(--workbench-muted); }
#workflow-nodes > .batch-image-edit-node .batch-progress .has-failures { color: var(--workbench-danger); }
#workflow-nodes > .batch-image-edit-node .run-batch-image-edit { width: 100%; min-height: 44px; margin: 0; border-radius: 12px; }
#workflow-nodes > .batch-image-edit-node .node-port { z-index: 10; width: 30px !important; height: 30px !important; }
#workflow-nodes > .batch-image-edit-node .node-port-in { left: -15px !important; }
#workflow-nodes > .batch-image-edit-node .node-port-out { right: -15px !important; }

/* User-created connection hubs replace the former automatic SVG junctions. */
#workflow-nodes > .junction-node {
  width: 132px !important;
  min-height: 72px !important;
  border: 1px solid color-mix(in srgb, var(--workbench-spruce) 44%, var(--workbench-border)) !important;
  border-radius: 20px !important;
  background: color-mix(in srgb, var(--workbench-surface) 88%, var(--workbench-spruce) 12%) !important;
  display: grid !important;
  place-content: center !important;
  gap: 4px !important;
  text-align: center;
  box-shadow: 0 10px 24px rgba(25, 48, 38, .16) !important;
}
#workflow-nodes > .junction-node strong { color: var(--workbench-text); font-size: 13px; }
#workflow-nodes > .junction-node small { color: var(--workbench-muted); font-size: 9px; }
#workflow-nodes > .junction-node .node-drag-strip { height: 12px; }
#workflow-nodes > .junction-node .remove-node { width: 22px; height: 22px; top: 5px; right: 5px; border-radius: 50%; opacity: .72; }
#workflow-nodes > .junction-node .node-port { width: 30px !important; height: 30px !important; z-index: 12; }
#workflow-nodes > .junction-node .node-port-in { left: -15px !important; }
#workflow-nodes > .junction-node .node-port-out { right: -15px !important; }
#workflow-nodes > .junction-node.selected {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--workbench-amber) 34%, transparent), 0 12px 28px rgba(25, 48, 38, .2) !important;
}
.workflow-canvas.connecting #workflow-nodes > .batch-image-edit-node.is-connection-target {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--workbench-spruce) 34%, transparent), var(--workbench-shadow) !important;
}
.workflow-canvas.connecting #workflow-nodes > .batch-image-edit-node.is-connection-target .node-port-in {
  background: var(--workbench-spruce) !important;
  border-color: #fff !important;
  color: #fff !important;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--workbench-spruce) 24%, transparent), 0 7px 16px rgba(25, 48, 38, .24);
}
body.workflow-dark-mode #workflow-nodes > .batch-image-edit-node { box-shadow: 0 0 0 1px rgba(255, 255, 255, .08) !important; }

.workflow-context-menu .selection-action-heading {
  display: grid;
  gap: 2px;
  padding: 8px 10px 9px;
  border-bottom: 1px solid color-mix(in srgb, var(--workbench-line) 74%, transparent);
}
.workflow-context-menu .selection-action-heading span { color: var(--workbench-ink); font-size: 12px; font-weight: 800; }
.workflow-context-menu .selection-action-heading small,
.workflow-context-menu button small { display: block; margin-top: 3px; color: var(--workbench-muted); font-size: 10px; font-weight: 500; }
.workflow-context-menu button b { color: var(--workbench-spruce); font-weight: 800; }

@media (max-width: 820px) {
  #workflow-nodes > .batch-image-edit-node { width: min(92vw, 440px); }
}

/* Language model node: multimodal input in, reusable text node out. */
#workflow-nodes > .language-model-node {
  width: 560px;
  padding: 0;
  overflow: visible;
  contain: none !important;
  border: 1px solid color-mix(in srgb, var(--workbench-spruce) 55%, var(--workbench-line));
  border-radius: 22px;
  background: var(--workbench-surface);
  box-shadow: var(--workbench-shadow);
}

#workflow-nodes > .language-model-node > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--workbench-line);
  background: color-mix(in srgb, var(--workbench-surface-muted) 72%, var(--workbench-surface));
  border-radius: 21px 21px 0 0;
}

/* Keep both language-model ports visible. Connected ports switch to the same
   warm signal colour as the wire, so reference and text links read instantly. */
#workflow-nodes > .language-model-node .node-port {
  top: 50% !important;
  z-index: 30 !important;
  width: 34px !important;
  height: 34px !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateY(-50%) scale(1) !important;
  border: 2px solid color-mix(in srgb, var(--workbench-moss) 76%, #fff) !important;
  background: var(--workbench-spruce) !important;
  color: #fff !important;
  font-size: 20px !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--workbench-surface) 88%, transparent), 0 7px 16px rgba(25, 48, 38, .24);
}
#workflow-nodes > .language-model-node .node-port-in { left: -18px !important; }
#workflow-nodes > .language-model-node .node-port-out { right: -18px !important; }
#workflow-nodes > .language-model-node.has-input-link .node-port-in,
#workflow-nodes > .language-model-node.has-output-link .node-port-out {
  border-color: color-mix(in srgb, var(--workbench-amber) 82%, #fff) !important;
  background: var(--workbench-amber) !important;
  color: #173023 !important;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--workbench-amber) 24%, transparent), 0 7px 16px rgba(25, 48, 38, .26);
}
.workflow-canvas.connecting #workflow-nodes > .language-model-node .node-port-in {
  border-color: #fff0bd !important;
  background: var(--workbench-amber) !important;
  color: #173023 !important;
  animation: language-model-port-ready .72s ease-in-out infinite alternate;
}
@keyframes language-model-port-ready {
  to { transform: translateY(-50%) scale(1.14) !important; box-shadow: 0 0 0 8px color-mix(in srgb, var(--workbench-amber) 22%, transparent), 0 8px 18px rgba(25, 48, 38, .28); }
}

#workflow-nodes > .language-model-node > header div {
  display: grid;
  gap: 3px;
}

#workflow-nodes > .language-model-node > header span {
  color: var(--workbench-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
}

#workflow-nodes > .language-model-node > header strong {
  color: var(--workbench-ink);
  font-size: 17px;
}

#workflow-nodes > .language-model-node > header .remove-node {
  position: static;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--workbench-muted);
  font-size: 20px;
  cursor: pointer;
}

.language-model-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 22px 0;
}

.language-model-settings label,
.language-model-prompt {
  display: grid;
  gap: 6px;
  color: var(--workbench-muted);
  font-size: 11px;
  font-weight: 700;
}

.language-model-settings select,
.language-model-prompt textarea {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--workbench-line);
  border-radius: 12px;
  background: var(--workbench-surface-muted);
  color: var(--workbench-ink);
  font: inherit;
}

.language-model-settings select {
  min-height: 38px;
  padding: 8px 10px;
}

.language-model-prompt {
  padding: 14px 22px 0;
}

.language-model-prompt textarea {
  min-height: 112px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.6;
}

.language-model-reference-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px 8px;
}

.language-model-reference-head strong {
  color: var(--workbench-ink);
  font-size: 12px;
}

.language-model-reference-head span {
  color: var(--workbench-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.language-model-reference-deck {
  padding: 0 22px;
}

.language-model-reference-deck .node-reference-panel {
  margin: 0;
  padding: 10px;
  border-radius: 14px;
}

.language-model-reference-deck .node-reference-panel > strong {
  display: none;
}

.language-model-reference-deck .node-reference-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.language-model-error {
  margin: 12px 22px 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--workbench-danger) 36%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--workbench-danger) 9%, transparent);
  color: var(--workbench-danger);
  font-size: 11px;
  line-height: 1.5;
}

#workflow-nodes > .language-model-node .run-language-model {
  width: calc(100% - 44px);
  min-height: 42px;
  margin: 16px 22px 20px;
  border: 0;
  border-radius: 13px;
  background: var(--workbench-spruce);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

#workflow-nodes > .language-model-node .run-language-model:disabled {
  cursor: wait;
  opacity: .55;
}

#workflow-nodes > .prompt-text-node .node-port-in {
  left: -16px;
}

body.workflow-dark-mode #workflow-nodes > .language-model-node {
  background: var(--workbench-surface);
}
body.workflow-dark-mode #workflow-nodes > .language-model-node .node-port {
  border-color: #9db8a7 !important;
  background: #244535 !important;
  color: #f4f7f2 !important;
  box-shadow: 0 0 0 4px rgba(12, 17, 18, .82), 0 8px 18px rgba(0, 0, 0, .42);
}
body.workflow-dark-mode #workflow-nodes > .language-model-node.has-input-link .node-port-in,
body.workflow-dark-mode #workflow-nodes > .language-model-node.has-output-link .node-port-out,
body.workflow-dark-mode .workflow-canvas.connecting #workflow-nodes > .language-model-node .node-port-in {
  border-color: #ffe7a5 !important;
  background: #d8ab4c !important;
  color: #16271f !important;
}

body.workflow-dark-mode #workflow-nodes > .language-model-node > header,
body.workflow-dark-mode #workflow-nodes > .language-model-node .language-model-settings select,
body.workflow-dark-mode #workflow-nodes > .language-model-node .language-model-prompt textarea {
  background: var(--workbench-surface-muted);
}

@media (max-width: 820px) {
  #workflow-nodes > .language-model-node {
    width: min(92vw, 560px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .workflow-canvas.connecting #workflow-nodes > .language-model-node .node-port-in { animation: none; }
}

/* A completed batch item can be regenerated without rerunning the full batch. */
#workflow-nodes > .batch-output-image .retry-batch-candidate {
  position: absolute;
  z-index: 8;
  top: 10px;
  right: 10px;
  min-height: 34px;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 10px;
  background: rgba(20, 54, 40, .92);
  color: #fff;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .28);
  backdrop-filter: blur(8px);
  font: 750 12px/1 inherit;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 0s linear 140ms, background-color 140ms ease;
}
#workflow-nodes > .batch-output-image.selected .retry-batch-candidate {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}
#workflow-nodes > .batch-output-image .retry-batch-candidate:hover {
  background: var(--workbench-spruce);
  transform: translateY(-1px);
}
#workflow-nodes > .batch-output-image .retry-batch-candidate:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--workbench-amber) 56%, transparent);
  outline-offset: 2px;
}
#workflow-nodes > .batch-output-result .selection-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 0 15px 15px;
}
#workflow-nodes > .batch-output-result .selection-actions .confirm-selection {
  width: 100% !important;
  min-height: 39px !important;
  margin: 0 !important;
}
#workflow-nodes > .batch-output-result .retry-batch-output {
  min-height: 39px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--workbench-spruce) 66%, var(--workbench-line));
  border-radius: 9px;
  background: color-mix(in srgb, var(--workbench-spruce) 8%, var(--workbench-surface));
  color: var(--workbench-spruce);
  font: 700 12px/1 inherit;
  white-space: nowrap;
  cursor: pointer;
}
#workflow-nodes > .batch-output-result .retry-batch-output:hover {
  background: color-mix(in srgb, var(--workbench-spruce) 16%, var(--workbench-surface));
}
#workflow-nodes > .batch-output-result .retry-batch-output:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--workbench-amber) 38%, transparent);
  outline-offset: 2px;
}

/* Failed generation output: keep recovery actions on the node itself. */
#workflow-nodes > .generation-failed-node {
  width: min(360px, 86vw);
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--workbench-danger) 52%, var(--workbench-line));
  border-radius: 22px;
  background: color-mix(in srgb, var(--workbench-surface) 96%, var(--workbench-danger));
  box-shadow: var(--workbench-shadow);
}

#workflow-nodes > .generation-failed-node .generation-failed {
  min-width: 0;
  padding: 24px 24px 18px;
}

#workflow-nodes > .generation-failed-node .generation-failed-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 32px;
}

#workflow-nodes > .generation-failed-node .generation-failed-heading > span {
  display: grid;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--workbench-danger) 14%, transparent);
  color: var(--workbench-danger);
  font-size: 15px;
  font-weight: 800;
  place-items: center;
}

#workflow-nodes > .generation-failed-node .generation-failed-heading strong {
  color: var(--workbench-danger);
  font-size: 15px;
}

#workflow-nodes > .generation-failed-node .generation-failed p {
  margin: 12px 0 18px;
  color: var(--workbench-muted);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

#workflow-nodes > .generation-failed-node .generation-failed-remove {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--workbench-muted);
  font-size: 20px;
  line-height: 1;
  place-items: center;
  cursor: pointer;
}

#workflow-nodes > .generation-failed-node .generation-failed-remove:hover {
  background: color-mix(in srgb, var(--workbench-danger) 12%, transparent);
  color: var(--workbench-danger);
}

#workflow-nodes > .generation-failed-node .generation-failed-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--workbench-line) 78%, transparent);
}

#workflow-nodes > .generation-failed-node .generation-failed-actions button {
  min-height: 38px;
  padding: 9px 15px;
  border: 1px solid var(--workbench-line);
  border-radius: 12px;
  background: var(--workbench-surface-muted);
  color: var(--workbench-ink);
  font: 700 12px/1 inherit;
  cursor: pointer;
}

#workflow-nodes > .generation-failed-node .generation-failed-actions .retry-generation {
  border-color: var(--workbench-spruce);
  background: var(--workbench-spruce);
  color: #fff;
}

#workflow-nodes > .generation-failed-node .generation-failed-actions .delete-failed-node:hover {
  border-color: color-mix(in srgb, var(--workbench-danger) 58%, var(--workbench-line));
  background: color-mix(in srgb, var(--workbench-danger) 10%, var(--workbench-surface));
  color: var(--workbench-danger);
}

#workflow-nodes > .generation-failed-node button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--workbench-amber) 46%, transparent);
  outline-offset: 2px;
}

body.workflow-dark-mode #workflow-nodes > .generation-failed-node {
  background: color-mix(in srgb, var(--workbench-surface) 92%, var(--workbench-danger));
}

body.workflow-dark-mode #workflow-nodes > .generation-failed-node .generation-failed-actions button:not(.retry-generation) {
  background: color-mix(in srgb, var(--workbench-surface-muted) 92%, #000);
}

/* Compact workbench selector: the active workspace is the only persistent detail. */
body:not(.workflow-dark-mode) > header .workbench-switch {
  grid-template-columns: 38px minmax(0, 1fr) 18px !important;
  min-height: 62px !important;
  gap: 9px !important;
  padding: 8px 10px !important;
  border-color: rgba(45, 89, 68, .18) !important;
  border-radius: 10px !important;
  background: rgba(250, 251, 246, .92) !important;
  box-shadow: 0 1px 2px rgba(21, 45, 34, .04) !important;
}
body:not(.workflow-dark-mode) > header .workbench-switch:hover,
body:not(.workflow-dark-mode) > header .workbench-switch[aria-expanded="true"] {
  border-color: rgba(63, 116, 83, .42) !important;
  background: #fffef9 !important;
  box-shadow: 0 5px 14px rgba(21, 45, 34, .09) !important;
}
body:not(.workflow-dark-mode) > header .workbench-switch-glyph {
  width: 36px !important;
  height: 36px !important;
  padding: 5px !important;
  border-radius: 9px !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .42), 0 3px 8px rgba(92, 72, 25, .16) !important;
}
body:not(.workflow-dark-mode) > header .workbench-switch-copy {
  display: grid !important;
  gap: 1px !important;
  min-width: 0 !important;
}
body:not(.workflow-dark-mode) > header .workbench-switch-copy small {
  color: #718078 !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: .08em !important;
  line-height: 1.2 !important;
}
body:not(.workflow-dark-mode) > header .workbench-switch-copy b {
  overflow: visible !important;
  color: #173b31 !important;
  font-size: 16px !important;
  font-weight: 750 !important;
  letter-spacing: -.02em !important;
  line-height: 1.25 !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
}
body:not(.workflow-dark-mode) > header .workbench-switch-mark {
  font-size: 13px !important;
  font-weight: 700 !important;
}
body.workflow-dark-mode > header .workbench-switch {
  grid-template-columns: 38px minmax(0, 1fr) 18px !important;
  min-height: 62px !important;
  gap: 9px !important;
  padding: 8px 10px !important;
}
body.workflow-dark-mode > header .workbench-switch-copy small {
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: .08em !important;
  line-height: 1.2 !important;
}
body.workflow-dark-mode > header .workbench-switch-copy b {
  overflow: visible !important;
  font-size: 16px !important;
  font-weight: 750 !important;
  letter-spacing: -.02em !important;
  line-height: 1.25 !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
}

/* The popover is a concise workbench picker, not a second product description. */
body:not(.workflow-dark-mode) > header .workbench-menu {
  top: calc(100% + 8px) !important;
  padding: 6px !important;
  border-color: rgba(45, 89, 68, .16) !important;
  border-radius: 12px !important;
  background: #fffef9 !important;
  box-shadow: 0 12px 28px rgba(21, 45, 34, .14), 0 1px 3px rgba(21, 45, 34, .06) !important;
}
body:not(.workflow-dark-mode) > header .workbench-menu button {
  grid-template-columns: 30px minmax(0, 1fr) 18px !important;
  min-height: 46px !important;
  gap: 9px !important;
  margin: 0 !important;
  padding: 7px 8px !important;
  border-radius: 8px !important;
}
body:not(.workflow-dark-mode) > header .workbench-menu button + button {
  margin-top: 3px !important;
}
body:not(.workflow-dark-mode) > header .workbench-menu button:hover {
  background: #f1f6ef !important;
}
body:not(.workflow-dark-mode) > header .workbench-menu button.active {
  border-color: rgba(77, 132, 93, .3) !important;
  background: #e8f2e7 !important;
}
body:not(.workflow-dark-mode) > header .workbench-menu button > span:nth-child(2) {
  display: block !important;
  min-width: 0 !important;
}
body:not(.workflow-dark-mode) > header .workbench-menu b {
  overflow: visible !important;
  color: #234a38 !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: -.01em !important;
  line-height: 1.2 !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
}
body:not(.workflow-dark-mode) > header .workbench-menu strong {
  font-size: 15px !important;
  font-weight: 700 !important;
}
body:not(.workflow-dark-mode) > header .workbench-option-icon {
  width: 30px !important;
  height: 30px !important;
  border-radius: 8px !important;
}
body.workflow-dark-mode > header .workbench-menu {
  top: calc(100% + 8px) !important;
  padding: 6px !important;
  border-radius: 12px !important;
}
body.workflow-dark-mode > header .workbench-menu button {
  grid-template-columns: 30px minmax(0, 1fr) 18px !important;
  min-height: 46px !important;
  gap: 9px !important;
  margin: 0 !important;
  padding: 7px 8px !important;
  border-radius: 8px !important;
}
body.workflow-dark-mode > header .workbench-menu button + button {
  margin-top: 3px !important;
}
body.workflow-dark-mode > header .workbench-menu b {
  overflow: visible !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  letter-spacing: -.01em !important;
  line-height: 1.2 !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
}

@media (prefers-reduced-motion: reduce) {
  .reference-image-node.will-expand .image-edit-hero,
  .reference-image-node.will-expand .image-edit-details { animation: none; }
  .workflow-link-bubble { display: none; }
}

/* An imported image expands as one node: the editor starts from the image's
   lower edge instead of becoming a second, offset work area.  These final
   rules intentionally override the earlier wide-console experiment. */
#workflow-nodes > .reference-image-node:not(.is-collapsed) {
  width: 320px !important;
  align-items: stretch !important;
}
/* Expanding an imported image must not create a second image card.  The
   existing bare source image stays exactly as the node visual; only its
   controls grow beneath its real lower edge. */
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-hero {
  width: min(280px, 34vw) !important;
  margin: 0 auto !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  overflow: visible !important;
  background: transparent !important;
  box-shadow: none !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-source {
  width: min(280px, 34vw) !important;
  height: auto !important;
  aspect-ratio: auto !important;
  object-fit: initial !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-details,
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-deck,
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-prompt-console {
  width: 320px !important;
  box-sizing: border-box !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-deck {
  margin: 0 !important;
  padding: 10px 12px 0;
  background: var(--workbench-surface);
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-grid {
  justify-content: flex-start;
  gap: 6px;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-prompt-console {
  padding: 12px !important;
  border-radius: 0 0 12px 12px;
}

/* Expanded controls must not move the data ports.  They belong to the source
   image, so keep the full circular targets at that image's midpoint. */
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-port {
  top: var(--source-port-y, 120px) !important;
  z-index: 20 !important;
  width: 30px !important;
  height: 30px !important;
  opacity: 1 !important;
  transform: translateY(-50%) scale(1) !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-port-in { left: -38px !important; }
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-port-out { right: -38px !important; }

/* Links stay behind nodes.  Without explicit layers the SVG can paint above
   a transparent image node and hide its connection ports. */
#workflow-links { z-index: 0 !important; }
#workflow-nodes { z-index: 2 !important; }
#workflow-nodes > .reference-image-node { z-index: 3; }
#workflow-nodes > .reference-image-node.selected { z-index: 4; }
/* The shared performance rule uses contain: content on nodes.  This node has
   ports intentionally outside its image bounds, so it must opt out or the
   browser clips those ports even though their styles and events still exist. */
#workflow-nodes > .reference-image-node,
#workflow-nodes > .image-result-node,
#workflow-nodes > .eightway-node,
#workflow-nodes > .normal-image-generation-node { contain: none !important; }

/* Ports are selection affordances, not permanent decoration. */
#workflow-nodes > .flow-node .node-port {
  opacity: 0 !important;
  pointer-events: none;
}
#workflow-nodes > .flow-node.selected .node-port,
.workflow-canvas.connecting .flow-node .node-port-in,
.workflow-canvas.connecting .flow-node.selected .node-port-out {
  opacity: 1 !important;
  pointer-events: auto;
}

/* Clicking an imported picture never replaces or resizes that picture.  The
   editor is a dock attached below the original node, outside its visual box. */
body #workflow-nodes > .reference-image-node:not(.is-collapsed) {
  display: block !important;
  width: min(280px, 34vw) !important;
  height: auto !important;
  padding: 0 !important;
  overflow: visible !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  animation: none !important;
}
body.workflow-dark-mode #workflow-nodes > .reference-image-node:not(.is-collapsed),
body.workflow-dark-mode #workflow-nodes > .reference-image-node:not(.is-collapsed).selected {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
body #workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-hero,
body #workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-source {
  display: block !important;
  width: min(280px, 34vw) !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  animation: none !important;
  transition: none !important;
}
body #workflow-nodes > .reference-image-node:not(.is-collapsed).selected .image-edit-source {
  outline: 2px solid var(--workbench-amber);
  outline-offset: 7px;
}
body #workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-details {
  position: absolute !important;
  top: calc(100% + 18px) !important;
  left: 50% !important;
  z-index: 12 !important;
  display: flex !important;
  flex-direction: column !important;
  width: 720px !important;
  max-width: calc(100vw - 64px) !important;
  margin: 0 !important;
  overflow: visible !important;
  border: 1px solid var(--workbench-line) !important;
  border-radius: 14px !important;
  background: var(--workbench-surface) !important;
  box-shadow: var(--workbench-shadow) !important;
  transform: translateX(-50%) !important;
  transform-origin: top center;
  animation: imported-prompt-dock-open 220ms var(--workbench-ease) both !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-reference-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--workbench-line);
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-deck {
  width: auto !important;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  background: transparent !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-panel,
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-grid {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-grid {
  display: grid !important;
  grid-template-columns: repeat(4, 46px);
  justify-content: start;
  gap: 6px;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-deck .reference-tile {
  width: 46px;
  height: 42px;
  flex: none;
  border-radius: 5px;
  box-shadow: none;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-prompt-console {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 156px !important;
  grid-template-areas:
    "prompt prompt"
    "options action" !important;
  gap: 10px 12px !important;
  width: auto !important;
  padding: 14px 16px 14px !important;
  border: 0 !important;
  border-radius: 0 0 14px 14px !important;
  background: transparent !important;
  box-shadow: none !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-prompt {
  display: block;
  gap: 0;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-prompt textarea {
  min-height: 224px;
  max-height: 440px;
  overflow-y: hidden;
  padding: 14px 15px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--workbench-muted) 48%, transparent) transparent;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-prompt textarea::-webkit-scrollbar {
  width: 8px;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .node-prompt textarea::-webkit-scrollbar-thumb {
  border: 2px solid var(--workbench-surface-muted);
  border-radius: 999px;
  background: color-mix(in srgb, var(--workbench-muted) 48%, transparent);
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-polish {
  position: static;
  flex: 0 0 auto;
  min-height: 28px;
  padding: 5px 8px;
  border-color: var(--workbench-line);
  background: var(--workbench-surface-muted);
  color: var(--workbench-muted);
  box-shadow: none;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-options {
  grid-template-columns: 1.15fr 1fr .85fr !important;
  align-items: end;
  gap: 6px !important;
  margin: 0 !important;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-options > output,
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-options > select {
  display: block;
  width: 100%;
  box-sizing: border-box;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-options output,
#workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-options select {
  min-height: 30px;
  padding: 4px 7px;
}
#workflow-nodes > .reference-image-node:not(.is-collapsed) .generate-node {
  align-self: end;
  min-height: 30px !important;
  padding: 5px 10px !important;
}
#workflow-nodes .animation-frame-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}
@media (max-width: 820px) {
  #workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-details {
    width: min(94vw, 620px) !important;
  }
  #workflow-nodes > .reference-image-node:not(.is-collapsed) .node-reference-deck {
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--workbench-line);
    border-radius: 14px 14px 0 0;
  }
  #workflow-nodes > .reference-image-node:not(.is-collapsed) .node-prompt-console {
    border-radius: 0 0 14px 14px !important;
  }
}

/* Animation production: one compact action produces four editable 256×64 direction strips. */
#workflow-nodes .animation-export-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#workflow-nodes .animation-export-actions .animation-pixelize {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border-color: #4f8564;
  background: #e8f2e7;
  color: #24583f;
  font-weight: 750;
}

#workflow-nodes .animation-export-actions .animation-pixelize:hover:not(:disabled) {
  background: #dcebdc;
}

#workflow-nodes .animation-export-actions .animation-pixelize:disabled {
  cursor: wait;
  opacity: .78;
}

#workflow-nodes .mini-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: animation-pixel-spin .8s linear infinite;
}

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

#workflow-nodes > .animation-strip-node {
  width: 336px !important;
  height: auto !important;
  min-height: 104px !important;
  contain: layout style !important;
  overflow: visible !important;
}

#workflow-nodes .animation-strip-art {
  position: relative;
  display: grid;
  grid-template-rows: 80px auto;
  width: 320px;
  min-width: 320px;
  margin: 0 auto;
  overflow: visible;
}

#workflow-nodes .animation-strip-image {
  display: block;
  width: 320px !important;
  min-width: 320px !important;
  max-width: none !important;
  height: 80px !important;
  min-height: 80px !important;
  max-height: none !important;
  aspect-ratio: 4 / 1 !important;
  object-fit: fill !important;
  object-position: center !important;
  overflow: visible !important;
  background: repeating-conic-gradient(#e4ebe2 0 25%, #f9fbf8 0 50%) 50% / 10px 10px;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 10px rgba(34, 48, 41, .16));
  pointer-events: none;
}

#workflow-nodes .missing-asset-notice {
  display: none;
  box-sizing: border-box;
  width: 320px;
  height: 80px;
  padding: 15px 18px;
  border: 1px dashed #d29358;
  border-radius: 8px;
  background: #fff7ea;
  color: #9a5629;
  text-align: center;
  align-content: center;
}

#workflow-nodes .missing-asset-notice strong,
#workflow-nodes .missing-asset-notice span {
  display: block;
}

#workflow-nodes .missing-asset-notice strong {
  margin-bottom: 4px;
  font-size: 14px;
}

#workflow-nodes .missing-asset-notice span {
  font-size: 10px;
}

#workflow-nodes > .animation-strip-node.is-missing-asset .animation-strip-image {
  display: none;
}

#workflow-nodes > .animation-strip-node.is-missing-asset .missing-asset-notice {
  display: block;
}

#workflow-nodes > .animation-strip-node .image-node-drag-hit {
  inset: -8px !important;
  width: calc(100% + 16px) !important;
  height: calc(100% + 16px) !important;
}

#workflow-nodes .animation-strip-art figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 320px;
  margin-top: 6px;
  padding: 0 2px;
  color: #587064;
  font-size: 10px;
  line-height: 1.2;
}

#workflow-nodes .animation-strip-art figcaption b {
  color: #255840;
  font-size: 12px;
}

#workflow-nodes > .animation-strip-node.selected .animation-strip-image {
  outline: 3px solid rgba(208, 158, 54, .88);
  outline-offset: 4px;
}

#workflow-nodes > .animation-strip-node .node-port {
  top: 40px !important;
}

body.workflow-dark-mode #workflow-nodes .animation-export-actions .animation-pixelize {
  border-color: #6e9b80;
  background: #1d3a2e;
  color: #b8ddc3;
}

body.workflow-dark-mode #workflow-nodes .animation-export-actions .animation-pixelize:hover:not(:disabled) {
  background: #244838;
}

body.workflow-dark-mode #workflow-nodes .animation-strip-image {
  background: repeating-conic-gradient(#28342f 0 25%, #1d2823 0 50%) 50% / 10px 10px;
}

body.workflow-dark-mode #workflow-nodes .animation-strip-art figcaption {
  color: #9db0a6;
}

body.workflow-dark-mode #workflow-nodes .animation-strip-art figcaption b {
  color: #cae1d0;
}

@keyframes imported-prompt-dock-open {
  from { opacity: 0; transform: translate(-50%, -8px) scale(.985); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  body #workflow-nodes > .reference-image-node:not(.is-collapsed) .image-edit-details {
    animation: none !important;
  }
}

/* Reusable prompt source. It is intentionally compact and exposes only an
   output port: one text block can feed several generation/edit nodes. */
#workflow-nodes > .prompt-text-node {
  contain: none !important;
  width: 420px;
  min-width: 320px;
  min-height: 280px;
  padding: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 88%, transparent);
  border-radius: 28px;
  background: var(--workbench-surface);
  color: var(--workbench-ink);
  box-shadow: 0 24px 56px rgba(31, 44, 39, .18);
}
body #workflow-nodes > .prompt-text-node.selected {
  border-color: color-mix(in srgb, var(--workbench-moss) 68%, var(--workbench-line)) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--workbench-moss) 18%, transparent), 0 24px 56px rgba(31, 44, 39, .2) !important;
}
#workflow-nodes > .prompt-text-node .node-drag-strip {
  top: 15px;
  z-index: 8;
}
#workflow-nodes > .prompt-text-node .prompt-text-remove {
  position: absolute;
  z-index: 9;
  top: 14px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0;
  border-radius: 50%;
  color: var(--workbench-muted);
  font-size: 18px;
}
#workflow-nodes > .prompt-text-node .prompt-text-remove:hover {
  background: color-mix(in srgb, var(--workbench-danger) 10%, transparent);
  color: var(--workbench-danger);
}
#workflow-nodes > .prompt-text-node .prompt-text-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  padding: 44px 28px 24px;
}
#workflow-nodes > .prompt-text-node .prompt-text-field {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  color: var(--workbench-muted);
  font-size: 12px;
  font-weight: 700;
}
#workflow-nodes > .prompt-text-node .prompt-text-value {
  flex: 1 1 auto;
  width: 100%;
  min-height: 96px;
  height: 100%;
  margin-top: 8px;
  padding: 16px;
  border: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 82%, transparent);
  color: var(--workbench-ink);
  font-size: 14px;
  line-height: 1.65;
  resize: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--workbench-line) 54%, transparent);
}
#workflow-nodes > .prompt-text-node > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 20px 28px 24px;
  border-top: 1px solid color-mix(in srgb, var(--workbench-line) 76%, transparent);
}
#workflow-nodes > .prompt-text-node > footer span {
  color: var(--workbench-muted);
  font-size: 11px;
}
#workflow-nodes > .prompt-text-node .prompt-text-polish {
  float: none;
  flex: 0 0 auto;
  min-height: 42px;
  margin: 0;
  padding: 9px 14px;
  border-color: color-mix(in srgb, var(--workbench-moss) 56%, var(--workbench-line));
  border-radius: 11px;
  background: color-mix(in srgb, var(--workbench-moss) 10%, var(--workbench-surface));
  color: var(--workbench-spruce);
}
.text-node-resize {
  position: absolute;
  z-index: 16;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  touch-action: none;
}
.text-node-resize::after {
  content: "";
  position: absolute;
  border-radius: 99px;
  background: color-mix(in srgb, var(--workbench-moss) 72%, var(--workbench-surface));
  opacity: .42;
  transition: opacity .16s ease, transform .16s ease;
}
.prompt-text-node:hover .text-node-resize::after,
.prompt-text-node.selected .text-node-resize::after,
.text-node-resize:focus-visible::after {
  opacity: .9;
}
.text-node-resize-x {
  top: 54px;
  right: -8px;
  bottom: 34px;
  width: 16px;
  cursor: ew-resize;
}
.text-node-resize-x::after {
  top: 50%;
  right: 6px;
  width: 3px;
  height: 42px;
  transform: translateY(-50%);
}
.text-node-resize-y {
  right: 34px;
  bottom: -8px;
  left: 34px;
  height: 16px;
  cursor: ns-resize;
}
.text-node-resize-y::after {
  bottom: 6px;
  left: 50%;
  width: 42px;
  height: 3px;
  transform: translateX(-50%);
}
.text-node-resize-xy {
  right: -8px;
  bottom: -8px;
  width: 28px;
  height: 28px;
  cursor: nwse-resize;
}
.text-node-resize-xy::after {
  right: 6px;
  bottom: 6px;
  width: 12px;
  height: 12px;
  border-right: 3px solid color-mix(in srgb, var(--workbench-moss) 82%, var(--workbench-surface));
  border-bottom: 3px solid color-mix(in srgb, var(--workbench-moss) 82%, var(--workbench-surface));
  border-radius: 0 0 5px 0;
  background: transparent;
}
#workflow-nodes > .prompt-text-node .node-port-out {
  top: 50% !important;
  right: -16px !important;
  z-index: 20 !important;
  width: 30px !important;
  height: 30px !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateY(-50%) scale(1) !important;
}
#workflow-nodes > .prompt-text-node.has-output-link .node-port-out {
  border-color: color-mix(in srgb, var(--workbench-amber) 82%, #fff) !important;
  background: color-mix(in srgb, var(--workbench-amber) 76%, var(--workbench-spruce)) !important;
  color: #173023 !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--workbench-amber) 20%, transparent);
}
.linked-prompt-status {
  display: inline-flex;
  float: right;
  align-items: center;
  min-height: 22px;
  margin: -4px 0 4px 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--workbench-moss) 12%, var(--workbench-surface));
  color: var(--workbench-spruce);
  font-size: 10px;
  font-weight: 700;
}
body.workflow-dark-mode #workflow-nodes > .prompt-text-node {
  border-color: rgba(211, 232, 218, .18) !important;
  background: #1b2224 !important;
  box-shadow: 0 28px 64px rgba(0, 0, 0, .42) !important;
}
body.workflow-dark-mode #workflow-nodes > .prompt-text-node.selected {
  border-color: color-mix(in srgb, var(--workbench-moss) 74%, #d3e8da) !important;
  box-shadow: 0 0 0 3px rgba(111, 150, 125, .2), 0 28px 64px rgba(0, 0, 0, .46) !important;
}
body.workflow-dark-mode #workflow-nodes > .prompt-text-node .node-port-out {
  border-color: #8eaa98 !important;
  background: #244535 !important;
  color: #f4f7f2 !important;
}
body.workflow-dark-mode #workflow-nodes > .prompt-text-node.has-output-link .node-port-out {
  border-color: #f1cf7a !important;
  background: #d8ab4c !important;
  color: #16271f !important;
}

/* Normal-image generation follows the reference panel's spatial hierarchy:
   references first, a generous prompt workspace, then one compact action row.
   The existing node controls and event hooks remain unchanged. */
body #workflow-nodes > .normal-image-generation-node {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  width: 620px !important;
  padding: 0 !important;
  /* Ports sit outside the card edge, so clipping here makes the reference
     input impossible to reach even though the connection logic is active. */
  overflow: visible !important;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 88%, transparent) !important;
  border-radius: 28px !important;
  background: var(--workbench-surface) !important;
  box-shadow: 0 24px 56px rgba(31, 44, 39, .18) !important;
}
body #workflow-nodes > .normal-image-generation-node.selected {
  border-color: color-mix(in srgb, var(--workbench-moss) 68%, var(--workbench-line)) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--workbench-moss) 18%, transparent), 0 24px 56px rgba(31, 44, 39, .2) !important;
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node {
  border-color: rgba(211, 232, 218, .18) !important;
  background: #1b2224 !important;
  box-shadow: 0 28px 64px rgba(0, 0, 0, .42) !important;
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node.selected {
  border-color: color-mix(in srgb, var(--workbench-moss) 74%, #d3e8da) !important;
  background: #1b2224 !important;
  box-shadow: 0 0 0 3px rgba(111, 150, 125, .2), 0 28px 64px rgba(0, 0, 0, .46) !important;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-result {
  position: relative;
  order: 0;
  width: 100%;
  overflow: hidden;
  border-radius: 27px 27px 0 0;
  background: color-mix(in srgb, var(--workbench-surface-muted) 90%, #fff);
}
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .normal-generation-reference,
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .normal-generation-prompt,
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .normal-generation-controls,
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .normal-generation-error {
  display: none !important;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .normal-generation-details {
  display: none !important;
}
body #workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) {
  display: inline-block !important;
  width: fit-content !important;
  height: fit-content !important;
  padding: 0 !important;
  overflow: visible !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .normal-generation-result {
  width: fit-content;
  overflow: visible;
  border-radius: 0;
  background: transparent;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .normal-generation-result > img {
  width: min(340px, 42vw) !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  object-fit: initial !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: 0 12px 24px rgba(31, 44, 39, .12);
  image-rendering: auto !important;
  cursor: pointer;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .normal-generation-result-label,
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .node-drag-strip {
  display: none !important;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .node-port {
  width: 30px !important;
  height: 30px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected):hover .node-port {
  opacity: 1 !important;
  pointer-events: auto !important;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .node-port-in {
  left: -36px !important;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result:not(.selected) .node-port-out {
  right: -36px !important;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-result > img {
  display: block;
  width: 100%;
  max-height: 680px;
  object-fit: contain;
  background: color-mix(in srgb, var(--workbench-surface-muted) 90%, #fff);
}
#workflow-nodes > .normal-image-generation-node.has-generation-result .normal-generation-result {
  width: min(340px, 42vw);
}
#workflow-nodes > .normal-image-generation-node.has-generation-result.selected .normal-generation-result {
  align-self: flex-start;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result .normal-generation-result > img {
  width: min(340px, 42vw) !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  object-fit: initial !important;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-details {
  order: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}
body #workflow-nodes > .normal-image-generation-node.has-generation-result.selected {
  display: flex !important;
  width: fit-content !important;
  height: fit-content !important;
  overflow: visible !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result.selected .normal-generation-result {
  overflow: visible;
  border-radius: 0;
  background: transparent;
}
#workflow-nodes > .normal-image-generation-node.has-generation-result.selected .normal-generation-result > img {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: 0 12px 24px rgba(31, 44, 39, .12);
}
#workflow-nodes > .normal-image-generation-node.has-generation-result.selected .normal-generation-details {
  width: min(620px, 82vw);
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 88%, transparent);
  border-radius: 28px;
  background: var(--workbench-surface);
  box-shadow: 0 24px 56px rgba(31, 44, 39, .18);
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node.has-generation-result.selected {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node.has-generation-result.selected .normal-generation-details {
  border-color: rgba(211, 232, 218, .18);
  background: #1b2224;
  box-shadow: 0 28px 64px rgba(0, 0, 0, .42);
}
#workflow-nodes > .normal-image-generation-node.has-generation-result .normal-generation-result-label,
#workflow-nodes > .normal-image-generation-node.has-generation-result .node-drag-strip {
  display: none !important;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-result-label {
  position: absolute;
  right: 16px;
  bottom: 14px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .44);
  border-radius: 999px;
  background: rgba(18, 34, 27, .72);
  color: #fff;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .04em;
  backdrop-filter: blur(8px);
}
#workflow-nodes > .normal-image-generation-node .normal-generation-result-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 28px;
  background: rgba(20, 31, 27, .66);
  color: #fff;
  text-align: center;
  backdrop-filter: blur(3px);
}
#workflow-nodes > .normal-image-generation-node .normal-generation-result-status i,
#workflow-nodes > .normal-image-generation-node .normal-generation-empty-state i {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, .34);
  border-top-color: #fff;
  border-radius: 50%;
  animation: generation-spin .84s linear infinite;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-result-status span,
#workflow-nodes > .normal-image-generation-node .normal-generation-empty-state span {
  font-size: 12px;
  opacity: .8;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-empty-state {
  order: 0;
  display: grid;
  min-height: 230px;
  place-content: center;
  justify-items: center;
  gap: 11px;
  padding: 28px;
  box-sizing: border-box;
  border-radius: 27px 27px 0 0;
  background: linear-gradient(145deg, color-mix(in srgb, var(--workbench-surface-muted) 86%, #fff), color-mix(in srgb, var(--workbench-moss) 10%, var(--workbench-surface)));
  color: var(--workbench-spruce);
  text-align: center;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-empty-state i {
  border-color: color-mix(in srgb, var(--workbench-moss) 22%, transparent);
  border-top-color: var(--workbench-moss);
}

/* While a normal image is generating, keep the canvas result compact even
   when the owner selects this node. */
body #workflow-nodes > .normal-image-generation-node.is-generating {
  display: block !important;
  width: 260px !important;
  height: 260px !important;
  min-height: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 88%, transparent) !important;
  border-radius: 20px !important;
  background: var(--workbench-surface) !important;
  box-shadow: 0 18px 38px rgba(31, 44, 39, .18) !important;
}
#workflow-nodes > .normal-image-generation-node.is-generating .normal-generation-details {
  display: none !important;
}
#workflow-nodes > .normal-image-generation-node.is-generating .normal-generation-result,
#workflow-nodes > .normal-image-generation-node.is-generating .normal-generation-empty-state {
  width: 260px !important;
  height: 260px !important;
  min-height: 260px !important;
  overflow: hidden !important;
  border-radius: 19px !important;
  cursor: grab;
  touch-action: none;
}
#workflow-nodes > .normal-image-generation-node.is-generating .normal-generation-result:active,
#workflow-nodes > .normal-image-generation-node.is-generating .normal-generation-empty-state:active { cursor: grabbing; }
#workflow-nodes > .normal-image-generation-node.is-generating .normal-generation-result > img {
  width: 260px !important;
  height: 260px !important;
  max-width: 260px !important;
  max-height: 260px !important;
  object-fit: cover !important;
}
#workflow-nodes > .normal-image-generation-node.is-generating .node-drag-strip {
  z-index: 7;
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node.is-generating {
  border-color: rgba(211, 232, 218, .18) !important;
  background: #1b2224 !important;
  box-shadow: 0 20px 44px rgba(0, 0, 0, .4) !important;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-error {
  order: 0;
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 14px 28px;
  border-top: 1px solid color-mix(in srgb, var(--danger, #a34c42) 32%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--danger, #a34c42) 24%, transparent);
  background: color-mix(in srgb, var(--danger, #a34c42) 8%, var(--workbench-surface));
  color: var(--workbench-ink);
  font-size: 12px;
  line-height: 1.5;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-error strong {
  color: var(--danger, #a34c42);
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node .normal-generation-result,
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node .normal-generation-result > img {
  background: #111719;
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node .normal-generation-empty-state {
  background: linear-gradient(145deg, #202a27, #18211f);
  color: #dce9df;
}
#workflow-nodes > .normal-image-generation-node .node-drag-strip {
  top: 15px;
  z-index: 8;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-prompt {
  position: relative;
  z-index: 2;
  order: 2;
  width: 100%;
  min-height: 244px;
  padding: 22px 28px 24px;
  box-sizing: border-box;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--workbench-line) 76%, transparent);
  background: transparent;
  box-shadow: none;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-prompt .node-prompt {
  display: block;
  margin: 0;
  color: var(--workbench-ink);
  font-size: 12px;
  font-weight: 700;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-prompt textarea {
  min-height: 184px;
  margin-top: 8px;
  padding: 16px 96px 16px 16px;
  resize: vertical;
  border: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 82%, transparent);
  font-size: 14px;
  line-height: 1.65;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--workbench-line) 54%, transparent);
}
#workflow-nodes > .normal-image-generation-node .normal-generation-prompt .polish-node {
  top: 38px;
  right: 10px;
  min-height: 34px;
  padding: 7px 11px;
  border-color: color-mix(in srgb, var(--workbench-moss) 56%, var(--workbench-line));
  background: color-mix(in srgb, var(--workbench-moss) 10%, var(--workbench-surface));
  color: var(--workbench-spruce);
}
#workflow-nodes > .normal-image-generation-node .normal-generation-reference {
  position: relative !important;
  z-index: 3 !important;
  order: 1;
  width: 100% !important;
  margin: 0 !important;
  padding: 36px 24px 16px !important;
  box-sizing: border-box;
  background: transparent !important;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-reference .node-reference-panel > strong {
  display: block;
  margin-bottom: 10px;
  color: var(--workbench-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-reference .node-reference-grid {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-reference .reference-tile {
  width: auto;
  height: auto;
  flex: none;
  aspect-ratio: 1;
  border: 1px dashed color-mix(in srgb, var(--workbench-moss) 72%, var(--workbench-line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 74%, transparent);
  box-shadow: none;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-controls {
  position: relative;
  z-index: 1;
  order: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 18px;
  align-items: end;
  width: 100%;
  min-height: 112px;
  padding: 20px 28px 24px;
  box-sizing: border-box;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--workbench-line) 76%, transparent);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-controls .image-edit-options {
  display: grid !important;
  grid-template-columns: 1.2fr 1fr .8fr .8fr !important;
  grid-area: auto !important;
  gap: 10px;
  min-width: 0;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-controls .image-edit-options output,
#workflow-nodes > .normal-image-generation-node .normal-generation-controls .image-edit-options select {
  min-height: 42px;
  border-radius: 9px;
}
#workflow-nodes > .normal-image-generation-node .normal-generation-controls .generate-node {
  grid-area: auto !important;
  min-height: 42px;
  margin: 0;
  border-radius: 11px;
  font-weight: 750;
}
#workflow-nodes > .normal-image-generation-node .node-port {
  top: 50% !important;
  z-index: 20 !important;
  width: 30px !important;
  height: 30px !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateY(-50%) scale(1) !important;
  box-shadow: 0 5px 12px rgba(25, 48, 38, .2);
}
#workflow-nodes > .normal-image-generation-node .node-port-in {
  left: -16px !important;
}
#workflow-nodes > .normal-image-generation-node .node-port-out {
  right: -16px !important;
}
#workflow-nodes > .normal-image-generation-node.has-input-link .node-port-in,
#workflow-nodes > .normal-image-generation-node.has-output-link .node-port-out {
  border-color: color-mix(in srgb, var(--workbench-amber) 82%, #fff) !important;
  background: color-mix(in srgb, var(--workbench-amber) 76%, var(--workbench-spruce)) !important;
  color: #173023 !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--workbench-amber) 20%, transparent), 0 5px 12px rgba(25, 48, 38, .22);
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node .node-port {
  border-color: #8eaa98 !important;
  background: #244535 !important;
  color: #f4f7f2 !important;
}
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node.has-input-link .node-port-in,
body.workflow-dark-mode #workflow-nodes > .normal-image-generation-node.has-output-link .node-port-out {
  border-color: #f1cf7a !important;
  background: #d8ab4c !important;
  color: #16271f !important;
}

.animation-config-node .animation-generation-error {
  margin: 10px 0;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--danger, #a34c42) 38%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--danger, #a34c42) 8%, transparent);
  font-size: 12px;
  line-height: 1.55;
}

.animation-config-node.error .generate-animation {
  width: 100%;
}

.animation-config-node .animation-review-ready {
  margin: 10px 0;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--workbench-amber) 46%, var(--workbench-line));
  border-radius: 7px;
  background: color-mix(in srgb, var(--workbench-amber-soft) 42%, var(--workbench-surface));
  color: var(--workbench-spruce);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.5;
}

body:has(#animation-frame-review-dialog[open]) > header {
  pointer-events: none;
}

#animation-frame-review-dialog {
  position: fixed;
  inset: 0;
  width: min(1180px, calc(100vw - 32px));
  max-width: none;
  height: min(820px, calc(100vh - 32px));
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--workbench-spruce) 20%, transparent);
  border-radius: 16px;
  background: var(--workbench-surface);
  color: var(--workbench-ink);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .7), 0 28px 80px rgba(24, 46, 37, .28);
}

#animation-frame-review-dialog::backdrop {
  background: rgba(25, 43, 36, .66);
  backdrop-filter: blur(3px);
}

#animation-frame-review-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
}

#animation-frame-review-dialog .animation-review-header {
  position: static;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0;
  padding: 20px 24px 16px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--workbench-line) 70%, transparent);
  background: var(--workbench-surface);
}

.animation-review-header > div > span {
  display: block;
  margin-bottom: 4px;
  color: var(--workbench-moss);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
}

.animation-review-header h2 {
  margin: 0;
  color: var(--workbench-spruce);
  font-size: 22px;
  font-weight: 760;
  line-height: 1.2;
  letter-spacing: -.02em;
  text-wrap: balance;
}

.animation-review-header p {
  margin: 7px 0 0;
  color: var(--workbench-muted);
  font-size: 13px;
  line-height: 1.5;
}

.animation-review-header > button {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 70%, transparent);
  border-radius: 9px;
  background: var(--workbench-surface-muted);
  color: var(--workbench-spruce);
  font-size: 22px;
}

.animation-review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 0;
}

.animation-review-board-panel,
.animation-review-source-panel {
  min-width: 0;
  min-height: 0;
  padding: 18px 20px;
  overflow: auto;
}

.animation-review-source-panel {
  border-left: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
  background: color-mix(in srgb, var(--workbench-surface-muted) 72%, var(--workbench-surface));
}

.animation-review-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.animation-review-section-heading b {
  display: block;
  color: var(--workbench-ink);
  font-size: 14px;
  font-weight: 750;
}

.animation-review-section-heading small {
  display: block;
  margin-top: 3px;
  color: var(--workbench-muted);
  font-size: 11px;
  line-height: 1.4;
}

#animation-review-count {
  flex: 0 0 auto;
  color: var(--workbench-danger);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.animation-review-board {
  display: grid;
  gap: 12px;
}

.animation-review-row {
  display: grid;
  grid-template-columns: 44px repeat(4, minmax(92px, 1fr));
  gap: 8px;
  align-items: center;
  min-width: 452px;
}

.animation-review-direction {
  color: var(--workbench-spruce);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.animation-review-frame,
.animation-review-source-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 90%, transparent);
  border-radius: 8px;
  background: repeating-conic-gradient(#e5e8e6 0 25%, #f7f8f7 0 50%) 50% / 12px 12px;
  color: var(--workbench-ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
  transition: transform 140ms var(--workbench-ease), border-color 140ms ease, box-shadow 140ms ease;
}

.animation-review-frame {
  aspect-ratio: 1;
}

.animation-review-frame:hover,
.animation-review-source-frame:hover {
  border-color: var(--workbench-moss);
}

.animation-review-frame:focus-visible,
.animation-review-source-frame:focus-visible,
.animation-review-sheet-tabs button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--workbench-amber) 34%, transparent);
  outline-offset: 2px;
}

.animation-review-frame:active,
.animation-review-source-frame:active,
.animation-review-header > button:active,
.animation-review-actions button:active {
  transform: scale(.97);
}

.animation-review-frame.is-target {
  border-color: var(--workbench-amber);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--workbench-amber) 24%, transparent);
}

.animation-review-frame.is-issue {
  border-color: color-mix(in srgb, var(--workbench-danger) 65%, var(--workbench-line));
}

.animation-review-frame.is-manual {
  border-color: var(--workbench-spruce);
}

.animation-review-frame canvas,
.animation-review-source-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  pointer-events: none;
}

.animation-review-frame-label,
.animation-review-source-label {
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 18px;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(24, 44, 35, .76);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.animation-review-frame-status {
  position: absolute;
  top: 5px;
  left: 5px;
  padding: 3px 6px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--workbench-danger) 88%, transparent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.animation-review-frame.is-manual .animation-review-frame-status {
  background: color-mix(in srgb, var(--workbench-spruce) 88%, transparent);
}

.animation-review-raw-sheet {
  display: block;
  width: 100%;
  max-height: 238px;
  margin-bottom: 12px;
  object-fit: contain;
  background: repeating-conic-gradient(#e5e8e6 0 25%, #f7f8f7 0 50%) 50% / 12px 12px;
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}

.animation-review-sheet-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  overflow-x: auto;
}

.animation-review-sheet-tabs button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 86%, transparent);
  border-radius: 7px;
  background: var(--workbench-surface);
  color: var(--workbench-muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.animation-review-sheet-tabs button.active {
  border-color: var(--workbench-spruce);
  color: var(--workbench-spruce);
  background: color-mix(in srgb, var(--workbench-moss) 10%, var(--workbench-surface));
}

.animation-review-source-pool {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.animation-review-source-frame {
  aspect-ratio: 1;
}

.animation-review-source-frame.is-issue {
  opacity: .58;
}

.animation-review-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 20px;
  border-top: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
  background: var(--workbench-surface);
}

.animation-review-actions p {
  max-width: 620px;
  margin: 0;
  color: var(--workbench-muted);
  font-size: 12px;
  line-height: 1.45;
}

.animation-review-actions > div {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.animation-review-actions button {
  min-height: 42px;
  margin: 0;
  padding: 9px 14px;
  border-radius: 8px;
}

.animation-review-actions button:disabled {
  cursor: wait;
  opacity: .58;
}

body.workflow-dark-mode #animation-frame-review-dialog,
body.workflow-dark-mode #animation-frame-review-dialog .animation-review-header,
body.workflow-dark-mode #animation-frame-review-dialog .animation-review-actions {
  background: #151c1a;
  color: #edf2ed;
  border-color: rgba(211, 232, 218, .14);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08);
}

body.workflow-dark-mode #animation-frame-review-dialog h2,
body.workflow-dark-mode #animation-frame-review-dialog b {
  color: #edf2ed;
}

body.workflow-dark-mode #animation-frame-review-dialog p,
body.workflow-dark-mode #animation-frame-review-dialog small {
  color: #a9b9b0;
}

body.workflow-dark-mode .animation-review-source-panel {
  background: #111815;
  border-color: rgba(211, 232, 218, .12);
}

body.workflow-dark-mode .animation-review-sheet-tabs button {
  background: #1b2521;
  color: #b5c3bb;
  border-color: rgba(211, 232, 218, .14);
}

@media (max-width: 820px) {
  #animation-frame-review-dialog {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }
  #animation-frame-review-dialog .animation-review-header {
    padding: 16px;
  }
  .animation-review-layout {
    display: block;
    overflow-y: auto;
  }
  .animation-review-board-panel,
  .animation-review-source-panel {
    overflow: visible;
    padding: 14px 16px;
  }
  .animation-review-board-panel {
    overflow-x: auto;
  }
  .animation-review-source-panel {
    border-top: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
    border-left: 0;
  }
  .animation-review-raw-sheet {
    max-height: 190px;
  }
  .animation-review-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }
  .animation-review-actions > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .animation-review-actions .primary {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .animation-review-frame,
  .animation-review-source-frame {
    transition: border-color 120ms ease, box-shadow 120ms ease;
  }
}

@media (max-width: 820px) {
  #workflow-nodes > .prompt-text-node {
    width: min(88vw, 420px);
  }
  body #workflow-nodes > .normal-image-generation-node {
    width: min(92vw, 620px) !important;
    border-radius: 22px !important;
  }
  #workflow-nodes > .normal-image-generation-node .normal-generation-reference {
    padding: 34px 16px 14px !important;
  }
  #workflow-nodes > .normal-image-generation-node .normal-generation-reference .node-reference-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
  }
  #workflow-nodes > .normal-image-generation-node .normal-generation-reference .reference-tile {
    width: auto;
    height: auto;
  }
  #workflow-nodes > .normal-image-generation-node .normal-generation-prompt {
    width: 100%;
    min-height: 224px;
    padding: 18px;
  }
  #workflow-nodes > .normal-image-generation-node .normal-generation-prompt textarea {
    min-height: 164px;
  }
  #workflow-nodes > .normal-image-generation-node .normal-generation-controls {
    grid-template-columns: 1fr;
    width: 100% !important;
    gap: 12px;
    padding: 18px;
  }
  #workflow-nodes > .normal-image-generation-node .normal-generation-controls .generate-node {
    width: 100%;
  }
}

/* Product reference node: a six-view intake deck, never an image compositor. */
#workflow-nodes > .product-reference-node {
  width: 880px;
  padding: 0;
  overflow: visible;
  contain: layout paint style;
  overflow-clip-margin: 40px;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 82%, transparent);
  border-radius: 22px;
  background: var(--workbench-surface);
  box-shadow: 0 0 0 1px rgba(27, 42, 39, .03), 0 14px 32px rgba(28, 45, 40, .12);
}
#workflow-nodes > .product-reference-node > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 32px;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 14px 16px 12px 20px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
  border-radius: 22px 22px 0 0;
  background: color-mix(in srgb, var(--workbench-surface) 88%, var(--workbench-surface-muted));
  cursor: grab;
}
#workflow-nodes > .product-reference-node > header:active { cursor: grabbing; }
#workflow-nodes > .product-reference-node > header > div { display: grid; gap: 2px; }
#workflow-nodes > .product-reference-node > header strong { color: var(--workbench-ink); font-size: 16px; line-height: 1.2; }
#workflow-nodes > .product-reference-node > header small { color: var(--workbench-muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
#workflow-nodes > .product-reference-node .product-reference-count {
  padding: 6px 9px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--workbench-spruce) 10%, transparent);
  color: var(--workbench-spruce);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
#workflow-nodes > .product-reference-node > header .remove-node {
  position: static;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--workbench-muted);
  place-items: center;
}
#workflow-nodes > .product-reference-node > header .remove-node:hover { background: color-mix(in srgb, var(--workbench-danger) 10%, transparent); color: var(--workbench-danger); }
#workflow-nodes > .product-reference-node .product-view-grid {
  display: contents;
}
.product-reference-visuals {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
  padding: 18px 20px 20px;
  border-bottom: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
}
#workflow-nodes > .product-reference-node .product-view-slot {
  position: relative;
  min-width: 0;
  height: auto;
  aspect-ratio: 1;
  border: 1px dashed color-mix(in srgb, var(--workbench-line) 84%, var(--workbench-muted));
  border-radius: 14px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 68%, var(--workbench-surface));
  transition: border-color 160ms var(--workbench-ease), background-color 160ms var(--workbench-ease), transform 120ms var(--workbench-ease);
}
#workflow-nodes > .product-reference-node .product-view-slot:hover,
#workflow-nodes > .product-reference-node .product-view-slot.is-drop-target { border-color: var(--workbench-spruce); background: color-mix(in srgb, var(--workbench-spruce) 7%, var(--workbench-surface)); }
#workflow-nodes > .product-reference-node .product-view-slot:active { transform: scale(.98); }
#workflow-nodes > .product-reference-node .product-view-slot.has-image { border-style: solid; }
#workflow-nodes > .product-reference-node .product-view-picker {
  position: absolute;
  inset: 0;
  display: grid;
  overflow: hidden;
  border-radius: 13px;
  cursor: pointer;
  place-items: center;
}
#workflow-nodes > .product-reference-node .product-view-picker > input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#workflow-nodes > .product-reference-node .product-view-picker > img { width: 100%; height: 100%; object-fit: cover; image-rendering: auto; }
#workflow-nodes > .product-reference-node .product-view-label {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--workbench-surface) 90%, transparent);
  box-shadow: 0 0 0 1px rgba(27, 42, 39, .06);
  backdrop-filter: blur(5px);
}
#workflow-nodes > .product-reference-node .product-view-label b { color: var(--workbench-ink); font-size: 11px; }
#workflow-nodes > .product-reference-node .product-view-label small { color: var(--workbench-muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
#workflow-nodes > .product-reference-node .product-view-add { margin-top: 18px; color: var(--workbench-spruce); font-size: 22px; line-height: 1; }
#workflow-nodes > .product-reference-node .product-view-empty { align-self: start; margin-top: 66px; color: var(--workbench-muted); font-size: 10px; }
#workflow-nodes > .product-reference-node .product-view-source {
  position: absolute;
  z-index: 2;
  right: 7px;
  bottom: 7px;
  padding: 3px 5px;
  border-radius: 6px;
  background: rgba(18, 34, 29, .72);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
}
#workflow-nodes > .product-reference-node .remove-product-view {
  position: absolute;
  z-index: 4;
  top: 6px;
  right: 6px;
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--workbench-surface) 88%, transparent);
  color: var(--workbench-muted);
  box-shadow: 0 0 0 1px rgba(27, 42, 39, .06);
  place-items: center;
  cursor: pointer;
}
#workflow-nodes > .product-reference-node .remove-product-view:hover { color: var(--workbench-danger); }
.product-detail-assets {
  display: contents;
}
.product-detail-asset-group .single-detail-reference-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}
.product-detail-asset-group .single-detail-reference-tile {
  width: auto;
  height: 100%;
  min-width: 0;
  aspect-ratio: 1;
  scroll-snap-align: start;
  border: 0;
  border-right: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
  border-radius: 0;
}
.product-detail-asset-group .single-detail-reference-tile:last-child { border-right: 0; }
.workflow-canvas.connecting .product-detail-asset-group { cursor: crosshair; }
.workflow-canvas.connecting .product-detail-asset-group.is-connection-target {
  border-color: var(--workbench-amber);
  background: color-mix(in srgb, var(--workbench-amber) 9%, var(--workbench-surface));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--workbench-amber) 24%, transparent), 0 0 0 4px color-mix(in srgb, var(--workbench-amber) 13%, transparent);
}
.product-detail-assets-heading { display: none; }
.product-detail-asset-group {
  position: relative;
  min-width: 0;
  height: auto;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 70%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 58%, var(--workbench-surface));
}
.product-detail-asset-group .single-detail-reference-heading {
  position: absolute;
  z-index: 4;
  top: 8px;
  left: 8px;
  width: auto;
  pointer-events: none;
}
.product-detail-asset-group .single-detail-reference-heading > div {
  display: block;
  padding: 4px 6px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--workbench-surface) 90%, transparent);
  box-shadow: 0 0 0 1px rgba(27, 42, 39, .06);
  backdrop-filter: blur(5px);
}
.product-detail-asset-group .single-detail-reference-heading strong { color: var(--workbench-ink); font-size: 11px; }
.product-detail-asset-group .single-detail-reference-heading small { display: none; }
.product-detail-asset-group .single-detail-reference-heading > span {
  padding: 3px 5px;
  border-radius: 6px;
  background: rgba(18, 34, 29, .72);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}
.product-detail-asset-group.is-drop-target { border-color: var(--workbench-spruce); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--workbench-spruce) 13%, transparent); }
.product-detail-description { display: grid; gap: 7px; }
.product-detail-description > span { display: flex; justify-content: space-between; gap: 12px; color: var(--workbench-ink); font-size: 11px; font-weight: 750; }
.product-detail-description > span small { color: var(--workbench-muted); font-size: 9px; font-weight: 500; }
.product-detail-description textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 104px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid var(--workbench-line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 76%, var(--workbench-surface));
  color: var(--workbench-ink);
  font: 500 12px/1.55 inherit;
}
.product-detail-description textarea:focus { border-color: var(--workbench-spruce); outline: 3px solid color-mix(in srgb, var(--workbench-spruce) 16%, transparent); }
.remove-product-detail-asset,
.disconnect-product-detail-asset {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--workbench-ink) 78%, transparent);
  color: var(--workbench-surface);
  opacity: 0;
}
.single-detail-reference-tile:hover .remove-product-detail-asset,
.single-detail-reference-tile:hover .disconnect-product-detail-asset,
.remove-product-detail-asset:focus-visible,
.disconnect-product-detail-asset:focus-visible { opacity: 1; }
.product-detail-description-panel {
  display: grid;
  gap: 10px;
  padding: 16px 20px 18px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 38%, var(--workbench-surface));
}
.product-detail-analysis-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.product-detail-analysis-bar > span { color: var(--workbench-muted); font-size: 9px; font-weight: 750; letter-spacing: .04em; }
.product-detail-analysis-bar button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--workbench-spruce) 28%, var(--workbench-line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--workbench-spruce) 9%, var(--workbench-surface));
  color: var(--workbench-spruce);
  font-size: 11px;
  font-weight: 800;
}
.product-detail-analysis-bar button:hover:not(:disabled) { background: color-mix(in srgb, var(--workbench-spruce) 16%, var(--workbench-surface)); }
.product-detail-analysis-bar button:disabled { cursor: not-allowed; opacity: .48; }
.product-detail-analysis-error { margin: 0; color: var(--workbench-danger); font-size: 10px; line-height: 1.45; }
#workflow-nodes > .product-reference-node .product-reference-input,
#workflow-nodes > .product-reference-node .product-reference-output {
  z-index: 20;
  top: 50% !important;
  width: 28px !important;
  height: 28px !important;
  opacity: 1 !important;
  transform: translateY(-50%) scale(1) !important;
  border-color: color-mix(in srgb, var(--workbench-spruce) 58%, white) !important;
  box-shadow: 0 0 0 3px var(--workbench-surface), 0 4px 10px rgba(20, 54, 40, .28);
}
#workflow-nodes > .product-reference-node .product-reference-input { left: -15px !important; pointer-events: none; }
.workflow-canvas.connecting #workflow-nodes > .product-reference-node .product-reference-input,
#workflow-nodes > .product-reference-node:hover .product-reference-input { opacity: 1 !important; transform: translateY(-50%) scale(1) !important; }
.workflow-canvas.connecting #workflow-nodes > .product-reference-node .product-view-slot { cursor: crosshair; }
.workflow-canvas.connecting #workflow-nodes > .product-reference-node .product-view-slot:hover,
.workflow-canvas.connecting #workflow-nodes > .product-reference-node .product-view-slot.is-connection-target { border-color: var(--workbench-spruce); background: color-mix(in srgb, var(--workbench-spruce) 10%, var(--workbench-surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--workbench-spruce) 20%, transparent); }
#workflow-nodes > .product-reference-node .product-view-slot.is-uploading::after {
  content: '正在导入';
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  border-radius: inherit;
  background: color-mix(in srgb, var(--workbench-surface) 88%, transparent);
  color: var(--workbench-spruce);
  font-size: 11px;
  font-weight: 800;
  place-items: center;
}
#workflow-nodes > .product-reference-node .product-dimensions {
  padding: 16px 20px 18px;
  border-top: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
  background: color-mix(in srgb, var(--workbench-surface-muted) 48%, var(--workbench-surface));
}
#workflow-nodes > .product-reference-node .product-dimensions-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#workflow-nodes > .product-reference-node .product-dimensions-heading strong { color: var(--workbench-ink); font-size: 12px; }
#workflow-nodes > .product-reference-node .product-dimensions-heading span { color: var(--workbench-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
#workflow-nodes > .product-reference-node .product-dimension-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
#workflow-nodes > .product-reference-node .product-dimension-grid label { display: grid; gap: 5px; color: var(--workbench-muted); font-size: 10px; font-weight: 700; }
#workflow-nodes > .product-reference-node .product-dimension-grid input,
#workflow-nodes > .product-reference-node .product-dimension-grid select {
  box-sizing: border-box;
  width: 100%;
  min-height: 36px;
  padding: 8px 9px;
  border: 1px solid var(--workbench-line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 76%, var(--workbench-surface));
  color: var(--workbench-ink);
  font: 600 12px/1 inherit;
  font-variant-numeric: tabular-nums;
}
#workflow-nodes > .product-reference-node .product-dimension-grid input:focus,
#workflow-nodes > .product-reference-node .product-dimension-grid select:focus { border-color: var(--workbench-spruce); outline: 3px solid color-mix(in srgb, var(--workbench-spruce) 16%, transparent); }
#workflow-nodes > .product-reference-node > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 20px;
  border-top: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
  border-radius: 0 0 22px 22px;
}
#workflow-nodes > .product-reference-node > footer span { color: var(--workbench-spruce); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
#workflow-nodes > .product-reference-node > footer small { color: var(--workbench-muted); font-size: 10px; }
#workflow-nodes > .product-reference-node .product-reference-output {
  right: -15px !important;
}
#workflow-nodes > .product-reference-node .product-reference-output:hover {
  background: var(--workbench-spruce) !important;
  color: var(--workbench-surface) !important;
}
body.workflow-dark-mode #workflow-nodes > .product-reference-node { background: var(--workbench-surface); box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }
body.workflow-dark-mode #workflow-nodes > .product-reference-node .product-view-label,
body.workflow-dark-mode #workflow-nodes > .product-reference-node .remove-product-view { box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }
@media (max-width: 820px) {
  #workflow-nodes > .product-reference-node { width: min(92vw, 420px); }
  .product-reference-visuals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #workflow-nodes > .product-reference-node .product-dimension-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Single-detail-page node: a compact ecommerce artboard that stays inside the
   image workbench's paper-and-moss system. Product readiness leads; optional
   references and settings recede until the single generation action. */
#workflow-nodes > .single-detail-page-node {
  width: 560px;
  box-sizing: border-box;
  display: grid;
  gap: 16px;
  padding: 20px;
  overflow: visible !important;
  contain: none !important;
  color: var(--workbench-ink);
  background: var(--workbench-surface);
  border: 1px solid color-mix(in srgb, var(--workbench-line) 78%, transparent);
  border-radius: 22px;
  box-shadow: var(--workbench-shadow);
}
#workflow-nodes > .single-detail-page-node.selected {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--workbench-amber) 72%, transparent), var(--workbench-shadow);
}
#workflow-nodes > .single-detail-page-node > .node-port-in { left: -15px !important; }
#workflow-nodes > .single-detail-page-node > .node-port-out { right: -15px !important; }
#workflow-nodes > .single-detail-page-node > .node-port {
  top: 50% !important;
  z-index: 30 !important;
  width: 34px !important;
  height: 34px !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateY(-50%) scale(1) !important;
  border: 2px solid color-mix(in srgb, var(--workbench-moss) 76%, #fff) !important;
  background: var(--workbench-spruce) !important;
  color: #fff !important;
  font-size: 20px !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--workbench-surface) 88%, transparent), 0 7px 16px rgba(25, 48, 38, .24);
}
#workflow-nodes > .single-detail-page-node > .node-port-in { left: -18px !important; }
#workflow-nodes > .single-detail-page-node > .node-port-out { right: -18px !important; }
#workflow-nodes > .single-detail-page-node.has-input-link > .node-port-in,
#workflow-nodes > .single-detail-page-node.has-output-link > .node-port-out {
  border-color: color-mix(in srgb, var(--workbench-amber) 82%, #fff) !important;
  background: var(--workbench-amber) !important;
  color: #173023 !important;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--workbench-amber) 24%, transparent), 0 7px 16px rgba(25, 48, 38, .26);
}
.workflow-canvas.connecting #workflow-nodes > .single-detail-page-node > .node-port-in {
  border-color: #fff0bd !important;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--workbench-amber) 24%, transparent), 0 7px 16px rgba(25, 48, 38, .26);
}
#workflow-nodes > .single-detail-page-node > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0;
  background: transparent;
  border: 0;
}
#workflow-nodes > .single-detail-page-node > header > div { display: grid; gap: 2px; }
#workflow-nodes > .single-detail-page-node > header span {
  color: var(--workbench-moss);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
}
#workflow-nodes > .single-detail-page-node > header strong { font-size: 18px; line-height: 1.2; letter-spacing: -.01em; }
#workflow-nodes > .single-detail-page-node > header .remove-node {
  width: 40px;
  height: 40px;
  margin: 0;
  color: var(--workbench-muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
}
#workflow-nodes > .single-detail-page-node > header .remove-node:hover { color: var(--workbench-danger); background: color-mix(in srgb, var(--workbench-danger) 9%, transparent); }
.single-detail-product-status {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 16px;
  background: var(--workbench-surface-muted);
  border: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
  border-radius: 14px;
}
.single-detail-product-status > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  color: var(--workbench-surface);
  background: var(--workbench-moss);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 800;
}
.single-detail-product-status.is-blocked > span { color: var(--workbench-danger); background: color-mix(in srgb, var(--workbench-danger) 14%, var(--workbench-surface)); }
.single-detail-product-status > div { display: grid; gap: 2px; }
.single-detail-product-status strong { font-size: 13px; }
.single-detail-product-status small { color: var(--workbench-muted); font-size: 11px; }
.single-detail-copy { display: grid; gap: 8px; }
.single-detail-detail-reference-setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, .9fr);
  align-items: center;
  gap: 6px 12px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--workbench-line) 70%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 58%, var(--workbench-surface));
  color: var(--workbench-ink);
  font-size: 11px;
  font-weight: 750;
}
.single-detail-detail-reference-setting select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--workbench-line);
  border-radius: 10px;
  background: var(--workbench-surface);
  color: var(--workbench-ink);
}
.single-detail-detail-reference-setting > span { grid-column: 1 / -1; color: var(--workbench-spruce); font-size: 9px; line-height: 1.35; }
.single-detail-copy > span { display: flex; justify-content: space-between; color: var(--workbench-ink); font-size: 12px; font-weight: 700; }
.single-detail-copy > span small { color: var(--workbench-muted); font-size: 10px; font-weight: 500; }
.single-detail-copy textarea,
.single-detail-run-details textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 132px;
  resize: vertical;
  padding: 12px 14px;
  color: var(--workbench-ink);
  background: color-mix(in srgb, var(--workbench-surface-muted) 82%, var(--workbench-surface));
  border: 1px solid var(--workbench-line);
  border-radius: 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
}
.single-detail-copy textarea:focus,
.single-detail-page-node select:focus,
.single-detail-run-details textarea:focus { border-color: var(--workbench-spruce); outline: 3px solid color-mix(in srgb, var(--workbench-spruce) 16%, transparent); }
.single-detail-reference-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: color-mix(in srgb, var(--workbench-surface-muted) 58%, var(--workbench-surface));
  border: 1px solid color-mix(in srgb, var(--workbench-line) 70%, transparent);
  border-radius: 14px;
}
.single-detail-reference-group.is-drop-target { border-color: var(--workbench-spruce); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--workbench-spruce) 13%, transparent); }
.workflow-canvas.connecting .single-detail-reference-group { cursor: crosshair; }
.workflow-canvas.connecting .single-detail-reference-group.is-connection-target {
  border-color: var(--workbench-amber);
  background: color-mix(in srgb, var(--workbench-amber) 9%, var(--workbench-surface));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--workbench-amber) 24%, transparent), 0 0 0 4px color-mix(in srgb, var(--workbench-amber) 13%, transparent);
}
.single-detail-reference-heading { position: static; display: flex; align-items: center; justify-content: space-between; width: auto; height: auto; margin: 0; padding: 0; color: inherit; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; }
.single-detail-reference-heading > div { display: grid; gap: 2px; }
.single-detail-reference-heading strong { font-size: 12px; }
.single-detail-reference-heading small,
.single-detail-reference-heading > span { color: var(--workbench-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.single-detail-reference-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.single-detail-reference-tile {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  background: var(--workbench-surface);
  border: 1px solid var(--workbench-line);
  border-radius: 10px;
}
.single-detail-reference-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.single-detail-reference-tile input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.single-detail-reference-add,
.single-detail-reference-limit { display: grid; place-content: center; gap: 2px; text-align: center; color: var(--workbench-spruce); cursor: pointer; }
.single-detail-reference-add { border-style: dashed; }
.single-detail-reference-add:hover { background: color-mix(in srgb, var(--workbench-spruce) 7%, var(--workbench-surface)); border-color: var(--workbench-spruce); }
.single-detail-reference-add span,
.single-detail-reference-limit span { font-size: 18px; line-height: 1; font-weight: 700; }
.single-detail-reference-add small,
.single-detail-reference-limit small { color: var(--workbench-muted); font-size: 9px; }
.remove-single-detail-reference,
.disconnect-single-detail-reference {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--workbench-surface);
  background: color-mix(in srgb, var(--workbench-ink) 78%, transparent);
  border: 0;
  border-radius: 8px;
  opacity: 0;
}
.single-detail-reference-tile:hover .remove-single-detail-reference,
.single-detail-reference-tile:hover .disconnect-single-detail-reference,
.remove-single-detail-reference:focus-visible,
.disconnect-single-detail-reference:focus-visible { opacity: 1; }
.single-detail-linked-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  max-width: calc(100% - 8px);
  overflow: hidden;
  padding: 3px 5px;
  color: #fff;
  background: color-mix(in srgb, var(--workbench-spruce) 86%, transparent);
  border-radius: 5px;
  font-size: 8px;
  font-weight: 750;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.single-detail-settings { display: grid; grid-template-columns: 1.22fr 1.18fr .8fr .8fr; gap: 8px; align-items: start; }
.single-detail-settings label { display: grid; gap: 6px; color: var(--workbench-muted); font-size: 10px; font-weight: 700; }
.single-detail-settings select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--workbench-ink);
  background: var(--workbench-surface-muted);
  border: 1px solid var(--workbench-line);
  border-radius: 10px;
}
.single-detail-page-type-status {
  min-height: 15px;
  color: var(--workbench-spruce);
  font-size: 9px;
  font-weight: 750;
  line-height: 1.35;
}
.single-detail-gate { min-height: 16px; margin: -4px 0 -8px; color: var(--workbench-danger); font-size: 11px; font-weight: 650; }
.single-detail-gate.is-ready { color: var(--workbench-spruce); }
.generate-single-detail {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 750;
  transition: transform 120ms var(--workbench-ease), opacity 120ms linear;
}
.generate-single-detail:active:not(:disabled) { transform: scale(.98); }
.generate-single-detail:disabled { cursor: not-allowed; opacity: .48; }
.single-detail-error { display: grid; gap: 4px; padding: 12px 14px; color: var(--workbench-danger); background: color-mix(in srgb, var(--workbench-danger) 8%, var(--workbench-surface)); border-radius: 12px; }
.single-detail-error strong { font-size: 12px; }
.single-detail-error span { font-size: 11px; line-height: 1.45; }
.single-detail-result,
.single-detail-result-empty,
.single-detail-generating {
  margin: 0;
  overflow: hidden;
  background: var(--workbench-surface-muted);
  border: 1px solid color-mix(in srgb, var(--workbench-line) 76%, transparent);
  border-radius: 16px;
}
.single-detail-result img { display: block; width: 100%; max-height: 720px; object-fit: contain; background: var(--workbench-surface-muted); }
.single-detail-result figcaption { padding: 10px 12px; color: var(--workbench-muted); font-size: 10px; font-weight: 700; text-align: center; }
.single-detail-result-empty,
.single-detail-generating { display: grid; place-items: center; align-content: center; gap: 6px; min-height: 180px; padding: 20px; text-align: center; }
.single-detail-result-empty > span { color: var(--workbench-moss); font-size: 32px; }
.single-detail-result-empty strong,
.single-detail-generating strong { font-size: 13px; }
.single-detail-result-empty small,
.single-detail-generating span { color: var(--workbench-muted); font-size: 10px; }
.single-detail-generating i { width: 28px; height: 28px; border: 3px solid var(--workbench-line); border-top-color: var(--workbench-spruce); border-radius: 50%; animation: single-detail-spin .8s linear infinite; }
@keyframes single-detail-spin { to { transform: rotate(360deg); } }
.single-detail-run-details { padding: 12px 14px; background: var(--workbench-surface-muted); border-radius: 12px; }
.single-detail-run-details summary { cursor: pointer; color: var(--workbench-spruce); font-size: 11px; font-weight: 750; }
.single-detail-used-page-type { margin: 12px 0 0; color: var(--workbench-muted); font-size: 10px; }
.single-detail-used-page-type b { color: var(--workbench-ink); }
.single-detail-used-summary { display: flex; gap: 8px; margin: 12px 0; }
.single-detail-used-summary span { flex: 1; display: grid; gap: 2px; padding: 8px 10px; background: var(--workbench-surface); border-radius: 8px; color: var(--workbench-muted); font-size: 10px; text-align: center; }
.single-detail-used-summary b { color: var(--workbench-ink); font-size: 11px; }
.single-detail-used-references { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.single-detail-used-references figure { position: relative; aspect-ratio: 1; min-width: 0; margin: 0; overflow: hidden; background: var(--workbench-surface); border-radius: 8px; }
.single-detail-used-references img { display: block; width: 100%; height: 100%; object-fit: cover; }
.single-detail-used-references figcaption { position: absolute; inset: auto 3px 3px; overflow: hidden; padding: 3px 4px; color: var(--workbench-surface); background: color-mix(in srgb, var(--workbench-ink) 76%, transparent); border-radius: 5px; font-size: 8px; font-weight: 700; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.single-detail-run-details label { display: grid; gap: 8px; color: var(--workbench-muted); font-size: 10px; font-weight: 700; }
.single-detail-run-details textarea { min-height: 220px; resize: vertical; }
body.workflow-dark-mode #workflow-nodes > .single-detail-page-node { box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }
body.workflow-dark-mode #workflow-nodes > .single-detail-page-node.selected { box-shadow: 0 0 0 2px color-mix(in srgb, var(--workbench-amber) 70%, transparent); }
@media (max-width: 720px) {
  #workflow-nodes > .single-detail-page-node { width: min(92vw, 480px); }
  .single-detail-reference-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .single-detail-settings { grid-template-columns: 1fr; }
  .single-detail-detail-reference-setting { grid-template-columns: 1fr; }
  .single-detail-detail-reference-setting > span { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .single-detail-generating i { animation: none; }
}

/* Keep each canvas card in one stacking layer. Complex nodes use local
   z-index values for ports, reference decks, and prompt controls; without an
   isolated parent those children can interleave with a neighbouring card, so
   two overlapping nodes appear to cover each other at the same time. */
#workflow-nodes > .flow-node {
  isolation: isolate;
  z-index: 1;
}

/* The active card is always presented as one complete surface above the rest. */
#workflow-nodes > .flow-node.selected {
  z-index: 40;
}

.workflow-context-menu.connection-create-mode {
  width: min(286px, calc(100vw - 32px));
  padding: 8px;
  overflow-y: auto;
  border: 1px solid color-mix(in srgb, var(--workbench-moss) 58%, var(--workbench-line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--workbench-surface) 96%, transparent);
  box-shadow: 0 22px 48px rgba(25, 43, 35, .24);
  backdrop-filter: blur(14px);
}
.connection-create-heading {
  display: grid;
  gap: 2px;
  margin: -2px -2px 6px;
  padding: 11px 12px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--workbench-line) 72%, transparent);
}
.connection-create-heading > span,
.connection-create-role-label {
  color: var(--workbench-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.connection-create-heading strong { color: var(--workbench-ink); font-size: 13px; }
.connection-create-heading small { color: var(--workbench-muted); font-size: 10px; font-weight: 500; }
.workflow-context-menu.connection-create-mode > button {
  display: grid !important;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 9px !important;
  border-radius: 9px;
}
.workflow-context-menu.connection-create-mode > button > span:last-child { display: grid; gap: 2px; min-width: 0; }
.workflow-context-menu.connection-create-mode button b { color: inherit; font-size: 12px; }
.workflow-context-menu.connection-create-mode button small { color: var(--workbench-muted); font-size: 9px; font-weight: 500; }
.connection-create-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--workbench-moss) 12%, var(--workbench-surface));
  color: var(--workbench-spruce);
  font-size: 13px;
  font-weight: 850;
}
.connection-create-role-label { padding: 8px 9px 5px; }
.connection-create-role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 3px;
}
.workflow-context-menu.connection-create-mode .connection-create-role-grid button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-height: 42px;
  padding: 6px 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--workbench-ink);
  text-align: left;
}
.workflow-context-menu.connection-create-mode .connection-create-role-grid button:hover,
.workflow-context-menu.connection-create-mode .connection-create-role-grid button:focus-visible {
  background: color-mix(in srgb, var(--workbench-moss) 11%, var(--workbench-surface));
}
.workflow-context-menu.connection-create-mode .connection-create-role-grid .connection-create-icon { width: 22px; height: 22px; font-size: 10px; }
.workflow-context-menu.connection-create-mode .connection-create-role-grid button > span:last-child { display: grid; gap: 1px; min-width: 0; }
.connection-create-empty { display: grid; gap: 3px; padding: 14px 12px; color: var(--workbench-muted); }
.connection-create-empty b { color: var(--workbench-ink); font-size: 11px; }
.connection-create-empty small { font-size: 9px; }
.workflow-context-menu.connection-create-mode .connection-create-cancel,
.workflow-context-menu.connection-create-mode .connection-create-back {
  display: block !important;
  width: 100%;
  min-height: 34px;
  margin-top: 5px !important;
  padding: 6px 9px !important;
  color: var(--workbench-muted) !important;
  text-align: center !important;
}
body.workflow-dark-mode .workflow-context-menu.connection-create-mode {
  border-color: rgba(211, 232, 218, .18);
  background: rgba(27, 34, 36, .96);
  box-shadow: 0 24px 54px rgba(0, 0, 0, .5);
}

/* The full-size node layer must not cover SVG junction controls in empty
   canvas space. Individual nodes remain interactive. */
#workflow-nodes { pointer-events: none; }
#workflow-nodes > .flow-node { pointer-events: auto; }
#workflow-links .workflow-link-junction-control,
#workflow-links .workflow-link-junction-hit { pointer-events: all; cursor: grab; }
#workflow-links .workflow-link-junction-control:active,
#workflow-links .workflow-link-junction-hit:active { cursor: grabbing; }
