/* ============================================================
 * styles-canvas.css —— 画布（#canvas）
 * 一页两态：
 *   ① 入口页：新手教程（4 个视频卡片）+ 我的创作（画布项目列表）
 *   ② 编辑器：无限画布 + 节点 + 连线 + 工具栏
 * 配色沿用站点变量，画布本身是一块「点阵底」的浅色工作区
 * ============================================================ */

/* ============================================================
   一、入口页
   ============================================================ */
.cv-land {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 4px 0 10px;
}

.cv-sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.cv-sec-t {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -.2px;
  color: var(--ink);
}
.cv-sec-sub { font-size: 11.5px; color: var(--faint); }
.cv-sec-btn {
  margin-left: auto;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  padding: 7px 11px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cv-sec-btn:hover { color: var(--ink); border-color: var(--muted); }
.cv-sec-btn svg { width: 13px; height: 13px; }

/* ---------- 新手教程：四张卡 ---------- */
.cv-tuts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.cv-tut {
  position: relative;
  text-align: left;
  appearance: none;
  display: flex;
  gap: 12px;
  min-height: 112px;
  padding: 14px 14px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(18, 160, 111, .10), transparent 58%),
    var(--panel);
  cursor: pointer;
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.cv-tut:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 12px 26px rgba(24, 48, 38, .09); }
.cv-tut-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.cv-tut-no {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.cv-tut-t { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.cv-tut-d { font-size: 11.5px; line-height: 1.65; color: var(--muted); }
.cv-tut-play {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
}
.cv-tut-play svg { width: 13px; height: 13px; }
/* 卡片右侧的小示意图：几块节点 + 一根线，纯 CSS/SVG，不用图片 */
.cv-tut-art {
  flex: 0 0 74px;
  width: 74px;
  align-self: center;
  color: var(--accent);
  opacity: .9;
}
.cv-tut-art svg { width: 100%; height: auto; display: block; }

/* ---------- 我的创作 ---------- */
.cv-projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.cv-proj-new {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 150px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.cv-proj-new:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.cv-proj-plus {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
}
.cv-proj-plus svg { width: 18px; height: 18px; }

.cv-proj {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  overflow: hidden;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.cv-proj:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 12px 26px rgba(24, 48, 38, .09); }
.cv-proj-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(circle at 1px 1px, rgba(120, 145, 135, .35) 1px, transparent 0) 0 0 / 14px 14px,
    var(--panel-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.cv-proj-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv-proj-empty { font-size: 11.5px; color: var(--faint); }
.cv-proj-meta { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 3px; }
.cv-proj-name {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cv-proj-time { font-size: 11px; color: var(--faint); }
.cv-proj-del {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: rgba(12, 20, 16, .5);
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .16s ease;
  z-index: 2;
}
.cv-proj:hover .cv-proj-del { opacity: 1; }
.cv-proj-del svg { width: 13px; height: 13px; }

/* ============================================================
   二、编辑器
   ============================================================ */
.cv-ed {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  overflow: hidden;
}

/* ---------- 顶部工具条 ---------- */
.cv-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.cv-back {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px 0 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
}
.cv-back:hover { color: var(--ink); border-color: var(--muted); }
.cv-back svg { width: 15px; height: 15px; }

.cv-name {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  padding: 6px 8px;
  border-radius: 8px;
  min-width: 80px;
  max-width: 300px;
  width: 200px;
}
.cv-name:hover { border-color: var(--line); }
.cv-name:focus { outline: none; border-color: var(--accent); background: var(--panel); }

.cv-saved { font-size: 11px; color: var(--faint); white-space: nowrap; }
.cv-saved.is-dirty { color: var(--gold); }

.cv-bar-r { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.cv-ib {
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  transition: color .14s ease, background .14s ease, border-color .14s ease;
}
.cv-ib svg { width: 17px; height: 17px; }
.cv-ib:hover { color: var(--ink); background: var(--accent-soft); }
.cv-ib:disabled { opacity: .38; cursor: default; background: transparent; }
.cv-ib.on { color: var(--accent); background: var(--accent-soft); }
.cv-bar-sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.cv-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 12.5px;
  white-space: nowrap;
}
.cv-btn:hover { border-color: var(--muted); }
.cv-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
html[data-theme="dark"] .cv-btn.primary { color: #0e1116; }
.cv-btn svg { width: 14px; height: 14px; }

/* ---------- 主体：左工具条 + 画布 ---------- */
.cv-body { flex: 1 1 auto; min-height: 0; display: flex; position: relative; }

.cv-rail {
  flex: 0 0 52px;
  width: 52px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  z-index: 3;
}
.cv-rail-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  transition: color .14s ease, background .14s ease;
}
.cv-rail-btn svg { width: 18px; height: 18px; }
.cv-rail-btn:hover { color: var(--ink); background: var(--accent-soft); }
.cv-rail-btn.on { color: var(--accent); background: var(--accent-soft); }
.cv-rail-sep { width: 22px; height: 1px; background: var(--line); margin: 5px 0; }
.cv-rail-tip {
  position: absolute;
  left: 54px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(24, 34, 30, .9);
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .12s ease, transform .12s ease;
  z-index: 9;
}
.cv-rail-btn:hover .cv-rail-tip { opacity: 1; transform: none; }

/* ---------- 画布舞台 ---------- */
.cv-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  background-color: var(--panel-soft);
  /* 点阵底：缩放时由 JS 更新 background-size / position，点距跟着世界坐标走 */
  background-image: radial-gradient(circle at 1px 1px, rgba(110, 138, 126, .38) 1px, transparent 0);
  background-size: 22px 22px;
  cursor: default;
  touch-action: none;
}
.cv-stage.is-pan { cursor: grabbing; }
.cv-stage.is-space { cursor: grab; }
.cv-stage.is-link { cursor: crosshair; }
/* 捏合缩放/拖拽时禁止浏览器选中文本与长按菜单，避免打断手势 */
.cv-stage.is-pan,
.cv-stage.is-space { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.cv-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.cv-edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
/* 连线：明显加粗并带箭头，拖动/悬停时进一步高亮 */
.cv-edge { fill: none; stroke: var(--line-strong); stroke-width: 2.8; stroke-linecap: round; pointer-events: none; transition: stroke-width .12s, stroke .12s; }
.cv-edge.is-hi { stroke: var(--accent); stroke-width: 4; }
.cv-edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 20;
  pointer-events: stroke;
  cursor: pointer;
}
.cv-edge-temp { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 7 5; stroke-linecap: round; }
html[data-theme="dark"] .cv-edge { stroke: #6f8390; }
html[data-theme="dark"] .cv-edge.is-hi { stroke: #4ade9f; }

/* ---------- 节点 ---------- */
.cv-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(24, 48, 38, .07);
  user-select: none;
}
.cv-node.is-sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(14, 138, 99, .16), 0 8px 22px rgba(24, 48, 38, .12); }
.cv-node.is-moving { cursor: grabbing; }
.cv-node.is-drop { border-color: var(--accent); }

.cv-node-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  height: 30px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  cursor: grab;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, rgba(246, 250, 248, .95), rgba(246, 250, 248, 0));
}
.cv-node-head:active { cursor: grabbing; }
.cv-node-head svg { width: 13px; height: 13px; flex: 0 0 auto; }
.cv-node-t {
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46%;
}
.cv-node-size { color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 10.5px; }
.cv-node-badge {
  margin-left: auto;
  font-size: 10px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.cv-node-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 0 0 12px 12px;
}
.cv-node-body img,
.cv-node-body video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--panel-soft);
}
.cv-node-body video { object-fit: contain; }
.cv-audio {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
}
.cv-audio audio { width: 100%; }
.cv-audio-t { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cv-text-in {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  resize: none;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink);
}
.cv-text-in::placeholder { color: var(--faint); }

.cv-node-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--faint);
  font-size: 11.5px;
  background:
    radial-gradient(circle at 1px 1px, rgba(120, 145, 135, .25) 1px, transparent 0) 0 0 / 12px 12px;
}
.cv-node-empty svg { width: 22px; height: 22px; opacity: .7; }
/* 起始节点空态的上传入口：常显、可直接点，不再只藏在右键菜单 */
.cv-node-empty-up {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 3px;
  padding: 6px 11px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft, rgba(74, 144, 226, .14));
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  opacity: 1;
  transition: filter .14s ease, transform .14s ease;
  z-index: 3;
}
.cv-node-empty-up:hover { filter: brightness(1.12); transform: translateY(-1px); }
.cv-node-empty-up svg { width: 13px; height: 13px; opacity: 1; }

/* ===== 起始节点：多图 + 内嵌提示词输入 ===== */
/* 有提示词区时，素材区收缩到剩余高度，不再撑满整个 body */
.cv-node-body:has(.cv-src-prompt) { display: flex; flex-direction: column; }
.cv-node-body:has(.cv-src-prompt) > img,
.cv-node-body:has(.cv-src-prompt) > video,
.cv-node-body:has(.cv-src-prompt) > .cv-audio,
.cv-node-body:has(.cv-src-prompt) > .cv-node-empty { flex: 1 1 auto; min-height: 0; height: auto; }
.cv-node-body:has(.cv-src-prompt) > img,
.cv-node-body:has(.cv-src-prompt) > video { object-fit: cover; }

.cv-img-stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.cv-image-node .cv-img-stage img,
.cv-img-stage > img { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--panel-soft); }
.cv-img-count {
  position: absolute; right: 6px; top: 6px;
  font-size: 10px; line-height: 1;
  padding: 4px 6px; border-radius: 6px;
  background: rgba(12, 20, 16, .66); color: #fff;
  pointer-events: none;
}
.cv-img-strip {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 3px; padding: 5px;
  background: linear-gradient(to top, rgba(8, 14, 11, .72), transparent);
  overflow-x: auto; scrollbar-width: thin;
}
.cv-img-strip img {
  flex: 0 0 auto; width: 34px; height: 34px;
  object-fit: cover; border-radius: 5px; cursor: pointer;
  border: 2px solid transparent; opacity: .68;
  transition: opacity .12s ease, border-color .12s ease;
}
.cv-img-strip img:hover { opacity: 1; }
.cv-img-strip img.is-on { opacity: 1; border-color: var(--accent); }

.cv-src-prompt {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
  padding: 6px 9px 8px;
}
.cv-src-prompt-h {
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px; color: var(--muted); margin-bottom: 3px;
}
.cv-src-prompt-h svg { width: 12px; height: 12px; }
.cv-src-prompt-in {
  width: 100%; height: 48px; box-sizing: border-box;
  resize: none; border: 0 !important; outline: none;
  border-radius: 0 !important; background: transparent !important;
  font-family: inherit; font-size: 11.5px; line-height: 1.6;
  color: var(--ink); padding: 0;
}
.cv-src-prompt-in::placeholder { color: var(--faint); }

/* hover 时的「替换图片」小按钮 */
.cv-node-swap {
  position: absolute;
  top: 7px;
  right: 7px;
  appearance: none;
  border: 0;
  border-radius: 7px;
  background: rgba(12, 20, 16, .62);
  color: #fff;
  font-size: 10.5px;
  line-height: 1;
  padding: 5px 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity .14s ease;
  z-index: 4;
}
.cv-node-swap svg { width: 11px; height: 11px; }
.cv-node:hover .cv-node-swap { opacity: 1; }

/* 端口 */
.cv-port {
  position: absolute;
  top: 50%;
  width: 11px;
  height: 11px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--panel);
  border: 1.6px solid var(--line-strong);
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
  z-index: 3;
}
.cv-port-in { left: -6px; }
.cv-port-out { right: -6px; cursor: crosshair; }
.cv-node:hover .cv-port-out { border-color: var(--accent); }
.cv-port-out:hover { transform: scale(1.28); border-color: var(--accent); background: var(--accent); }
.cv-node:hover .cv-port-in { border-color: var(--accent); }

/* 缩放手柄 */
.cv-node-resize {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: var(--panel);
  border: 1.6px solid var(--accent);
  cursor: nwse-resize;
  z-index: 4;
  opacity: 0;
  transition: opacity .12s ease;
}
.cv-node.is-sel .cv-node-resize { opacity: 1; }

/* 选中态浮动工具条 */
.cv-node-tools {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(20, 36, 30, .13);
  white-space: nowrap;
  z-index: 6;
}
.cv-nt {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  height: 26px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cv-nt svg { width: 13px; height: 13px; }
.cv-nt:hover { color: var(--ink); background: var(--accent-soft); }
.cv-nt.is-danger:hover { color: var(--danger); background: rgba(194, 65, 90, .1); }
.cv-nt-sep { width: 1px; height: 14px; background: var(--line); margin: 0 2px; }

/* ---------- 框选框 / 生成中 ---------- */
.cv-marquee {
  position: absolute;
  border: 1px solid var(--accent);
  background: rgba(14, 138, 99, .08);
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
}

.cv-node.is-solving { border-color: var(--accent); }
.cv-generating {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: rgba(246, 250, 248, .86);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  z-index: 3;
}
html[data-theme="dark"] .cv-generating { background: rgba(20, 26, 22, .86); }
/* 旋转环：让「进行中」一眼可见，而不是靠文字明灭 */
.cv-generating::before {
  content: '';
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: cv-spin .8s linear infinite;
}
@keyframes cv-spin { to { transform: rotate(360deg); } }
@keyframes cv-breathe {
  0%, 100% { opacity: .72; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .cv-generating::before { animation-duration: 2.4s; }
}

/* ---------- 缩放控件 / 提示 ---------- */
.cv-zoom {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 6px 18px rgba(20, 36, 30, .09);
  z-index: 5;
}
html[data-theme="dark"] .cv-zoom { background: rgba(20, 24, 33, .92); }
.cv-zoom-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 14px;
  padding: 0;
}
.cv-zoom-btn:hover { color: var(--ink); background: var(--accent-soft); }
.cv-zoom-btn svg { width: 13px; height: 13px; }
.cv-zoom-val {
  min-width: 46px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cv-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--faint);
  background: rgba(255, 255, 255, .86);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
}
html[data-theme="dark"] .cv-hint { background: rgba(20, 24, 33, .86); }

/* 空画布的一次性引导块 */
.cv-empty-cta {
  position: absolute;
  pointer-events: none;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(420px, 80%);
  padding: 22px 24px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, .72);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 3;
}
html[data-theme="dark"] .cv-empty-cta { background: rgba(20, 24, 33, .78); }
.cv-empty-cta-t { font-size: 14px; font-weight: 700; color: var(--ink); }
.cv-empty-cta-d { font-size: 11.5px; line-height: 1.7; color: var(--muted); }
.cv-empty-cta .cv-btn { white-space: nowrap; margin-top: 4px; pointer-events: auto; }
.cv-empty-cta-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.cv-empty-cta-row .cv-btn { display: inline-flex; align-items: center; gap: 5px; margin-top: 0; }
.cv-empty-cta-row .cv-btn svg { width: 14px; height: 14px; }

/* 工作流处理节点（图片生成 / 视频生成 / 自定义注册类型） */
.cv-proc { height: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: 8px; padding: 10px 11px; overflow: hidden; }
.cv-proc-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cv-proc-title > span:first-child { font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.cv-proc-badge { font-size: 10px; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-proc-inputs { font-size: 10.5px; color: var(--muted); line-height: 1.5; }
.cv-proc-empty, .cv-proc-result {
  flex: 1 1 auto;
  min-height: 38px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--faint);
  background: var(--panel-soft);
  overflow: auto;
  word-break: break-all;
}
.cv-proc-result { color: var(--muted); border-style: solid; }
.cv-proc img, .cv-proc video { width: 100%; max-height: 140px; object-fit: cover; border-radius: 8px; display: block; background: var(--panel-soft); }
.cv-proc video { object-fit: contain; }
.cv-proc-run {
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 11.5px;
  font-weight: 650;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}
.cv-proc-run:disabled { opacity: .55; cursor: default; }
html[data-theme="dark"] .cv-proc-run { color: #0e1116; }
.cv-proc-run:hover:not(:disabled) { filter: brightness(1.06); }
.cv-wf-note { font-size: 10.5px; line-height: 1.6; color: var(--faint); padding: 4px 0; }

/* ---------- 右键菜单 ---------- */
.cv-menu {
  position: fixed;
  min-width: 212px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 38px rgba(18, 32, 26, .18);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 1px;
  /* 矮屏（如 720p）下菜单会超出视口：限制高度并允许滚动 */
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cv-menu-h {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--faint);
  padding: 6px 8px 4px;
  letter-spacing: .04em;
}
/* 分组标题右侧的信息图标：hover 有说明 */
.cv-menu-info { margin-left: auto; display: inline-flex; align-items: center; opacity: .55; cursor: help; }
.cv-menu-info:hover { opacity: 1; }
.cv-menu-info svg { width: 12px; height: 12px; }
.cv-menu-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 12.5px;
  padding: 7px 9px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cv-menu-item svg { width: 14px; height: 14px; color: var(--muted); flex: 0 0 auto; }
.cv-menu-item:hover { background: var(--accent-soft); }
.cv-menu-item.is-danger:hover { background: rgba(194, 65, 90, .1); color: var(--danger); }
.cv-menu-item.is-danger:hover svg { color: var(--danger); }
/* 菜单文字吃满剩余宽度，把 NEW / 快捷键推到右侧 */
.cv-menu-t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-menu-k {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--faint);
  padding-left: 12px;
  letter-spacing: .02em;
}
.cv-menu-badge {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  color: #1677c9;
  background: rgba(22, 119, 201, .14);
  letter-spacing: .05em;
}
html[data-theme="dark"] .cv-menu-badge { color: #6cbcf0; background: rgba(88, 176, 240, .18); }
/* 不可用项（如未选中节点时的「反推提示词」、空剪贴板时的「粘贴」） */
.cv-menu-item.is-off { opacity: .38; cursor: default; }
.cv-menu-item.is-off:hover { background: transparent; }
.cv-menu-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* ---------- 侧边浮层：历史 / 帮助 / 模版 ---------- */
.cv-panel {
  position: absolute;
  top: 10px;
  left: 62px;
  width: 268px;
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(18, 32, 26, .16);
  z-index: 8;
  overflow: hidden;
}
.cv-panel-h {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink);
}
.cv-panel-h .cv-ib { margin-left: auto; width: 26px; height: 26px; }
.cv-panel-b { flex: 1 1 auto; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }

.cv-hist-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 8px 9px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cv-hist-item:hover { background: var(--accent-soft); }
.cv-hist-t { font-size: 12px; color: var(--ink); }
.cv-hist-d { font-size: 10.5px; color: var(--faint); }

.cv-help-step {
  display: flex;
  gap: 8px;
  padding: 7px 8px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}
.cv-help-no {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.cv-help-k { color: var(--ink); font-weight: 600; }

.cv-tpl {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  padding: 9px 10px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cv-tpl:hover { border-color: var(--accent); }
.cv-tpl-t { font-size: 12px; font-weight: 600; color: var(--ink); }
.cv-tpl-d { font-size: 10.5px; color: var(--faint); line-height: 1.5; }

/* ---------- 视频教程弹窗 ---------- */
.cv-tut-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background: rgba(8, 14, 11, .62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  padding: 24px;
}
.cv-tut-box {
  width: min(1080px, 100%);
  border-radius: 16px;
  overflow: hidden;
  background: #0c0f0d;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .45);
  display: flex;
  flex-direction: column;
}
.cv-tut-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: #e7ece9;
  font-size: 12.5px;
  background: rgba(255, 255, 255, .05);
}
.cv-tut-top .cv-ib { margin-left: auto; color: #cfd8d3; }
.cv-tut-top .cv-ib:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.cv-tut-video { width: 100%; aspect-ratio: 16 / 9; background: #000; display: block; }
.cv-tut-note { padding: 9px 14px 12px; color: #9fb0a8; font-size: 11.5px; line-height: 1.6; }
.cv-tut-note b { color: #dfe7e3; font-weight: 600; }

/* ---------- 空态 ---------- */
.cv-empty {
  padding: 26px 12px;
  text-align: center;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.8;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1100px) {
  .cv-tuts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* ---------- 画布助理面板（右侧）---------- */
.cv-ai {
  position: absolute;
  top: 10px;
  right: 12px;
  bottom: 162px; /* 给右下角小地图让位 */
  width: 322px;
  max-width: calc(100% - 90px);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(18, 32, 26, .2);
  z-index: 9;
  overflow: hidden;
}
html[data-theme="dark"] .cv-ai { box-shadow: 0 18px 44px rgba(0, 0, 0, .45); }
.cv-ai-h {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}
.cv-ai-title { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink); white-space: nowrap; }
.cv-ai-title b { font-weight: 680; white-space: nowrap; }
.cv-ai-h .cv-ib { margin-left: auto; width: 26px; height: 26px; }
.cv-ai-mark {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 4px;
  background: conic-gradient(from 210deg, #5b8cff, #a06bff, #5b8cff);
  box-shadow: 0 0 0 2px rgba(120, 140, 255, .16);
  flex: 0 0 auto;
}
.cv-ai-mark.big { width: 34px; height: 34px; border-radius: 10px; margin: 0 auto 10px; }

.cv-ai-log {
  flex: 1 1 auto;
  overflow: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cv-ai-welcome { text-align: center; padding: 18px 8px 6px; }
.cv-ai-wt { font-size: 14px; font-weight: 700; color: var(--ink); }
.cv-ai-wd { font-size: 11.5px; line-height: 1.6; color: var(--muted); margin-top: 6px; }
.cv-ai-msg { display: flex; }
.cv-ai-msg.me { justify-content: flex-end; }
.cv-ai-bubble {
  max-width: 88%;
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--ink);
}
.cv-ai-msg.me .cv-ai-bubble {
  background: linear-gradient(135deg, rgba(91, 140, 255, .16), rgba(160, 107, 255, .14));
  border-color: transparent;
}
.cv-ai-msg.ai .cv-ai-bubble:empty::after {
  content: '';
  display: inline-block;
  width: 6px; height: 6px; margin: 3px 1px;
  border-radius: 50%;
  background: var(--muted);
  animation: cv-ai-dot 1s infinite ease-in-out alternate;
}
@keyframes cv-ai-dot { from { opacity: .25; } to { opacity: 1; } }

.cv-ai-quick {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 10px 8px;
}
.cv-ai-q {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.cv-ai-q:hover { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); }

.cv-ai-foot { flex: 0 0 auto; padding: 8px 10px 10px; border-top: 1px solid var(--line); position: relative; }
.cv-ai-ctx { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted); margin-bottom: 6px; cursor: pointer; }
.cv-ai-inputwrap {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}
.cv-ai-input {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  line-height: 1.5;
  max-height: 110px;
}
.cv-ai-input::placeholder { color: var(--faint); }
.cv-ai-send {
  appearance: none;
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 8px;
  background: var(--accent, #3b7d63);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
}
.cv-ai-send:hover { filter: brightness(1.08); }
.cv-ai-send svg { width: 15px; height: 15px; }
.cv-ai-send.is-stop { background: var(--muted); }
.cv-ai-fhint { font-size: 10px; color: var(--faint); margin-top: 6px; }

/* @ 引用节点浮层 */
.cv-ai-mention {
  position: absolute;
  left: 10px; right: 10px; bottom: 96px;
  max-height: 160px;
  overflow: auto;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(18, 32, 26, .16);
  z-index: 12;
}
.cv-ai-mention-item {
  display: block; width: 100%;
  appearance: none; border: 0; background: transparent;
  color: var(--ink); text-align: left;
  font-size: 11.5px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
}
.cv-ai-mention-item:hover { background: var(--accent-soft); }

/* 接口设置折叠区 */
.cv-ai-settings {
  flex: 0 0 auto;
  max-height: 250px;
  overflow: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cv-ai-field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.cv-ai-field-inline { flex-direction: row; align-items: center; gap: 6px; }
.cv-ai-field-in {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  font: inherit; font-size: 11.5px;
  background: var(--panel);
  color: var(--ink);
  outline: 0;
}
.cv-ai-field-in:focus { border-color: var(--accent); }
.cv-ai-note { font-size: 10px; line-height: 1.5; color: var(--faint); }

/* ---------- 底部控制条（背景/工具/滚轮模式）与小地图 · 对齐参考站 ---------- */
.cv-bottombar {
  position: absolute;
  left: 12px;
  bottom: 52px; /* 让出左下角缩放控件的位置 */
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 7px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 6px 18px rgba(20, 36, 30, .09);
  z-index: 5;
  -webkit-user-select: none;
  user-select: none;
}
html[data-theme="dark"] .cv-bottombar { background: rgba(20, 24, 33, .92); }
.cv-seg { display: flex; align-items: center; gap: 2px; }
.cv-seg-gap { width: 1px; height: 18px; background: var(--line); }
.cv-seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1;
  padding: 6px 9px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s ease, background .12s ease;
}
.cv-seg-btn:hover { color: var(--ink); background: var(--accent-soft); }
.cv-seg-btn.on {
  color: var(--accent, #3b7d63);
  background: var(--accent-soft, rgba(59, 125, 99, .12));
  font-weight: 650;
}

.cv-minimap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 168px;
  padding: 5px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 6px 18px rgba(20, 36, 30, .09);
  z-index: 5;
}
html[data-theme="dark"] .cv-minimap { background: rgba(20, 24, 33, .94); }
.cv-minimap-cv {
  display: block;
  width: 158px;
  height: 106px;
  border-radius: 6px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  cursor: crosshair;
  touch-action: none;
}
.cv-mini-fit {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 5px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 5px 0;
  border-radius: 7px;
  cursor: pointer;
}
.cv-mini-fit:hover { color: var(--ink); background: var(--accent-soft); }

/* 三种背景图案：由 applyView 写入的 data-bg 驱动，JS 只更新 size/position */
.cv-stage[data-bg="dot"] {
  background-image: radial-gradient(circle at 1px 1px, rgba(110, 138, 126, .38) 1px, transparent 0);
}
.cv-stage[data-bg="grid"] {
  background-image:
    linear-gradient(to right, rgba(110, 138, 126, .16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(110, 138, 126, .16) 1px, transparent 1px);
}
.cv-stage[data-bg="solid"] { background-image: none; }
html[data-theme="dark"] .cv-stage[data-bg="dot"] {
  background-image: radial-gradient(circle at 1px 1px, rgba(150, 170, 190, .22) 1px, transparent 0);
}
html[data-theme="dark"] .cv-stage[data-bg="grid"] {
  background-image:
    linear-gradient(to right, rgba(150, 170, 190, .12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(150, 170, 190, .12) 1px, transparent 1px);
}

/* ---------- 反推提示词 / 独立接口设置弹层 ---------- */
.cv-rev-count {
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.cv-rev-body { gap: 10px; padding: 14px; }
.cv-rev-desc { font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.cv-rev-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.cv-rev-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 7px 3px 3px;
  font-size: 10.5px;
  color: var(--muted);
  background: var(--panel-soft);
}
.cv-rev-chip img { width: 26px; height: 26px; object-fit: cover; border-radius: 5px; display: block; }
.cv-rev-chip-ic {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}
.cv-rev-status { font-size: 11px; line-height: 1.5; color: var(--muted); min-height: 16px; }
.cv-rev-status.is-busy { color: var(--accent); }
.cv-rev-status.is-failed { color: var(--danger); }
.cv-rev-status.is-nomedia,
.cv-rev-status.is-unconfigured { color: #c98620; }
html[data-theme="dark"] .cv-rev-status.is-nomedia,
html[data-theme="dark"] .cv-rev-status.is-unconfigured { color: #e5ae55; }
.cv-rev-text { min-height: 150px; line-height: 1.7; resize: vertical; }
/* 导演台：一行一个镜头 */
.cv-director .cv-panel-b { gap: 8px; }
.cv-director-in { min-height: 152px; line-height: 1.7; resize: vertical; font-size: 12px; }
.cv-rev-foot {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
}
.cv-rev-foot .cv-btn:disabled { opacity: .45; cursor: default; }
.cv-rev .cv-ai-note { margin-top: 4px; }
@media (max-width: 620px) {
  .cv-rev-foot { justify-content: stretch; }
  .cv-rev-foot .cv-btn { flex: 1 1 auto; }
}

@media (max-width: 900px) {
  .cv-tuts { grid-template-columns: 1fr; }
  .cv-tut-art { display: none; }
  .cv-rail { flex: 0 0 44px; width: 44px; }
  .cv-rail-btn { width: 32px; height: 32px; }
  .cv-panel { left: 52px; width: calc(100% - 62px); }
  .cv-hint { display: none; }
  .cv-node-tools { bottom: auto; top: calc(100% + 8px); }

  /* 顶部工具条窄屏：返回只留图标、名字吃满剩余宽度、右侧只留必要按钮 */
  .cv-bar { padding: 7px 8px; gap: 6px; }
  .cv-back span { display: none; }
  .cv-back { padding: 0 8px; }
  .cv-name { flex: 1 1 auto; width: auto; min-width: 0; font-size: 13px; }
  .cv-saved { display: none; }
  .cv-bar-r { gap: 2px; }
  .cv-bar-r .cv-btn { display: none; }
  .cv-bar-sep { display: none; }
  .cv-ib { width: 30px; height: 30px; }

  .cv-empty-cta { width: min(320px, 86%); padding: 18px 16px; }
  .cv-empty-cta .cv-btn { font-size: 12px; padding: 0 10px; }

  /* 底部控制条窄屏收紧；小地图进一步缩小，避免遮挡画布 */
  .cv-bottombar { gap: 4px; padding: 3px 5px; bottom: 48px; }
  .cv-seg-btn { font-size: 10.5px; padding: 5px 6px; }
  .cv-minimap { width: 118px; }
  .cv-minimap-cv { width: 108px; height: 72px; }
  .cv-mini-fit { font-size: 10px; padding: 4px 0; }
  /* 助理面板窄屏改为贴右全高覆盖，避开底部控制条 */
  .cv-ai { left: 52px; right: 6px; top: 6px; bottom: 52px; width: auto; max-width: none; }
}
@media (max-width: 620px) {
  /* 极窄屏：滚轮模式与工具组对触屏意义不大，隐藏，仅保留背景切换 */
  .cv-bottombar .cv-seg:nth-of-type(3),
  .cv-bottombar .cv-seg-gap ~ .cv-seg:nth-of-type(3) { display: none; }
  .cv-minimap { display: none; }
  .cv-ai { bottom: 46px; }
}

/* ============================================================
   十、节点卡片 v2（对齐参考站的节点框）
   ------------------------------------------------------------
   结构：图标色块 + 主标题/类型副标题 + 状态 · 内容区 · 底栏（链路 + 模型 + 运行）
   端口：输入口按 accepts 显示、输出口常显，颜色跟着数据类型走
   ============================================================ */
.cv-node {
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(18, 32, 26, .05), 0 14px 30px -22px rgba(18, 32, 26, .45);
  transition: border-color .16s ease, box-shadow .16s ease, opacity .18s ease;
}
.cv-node:hover { box-shadow: 0 2px 6px rgba(18, 32, 26, .07), 0 20px 38px -24px rgba(18, 32, 26, .5); }
.cv-node.is-sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 20px 40px -26px rgba(9, 90, 66, .55);
}
.cv-node.is-dim { opacity: .4; }
.cv-node.is-dim:hover { opacity: .78; }

/* ---------- 标题栏 ---------- */
.cv-node-head {
  height: 44px;
  padding: 0 7px 0 10px;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  border-radius: 14px 14px 0 0;
}
.cv-node-ic {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cv-node-ic svg { width: 14px; height: 14px; }
.cv-node-tt {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}
.cv-node-t {
  max-width: none;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.25;
  color: var(--ink);
}
.cv-node-sub {
  font-size: 10px;
  line-height: 1.2;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cv-node-stale {
  flex: 0 0 auto;
  font-size: 9.5px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  color: #a86412;
  background: rgba(217, 154, 43, .16);
  white-space: nowrap;
}
html[data-theme="dark"] .cv-node-stale { color: #f0bb6a; }
.cv-node-badge { margin-left: 0; flex: 0 0 auto; }
.cv-node-size { flex: 0 0 auto; }

/* 关闭（删除）按钮：hover 卡片才出现，避免误触 */
.cv-node-x {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease, background .12s ease, color .12s ease;
}
.cv-node:hover .cv-node-x,
.cv-node.is-sel .cv-node-x { opacity: 1; }
.cv-node-x:hover { background: rgba(194, 65, 90, .12); color: var(--danger); }
.cv-node-x svg { width: 12px; height: 12px; }

/* ---------- 内容区 ---------- */
.cv-node-body { border-radius: 0; }
.cv-text-in { padding: 9px 11px; font-size: 12px; line-height: 1.66; }
.cv-node-empty { gap: 6px; font-size: 11px; }
.cv-node-empty svg { width: 20px; height: 20px; }
.cv-node-empty-up { height: 27px; padding: 0 10px; border-radius: 8px; font-size: 11px; }
.cv-src-prompt { padding: 5px 10px 7px; }
.cv-src-prompt-in { height: 40px; font-size: 11px; }
.cv-node-swap { display: none; }   /* 替换入口统一收进底栏 */

/* ---------- 底栏 ---------- */
.cv-node-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  background: var(--panel-soft);
  box-sizing: border-box;
}
.cv-node-chip {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
}
.cv-node-chip-t { overflow: hidden; text-overflow: ellipsis; }
.cv-model-chip {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  line-height: 20px;
  text-overflow: ellipsis;
  font-size: 10px;
  color: var(--faint);
}
.cv-words { flex: 0 0 auto; margin-left: auto; }
.cv-node-act {
  flex: 0 0 auto;
  margin-left: auto;
  height: 26px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.cv-node-act svg { width: 12px; height: 12px; }
.cv-node-act:hover { background: var(--accent); color: #fff; }
.cv-node-act:disabled { opacity: .55; cursor: default; }
.cv-node-act:disabled:hover { background: var(--accent-soft); color: var(--accent); }
.cv-node-act.is-ghost { border-color: var(--line); background: var(--panel); color: var(--muted); font-weight: 550; }
.cv-node-act.is-ghost:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.cv-node-ico {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}
.cv-node-ico:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.cv-node-ico svg { width: 13px; height: 13px; }
html[data-theme="dark"] .cv-node-act:hover { color: #0d1512; }

/* ---------- 端口 ---------- */
.cv-port {
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border: 2px solid var(--port-color, var(--line-strong));
  background: var(--panel);
  box-shadow: 0 0 0 2px var(--panel);
}
.cv-port-in { left: -6px; }
.cv-port-out {
  right: -6px;
  background: var(--port-color, var(--accent));
  cursor: crosshair;
}
.cv-port-out:hover {
  transform: scale(1.3);
  border-color: var(--port-color, var(--accent));
  background: var(--port-color, var(--accent));
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 5px rgba(14, 138, 99, .16);
}
.cv-port-t {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 5px;
  border-radius: 5px;
  background: rgba(16, 26, 22, .84);
  color: #fff;
  font-size: 9.5px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}
.cv-port-in .cv-port-t { right: 15px; }
.cv-port-out .cv-port-t { left: 15px; }
.cv-port:hover .cv-port-t { opacity: 1; }

/* ---------- 输出模块的内容区 ---------- */
.cv-proc { gap: 7px; padding: 9px 10px; }
.cv-proc-io { display: flex; flex-wrap: wrap; gap: 4px; min-height: 18px; align-items: center; }
.cv-io-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.5;
}
.cv-io-chip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--k, #8a95a5);
  flex: 0 0 auto;
}
.cv-proc-wait { font-size: 10px; color: var(--faint); }
.cv-proc-desc {
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cv-proc-res {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 9px;
  overflow: hidden;
  position: relative;
}
.cv-proc-res > img,
.cv-proc img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  display: block;
}
.cv-proc-res > video,
.cv-proc video { width: 100%; height: 100%; max-height: none; object-fit: contain; display: block; }
.cv-proc-res > audio { width: 100%; }
.cv-proc-result,
.cv-proc-empty {
  height: 100%;
  min-height: 54px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 9px;
  border-radius: 9px;
  font-size: 10.5px;
  line-height: 1.6;
  overflow: auto;
}
.cv-proc-result { color: var(--ink-soft); background: var(--panel-soft); border: 1px solid var(--line); white-space: pre-wrap; }
.cv-proc-empty { color: var(--faint); border: 1px dashed var(--line-strong); background: transparent; }
.cv-proc-run { display: none; }   /* 运行按钮已移到卡片底栏 */

/* ---------- 连线：按数据类型着色 + 链路上流动 ---------- */
.cv-edge { stroke-width: 2.4; opacity: .8; }
.cv-edge[data-kind="text"] { stroke: #5b8def; }
.cv-edge[data-kind="image"] { stroke: #2f9e6e; }
.cv-edge[data-kind="video"] { stroke: #8b5cf6; }
.cv-edge[data-kind="audio"] { stroke: #d99a2b; }
.cv-edge.is-hi { stroke-width: 3.4; opacity: 1; stroke: var(--accent); }
.cv-edge.is-chain {
  opacity: 1;
  stroke-width: 2.8;
  stroke-dasharray: 7 5;
  animation: cv-flow .9s linear infinite;
}
.cv-edge.is-dim { opacity: .16; }
@keyframes cv-flow { to { stroke-dashoffset: -12; } }
html[data-theme="dark"] .cv-edge[data-kind="text"] { stroke: #7aa2f7; }
html[data-theme="dark"] .cv-edge[data-kind="image"] { stroke: #4ade9f; }
html[data-theme="dark"] .cv-edge[data-kind="video"] { stroke: #a78bfa; }
html[data-theme="dark"] .cv-edge[data-kind="audio"] { stroke: #e5ae55; }
html[data-theme="dark"] .cv-edge.is-hi { stroke: #4ade9f; }
html[data-theme="dark"] .cv-node {
  box-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 34px -22px rgba(0, 0, 0, .8);
}
html[data-theme="dark"] .cv-node-foot { background: rgba(255, 255, 255, .03); }

/* 连线拖动：临时线跟着源节点的数据类型着色，悬停落点区分可接 / 不可接 */
.cv-edge-temp[data-kind="text"] { stroke: #5b8def; }
.cv-edge-temp[data-kind="image"] { stroke: #2f9e6e; }
.cv-edge-temp[data-kind="video"] { stroke: #8b5cf6; }
.cv-edge-temp[data-kind="audio"] { stroke: #d99a2b; }
.cv-node.is-drop {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 20px 38px -24px rgba(18, 32, 26, .5);
}
.cv-node.is-drop-bad {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(194, 65, 90, .14);
  cursor: not-allowed;
}
html[data-theme="dark"] .cv-edge-temp[data-kind="text"] { stroke: #7aa2f7; }
html[data-theme="dark"] .cv-edge-temp[data-kind="image"] { stroke: #4ade9f; }
html[data-theme="dark"] .cv-edge-temp[data-kind="video"] { stroke: #a78bfa; }
html[data-theme="dark"] .cv-edge-temp[data-kind="audio"] { stroke: #e5ae55; }

/* 卡片顶部类型色：细线 + 选中加强，远看也能区分节点类型 */
.cv-node::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  top: -1px;
  height: 2px;
  border-radius: 0 0 3px 3px;
  background: var(--tc, transparent);
  opacity: .6;
  pointer-events: none;
}
.cv-node.is-sel::after { opacity: 1; height: 3px; }

/* ============================================================
   十一、画布全屏工作区：进入编辑器后隐藏页面顶栏胶囊
   （右侧计费/充值/积分/登录，快捷条客服微信/公告/外观）
   由 openEditor 加 body.cv-full，leaveEditor 移除
   ============================================================ */
body.cv-full .topbar,
body.cv-full .quickbar,
body.cv-full .contact-row { display: none; }

/* 画布完全扩充整个工作区：解除 1200px 行宽上限，主列撑满 */
body.cv-full .main-col { max-width: none; padding: 0; }

/* ============================================================
   十二、图片创作页「技能板块」：人物图片 / 商品图片 / 场景图片
   对齐视频创作「电商带货 / 同城到店 / 剧情短片」的板块化结构
   ============================================================ */
.img-skill-tab {
  height: 32px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.img-skill-tab:hover { border-color: var(--accent); color: var(--accent-deep); }
html[data-theme="dark"] .img-skill-tab:hover { color: var(--accent); }
.img-skill-tab.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}
html[data-theme="dark"] .img-skill-tab.on { color: var(--accent); }

.img-skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.img-skill-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  text-align: left;
  cursor: pointer;
  transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease;
}
.img-skill-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -12px rgba(9, 90, 66, .5);
}
.img-skill-t { font-size: 13px; font-weight: 650; color: var(--ink); }
.img-skill-d { font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.img-skill-ref { font-size: 10.5px; line-height: 1.4; color: var(--faint); }
