/* ---------- 视口和网格 ---------- */
#editor { position: fixed; inset: 0; }
#viewport { position: absolute; inset: 0; overflow: hidden; background-color: var(--bg); cursor: default; touch-action: none;
  background-image: radial-gradient(circle, #2a2f37 1.1px, transparent 1.3px); }
#viewport.no-grid { background-image: none; }
#viewport[data-tool="hand"] { cursor: grab; }
#viewport.panning { cursor: grabbing !important; }
#viewport[data-tool="note"], #viewport[data-tool="add"] { cursor: crosshair; }
#viewport.drop::after { content: '松开鼠标上传到画布'; position: absolute; inset: 14px; display: grid; place-items: center; border: 2px dashed var(--accent);
  border-radius: 16px; background: rgba(45, 212, 191, .06); color: var(--accent); font-size: 18px; pointer-events: none; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.edge-svg { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
#marquee { position: absolute; display: none; border: 1px solid var(--accent); background: rgba(45, 212, 191, .08); border-radius: 3px; pointer-events: none; }
.empty-hint { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--mute); font-size: 14px; pointer-events: none;
  padding: 14px 22px; border: 1px dashed #2a303a; border-radius: 12px; }

/* ---------- 连线 ---------- */
/* 连上的线一直沿方向流动；生成中变成主题色并加快 */
.edge { fill: none; stroke: #8fb0da; stroke-width: 2.6; vector-effect: non-scaling-stroke; stroke-dasharray: 10 6;
  animation: flow 1.2s linear infinite; stroke-linecap: round;
  filter: drop-shadow(0 0 2px rgba(140, 180, 245, .9)) drop-shadow(0 0 7px rgba(120, 165, 235, .45)); }
.edge-g:hover .edge { stroke: #cfe0fa; stroke-width: 3; }
.edge.selected { stroke: var(--accent); stroke-width: 3.4;
  filter: drop-shadow(0 0 3px rgba(45, 212, 191, .9)) drop-shadow(0 0 9px rgba(45, 212, 191, .45)); }
.edge.flow { stroke: var(--accent); stroke-width: 3; animation-duration: .5s;
  filter: drop-shadow(0 0 3px rgba(45, 212, 191, .95)) drop-shadow(0 0 10px rgba(45, 212, 191, .5)); }
.edge.tmp { stroke: var(--accent); stroke-dasharray: 6 5; animation: none; }
@media (prefers-reduced-motion: reduce) { .edge { animation: none; } }
.edge-cut { pointer-events: all; cursor: pointer; opacity: 0; transition: opacity .12s; }
.edge-g:hover .edge-cut, .edge-g.sel .edge-cut { opacity: 1; }
.edge-cut circle { fill: var(--panel2); stroke: var(--line2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.edge-cut path { fill: none; stroke: var(--dim); stroke-width: 1.6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.edge-cut:hover circle { fill: var(--danger); stroke: var(--danger); }
.edge-cut:hover path { stroke: #fff; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
@keyframes flow { to { stroke-dashoffset: -14; } }

/* ---------- 分组 ---------- */
.group { position: absolute; left: 0; top: 0; border: 1.5px dashed #3b4452; border-radius: 16px; background: rgba(148, 163, 184, .04); }
.group-label { position: absolute; left: 14px; top: 6px; font-size: 13px; color: var(--dim); cursor: text; user-select: none; }

/* ---------- 节点 ---------- */
.node { position: absolute; left: 0; top: 0; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); user-select: none;
  --c: var(--accent); }
.node.t-text { --c: var(--c-text); } .node.t-image { --c: var(--c-image); } .node.t-video { --c: var(--c-video); }
.node.t-audio { --c: var(--c-audio); } .node.t-note { --c: var(--c-note); background: #2a2614; border-color: #4a4320; }
.node:hover { border-color: #3d4655; }
.node.selected { border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 8px 28px rgba(0, 0, 0, .4); }
.node.link-target { box-shadow: 0 0 0 3px var(--accent); }
.node.busy { border-color: transparent; }
.node.busy::before { content: ''; position: absolute; inset: -2px; border-radius: 13px; z-index: -1;
  background: conic-gradient(from var(--a, 0deg), var(--c), transparent 30%, transparent 60%, var(--c)); animation: rot 2s linear infinite; }
@property --a { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes rot { to { --a: 360deg; } }
.node-head { position: absolute; left: 2px; bottom: 100%; margin-bottom: 6px; display: flex; align-items: center; gap: 5px; width: 100%;
  color: var(--c); font-size: 12px; white-space: nowrap; pointer-events: none; }
.node-title { color: var(--dim); overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.node.selected .node-title { color: var(--text); }
.node-size { margin-left: auto; padding-right: 4px; color: var(--mute); font-size: 11px; }
.node-body { position: absolute; inset: 0; border-radius: 11px; overflow: hidden; background: inherit; }
.media { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.play-tip { position: absolute; right: 8px; bottom: 8px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; pointer-events: none; }
.node:hover .play-tip { opacity: 0; }
.node-text { width: 100%; height: 100%; padding: 12px 14px; border: 0; outline: none; resize: none; background: transparent; color: var(--text);
  line-height: 1.65; cursor: inherit; user-select: none; }
.node.editing .node-text { cursor: text; user-select: text; }
.node.t-note .node-text { color: #fde68a; }
.node-text::placeholder { color: var(--mute); }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--mute);
  background-image: radial-gradient(#232931 1px, transparent 1px); background-size: 12px 12px; }
.empty .ic { color: var(--c); opacity: .7; }
.empty .row { display: flex; gap: 8px; }
.empty .btn.recording { border-color: var(--danger); color: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .55; } }
.audio-box { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 12px; }
.audio-box audio { width: 100%; height: 40px; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px;
  text-align: center; font-size: 12px; }
.overlay.run { background: rgba(11, 13, 16, .72); color: var(--dim); }
.overlay.run b { color: var(--accent); font-weight: 500; }
.overlay.fail { background: rgba(40, 14, 16, .85); color: #fecaca; flex-direction: row; align-items: flex-start; justify-content: flex-start; }
.handle { position: absolute; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel2); border: 1.5px solid var(--c); color: var(--c); font-size: 15px; line-height: 1; opacity: 0; transition: opacity .12s, transform .12s; cursor: crosshair; }
.handle.in { left: -11px; width: 12px; height: 12px; margin-top: -6px; left: -6px; }
.handle.out { right: -11px; }
.node:hover .handle, .node.selected .handle, .node.link-target .handle { opacity: 1; }
.handle.out:hover { transform: scale(1.2); background: var(--c); color: #0b0d10; }
.resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; }
.node.selected .resize::after { content: ''; position: absolute; right: 3px; bottom: 3px; width: 7px; height: 7px;
  border-right: 2px solid var(--c); border-bottom: 2px solid var(--c); border-radius: 0 0 3px 0; }
.node.t-audio .resize { display: none; }

/* ---------- 顶部栏 / 工具栏 / 缩放栏 ---------- */
.topbar { position: fixed; top: 12px; z-index: 50; display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 12px;
  background: rgba(23, 27, 33, .92); border: 1px solid var(--line); backdrop-filter: blur(8px); }
.topbar.left { left: 12px; }
.topbar.right { right: 12px; }
.name-input { width: 220px; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px; background: transparent; outline: none; font-weight: 600; }
.name-input:hover { border-color: var(--line2); }
.name-input:focus { border-color: var(--accent); background: var(--bg2); }
.save-state { color: var(--mute); font-size: 12px; padding-right: 8px; min-width: 52px; }
.save-state[data-s="error"] { color: var(--danger); }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; color: #fcd34d; background: rgba(250, 204, 21, .1); border: 1px solid rgba(250, 204, 21, .3); cursor: help; }
.topbar .btn.active { border-color: var(--accent); color: var(--accent); }

.toolbar { position: fixed; left: 12px; top: 50%; transform: translateY(-50%); z-index: 50; display: flex; flex-direction: column; gap: 2px; padding: 6px;
  border-radius: 14px; background: rgba(23, 27, 33, .92); border: 1px solid var(--line); backdrop-filter: blur(8px); }
.toolbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 50px; padding: 8px 0 6px; border: 0; border-radius: 9px;
  background: transparent; color: var(--dim); font-size: 11px; }
.toolbar button:hover { background: #242a33; color: var(--text); }
.toolbar button.active { background: rgba(45, 212, 191, .14); color: var(--accent); }
.tb-sep { height: 1px; margin: 4px 8px; background: var(--line); }

.zoombar { position: fixed; left: 12px; bottom: 12px; z-index: 50; display: flex; align-items: center; gap: 4px; padding: 5px 8px 5px 5px;
  border-radius: 12px; background: rgba(23, 27, 33, .92); border: 1px solid var(--line); backdrop-filter: blur(8px); }
#zoomRange { width: 120px; accent-color: var(--accent); }
.zoom-text { width: 44px; text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; margin-right: 4px; }
.minimap { position: fixed; left: 12px; bottom: 60px; z-index: 50; padding: 6px; border-radius: 12px; background: rgba(23, 27, 33, .94); border: 1px solid var(--line); }
.minimap canvas { display: block; cursor: pointer; border-radius: 6px; background: #0f1216; }

/* ---------- 浅色主题（画布编辑器）：复用首页浅色变量，再覆盖写死的深色 ---------- */
#editor[data-theme="light"] {
  --bg: #f6f7f9; --bg2: #eef0f4; --panel: #ffffff; --panel2: #f1f3f6; --line: #e3e6eb; --line2: #d3d8e0;
  --text: #1c2230; --dim: #586273; --mute: #8a93a3; --accent: #0d9488;
  --shadow: 0 10px 28px rgba(30, 40, 60, .12);
}
#editor[data-theme="light"] #viewport { background-image: radial-gradient(circle, #cbd2dc 1.1px, transparent 1.3px); }
#editor[data-theme="light"] .empty-hint { border-color: var(--line2); }
#editor[data-theme="light"] .edge { stroke: #64748b; filter: drop-shadow(0 0 2px rgba(100, 116, 139, .5)); }
#editor[data-theme="light"] .group { border-color: #c3c9d3; background: rgba(100, 116, 139, .05); }
#editor[data-theme="light"] .node:hover { border-color: #c3c9d3; }
#editor[data-theme="light"] .node.selected { box-shadow: 0 0 0 1px var(--c), 0 8px 24px rgba(30, 40, 60, .18); }
#editor[data-theme="light"] .node.t-note { background: #fef9c3; border-color: #fde68a; }
#editor[data-theme="light"] .node.t-note .node-text { color: #854d0e; }
#editor[data-theme="light"] .empty { background-image: radial-gradient(#d3d8e0 1px, transparent 1px); }
#editor[data-theme="light"] .edge-cut:hover path { stroke: #fff; }
#editor[data-theme="light"] .toolbar button:hover { background: #e9ecf1; }
#editor[data-theme="light"] .topbar,
#editor[data-theme="light"] .toolbar { background: rgba(255, 255, 255, .92); }
#editor[data-theme="light"] .toolbar button.active { background: rgba(13, 148, 136, .1); }
#editor[data-theme="light"] .zoombar { background: rgba(255, 255, 255, .92); }
#editor[data-theme="light"] .minimap { background: rgba(255, 255, 255, .94); }
#editor[data-theme="light"] .minimap canvas { background: #eef0f4; }
#editor[data-theme="light"] .icon-btn:hover { background: #e9ecf1; }
#editor[data-theme="light"] .btn:hover:not(:disabled) { background: #f1f3f6; border-color: #c3c9d3; }
#editor[data-theme="light"] .send:hover { background: #14b8a6; }
/* 面板（生成 / 节点栏 / 侧栏 / 任务）都在 #editor 内 */
#editor[data-theme="light"] .rl-item:hover { background: #f1f3f6; border-color: #c3c9d3; }
#editor[data-theme="light"] .nb-btn:hover { background: #e9ecf1; }
#editor[data-theme="light"] .gp-prompt:focus { border-color: var(--accent); }
#editor[data-theme="light"] .pill:hover,
#editor[data-theme="light"] .vs-seg button:hover:not(:disabled) { border-color: #c3c9d3; }
#editor[data-theme="light"] .hist-item,
#editor[data-theme="light"] .help-row,
#editor[data-theme="light"] .st-models { border-color: var(--line); }
#editor[data-theme="light"] .tpl-mini { background-image: radial-gradient(#d3d8e0 1px, transparent 1px); }
#editor[data-theme="light"] .tpl-mini b { background: #9aa3b2; }
#editor[data-theme="light"] .asset-thumb { background: #eef0f4; }
#editor[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cfd4dc; }
