:root {
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --line: #dce4ef;
  --line-strong: #c8d4e3;
  --ink: #172033;
  --muted: #68758a;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --cyan: #1fb6b2;
  --green: #13a46b;
  --red: #df3e58;
  --amber: #c77b12;
  --shadow: 0 16px 48px rgba(46, 63, 92, 0.12);
  --node-shadow: 0 10px 30px rgba(47, 65, 95, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

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

button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.22); outline-offset: 2px; }
.hidden { display: none !important; }
.app-shell { width: 100%; height: 100%; }

.topbar {
  position: relative;
  z-index: 80;
  height: 72px;
  display: grid;
  grid-template-columns: 310px 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.brand-block, .project-block, .account-block { display: flex; align-items: center; }
.brand-block { gap: 12px; }
.brand-icon { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; box-shadow: 0 6px 18px rgba(219, 67, 118, 0.2); }
.brand-block div { display: grid; gap: 1px; }
.brand-block strong { font-size: 16px; }
.brand-block span { color: var(--muted); font-size: 12px; }

.project-block { justify-content: center; gap: 10px; }
.project-switcher-btn, .project-chevron-btn { width: 34px; height: 34px; border: 0; border-radius: 6px; background: transparent; display: grid; place-items: center; cursor: pointer; color: #59677c; }
.project-switcher-btn:hover, .project-chevron-btn:hover { background: #f0f3f8; color: var(--blue); }
.project-switcher-btn svg { width: 17px; }
.project-chevron-btn { width: 26px; margin-left: -9px; }
.project-chevron-btn svg { width: 14px; }
.project-block input { width: min(360px, 45vw); border: 0; background: transparent; font-size: 15px; font-weight: 650; text-align: center; padding: 8px 12px; border-radius: 6px; }
.project-block input:hover { background: #f5f7fa; }
.save-status { display: inline-flex; align-items: center; gap: 5px; color: var(--green); font-size: 12px; white-space: nowrap; }
.save-status svg { width: 15px; height: 15px; }

.account-block { justify-content: flex-end; gap: 8px; }
.top-icon-btn, .credits-btn, .account-btn { border: 1px solid var(--line); background: #fff; height: 40px; border-radius: 7px; cursor: pointer; }
.top-icon-btn { position: relative; width: 40px; display: grid; place-items: center; }
.top-icon-btn svg { width: 18px; }
.count-badge { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; display: grid; place-items: center; border-radius: 10px; background: var(--red); color: #fff; font-size: 10px; border: 2px solid #fff; }
.credits-btn { display: flex; align-items: center; gap: 7px; padding: 0 12px; color: #5d470f; background: #fff9e7; border-color: #f2dfaa; }
.credits-btn svg { width: 16px; color: #d39819; }
.account-btn { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 6px; }
.account-btn img { width: 28px; height: 28px; border-radius: 7px; object-fit: cover; }
.account-btn svg { width: 15px; color: var(--muted); }

.workspace { height: calc(100% - 72px); display: grid; grid-template-columns: 66px 1fr 330px; }
.left-toolbar { z-index: 60; padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; background: rgba(255,255,255,.94); border-right: 1px solid var(--line); }
.tool-btn { width: 42px; height: 42px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; display: grid; place-items: center; color: #4f5c70; }
.tool-btn:hover { background: #f0f3f8; color: var(--ink); }
.tool-btn.active { background: #eaf1ff; color: var(--blue); }
.tool-btn.accent { background: var(--ink); color: #fff; }
.tool-btn svg { width: 19px; height: 19px; }
.toolbar-divider { width: 28px; height: 1px; background: var(--line); margin: 3px 0; }
.toolbar-spacer { flex: 1; }

.canvas-viewport { position: relative; overflow: hidden; background: #f5f7fa; touch-action: none; }
.canvas-viewport.is-panning { cursor: grabbing !important; }
.canvas-viewport.drag-over::after { content: "放开以添加到画布"; position: absolute; inset: 18px; z-index: 90; display: grid; place-items: center; border: 2px dashed #6d91e9; background: rgba(238, 244, 255, 0.9); color: var(--blue); font-weight: 700; font-size: 18px; border-radius: 8px; }
.canvas-grid { position: absolute; inset: 0; background-image: radial-gradient(circle, #cfd7e3 1px, transparent 1px); background-size: 22px 22px; pointer-events: none; }
.canvas-world { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.node-layer, .selection-overlay { position: absolute; inset: 0; }
.selection-overlay { pointer-events: none; }
.marquee-box { position: absolute; z-index: 70; border: 1px solid #4f7ee8; background: rgba(79, 126, 232, .12); pointer-events: none; }
.edge-layer { position: absolute; left: -10000px; top: -10000px; width: 20000px; height: 20000px; overflow: visible; pointer-events: none; }
.edge-path { fill: none; stroke: #a9baf8; stroke-width: 2; stroke-dasharray: 7 8; vector-effect: non-scaling-stroke; }
.edge-path.active { stroke: #6f7ef5; stroke-width: 2.5; }
.edge-path.selected { stroke: #2367e8; stroke-width: 3.5; stroke-dasharray: none; }
.edge-path.edge-trunk { stroke-dasharray: none; stroke-width: 2.6; }
.edge-path.sequence-edge, .edge-path.sequence-input-edge { stroke: #6d8ed8; }
.edge-path.element-edge { stroke: #d78a36; }
.edge-path.element-edge.active { stroke: #bf6810; }
.edge-hit { fill: none; stroke: rgba(17, 44, 92, .001); stroke-width: 18; vector-effect: non-scaling-stroke; pointer-events: stroke; cursor: pointer; }

.empty-state { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); width: min(760px, calc(100% - 80px)); display: grid; gap: 26px; z-index: 8; }
.empty-heading { display: flex; align-items: center; justify-content: center; gap: 15px; }
.empty-heading img { width: 56px; height: 56px; object-fit: cover; border-radius: 14px; box-shadow: 0 10px 28px rgba(219, 67, 118, .18); }
.empty-heading h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: 0; }
.empty-heading p { margin: 0; color: var(--muted); }
.start-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.start-card { min-width: 0; height: 132px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.86); cursor: pointer; display: grid; grid-template-columns: 36px 1fr; grid-template-rows: auto auto; text-align: left; gap: 3px 10px; align-content: center; padding: 22px; box-shadow: 0 8px 30px rgba(67, 83, 110, .06); }
.start-card:hover { transform: translateY(-2px); border-color: #aec4f3; box-shadow: var(--node-shadow); }
.start-card svg { grid-row: 1 / 3; width: 27px; color: var(--blue); align-self: center; }
.start-card strong { font-size: 15px; align-self: end; }
.start-card span { color: var(--muted); font-size: 12px; line-height: 1.45; }

.canvas-node { position: absolute; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-solid); box-shadow: var(--node-shadow); user-select: none; cursor: default; overflow: visible; }
.canvas-node.selected { border-color: #6b8fe7; box-shadow: 0 0 0 2px rgba(37, 99, 235, .12), var(--node-shadow); }
.canvas-node.connection-target { border-color: #2f75ea; box-shadow: 0 0 0 4px rgba(47,117,234,.18), 0 16px 44px rgba(44,62,90,.18); }
.canvas-node.dragging { box-shadow: 0 18px 48px rgba(44, 62, 90, .2); }
.canvas-node .node-body, .canvas-node .node-head, .canvas-node .node-foot { cursor: grab; }
.canvas-node.dragging .node-body, .canvas-node.dragging .node-head, .canvas-node.dragging .node-foot { cursor: grabbing; }
.node-head { height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border-bottom: 1px solid #edf1f5; cursor: grab; }
.node-head:active { cursor: grabbing; }
.node-type-icon { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 6px; background: var(--blue-soft); color: var(--blue); }
.node-type-icon svg { width: 14px; }
.node-head strong { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-head small { color: var(--muted); font-size: 10px; }
.node-more { width: 26px; height: 26px; border: 0; background: transparent; border-radius: 6px; display: grid; place-items: center; cursor: pointer; }
.node-more:hover { background: #f1f4f8; }
.node-more svg { width: 15px; }
.folder-toggle { width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: #68768a; display: grid; place-items: center; cursor: pointer; }
.folder-toggle:hover { background: #f1f4f8; color: var(--blue); }
.folder-toggle svg { width: 15px; height: 15px; }
.node-body { min-height: 170px; padding: 10px; position: relative; }
.asset-preview { width: 100%; height: 170px; object-fit: cover; border-radius: 6px; background: #edf1f5; display: block; }
.asset-stack { position: relative; height: 172px; }
.asset-stack img { position: absolute; width: calc(100% - 16px); height: 160px; object-fit: cover; border-radius: 6px; border: 1px solid #fff; box-shadow: 0 5px 14px rgba(36, 52, 77, .14); }
.asset-stack img:nth-child(1) { left: 0; top: 0; z-index: 4; }
.asset-stack img:nth-child(2) { left: 7px; top: 5px; z-index: 3; }
.asset-stack img:nth-child(3) { left: 14px; top: 10px; z-index: 2; }
.asset-stack img:nth-child(4) { left: 20px; top: 15px; z-index: 1; }
.asset-count { position: absolute; right: 10px; bottom: 10px; z-index: 6; padding: 4px 8px; border-radius: 12px; background: rgba(20, 29, 43, .78); color: white; font-size: 10px; }
.folder-node { border-color: #a9bce2; box-shadow: 7px 7px 0 #edf2fb, 14px 14px 0 #f6f8fc, var(--node-shadow); }
.folder-node .node-type-icon { background: #fff5da; color: #9b6a13; }
.folder-path-label { position: absolute; left: 13px; bottom: 12px; z-index: 7; max-width: calc(100% - 86px); display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 5px; background: rgba(255,255,255,.9); color: #5f6f84; font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-shadow: 0 2px 8px rgba(42,57,84,.08); }
.folder-path-label svg { width: 11px; flex: none; }
.node-foot { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 11px; border-top: 1px solid #edf1f5; color: var(--muted); font-size: 11px; }
.node-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-foot button { border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 11px; }
.addon-node .node-type-icon { background: #fff2e9; color: #c56e27; }
.task-node .node-type-icon { background: #edf8f3; color: var(--green); }
.result-node .node-type-icon { background: #f0ecff; color: #7556d9; }
.image-node .node-type-icon, .stack-node .node-type-icon { background: #f0ecff; color: #7556d9; }
.image-node .image-node-body { min-height: 238px; padding: 8px; display: grid; place-items: center; background: #f4f5f7; }
.generated-image { width: 100%; height: 238px; object-fit: contain; display: block; border-radius: 5px; background: #eceff3; cursor: zoom-in; }
.stack-node { box-shadow: 7px 7px 0 #eef0f8, 14px 14px 0 #f6f7fb, var(--node-shadow); }
.prompt-node .node-type-icon { background: #eaf3ff; color: #2f6dd5; }
.sequence-node { border-color: #9cb8df; box-shadow: 0 14px 38px rgba(43, 67, 103, .14); }
.sequence-node .node-type-icon { background: #e9f7f4; color: #16836f; }
.sequence-node-body { min-height: 176px; padding: 15px 16px; display: flex; flex-direction: column; gap: 12px; cursor: grab; }
.sequence-node-body p { margin: 0; color: #47586e; font-size: 12px; line-height: 1.55; }
.sequence-node-body > small { color: #7b8899; font-size: 10px; line-height: 1.45; }
.sequence-flow { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 8px 10px; border: 1px solid #d9e4f1; border-radius: 6px; background: #f7faff; color: #53647a; font-size: 11px; }
.sequence-flow span { display: inline-flex; align-items: baseline; gap: 4px; }
.sequence-flow strong { color: #215ec9; font-size: 15px; }
.sequence-flow svg { width: 15px; color: #6284bd; flex: none; }
.sequence-element-row { min-height: 34px; display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-left: 3px solid #f0a34a; background: #fff8ee; color: #75562f; font-size: 11px; }
.sequence-element-row svg { width: 14px; flex: none; }
.sequence-element-row span { flex: 1; }
.sequence-element-row strong { min-width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #b46719; }
.prompt-node-body { min-height: 145px; display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; color: #526174; }
.prompt-node-body > svg { width: 30px; height: 30px; color: #4f7ee8; }
.prompt-node-body strong { font-size: 14px; color: var(--ink); }
.prompt-node-body small { max-width: 185px; line-height: 1.5; }
.note-node { box-shadow: 0 7px 22px rgba(52, 65, 86, .08); }
.note-node .node-body { min-height: 110px; padding: 14px; }
.note-node textarea { width: 100%; min-height: 100px; border: 0; resize: none; background: transparent; color: var(--ink); line-height: 1.6; }
.canvas-node textarea, .canvas-node input, .canvas-node select { cursor: text; }

.task-summary { display: grid; place-items: center; min-height: 170px; text-align: center; padding: 18px; }
.task-ring { --progress: 0; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--blue) calc(var(--progress) * 1%), #e8edf4 0); position: relative; }
.task-ring::after { content: ""; width: 58px; height: 58px; border-radius: 50%; background: #fff; position: absolute; }
.task-ring strong { position: relative; z-index: 1; font-size: 14px; }
.task-summary p { margin: 12px 0 4px; font-size: 13px; font-weight: 650; }
.task-summary small { color: var(--muted); }
.task-node.error .task-ring { background: #fbe4e8; color: var(--red); }
.task-node.completed .task-ring { background: #e7f6ef; color: var(--green); }
.result-grid-node { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.result-grid-node img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; background: #eef1f4; cursor: zoom-in; }
.result-grid-node.single { grid-template-columns: 1fr; }
.result-grid-node.single img { aspect-ratio: 4/3; }

.bare-image-node,
.bare-loading-node,
.compact-stack-node {
  min-height: 0 !important;
  padding: 0;
  border-radius: 7px;
  background: #eef1f5;
  box-shadow: 0 8px 24px rgba(42, 56, 79, .12);
}
.bare-image-node { border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.bare-image-node.selected,
.bare-loading-node.selected,
.compact-stack-node.selected { box-shadow: 0 0 0 3px rgba(37, 99, 235, .17), 0 9px 26px rgba(42, 56, 79, .14); }
.bare-image-node.selected { box-shadow: 0 0 0 2px rgba(37, 99, 235, .62); }
.bare-node-image { width: 100%; height: auto; display: block; object-fit: contain; border-radius: 0; background: transparent; pointer-events: none; }
.bare-node-empty { width: 100%; height: 100%; display: grid; place-items: center; color: #9aa6b7; }
.bare-node-empty svg { width: 30px; height: 30px; }
.node-resize-handle { position: absolute; right: -7px; bottom: -7px; z-index: 12; width: 15px; height: 15px; border: 2px solid #fff; border-radius: 50%; background: #3974e6; box-shadow: 0 2px 7px rgba(37,73,138,.28); cursor: nwse-resize; opacity: 0; pointer-events: none; }
.canvas-node.selected > .node-resize-handle, .canvas-node:hover > .node-resize-handle { opacity: 1; pointer-events: auto; }
.canvas-world.multi-selection-active .canvas-node.selected > .node-resize-handle { opacity: 0; pointer-events: none; }
.bare-loading-node { overflow: visible; }
.loading-image-skeleton { position: absolute; inset: 0; overflow: hidden; display: grid; place-items: center; border-radius: 6px; background: #e8ebf0; color: #647187; }
.loading-image-skeleton::before { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,.72) 48%, transparent 76%); animation: image-placeholder-shimmer 1.45s ease-in-out infinite; }
.loading-image-skeleton > span { position: relative; z-index: 2; min-width: 54px; height: 32px; padding: 0 10px; border-radius: 16px; display: grid; place-items: center; background: rgba(255,255,255,.84); box-shadow: 0 4px 14px rgba(42,56,79,.08); font-size: 12px; font-weight: 700; }
.loading-image-skeleton > span svg { width: 17px; height: 17px; color: var(--red); }
.loading-progress-track { position: absolute; left: 12px; right: 12px; bottom: 11px; z-index: 2; height: 3px; overflow: hidden; border-radius: 2px; background: rgba(255,255,255,.72); }
.loading-progress-track i { display: block; height: 100%; border-radius: inherit; background: var(--blue); transition: width .35s ease; }
.bare-loading-node.loading-failed { border-color: #e9a8b3; }
.bare-loading-node.loading-failed .loading-image-skeleton { background: #f8ecef; }
@keyframes image-placeholder-shimmer { 100% { transform: translateX(100%); } }

.compact-stack-node { background: transparent; border-color: transparent; box-shadow: none; }
.compact-stack-preview { position: absolute; inset: 0; }
.compact-stack-preview > img,
.compact-stack-preview > .stack-loading-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: 1px solid #fff; border-radius: 7px; background: #edf0f4; box-shadow: 0 9px 22px rgba(42,56,79,.14); }
.compact-stack-preview > :nth-child(1) { transform: translate(0, 0); z-index: 4; }
.compact-stack-preview > :nth-child(2) { transform: translate(9px, 7px); z-index: 3; }
.compact-stack-preview > :nth-child(3) { transform: translate(18px, 14px); z-index: 2; }
.compact-stack-preview > :nth-child(4) { transform: translate(27px, 21px); z-index: 1; }
.stack-loading-preview { display: grid; place-items: center; color: #6c788c; font-size: 11px; background: #e8ebf0 !important; }
.stack-expand-button { position: absolute; z-index: 8; right: 8px; top: 8px; width: 30px; height: 30px; border: 0; border-radius: 6px; display: grid; place-items: center; background: rgba(255,255,255,.9); color: #5b687b; cursor: pointer; opacity: 0; transition: opacity .14s ease; }
.compact-stack-node:hover .stack-expand-button,
.compact-stack-node.selected .stack-expand-button { opacity: 1; }
.stack-expand-button svg { width: 15px; height: 15px; }

.folder-node .node-body { min-height: 195px; padding: 10px; }
.folder-node .asset-stack { height: 190px; }
.folder-node .asset-stack img { height: 176px; }
.folder-node .node-head { border-bottom: 0; }
.folder-node .folder-expanded-body { min-height: 0; padding: 12px; }
.folder-expanded-grid { display: grid; grid-template-columns: repeat(var(--folder-columns, 4), minmax(0, 1fr)); gap: 8px; }
.folder-expanded-grid img { width: 100%; height: 118px; object-fit: contain; display: block; background: #f1f3f6; }

.prompt-node { border-color: #aabfe8; box-shadow: 0 12px 34px rgba(45,65,99,.13); }
.prompt-node .node-head { height: 40px; }
.prompt-node-editor { min-height: 0; padding: 10px; cursor: default !important; }
.prompt-context-strip { display: flex; gap: 5px; overflow-x: auto; padding: 0 0 7px; }
.prompt-context-strip .context-chip { max-width: 150px; }
.prompt-context-strip .context-chip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-node-editor textarea { width: 100%; min-height: 92px; max-height: 190px; resize: vertical; border: 0; border-radius: 0; padding: 4px 3px 8px; background: transparent; color: var(--ink); line-height: 1.55; }
.prompt-node-editor textarea::placeholder { color: #9ba6b7; }
.prompt-node-toolbar { min-height: 42px; padding-top: 8px; border-top: 1px solid #e9edf3; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prompt-node-tools { min-width: 0; display: flex; align-items: center; gap: 5px; }
.prompt-tool-button,
.prompt-icon-button,
.prompt-param-select { height: 32px; border: 1px solid #d5deea; border-radius: 6px; background: #fff; color: #4b596d; font-size: 10px; }
.prompt-tool-button { max-width: 100px; padding: 0 8px; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.prompt-tool-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-tool-button svg { width: 13px; flex: none; }
.prompt-icon-button { width: 32px; padding: 0; display: grid; place-items: center; cursor: pointer; font-weight: 700; }
.prompt-icon-button svg { width: 13px; }
.prompt-param-select { max-width: 72px; padding: 0 5px; cursor: pointer !important; }
.prompt-node-submit { flex: none; display: flex; align-items: center; gap: 8px; }
.prompt-node-submit > span { color: var(--muted); font-size: 9px; white-space: nowrap; }
.prompt-node-submit button { height: 34px; border: 0; border-radius: 7px; padding: 0 11px; display: inline-flex; align-items: center; gap: 5px; background: var(--blue); color: #fff; cursor: pointer; font-size: 11px; font-weight: 700; }
.prompt-node-submit button:hover { background: #1f55cd; }
.prompt-node-submit button svg { width: 14px; }

.node-plus { position: absolute; z-index: 12; top: 50%; width: 30px; height: 30px; margin-top: -15px; border-radius: 50%; border: 1px solid #b9c6d9; background: #fff; box-shadow: 0 5px 15px rgba(41, 56, 80, .14); display: grid; place-items: center; color: #58677d; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .14s ease, transform .14s ease, box-shadow .14s ease; }
.node-plus::before { content: ""; position: absolute; inset: -11px; border-radius: 50%; }
.canvas-node.selected .node-plus, .canvas-node:hover .node-plus { opacity: 1; pointer-events: auto; }
.canvas-world.is-connecting .node-plus { opacity: .78; pointer-events: auto; }
.canvas-world.multi-selection-active .canvas-node.selected .node-plus { opacity: 0; pointer-events: none; }
.node-plus:hover { color: var(--blue); border-color: #7799e7; transform: scale(1.08); }
.node-plus.connection-port-target { opacity: 1; color: #fff; border-color: #2f75ea; background: #2f75ea; box-shadow: 0 0 0 7px rgba(47,117,234,.16), 0 7px 18px rgba(39,91,191,.28); transform: scale(1.13); }
.node-plus.left { left: -46px; }
.node-plus.right { right: -46px; }
.node-plus.top { top: -46px; left: 50%; margin-top: 0; margin-left: -15px; }
.node-plus.bottom { top: auto; bottom: -46px; left: 50%; margin-top: 0; margin-left: -15px; }
.sequence-node .node-plus.top,
.sequence-node .node-plus.bottom { border-color: #e6aa63; color: #a86016; }
.sequence-node .node-plus.top:hover,
.sequence-node .node-plus.bottom:hover { border-color: #d88424; color: #a15407; }
.node-plus svg { width: 15px; }
.edge-path.connection-preview { stroke: #2f75ea; stroke-width: 3; stroke-dasharray: 5 6; }

.local-composer { position: absolute; z-index: 35; width: 560px; border: 1px solid #cbd7e8; border-radius: 8px; background: rgba(255,255,255,.98); box-shadow: 0 20px 60px rgba(42, 57, 84, .18); padding: 12px; transform-origin: top left; pointer-events: auto; }
.multi-local-composer { z-index: 40; }
.multi-selection-frame { position: absolute; z-index: 38; border: 1px dashed #7395e8; border-radius: 8px; background: rgba(88,126,218,.025); pointer-events: none; }
.group-resize-handle { position: absolute; right: -8px; bottom: -8px; width: 17px; height: 17px; border: 2px solid #fff; border-radius: 50%; background: #3974e6; box-shadow: 0 3px 9px rgba(37,73,138,.3); cursor: nwse-resize; pointer-events: auto; }
.alignment-guide { position: absolute; z-index: 80; pointer-events: none; background: rgba(225, 63, 128, .78); box-shadow: 0 0 0 1px rgba(255,255,255,.68); }
.alignment-guide.vertical { top: -10000px; width: 1px; height: 20000px; }
.alignment-guide.horizontal { left: -10000px; width: 20000px; height: 1px; }
.multi-action-bar { position: absolute; left: 50%; top: -47px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; pointer-events: auto; }
.multi-stack-button,
.multi-arrange-button { height: 34px; border: 1px solid #c5d3eb; border-radius: 7px; background: rgba(255,255,255,.98); box-shadow: 0 10px 26px rgba(42,57,84,.14); color: #335781; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; font-size: 11px; font-weight: 650; cursor: pointer; pointer-events: auto; white-space: nowrap; }
.multi-stack-button:hover,
.multi-arrange-button:hover { border-color: #7f9ee6; color: #1f5ed2; background: #f6f9ff; }
.multi-stack-button svg,
.multi-arrange-button svg { width: 14px; height: 14px; }
.multi-selection-frame.stack-inside .multi-action-bar { top: 9px; }
.group-plus { position: absolute; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; border: 1px solid #aebed7; background: #fff; box-shadow: 0 7px 20px rgba(41,56,80,.15); color: #52657f; display: grid; place-items: center; cursor: pointer; pointer-events: auto; }
.group-plus:hover { border-color: #648be5; color: #2461d2; transform: translateY(-50%) scale(1.08); }
.group-plus.left { left: -49px; }
.group-plus.right { right: -49px; }
.multi-selection-frame.left-inside .group-plus.left { left: 9px; }
.multi-selection-frame.right-inside .group-plus.right { right: 9px; }
.group-plus svg { width: 15px; height: 15px; }
.composer-context { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 7px; }
.context-chip { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 4px 7px 4px 4px; border-radius: 6px; background: #f0f4fa; font-size: 11px; }
.context-chip img { width: 25px; height: 25px; object-fit: cover; border-radius: 4px; }
.local-composer textarea { width: 100%; min-height: 88px; border: 0; resize: vertical; padding: 7px 4px; color: var(--ink); line-height: 1.55; }
.local-composer textarea::placeholder, .global-composer textarea::placeholder { color: #a1aaba; }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 9px; border-top: 1px solid #edf1f5; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.icon-text-btn, .parameter-btn, .composer-icon-btn { height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 0 9px; font-size: 11px; white-space: nowrap; }
.composer-icon-btn { width: 34px; justify-content: center; padding: 0; font-weight: 700; }
.icon-text-btn svg, .parameter-btn svg, .composer-icon-btn svg { width: 14px; }
.parameter-select { height: 34px; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 0 7px; font-size: 11px; }
.price-hint { color: var(--muted); font-size: 11px; }
.generate-btn { height: 36px; border: 0; border-radius: 7px; background: var(--blue); color: #fff; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-weight: 650; white-space: nowrap; flex: none; }
.generate-btn:hover { background: #1e55cf; }
.generate-btn svg { width: 15px; }

.floating-menu { position: absolute; z-index: 110; width: 250px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.floating-menu button { width: 100%; border: 0; background: transparent; border-radius: 6px; padding: 10px; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; }
.floating-menu button:hover { background: #f2f5fa; }
.floating-menu svg { width: 18px; color: var(--blue); }
.floating-menu span { display: grid; gap: 2px; }
.floating-menu strong { font-size: 12px; }
.floating-menu small { font-size: 10px; color: var(--muted); }
.add-node-menu { width: 280px; padding: 8px; }
.add-node-search { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 10px; margin-bottom: 5px; border: 1px solid #d6deea; border-radius: 6px; background: #f7f9fc; }
.add-node-search svg { width: 15px; color: #748196; }
.add-node-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.add-node-list { display: grid; gap: 2px; }
.add-node-list button.filtered-out { display: none; }

.canvas-controls { position: absolute; left: 18px; bottom: 18px; z-index: 50; height: 38px; display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.94); box-shadow: 0 8px 24px rgba(53, 67, 91, .1); }
.canvas-controls button { width: 30px; height: 30px; border: 0; border-radius: 5px; background: transparent; display: grid; place-items: center; cursor: pointer; }
.canvas-controls button:hover { background: #eef2f7; }
.canvas-controls svg { width: 15px; }
.canvas-controls span { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.canvas-controls .zoom-value { width: 52px; font-size: 11px; }

.assistant-panel { position: relative; z-index: 55; display: grid; grid-template-rows: 70px 1fr auto; background: rgba(255,255,255,.96); border-left: 1px solid var(--line); min-width: 0; }
.assistant-head { padding: 0 14px 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.assistant-head > div:first-child { display: grid; gap: 2px; }
.assistant-head span { color: var(--blue); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.assistant-head strong { font-size: 14px; }
.assistant-head-actions { display: flex; align-items: center; gap: 5px; }
.assistant-status { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 11px; background: #f1f3f7; color: var(--muted); font-size: 9px; font-style: normal; white-space: nowrap; }
.assistant-status.ready { background: #e8f7ef; color: var(--green); }
.assistant-status.busy { background: #edf3ff; color: var(--blue); }
.assistant-status.error { background: #fcecef; color: var(--red); }
.assistant-head button, .assistant-toggle { border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; border-radius: 6px; }
.assistant-head button { width: 34px; height: 34px; }
.assistant-head button:hover { background: #f0f3f7; }
.assistant-head svg, .assistant-toggle svg { width: 17px; }
.assistant-feed { overflow: auto; padding: 22px 18px; }
.assistant-welcome { display: grid; gap: 7px; text-align: center; margin-top: 25%; }
.assistant-mark { margin: 0 auto 3px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.assistant-mark svg { width: 17px; }
.assistant-welcome strong { font-size: 14px; }
.assistant-welcome p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.feed-message { margin-bottom: 16px; padding: 11px 12px; border-radius: 7px; font-size: 12px; line-height: 1.6; }
.feed-message.user { margin-left: 26px; background: #edf3ff; }
.feed-message.assistant, .feed-message.system { margin-right: 26px; background: #f3f5f8; color: #526078; }
.global-composer { margin: 0 12px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; padding: 10px; box-shadow: 0 9px 28px rgba(43,58,82,.08); }
.global-composer textarea { width: 100%; border: 0; resize: none; min-height: 76px; padding: 2px; line-height: 1.55; }
.mention-chips { display: flex; gap: 5px; overflow-x: auto; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; }
.composer-actions > div { display: flex; gap: 4px; }
.composer-actions button { width: 31px; height: 31px; border: 0; border-radius: 6px; background: transparent; display: grid; place-items: center; cursor: pointer; font-weight: 700; }
.composer-actions button:hover { background: #eef2f7; }
.composer-actions svg { width: 15px; }
.composer-actions .send-btn { background: var(--blue); color: #fff; }
.composer-actions .send-btn:disabled { cursor: wait; opacity: .55; }
.assistant-toggle { position: absolute; z-index: 70; right: 18px; top: 18px; width: 40px; height: 40px; background: #fff; border: 1px solid var(--line); box-shadow: var(--node-shadow); }
.workspace.assistant-collapsed { grid-template-columns: 66px 1fr 0; }
.workspace.assistant-collapsed .assistant-panel { overflow: hidden; border-left: 0; }

.app-dialog { border: 0; border-radius: 10px; padding: 0; background: #fff; color: var(--ink); box-shadow: 0 30px 100px rgba(28, 39, 58, .26); }
.app-dialog::backdrop { background: rgba(29, 39, 57, .26); backdrop-filter: blur(3px); }
.login-dialog { width: 420px; }
.login-dialog form { padding: 34px; display: grid; gap: 16px; position: relative; }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; display: grid; place-items: center; cursor: pointer; }
.dialog-close:hover { background: #f1f3f7; }
.dialog-close svg { width: 17px; }
.dialog-brand { width: 58px; height: 58px; border-radius: 14px; object-fit: cover; }
.login-dialog h2 { margin: 0; font-size: 22px; }
.login-dialog p { margin: -8px 0 3px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.login-dialog label { display: grid; gap: 6px; font-size: 12px; font-weight: 650; }
.login-dialog input { width: 100%; height: 44px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 12px; }
.code-field { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.code-field button { border: 1px solid var(--line); border-radius: 7px; background: #f5f7fa; padding: 0 12px; cursor: pointer; }
.primary-btn { height: 44px; border: 0; border-radius: 7px; background: var(--blue); color: white; font-weight: 700; cursor: pointer; }
.login-dialog small { color: var(--muted); text-align: center; }
.auth-locked .login-dialog .dialog-close { display: none; }
.member-dialog { width: min(430px, calc(100vw - 32px)); }
.member-dialog form { padding: 34px; display: grid; gap: 14px; position: relative; }
.member-dialog h2 { margin: 0; font-size: 22px; }
.member-dialog p { margin: -8px 0 0; color: var(--muted); font-size: 13px; }
.member-balance { display: flex; align-items: end; justify-content: space-between; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: #f7faff; }
.member-balance span { color: var(--muted); font-size: 13px; }
.member-balance strong { color: var(--blue); font-size: 28px; line-height: 1; }
.member-dialog-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.member-dialog-stats div { min-width: 0; padding: 12px 8px; border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.member-dialog-stats strong, .member-dialog-stats span { display: block; overflow: hidden; text-overflow: ellipsis; }
.member-dialog-stats strong { font-size: 15px; }
.member-dialog-stats span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.member-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.member-dialog-actions a, .member-dialog-actions button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); font: inherit; font-size: 13px; text-decoration: none; cursor: pointer; }
.member-dialog-actions svg { width: 16px; height: 16px; }
.project-dialog { width: min(780px, calc(100vw - 60px)); }
.project-dialog form { padding: 24px; }
.project-dialog-head { align-items: center; }
.project-dialog-actions { display: flex; align-items: center; gap: 8px; }
.secondary-action-btn { min-height: 36px; border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; color: var(--ink); font-weight: 650; }
.secondary-action-btn:hover { border-color: #9fb8ee; background: #f7faff; }
.secondary-action-btn svg { width: 15px; }
.project-list { max-height: 560px; overflow: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.project-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.project-card.active { border-color: #7b9ee9; box-shadow: 0 0 0 2px rgba(37,99,235,.08); }
.project-open { width: 100%; min-height: 92px; border: 0; background: transparent; padding: 14px; display: grid; grid-template-columns: 38px 1fr auto; grid-template-rows: 1fr auto; gap: 5px 10px; text-align: left; cursor: pointer; }
.project-open:hover { background: #f8faff; }
.project-thumb { grid-row: 1 / 3; width: 38px; height: 38px; border-radius: 7px; display: grid; place-items: center; background: #edf3ff; color: var(--blue); }
.project-thumb svg { width: 18px; }
.project-copy { min-width: 0; display: grid; gap: 5px; }
.project-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.project-copy small { color: var(--muted); font-size: 10px; }
.project-open em { grid-column: 2; color: var(--green); font-size: 10px; font-style: normal; }
.project-open b { grid-column: 3; grid-row: 1; align-self: start; padding: 3px 7px; border-radius: 9px; background: #e9f1ff; color: var(--blue); font-size: 9px; }
.project-card-actions { min-height: 38px; border-top: 1px solid #edf1f5; padding: 0 8px 0 14px; display: flex; align-items: center; gap: 4px; }
.project-card-actions span { margin-right: auto; color: var(--muted); font-size: 10px; }
.project-card-actions button { width: 29px; height: 29px; border: 0; border-radius: 5px; background: transparent; display: grid; place-items: center; cursor: pointer; color: #657287; }
.project-card-actions button:hover { background: #f0f3f7; color: var(--blue); }
.project-card-actions button:disabled { opacity: .28; cursor: not-allowed; }
.project-card-actions svg { width: 14px; }
.project-empty { grid-column: 1 / -1; min-height: 180px; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 8px; }
.library-dialog { width: min(780px, calc(100vw - 60px)); }
.library-dialog form, .task-dialog form, .help-dialog form { padding: 24px; }
.dialog-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dialog-title-row div { display: grid; gap: 3px; }
.dialog-title-row span { color: var(--blue); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.dialog-title-row h2 { margin: 0; font-size: 20px; }
.dialog-close.inline { position: static; }
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-height: 500px; overflow: auto; }
.template-card { min-height: 126px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; padding: 16px; text-align: left; display: grid; align-content: space-between; gap: 14px; }
.template-card:hover, .template-card.active { border-color: #7d9eea; box-shadow: 0 7px 24px rgba(47, 76, 136, .1); }
.template-card .template-icon { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; background: #edf3ff; color: var(--blue); }
.template-card svg { width: 17px; }
.template-card div { display: grid; gap: 4px; }
.template-card strong { font-size: 13px; }
.template-card span { font-size: 11px; color: var(--muted); line-height: 1.45; }
.task-dialog { width: min(760px, calc(100vw - 60px)); }
.task-list { max-height: 560px; overflow: auto; display: grid; gap: 8px; }
.task-row { border: 1px solid var(--line); border-radius: 7px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.task-row > div { display: grid; gap: 4px; }
.task-row strong { font-size: 13px; }
.task-row span, .task-row small { color: var(--muted); font-size: 11px; }
.task-row-actions { display: flex; align-items: center; gap: 6px; }
.task-row-actions button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 7px 9px; cursor: pointer; font-size: 11px; }
.status-pill { justify-self: start; padding: 3px 7px; border-radius: 9px; background: #eef2f7; font-size: 10px !important; }
.status-pill.completed { background: #e6f6ee; color: var(--green); }
.status-pill.error { background: #fce9ed; color: var(--red); }
.help-dialog { width: 520px; }
.help-dialog ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 11px; }
.help-dialog li { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 7px; }
.help-dialog span { color: var(--muted); font-size: 12px; line-height: 1.5; }

.mention-menu, .history-menu { position: fixed; z-index: 200; width: 230px; max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); padding: 6px; }
.mention-menu button, .history-menu .history-item { width: 100%; border: 0; border-radius: 6px; background: transparent; padding: 8px; display: flex; align-items: center; gap: 9px; text-align: left; cursor: pointer; }
.mention-menu button:hover, .history-menu .history-item:hover { background: #f1f4f8; }
.mention-menu img { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; background: #eef1f4; }
.mention-menu span { display: grid; gap: 2px; }
.mention-menu strong, .history-menu strong { font-size: 11px; }
.mention-menu small, .history-menu small { color: var(--muted); font-size: 10px; }
.history-item { justify-content: space-between; }
.history-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.history-item button { width: 26px; height: 26px; flex: none; border: 0; background: transparent; color: var(--red); cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 300; transform: translateX(-50%); min-width: 220px; max-width: 520px; padding: 11px 15px; border-radius: 7px; background: #182133; color: #fff; box-shadow: var(--shadow); font-size: 12px; text-align: center; }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 250px 1fr auto; }
  .brand-block span, .credits-btn span { display: none; }
  .workspace { grid-template-columns: 58px 1fr 290px; }
  .left-toolbar { padding-inline: 7px; }
}

@media (max-width: 820px) {
  .topbar { grid-template-columns: auto 1fr auto; height: 64px; padding: 0 10px; }
  .brand-block div, .save-status, .account-btn > span, .account-btn > svg { display: none; }
  .project-block input { width: 100%; text-align: left; }
  .workspace { height: calc(100% - 64px); grid-template-columns: 54px 1fr; }
  .assistant-panel { position: absolute; top: 64px; right: 0; bottom: 0; width: min(360px, calc(100vw - 54px)); box-shadow: -16px 0 50px rgba(39, 54, 80, .16); }
  .assistant-panel.mobile-hidden { display: none; }
  .assistant-toggle { display: grid !important; }
  .start-actions { grid-template-columns: 1fr; }
  .empty-state { width: min(420px, calc(100% - 30px)); }
  .start-card { height: 88px; }
  .local-composer { width: min(520px, calc(100vw - 100px)); }
  .template-grid { grid-template-columns: 1fr 1fr; }
  .project-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
