.wf-view {
  height: calc(100dvh - 72px);
  min-height: 520px;
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(188, 90, 69, 0.08), transparent 55%),
    var(--bg);
}
.wf-shell {
  height: 100%;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
}
.wf-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  min-height: 0;
}
.wf-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b45309;
}
.wf-side-title {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.25;
}
.wf-side-desc {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.wf-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wf-empty {
  padding: 14px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.wf-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}
.wf-item strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}
.wf-item span {
  color: var(--muted);
  font-size: 11px;
}
.wf-item.active {
  border-color: rgba(188, 90, 69, 0.55);
  background: rgba(188, 90, 69, 0.06);
}
.wf-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.wf-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
}
.wf-title-input {
  flex: 1 1 180px;
  min-width: 140px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
.wf-save-state {
  font-size: 12px;
  color: var(--muted);
  min-width: 52px;
}
.wf-board {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: #f3f4f6;
}
.wf-board.is-panning { cursor: grabbing; }
.wf-palette {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 20;
  width: 188px;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 16px;
  border: 1px solid rgba(76, 50, 31, 0.12);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 36px rgba(76, 50, 31, 0.16);
  user-select: none;
}
.wf-palette-grip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 8px;
  border-bottom: 1px solid var(--border);
  background: #f7f4f1;
  border-radius: 16px 16px 0 0;
  cursor: grab;
  touch-action: none;
}
.wf-palette.is-dragging .wf-palette-grip { cursor: grabbing; }
.wf-grip-dots {
  width: 10px;
  height: 16px;
  flex: none;
  background-image: radial-gradient(circle, #8b8178 1.15px, transparent 1.25px);
  background-size: 5px 5.2px;
  background-position: center;
}
.wf-palette-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.wf-palette-copy strong {
  font-size: 12px;
  line-height: 1.2;
  color: var(--text);
}
.wf-palette-copy em {
  font-style: normal;
  font-size: 10px;
  line-height: 1.2;
  color: var(--muted);
}
.wf-palette-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}
.wf-tool {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 8px 18px 8px 16px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: grab;
  touch-action: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  text-align: left;
  box-shadow: 0 4px 10px rgba(76, 50, 31, 0.05);
}
.wf-tool:hover {
  background: #fffdf8;
  box-shadow: 0 6px 14px rgba(76, 50, 31, 0.08);
}
.wf-tool:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.wf-tool.is-dragging-source { opacity: 0.4; }
.wf-board.is-drop-ok {
  box-shadow: inset 0 0 0 2px rgba(188, 90, 69, 0.55);
}
.wf-tool-ghost {
  position: fixed;
  z-index: 90;
  margin: 0;
  pointer-events: none;
  transform: translate(-28px, -22px);
  filter: drop-shadow(0 14px 28px rgba(76, 50, 31, 0.28));
}
.wf-tool-ghost[hidden] { display: none !important; }
.wf-tool-ghost .wf-tool {
  width: 196px;
  cursor: grabbing;
}
.wf-tool-ghost.is-invalid { opacity: 0.4; }
body.wf-tool-dragging,
body.wf-tool-dragging * { cursor: grabbing !important; }
.wf-tool[data-add="image"] { border-left-color: #2e7d5f; }
.wf-tool[data-add="prompt"] { border-left-color: #b45309; }
.wf-tool[data-add="generate"] { border-left-color: var(--accent); min-height: 56px; }
.wf-tool[data-add="generate-video"] { border-left-color: #1d4ed8; min-height: 56px; }
.wf-tool-icon {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.wf-tool[data-add="image"] .wf-tool-icon {
  color: #2e7d5f;
  background: rgba(46, 125, 95, 0.12);
}
.wf-tool[data-add="prompt"] .wf-tool-icon {
  color: #b45309;
  background: rgba(180, 83, 9, 0.12);
}
.wf-tool[data-add="generate"] .wf-tool-icon {
  color: var(--accent);
  background: rgba(188, 90, 69, 0.12);
}
.wf-tool[data-add="generate-video"] .wf-tool-icon {
  color: #1d4ed8;
  background: rgba(29, 78, 216, 0.12);
}
.wf-tool-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.wf-tool-label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}
.wf-tool-sub {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
}
.wf-mini-port {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  pointer-events: none;
  top: 50%;
  transform: translateY(-50%);
}
.wf-mini-port.out { right: -5px; }
.wf-mini-port.in { left: -5px; }
.wf-mini-port.image { background: #2e7d5f; box-shadow: 0 0 0 1px rgba(46, 125, 95, 0.4); }
.wf-mini-port.text { background: #b45309; box-shadow: 0 0 0 1px rgba(180, 83, 9, 0.4); }
.wf-mini-port.video { background: #1d4ed8; box-shadow: 0 0 0 1px rgba(29, 78, 216, 0.4); }
.wf-tool[data-add="generate"] .wf-mini-port.in.image { top: 16px; transform: none; }
.wf-tool[data-add="generate"] .wf-mini-port.in.text { top: auto; bottom: 12px; transform: none; }
.wf-tool[data-add="generate-video"] .wf-mini-port.in.image { top: 16px; transform: none; }
.wf-tool[data-add="generate-video"] .wf-mini-port.in.text { top: auto; bottom: 12px; transform: none; }
.wf-tool[data-add="generate-video"] .wf-mini-port.out.video {
  right: -5px;
  left: auto;
  top: 50%;
  background: #1d4ed8;
}
.wf-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 8000px;
  height: 6000px;
  transform-origin: 0 0;
  background-image: radial-gradient(rgba(30, 27, 24, 0.16) 1px, transparent 1px);
  background-size: 22px 22px;
}
.wf-links {
  position: absolute;
  inset: 0;
  width: 8000px;
  height: 6000px;
  overflow: visible;
  pointer-events: none;
}
.wf-link {
  fill: none;
  stroke: #bc5a45;
  stroke-width: 2.5;
  pointer-events: stroke;
  cursor: pointer;
}
.wf-link-temp {
  stroke: #9f4734;
  stroke-dasharray: 6 5;
  pointer-events: none;
}
.wf-nodes { position: absolute; inset: 0; }
.wf-node {
  position: absolute;
  width: 280px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(76, 50, 31, 0.08);
  user-select: none;
}
.wf-node.is-selected {
  border-color: rgba(188, 90, 69, 0.7);
  box-shadow: 0 0 0 3px rgba(188, 90, 69, 0.12);
}
.wf-node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 8px;
  cursor: grab;
}
.wf-node-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.wf-node-image .wf-node-kicker { color: #2e7d5f; }
.wf-node-prompt .wf-node-kicker { color: #b45309; }
.wf-node-generate .wf-node-kicker { color: var(--accent); }
.wf-node-generate-video .wf-node-kicker { color: #1d4ed8; }
.wf-node-body {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wf-node textarea,
.wf-node select,
.wf-node input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: #fff;
  user-select: text;
}
.wf-node textarea {
  min-height: 88px;
  resize: vertical;
}
.wf-preview {
  width: 100%;
  max-height: 150px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.wf-preview-empty {
  height: 92px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  background: var(--panel);
}
.wf-image-name {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wf-image-actions .btn {
  padding-left: 8px;
  padding-right: 8px;
  white-space: nowrap;
}
.wf-row {
  display: flex;
  gap: 6px;
}
.wf-row > * { flex: 1; }
.wf-status {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.wf-status-running { color: #b45309; }
.wf-status-done { color: var(--success); }
.wf-status-error { color: #b42318; }
.wf-port {
  position: absolute;
  z-index: 5;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #bc5a45;
  box-shadow: 0 0 0 1px rgba(188, 90, 69, 0.45);
  padding: 0;
  cursor: crosshair;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.wf-port-in { left: -12px; }
.wf-port-out { right: -12px; }
.wf-port-image { top: 42px; background: #2e7d5f; box-shadow: 0 0 0 1px rgba(46, 125, 95, 0.4); }
.wf-port-text { top: 74px; background: #b45309; box-shadow: 0 0 0 1px rgba(180, 83, 9, 0.4); }
.wf-port-video { top: 48px; background: #1d4ed8; box-shadow: 0 0 0 1px rgba(29, 78, 216, 0.45); }
.wf-node-image .wf-port-out,
.wf-node-prompt .wf-port-out,
.wf-node-generate .wf-port-out,
.wf-node-generate-video .wf-port-out { top: 48px; }
.wf-preview-hit {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.wf-preview-hit .wf-preview {
  display: block;
}
.wf-preview-video,
.wf-export-video {
  width: 100%;
  display: block;
  background: #0f172a;
  max-height: 180px;
  object-fit: cover;
}
.wf-lightbox video {
  max-width: min(92vw, 960px);
  max-height: 82vh;
  background: #000;
}
.wf-result {
  position: relative;
}
.wf-result.is-loading,
.wf-result.is-waiting {
  min-height: 120px;
}
.wf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.86);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.wf-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(188, 90, 69, 0.22);
  border-top-color: var(--accent);
  animation: wf-spin 0.8s linear infinite;
}
@keyframes wf-spin {
  to { transform: rotate(360deg); }
}
.wf-node.is-waiting {
  pointer-events: none;
}
.wf-node [data-act="run"]:disabled,
.wf-node [data-act="run"]:disabled:hover,
.wf-node.is-waiting [data-act="run"],
.wf-node.is-waiting [data-act="run"]:hover {
  background: #e4e7ec;
  color: #98a2b3;
  cursor: not-allowed;
  pointer-events: none;
}
.wf-node.is-waiting .wf-port {
  pointer-events: none;
  opacity: 0.35;
}
.wf-waiting {
  background: rgba(255, 253, 248, 0.9);
  color: var(--muted);
}
.wf-status-wait { color: var(--muted); }
.wf-node.is-running .wf-port {
  pointer-events: none;
  opacity: 0.35;
}
.wf-board.is-busy {
  cursor: default;
}
#wfExportBtn:disabled,
#wfExportBtn:disabled:hover {
  opacity: 0.42;
  cursor: not-allowed;
  background: #eef0f3;
  color: var(--text);
}
#wfExportBtn.is-open {
  background: rgba(188, 90, 69, 0.12);
  color: var(--accent);
}
.wf-export-drawer[hidden] {
  display: none !important;
}
.wf-export-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 300px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.98);
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 40px rgba(76, 50, 31, 0.16);
}
.wf-export-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.wf-export-head strong {
  font-size: 14px;
}
.wf-export-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wf-export-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.wf-export-item.is-active {
  border-color: rgba(188, 90, 69, 0.7);
  box-shadow: 0 0 0 3px rgba(188, 90, 69, 0.12);
}
.wf-export-shot {
  position: relative;
}
.wf-export-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  margin: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 8px rgba(76, 50, 31, 0.16);
  cursor: pointer;
}
.wf-export-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.wf-export-item.is-checked {
  border-color: rgba(188, 90, 69, 0.55);
}
.wf-export-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.wf-export-all {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.wf-export-all input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
#wfExportSelected {
  flex: none;
}
#wfExportSelected:disabled,
#wfExportSelected:disabled:hover {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--accent);
  color: #fff;
}
.wf-export-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #f7f4f1;
  cursor: pointer;
}
.wf-export-thumb img {
  display: block;
  width: 100%;
  height: 148px;
  object-fit: contain;
  background: #f7f4f1;
}
.wf-export-thumb:hover img {
  outline: 2px solid rgba(188, 90, 69, 0.45);
  outline-offset: -2px;
}
.wf-export-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(30, 27, 24, 0.78);
  cursor: zoom-in;
}
.wf-export-zoom:hover {
  background: rgba(30, 27, 24, 0.92);
}
.wf-export-prompt {
  margin: 0;
  padding: 8px 10px 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}
.wf-export-prompt.is-empty {
  color: var(--muted);
}
.wf-lightbox[hidden] {
  display: none !important;
}
.wf-lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 20px;
  background: rgba(30, 27, 24, 0.72);
}
.wf-lightbox img {
  max-width: min(92vw, 1100px);
  max-height: 86vh;
  object-fit: contain;
  border-radius: 16px;
  background: #fffdf8;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}
.wf-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
}
.wf-linked-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.wf-hint {
  margin: 0;
  padding: 8px 14px 10px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--border);
}
@media (max-width: 860px) {
  .wf-view { height: auto; min-height: calc(100dvh - 64px); }
  .wf-shell { grid-template-columns: 1fr; }
  .wf-side { border-right: 0; border-bottom: 1px solid var(--border); }
  .wf-list { max-height: 140px; }
  .wf-board { height: 68dvh; flex: none; }
  .wf-export-drawer { width: min(300px, 88%); }
}
