/* =========================================================================
   画布（节点图）样式

   和 styles.css 的关系：styles.css 只管站点通用组件；画布这一套单独一个文件，
   因为它量大、且大量使用「层 + 变换」的定位，混在一起容易互相覆盖。
   主题色一律走 :root 里的变量，改主题只改 styles.css 顶部那一处。
   ========================================================================= */

/* ---------- 页面外壳 ---------- */

.cv-page {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  background: var(--bg);
}

.cv-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(var(--nav-rgb), .94);
  flex-wrap: wrap;
}
.cv-back { font-size: 13.5px; color: var(--text-dim); padding: 7px 12px; border-radius: 8px; }
.cv-back:hover { background: rgba(var(--wash-rgb), .05); color: var(--text); }
.cv-name {
  width: 220px; padding: 7px 10px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text);
  font-weight: 600; font-size: 14.5px;
}
.cv-name:hover, .cv-name:focus { border-color: var(--border-strong); background: var(--bg-soft); outline: none; }
.cv-state { font-size: 12.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.cv-project { font-size: 12.5px; color: var(--text-faint); }
.cv-bar .grow { flex: 1; }

.cv-main { flex: 1; display: flex; min-height: 0; }
.cv-editor { position: relative; flex: 1; min-width: 0; }

/* ---------- 素材库侧栏 ---------- */

.cv-side {
  width: 276px; flex: 0 0 auto;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
}
.cv-side.hidden { display: none; }
.cv-side-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px 8px;
  font-size: 13.5px; font-weight: 600; color: var(--text-dim);
}
.cv-side-head .hint { font-weight: 400; color: var(--text-faint); }
.cv-side-search { padding: 0 12px 8px; }
.cv-side-search input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-elev, var(--panel)); color: var(--text);
  font-size: 13.5px;
}
.cv-side-search input:focus { outline: none; border-color: var(--border-strong); }
.cv-filter { display: flex; gap: 4px; padding: 0 12px 10px; flex-wrap: wrap; }
.cv-filter button {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--text-faint);
  font-size: 12.5px; cursor: pointer;
}
.cv-filter button.on { border-color: var(--cream-dim); color: var(--cream); background: rgba(var(--ring-rgb), .08); }
.cv-side-actions { padding: 0 12px 10px; }
.cv-side-actions .btn { width: 100%; }
.cv-side-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.cv-side-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 6px; border: 0; border-radius: 8px;
  background: transparent; cursor: grab; text-align: left;
}
.cv-side-item:hover { background: rgba(var(--wash-rgb), .06); }
.cv-side-item:active { cursor: grabbing; }
.cv-side-thumb {
  position: relative; width: 46px; height: 34px; flex: 0 0 auto;
  border-radius: 6px; overflow: hidden; background: var(--matte);
  display: grid; place-items: center; color: var(--text-faint); font-size: 14px;
}
.cv-side-thumb img, .cv-side-thumb video { width: 100%; height: 100%; object-fit: cover; }
.cv-side-thumb .asset-kind { display: none; }
.cv-side-name {
  font-size: 13.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-side-tip {
  margin: 0; padding: 10px 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px; color: var(--text-faint); line-height: 1.6;
}

/* ---------- 视口 ---------- */

.cv {
  position: absolute; inset: 0;
  overflow: hidden;
  cursor: default;
  touch-action: none;
  background: radial-gradient(900px 600px at 50% 40%, rgba(var(--glow-rgb), .05), transparent 70%);
}
.cv.space-pan { cursor: grab; }
.cv.panning { cursor: grabbing; }
.cv.drop-active { box-shadow: inset 0 0 0 2px rgba(var(--ring-rgb), .35); }

.cv-grid { position: absolute; inset: 0; pointer-events: none; }
.cv-grid[data-mode="dots"] {
  background-image: radial-gradient(rgba(var(--wash-rgb), .075) 1px, transparent 1px);
}
.cv-grid[data-mode="lines"] {
  background-image:
    linear-gradient(rgba(var(--wash-rgb), .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--wash-rgb), .055) 1px, transparent 1px);
}
.cv-grid[data-mode="blank"] { background-image: none; }

.cv-stage {
  position: absolute; left: 0; top: 0;
  width: 0; height: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.cv-groups, .cv-nodes { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.cv-links { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }

/* ---------- 连线 ---------- */

.cv-link {
  fill: none;
  stroke: var(--edge);
  stroke-width: 2;
  transition: stroke .15s;
}
.cv-link.hot { stroke: var(--edge-hot); }
.cv-link.sel { stroke: var(--cream); stroke-width: 2.6; }
.cv-link.drafting {
  stroke: var(--edge-hot);
  stroke-dasharray: 7 5;
  stroke-width: 2;
}
.cv-link-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  pointer-events: stroke;
  cursor: pointer;
}

/* ---------- 节点外壳 ---------- */

.cv-node {
  position: absolute;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  /* 注意：这里不能 overflow:hidden，否则挂在边缘的连线端口会被裁掉 */
  overflow: visible;
  box-shadow: var(--shadow-node);
  transition: box-shadow .16s, border-color .16s;
  container-type: inline-size;
}
.cv-head {
  border-radius: 11px 11px 0 0;
  overflow: hidden;
}
.cv-body {
  border-radius: 0 0 11px 11px;
  overflow: hidden;
}
.cv-body.gen { overflow-y: auto; }
.cv-node.selected {
  border-color: var(--cream-dim);
  box-shadow: 0 0 0 1px rgba(var(--ring-rgb), .45), var(--shadow-node-lg);
}
.cv-node.dragging { box-shadow: var(--shadow-node-lg); cursor: grabbing; }
.cv-node.drop-ok { border-color: var(--ok); box-shadow: 0 0 0 2px rgba(var(--ok-rgb), .35); }
.cv-node.drop-no { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(var(--danger-rgb), .3); }
.cv-node.active { border-color: rgba(var(--ring-rgb), .55); }

.cv-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: rgba(var(--wash-rgb), .045);
  border-bottom: 1px solid var(--border-soft);
  cursor: grab; user-select: none;
  flex: 0 0 auto;
}
.cv-node.dragging .cv-head { cursor: grabbing; }
.cv-kind-tag {
  font-size: 12px; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 4px;
  background: rgba(var(--ring-rgb), .1); color: var(--text-dim);
  flex: 0 0 auto;
}
.cv-title {
  flex: 1; font-size: 13.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500;
}
.cv-del {
  border: 0; background: none; color: var(--text-dim);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}
.cv-del:hover { color: var(--danger); }

.cv-dot {
  width: 10px; height: 10px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--panel-3);
  border: 1px solid var(--border-strong);
}
.cv-dot.out:hover { background: var(--cream); border-color: var(--cream); }

/* 连线端口：贴在节点左右边的正中间。
   外面 48px 是热区（好点），里面 12px 才是看到的圆点；平时淡一点，hover/选中变亮。 */
.cv-port {
  position: absolute; top: 50%; z-index: 6;
  width: 48px; height: 48px;
  margin-top: -24px;
  display: grid; place-items: center;
  cursor: crosshair;
  opacity: .28;
  transition: opacity .15s;
}
.cv-port.in { left: -24px; }
.cv-port.out { right: -24px; }
.cv-node:hover .cv-port,
.cv-group:hover .cv-port,
.cv-node.selected .cv-port,
.cv-group.selected .cv-port { opacity: 1; }
.cv-port i {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--border-strong);
  box-shadow: 0 0 0 3px rgba(var(--nav-rgb), .55);
  transition: transform .15s, background .15s, border-color .15s;
}
.cv-port.out i { border-color: var(--cream-dim); }
.cv-port:hover i { transform: scale(1.35); background: var(--cream); border-color: var(--cream); }
.cv-node:hover .cv-port.in i { border-color: var(--cream-dim); }

/* 四角缩放 */
.cv-resize {
  position: absolute; width: 12px; height: 12px;
  opacity: 0; transition: opacity .15s;
  z-index: 3;
}
.cv-node:hover .cv-resize, .cv-node.selected .cv-resize { opacity: 1; }
.cv-resize[data-resize="nw"] { left: -3px; top: -3px; cursor: nwse-resize; }
.cv-resize[data-resize="ne"] { right: -3px; top: -3px; cursor: nesw-resize; }
.cv-resize[data-resize="sw"] { left: -3px; bottom: -3px; cursor: nesw-resize; }
.cv-resize[data-resize="se"] { right: -3px; bottom: -3px; cursor: nwse-resize; }

/* ---------- 素材节点 ---------- */

.cv-body { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.cv-body.media {
  display: grid; place-items: center;
  background: var(--matte);
}
.cv-body.media img, .cv-body.media > video {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.cv-audio { display: grid; place-items: center; gap: 6px; width: 100%; padding: 12px; }
.cv-audio-icon { font-size: 20px; color: var(--text-faint); }
.cv-audio-name { font-size: 13.5px; color: var(--text-dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-audio audio { width: 100%; height: 30px; }
.cv-missing {
  display: grid; place-items: center; height: 100%; padding: 12px;
  color: var(--text-faint); font-size: 13.5px; text-align: center;
}

/* ---------- 文本节点 ---------- */

.cv-body.text { background: var(--panel); }
.cv-text {
  width: 100%; height: 100%; resize: none;
  border: 0; background: transparent; color: var(--text);
  padding: 11px 13px 24px; font-size: 14.5px; line-height: 1.7;
  font-family: inherit;
}
.cv-text:focus { outline: none; box-shadow: none; }
.cv-text::placeholder { color: var(--text-faint); }
.cv-count {
  position: absolute; right: 10px; bottom: 6px;
  font-size: 12px; color: var(--text-faint);
  font-variant-numeric: tabular-nums; pointer-events: none;
}

/* ---------- 生成节点公共 ---------- */

.cv-body.gen {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 14px 12px; overflow-y: auto; background: var(--panel);
}

.gn-problems {
  border: 1px solid rgba(var(--danger-rgb), .4);
  background: var(--danger-bg);
  border-radius: 9px; padding: 8px 10px;
  font-size: 12.5px; line-height: 1.55; color: var(--err-ink);
}
.gn-problems p { margin: 0 0 2px; }
.gn-problems p.warn { color: var(--warn); }
.gn-problems p:last-of-type { margin-bottom: 0; }
.gn-fix {
  margin-top: 6px; padding: 3px 8px;
  border: 1px solid rgba(var(--danger-rgb), .5); border-radius: 6px;
  background: transparent; color: var(--err-ink); font-size: 12.5px; cursor: pointer;
}
.gn-fix:hover { background: rgba(var(--danger-rgb), .18); }

.gn-inputs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px; border-radius: 8px;
  background: var(--bg-soft); border: 1px dashed var(--border);
}
.gn-inputs.empty { justify-content: space-between; border-style: dashed; color: var(--text-faint); font-size: 12.5px; }
.gn-inputs-hint { color: var(--text-faint); font-size: 12px; }
.gn-inputs-count { margin-left: auto; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.gn-chip {
  position: relative; display: flex; align-items: center; gap: 4px;
  padding: 3px 20px 3px 3px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
}
.gn-chip[data-role="mention"] { cursor: pointer; }
.gn-chip[data-role="mention"]:hover { border-color: var(--border-strong); background: var(--panel-3); }
.gn-chip img { width: 34px; height: 26px; object-fit: cover; border-radius: 4px; display: block; }
.gn-chip-icon {
  width: 34px; height: 26px; display: grid; place-items: center;
  border-radius: 4px; background: var(--panel-3); color: var(--cream-dim); font-size: 12px;
}
.gn-chip-label {
  font-size: 12px; color: var(--text-dim); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.gn-chip button {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-faint);
  font-size: 12px; line-height: 1; cursor: pointer;
}
.gn-chip button:hover { background: var(--danger-bg); color: var(--danger); }

.gn-prompt-wrap { position: relative; flex: 1 1 auto; display: flex; flex-direction: column; min-height: 100px; }
.gn-prompt {
  flex: 1 1 auto; width: 100%; min-height: 0; max-height: none;
  padding: 2px 0 8px;
  background: transparent; color: var(--text);
  font-size: 14.5px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
  overflow-y: auto; cursor: text;
  /* 内容长了也不显示滚动条：那条灰线看起来像给输入框加了边框 */
  scrollbar-width: none;
}
.gn-prompt::-webkit-scrollbar { width: 0; height: 0; display: none; }
.gn-prompt:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}
.gn-prompt:focus, .gn-prompt:focus-visible {
  outline: none; box-shadow: none;
  background: transparent;
}
.gn-prompt-chip {
  display: inline-flex; align-items: center; justify-content: center;
  height: 24px; min-width: 24px; max-width: 150px;
  margin: 0 3px; border-radius: 5px; overflow: hidden;
  vertical-align: -6px;
  background: var(--panel-3); border: 1px solid var(--border);
  user-select: none;
}
.gn-prompt-chip img { width: 22px; height: 22px; object-fit: cover; display: block; }
.gn-prompt-chip.is-text {
  padding: 0 6px; gap: 3px;
  font-size: 12px; color: var(--text-dim);
}
.gn-prompt-chip.is-text i { font-style: normal; font-size: 10px; }
.gn-prompt-foot {
  position: relative; z-index: 1; flex: 0 0 auto;
  display: flex; justify-content: flex-start; align-items: center; gap: 6px;
  padding-top: 6px;
  background: var(--panel);
  pointer-events: none;
}
.gn-sync {
  pointer-events: auto; cursor: pointer;
  font-size: 12px; padding: 2px 7px; border-radius: 999px;
  background: var(--panel-3); color: var(--text-dim);
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}
.gn-sync.on { background: rgba(var(--ok-rgb), .16); color: var(--ok-ink); }
.gn-at {
  pointer-events: auto; cursor: pointer;
  padding: 2px 8px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-faint);
  font-size: 12px; font-family: inherit;
  min-height: 24px;
}
.gn-at:hover { background: rgba(var(--ring-rgb), .12); color: var(--cream); }
.gn-count { margin-left: auto; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.gn-row { display: flex; gap: 6px; align-items: center; }
/* 生图一行三格：模型吃掉剩余宽度，清晰度 / 比例按内容定宽；窄节点自动换行。
   注意 styles.css 里 select 是 width:100%，所以这两格必须显式 width:auto 才收得住。 */
.gn-row.params { flex-wrap: wrap; }
.gn-row.params .gn-select.model { flex: 1 1 132px; width: auto; min-width: 0; }
.gn-row.params .gn-select.tier,
.gn-row.params .gn-select.ratio { flex: 0 0 auto; width: auto; min-width: 66px; }
.gn-select {
  flex: 1; min-width: 0;
  padding: 6px 9px; font-size: 13.5px; border-radius: 7px;
  background: var(--bg-elev, var(--panel-2));
  border: 1px solid var(--border); color: var(--text);
}
.gn-select:focus { outline: none; border-color: var(--border-strong); box-shadow: none; }
.gn-select:disabled { opacity: .6; }
.gn-select.wide { flex: 1 1 100%; }

.gn-switch {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 8px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg-elev, var(--panel-2));
  font-size: 13.5px; color: var(--text-dim); cursor: pointer; flex: 0 0 auto;
}
.gn-switch { min-height: 28px; }
.gn-switch input { accent-color: var(--cream-dim); margin: 0; width: 16px; height: 16px; }
.gn-mode-hint { font-size: 12px; color: var(--text-faint); margin-top: -4px; }

.gn-adv { border-top: 1px dashed var(--border-soft); padding-top: 4px; }
.gn-adv summary {
  cursor: pointer; font-size: 12.5px; color: var(--text-dim);
  padding: 5px 0; list-style: none;
}
.gn-adv summary::-webkit-details-marker { display: none; }
.gn-adv summary::before { content: '▸ '; }
.gn-adv[open] summary::before { content: '▾ '; }
.gn-adv-field { display: flex; flex-direction: column; gap: 3px; margin-top: 7px; }
.gn-adv-field > span { font-size: 12px; color: var(--text-faint); }
.gn-negative {
  width: 100%; min-height: 48px; margin-top: 0;
  padding: 6px 8px; border-radius: 7px;
  background: var(--bg-elev, var(--panel-2)); border: 1px solid var(--border);
  color: var(--text); font-size: 13.5px; line-height: 1.5;
  resize: vertical; font-family: inherit;
}
.gn-seed {
  width: 100%; margin-top: 0; padding: 5px 8px;
  border-radius: 7px; background: var(--bg-elev, var(--panel-2));
  border: 1px solid var(--border); color: var(--text); font-size: 13.5px;
}
.gn-negative:focus, .gn-seed:focus {
  outline: none; border-color: var(--border-strong); box-shadow: none;
}

/* ---------- 视频节点：参考内容 / 底部操作条 / 设置面板 ---------- */

.gn-refs { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.gn-refs-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; color: var(--text);
  font-weight: 500;
}
.gn-refs-count { color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 12px; }
.gn-refs-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gn-ref {
  position: relative; width: 60px; height: 60px; flex: 0 0 auto;
  border-radius: 10px; overflow: hidden;
  background: var(--matte); border: 1px solid var(--border);
  cursor: pointer;
}
.gn-ref img, .gn-ref > video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gn-ref-ph {
  display: grid; place-items: center; width: 100%; height: 100%;
  color: var(--text-faint); font-size: 18px;
}
.gn-ref-tag {
  position: absolute; left: 4px; bottom: 4px;
  padding: 0 5px; border-radius: 4px;
  background: rgba(0, 0, 0, .62); color: #f3ece1;
  font-size: 12px; line-height: 1.6; pointer-events: none;
}
.gn-ref-x {
  position: absolute; right: 2px; top: 2px;
  width: 18px; height: 18px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .62); color: #fff;
  font-size: 12px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.gn-ref:hover .gn-ref-x { opacity: 1; }
.gn-ref-add {
  width: 60px; height: 60px; flex: 0 0 auto;
  border-radius: 10px; border: 1px dashed var(--border-strong);
  background: transparent; color: var(--text-faint);
  font-size: 20px; line-height: 1; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.gn-ref-add:hover {
  border-color: var(--cream-dim); color: var(--cream);
  background: rgba(var(--ring-rgb), .06);
}

/* 底部操作条：复制提示词 / 模型 / 参数摘要 / 价格 / 生成 */
.gn-bar {
  /* 粘在内容区底部：字放大后内容偶尔比节点高，操作条也不能被挤出可视区 */
  position: sticky; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  flex: 0 0 auto; margin-top: auto; padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  background: var(--panel); overflow: hidden;
}
.gn-icon {
  width: 32px; height: 32px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text-faint); font-size: 13px; line-height: 1; cursor: pointer;
}
.gn-icon svg, .gn-send svg { display: block; }
.gn-icon:hover { background: rgba(var(--wash-rgb), .08); color: var(--text); }
.gn-model {
  flex: 0 1 auto; min-width: 0; max-width: 152px;
  padding: 5px 6px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-elev, var(--panel-2));
  color: var(--text-dim); font-size: 12.5px; font-family: inherit;
}
.gn-model:focus { outline: none; border-color: var(--border-strong); box-shadow: none; }
/* 参数摘要胶囊：两家共用，flex 撑满中间那段，所以操作框拖宽拖窄它自己伸缩，
   发送键永远贴在右边缘。点开是设置面板。 */
.gn-summary {
  flex: 1 1 auto; min-width: 0;
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-elev, var(--panel-2));
  color: var(--text-dim); font-size: 12.5px; font-family: inherit;
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.gn-summary:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.gn-summary:disabled { opacity: .55; cursor: default; }
/* 价格紧跟在参数摘要后面、发送键前面：跟在「这些参数」的语境里读，不贴着左边模型 */
.gn-bar .gn-price {
  flex: 0 0 auto;
  font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums;
}
.gn-send {
  width: 38px; height: 38px; flex: 0 0 auto;
  /* 撑满中间的是参数摘要；这里再顶一下兜底，摘要没渲染出来时发送键也不会跑中间 */
  margin-left: auto;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--cream); color: var(--accent-ink);
  font-size: 17px; line-height: 1; cursor: pointer;
  transition: transform .15s, opacity .15s, background .15s;
}
.gn-send:hover:not(:disabled) { transform: translateY(-1px); background: var(--primary-hover); }
.gn-send:disabled { opacity: .35; cursor: not-allowed; }
.gn-send.is-cancel {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid rgba(var(--danger-rgb), .42); font-size: 13.5px;
}

/* 设置面板：盖住内容区，底部操作条始终可见 */
.gn-settings {
  position: absolute; left: 0; right: 0; top: 0; bottom: 56px;
  z-index: 4; display: none; flex-direction: column; gap: 12px;
  padding: 14px 14px 18px; overflow-y: auto;
  background: var(--panel);
  border-bottom: 1px solid var(--border-soft);
}
.gn-settings.open { display: flex; }
.gn-set-head { display: flex; align-items: center; justify-content: space-between; }
.gn-set-head b { font-size: 13.5px; color: var(--text); }
.gn-set-x {
  width: 28px; height: 28px; flex: 0 0 auto;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text-faint); font-size: 14px; cursor: pointer;
}
.gn-set-x:hover { background: rgba(var(--wash-rgb), .08); color: var(--text); }
.gn-set-note {
  margin: 0; padding: 8px 10px; border-radius: 9px;
  background: var(--bg-soft); color: var(--text-faint);
  font-size: 12px; line-height: 1.6;
}
.gn-set { display: flex; flex-direction: column; gap: 8px; }
.gn-set > label { font-size: 12.5px; color: var(--text-dim); }
.gn-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gn-chip2 {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); font-size: 13.5px; font-family: inherit; cursor: pointer;
}
.gn-chip2:hover:not(.on) { border-color: var(--border-strong); color: var(--text); }
.gn-chip2.on {
  border-color: var(--cream); background: var(--cream);
  color: var(--accent-ink); font-weight: 600;
}
.gn-ratios { display: flex; flex-wrap: wrap; gap: 6px; }
.gn-ratio {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  flex: 0 0 80px; padding: 8px 4px; border-radius: 10px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); font-size: 12px; font-family: inherit; cursor: pointer;
}
.gn-ratio i {
  display: block; height: 16px; border: 1.5px solid currentColor;
  border-radius: 2px; box-sizing: border-box;
}
.gn-ratio:hover:not(.on) { border-color: var(--border-strong); color: var(--text); }
.gn-ratio.on {
  border-color: var(--cream); background: rgba(var(--ring-rgb), .1); color: var(--cream);
}
.gn-dur { display: flex; align-items: center; gap: 10px; }
.gn-dur input[type="range"] {
  flex: 1; min-width: 0; height: 24px; accent-color: var(--cream-dim); cursor: pointer;
}
.gn-dur input[type="range"]:disabled { opacity: .5; cursor: default; }
.gn-dur-input { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.gn-dur-input input {
  width: 64px; padding: 5px 6px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-elev, var(--panel-2));
  color: var(--text); font-size: 13.5px; text-align: center; font-family: inherit;
}
.gn-dur-input input:focus {
  outline: none; border-color: var(--border-strong); box-shadow: none;
}
.gn-dur-input span { font-size: 12.5px; color: var(--text-faint); }
.gn-set-hint { margin: 0; font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.gn-set-switch { align-self: flex-start; }
.gn-settings .gn-adv { margin-top: 2px; }

/* 窄节点（老画布里 348px 宽的生视频节点）优先把参数摘要露出来，价格收进 title。
   字放大后 452px 的标准宽度也快挤不下，所以门槛跟着提到 460px。 */
@container (max-width: 460px) {
  .gn-bar .gn-price { display: none; }
  /* 价格收起来后这里反而空出一截，模型名别被 132 的白白切掉 */
  .gn-model { max-width: 160px; }
}
/* 再窄下去（操作框能拖到 320）一行放不下：只收紧间距和宽度，不换行。
   模型名太长时让下拉自己截断（title 里有全名），比让参数跳到第二行整齐。 */
@container (max-width: 400px) {
  .gn-bar { gap: 4px; }
  .gn-bar .gn-icon { width: 28px; }
  .gn-model { max-width: 112px; padding: 5px 4px 5px 5px; }
}

.gn-foot {
  position: sticky; bottom: -10px; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  margin-top: auto; padding: 6px 0 2px;
  background: var(--panel);
}
.gn-foot-gap { flex: 1; }
.gn-price {
  font-size: 13.5px; color: var(--cream); font-variant-numeric: tabular-nums;
}
.gn-btn {
  padding: 7px 18px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.gn-btn.primary { background: var(--cream); color: var(--accent-ink); }
.gn-btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.gn-btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.gn-btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--text-dim); }
.gn-btn.ghost:hover { color: var(--danger); border-color: var(--danger); }

.cv-status {
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-3); color: var(--text-dim); white-space: nowrap;
}
.cv-status.st-queued, .cv-status.st-submitting { background: var(--warn-bg); color: var(--warn); }
.cv-status.st-running { background: rgba(var(--info-rgb), .14); color: var(--info-ink); }
.cv-status.st-success { background: var(--ok-bg); color: var(--ok-ink); }
.cv-status.st-failed { background: var(--danger-bg); color: var(--danger); }
.cv-status.st-canceled { background: var(--panel-3); color: var(--text-dim); }
.cv-status.st-unknown { background: var(--danger-bg); color: var(--warn); }

.gn-result { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.gn-result video {
  width: 100%; max-height: 260px; object-fit: contain;
  border-radius: 8px; display: block; background: #000;
}
/* 生图结果：按图片原比例展示，超高时裁切 */
.gn-result img {
  width: 100%; max-height: 320px; object-fit: cover;
  border-radius: 8px; display: block; background: var(--panel-3);
}
.gn-hint { font-size: 12.5px; line-height: 1.5; color: var(--text-faint); }
.gn-result-actions { display: flex; gap: 6px; }
.gn-result-actions button {
  flex: 1; padding: 4px 8px; border-radius: 7px;
  border: 1px solid var(--border-strong); background: transparent;
  color: var(--text-dim); font-size: 13.5px; cursor: pointer;
}
.gn-result-actions button:hover:not(:disabled) { color: var(--text); border-color: var(--cream-dim); }
.gn-result-actions button:disabled { opacity: .5; cursor: default; }
.gn-progress { height: 5px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.gn-progress > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--cream-dim), var(--ok));
  transition: width .45s;
}
.gn-error { font-size: 13.5px; line-height: 1.6; color: var(--err-ink); }
.gn-error a { color: var(--cream); text-decoration: underline; }
.gn-muted { font-size: 13.5px; color: var(--text-faint); }

/* =========================================================================
   v4：视频生成节点 = 上面预览（节点本体）+ 下面操作框（选中时浮在节点下方）

   为什么要这样拆：
   - 节点本体就是一个「屏幕」，成片多大就显示多大，不再被表单挤成一条缝；
   - 提示词 / 参考素材 / 模型参数是「改的时候才看」的东西，选中节点才展开，
     画布上多放几个视频节点也不会糊成一片表单。
   ========================================================================= */

.cv-node.type-gen {
  --stage-bg: #100e0c;
  --stage-line: rgba(255, 255, 255, .1);
  background: var(--stage-bg);
  border-color: var(--stage-line);
}
/* 标题栏浮在画面上：拖动、状态、删除都还在，但不占预览的高度 */
.cv-node.type-gen .cv-head {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  padding: 7px 10px;
  background: linear-gradient(180deg, rgba(8, 7, 6, .82), rgba(8, 7, 6, .34) 58%, transparent);
  border-bottom: 0;
  border-radius: 11px 11px 0 0;
}
.cv-node.type-gen .cv-title { color: #f2ede5; }
.cv-node.type-gen .cv-kind-tag { background: rgba(255, 255, 255, .14); color: rgba(255, 255, 255, .82); }
.cv-node.type-gen .cv-del { color: rgba(255, 255, 255, .55); }
.cv-node.type-gen .cv-del:hover { color: #fff; }
.cv-node.type-gen .cv-status { background: rgba(255, 255, 255, .11); color: rgba(255, 255, 255, .74); }
.cv-node.type-gen .cv-status.st-queued,
.cv-node.type-gen .cv-status.st-submitting { background: rgba(230, 180, 70, .26); color: #ffe6b8; }
.cv-node.type-gen .cv-status.st-running { background: rgba(96, 150, 255, .28); color: #d6e6ff; }
.cv-node.type-gen .cv-status.st-success { background: rgba(78, 176, 120, .3); color: #cdf0da; }
.cv-node.type-gen .cv-status.st-failed,
.cv-node.type-gen .cv-status.st-unknown { background: rgba(220, 92, 80, .32); color: #ffd7d1; }
.cv-node.type-gen .cv-status.st-canceled { background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .72); }

.cv-body.stage {
  position: relative; flex: 1; min-height: 0;
  padding: 0; overflow: hidden;
  border-radius: 0 0 11px 11px;
  background: var(--stage-bg, #100e0c);
}
.gn-stage { position: absolute; inset: 0; display: grid; place-items: center; }
.gn-stage > video,
.gn-stage > img {
  width: 100%; height: 100%; display: block;
  object-fit: contain; background: transparent;
}

/* 空 / 生成中 / 失败：都在深色舞台里居中说话 */
.gn-stage-empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 0 20px; text-align: center;
  color: rgba(255, 255, 255, .55); font-size: 13.5px; line-height: 1.6;
}
.gn-stage-empty svg { opacity: .55; }
.gn-stage-loading {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: rgba(255, 255, 255, .74); font-size: 13px;
}
.gn-stage-spin {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .18); border-top-color: rgba(255, 255, 255, .84);
  animation: gnspin .9s linear infinite;
}
@keyframes gnspin { to { transform: rotate(360deg); } }
.gn-stage-loading-text { font-variant-numeric: tabular-nums; }
.gn-stage-bar {
  display: block; width: 156px; height: 4px;
  border-radius: 999px; background: rgba(255, 255, 255, .15); overflow: hidden;
}
.gn-stage-bar > i { display: block; height: 100%; background: #e9dfc9; transition: width .45s; }
.gn-stage-note {
  display: flex; flex-direction: column; gap: 6px;
  max-width: 330px; padding: 0 20px; text-align: center;
  color: rgba(255, 255, 255, .66); font-size: 13px; line-height: 1.65;
}
.gn-stage-note b { color: #f2ede5; font-size: 13.5px; }
.gn-stage-note.is-err b { color: #ff9c90; }
.gn-stage-note a { color: #e9dfc9; text-decoration: underline; }

/* 成片的下载 / 存素材库：压在画面右上角，hover 才露 */
.gn-stage-actions {
  position: absolute; right: 8px; top: 38px; z-index: 4;
  display: flex; gap: 6px;
  opacity: 0; transition: opacity .15s;
}
.cv-node:hover .gn-stage-actions,
.cv-node.selected .gn-stage-actions { opacity: 1; }
.gn-stage-actions button {
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(0, 0, 0, .52); color: rgba(255, 255, 255, .88);
  font-size: 12px; font-family: inherit; cursor: pointer;
  backdrop-filter: blur(6px);
}
.gn-stage-actions button:hover:not(:disabled) { background: rgba(255, 255, 255, .18); color: #fff; }
.gn-stage-actions button:disabled { opacity: .55; cursor: default; }

/* ---------- 操作框（浮在节点下方） ---------- */

.cv-composer {
  position: absolute; left: 50%; top: calc(100% + 10px); z-index: 9;
  /* 水平位移由 JS 给（--composer-shift）：节点贴边时把卡片推回视口内 */
  transform: translateX(calc(-50% + var(--composer-shift, 0px)));
  /* 尺寸跟节点完全独立：默认 560，拖右下角手柄自己改宽 / 高（存 meta.composerW/composerH） */
  width: var(--composer-w, 560px);
  min-width: 320px;
  max-width: min(calc(100vw - 40px), 1100px);
  display: none;
  /* 自己当一个尺寸容器：里面的 @container 规则按操作框的宽度算，而不是节点宽度 */
  container-type: inline-size;
}
.cv-node.selected .cv-composer { display: block; }
/* 节点贴着画布下沿时，操作框翻到节点上方（预览留在下面还能看见） */
.cv-composer.is-flipped { top: auto; bottom: calc(100% + 10px); }
.cv-composer-card {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  min-height: var(--composer-h, 0);
  padding: 12px 13px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-node-lg);
}
/* 拖右下角改操作框大小：手柄贴着卡片圆角，别浮在角外当装饰。
   热区往外多伸 5px 好抓，可见的折角留在卡片里侧，看起来像卡片自带的角。 */
.cv-composer-grip {
  position: absolute; right: -5px; bottom: -5px;
  width: 20px; height: 20px; z-index: 2;
  cursor: nwse-resize;
  opacity: 0; transition: opacity .15s;
}
.cv-composer-grip::after {
  content: '';
  position: absolute; right: 4px; bottom: 4px;
  width: 10px; height: 10px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  border-radius: 0 0 4px 0;
}
.cv-node:hover .cv-composer-grip,
.cv-node.selected .cv-composer-grip { opacity: .75; }
.cv-composer-grip:hover { opacity: 1; }
.cv-composer-grip:hover::after { border-color: var(--cream); }
.cv-composer-card .gn-prompt-wrap { flex: 1 1 auto; min-height: 78px; }
.cv-composer-card .gn-prompt { padding: 6px 2px 4px; }
.cv-composer-card .gn-prompt-foot { padding-top: 4px; }
/* 操作框按内容定高：底部条不再需要 sticky 兜底 */
.cv-composer-card .gn-bar {
  position: static; margin-top: 0; padding-top: 9px;
  background: transparent;
}
/* 设置面板：在操作框内部展开（点底部那条参数摘要开关）。
   不做浮层：浮层要么盖住预览、要么顶出画布被裁，展开在卡片里始终看得见。 */
.cv-composer-card .gn-settings {
  position: static; inset: auto;
  z-index: 1;
  width: 100%; max-width: none; max-height: 52vh;
  padding: 10px 0 0;
  border: 0; border-top: 1px solid var(--border-soft); border-radius: 0;
  background: transparent; box-shadow: none;
  overflow-y: auto;
}
/* 设置项两列排：清晰度 / 比例 / 秒数 / 模式，高度省一半，操作框不至于顶出画布 */
.cv-composer-card .gn-settings.open {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px 16px; align-items: start;
}
.cv-composer-card .gn-settings.open > .gn-set-head,
.cv-composer-card .gn-settings.open > .gn-set-note,
.cv-composer-card .gn-settings.open > .gn-switch,
.cv-composer-card .gn-settings.open > .gn-adv { grid-column: 1 / -1; }
.cv-composer-card .gn-settings .gn-adv { margin-top: 0; }

/* ---------- 提示词放大编辑（模态） ---------- */

.cv-modal-card.cv-prompt-modal {
  width: min(880px, 92vw);
  height: min(76vh, 720px);
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 18px 14px;
}
.cv-prompt-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cv-prompt-modal-head h3 { margin: 0; font-size: 15.5px; }
.cv-prompt-modal-x {
  width: 28px; height: 28px; flex: 0 0 auto;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--text-faint); font-size: 15px; cursor: pointer;
}
.cv-prompt-modal-x:hover { background: rgba(var(--wash-rgb), .08); color: var(--text); }
.cv-prompt-modal-refs { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.cv-prompt-modal-label { font-size: 12.5px; color: var(--text-faint); }
.cv-prompt-modal-empty { font-size: 12.5px; color: var(--text-faint); }
.cv-prompt-modal-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-soft);
  font-size: 14.5px; line-height: 1.8;
}
.cv-prompt-modal-body:focus { outline: none; border-color: var(--border-strong); box-shadow: none; }
.cv-prompt-modal-body .gn-prompt-chip { height: 26px; min-width: 26px; }
.cv-prompt-modal-body .gn-prompt-chip img { width: 24px; height: 24px; }
.cv-prompt-modal-foot {
  display: flex; align-items: center; gap: 12px; flex: 0 0 auto;
}
.cv-prompt-modal-hint { font-size: 12px; color: var(--text-faint); }
.cv-prompt-modal-foot .gn-count { margin-left: auto; }
.cv-prompt-modal .gn-ref { width: 56px; height: 56px; }

/* ---------- 组节点 ---------- */

.cv-group {
  background: rgba(var(--ring-rgb), .035);
  border: 1px dashed rgba(var(--ring-rgb), .34);
  border-radius: 16px;
  box-shadow: none;
  overflow: visible;
}
.cv-group.selected {
  border-color: var(--cream-dim);
  background: rgba(var(--ring-rgb), .06);
  box-shadow: 0 0 0 1px rgba(var(--ring-rgb), .2);
}
.cv-group.dragging { cursor: grabbing; }
.cv-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; cursor: grab; user-select: none;
  border-bottom: 1px dashed rgba(var(--ring-rgb), .16);
  background: rgba(var(--nav-rgb), .55);
  border-radius: 14px 14px 0 0;
}
.cv-group-title { font-size: 13.5px; color: var(--cream-dim); font-weight: 600; }
.cv-group-count { font-size: 12px; color: var(--text-faint); }
.cv-group-head .cv-del {
  margin-left: auto; font-size: 12px;
  padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-dim);
}
.cv-group-head .cv-del:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- 浮动控件 ---------- */

.cv-hud {
  position: absolute; left: 14px; top: 14px;
  display: flex; align-items: center; gap: 2px;
  padding: 4px; border-radius: 10px;
  background: rgba(var(--float-rgb), .92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(6px);
}
.cv-hud button {
  width: 28px; height: 28px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-dim);
  font-size: 14px; line-height: 1; cursor: pointer;
}
.cv-hud button:hover:not(:disabled) { background: rgba(var(--wash-rgb), .09); color: var(--text); }
.cv-hud button.on { background: rgba(var(--ring-rgb), .16); color: var(--cream); }
.cv-hud button:disabled { opacity: .32; cursor: default; }
.cv-hud-sep { width: 1px; height: 16px; margin: 0 3px; background: var(--border); }

.cv-tools {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 2px; padding: 5px;
  border-radius: 999px;
  background: rgba(var(--float-rgb), .94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.cv-tools button {
  padding: 7px 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-dim); font-size: 13.5px; cursor: pointer;
}
.cv-tools button:hover { background: rgba(var(--wash-rgb), .09); color: var(--text); }

.cv-zoom {
  position: absolute; left: 14px; bottom: 18px;
  display: flex; align-items: center; gap: 2px;
  padding: 4px 6px; border-radius: 999px;
  background: rgba(var(--float-rgb), .94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13.5px; color: var(--text-dim);
}
.cv-zoom button {
  width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-dim); font-size: 15px; cursor: pointer;
}
.cv-zoom button:hover { background: rgba(var(--wash-rgb), .09); color: var(--text); }
.cv-zoom span { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }

.cv-mini {
  position: absolute; right: 14px; bottom: 18px;
  padding: 4px; border-radius: 10px;
  background: rgba(var(--float-rgb), .92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  line-height: 0;
}
.cv-mini[hidden] { display: none; }
.cv-mini canvas { width: 200px; height: 132px; display: block; border-radius: 6px; cursor: grab; }
.cv-mini:hover { border-color: var(--border-strong); }
.cv-mini.dragging canvas { cursor: grabbing; }

/* ---------- 节点浮动工具条 ---------- */

/* 用屏幕坐标定位（不在 stage 里），所以缩放画布时它不会跟着变小，图标和字都能看清。
   位置在节点正上方；顶到视口边缘时翻到节点下方（data-below=1）。 */
.cv-node-tools {
  position: absolute; z-index: 32;
  display: flex; align-items: center; gap: 1px;
  padding: 3px; border-radius: 12px;
  background: rgba(var(--float-rgb), .97);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-menu);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.cv-node-tools[hidden] { display: none; }
.cv-ntool {
  display: flex; align-items: center; gap: 5px;
  height: 34px; padding: 0 9px;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--text-dim); font-size: 13.5px; font-family: inherit; cursor: pointer;
}
.cv-ntool:hover:not(:disabled) { background: rgba(var(--wash-rgb), .1); color: var(--text); }
.cv-ntool:disabled { opacity: .5; cursor: default; }
.cv-ntool.danger { color: var(--danger); }
.cv-ntool.danger:hover:not(:disabled) { background: var(--danger-bg); }
.cv-ntool-ic { width: 14px; text-align: center; font-size: 14px; line-height: 1; }
.cv-ntool-label { line-height: 1; }

/* ---------- 提示词 @ 引用菜单 ---------- */

.cv-mention {
  position: absolute; z-index: 38;
  width: 284px; max-height: 244px; overflow-y: auto;
  padding: 5px; border-radius: 12px;
  background: rgba(var(--float-rgb), .98);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-menu);
}
.cv-mention[hidden] { display: none; }
/* 弹窗里输入的 @：菜单要浮在遮罩（z-index 60）上面 */
.cv-mention.is-modal { z-index: 72; }
.cv-mention-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 6px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); text-align: left;
  font-family: inherit; cursor: pointer;
}
.cv-mention-item:hover, .cv-mention-item.on { background: rgba(var(--ring-rgb), .14); }
.cv-mention-item img, .cv-mention-item video {
  width: 38px; height: 30px; object-fit: cover;
  border-radius: 5px; background: var(--matte); flex: 0 0 auto;
}
.cv-mention-ic {
  width: 38px; height: 30px; display: grid; place-items: center;
  border-radius: 5px; background: var(--panel-3);
  color: var(--cream-dim); font-size: 12px; flex: 0 0 auto;
}
.cv-mention-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cv-mention-text b { font-size: 13.5px; font-weight: 600; }
.cv-mention-text small {
  font-size: 12px; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-mention-empty {
  padding: 10px 8px; font-size: 12.5px; color: var(--text-faint); line-height: 1.6;
}

/* ---------- 框选 / 空状态 ---------- */

.cv-marquee {
  position: absolute; pointer-events: none;
  border: 1px solid rgba(var(--ring-rgb), .75);
  background: rgba(var(--ring-rgb), .1);
  border-radius: 3px;
}
.cv-marquee[hidden] { display: none; }

.cv-empty-host { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.cv-empty { text-align: center; }
.cv-empty-title { margin: 0 0 8px; font-size: 16px; color: var(--text-dim); font-weight: 600; }
.cv-empty-line { margin: 3px 0; font-size: 14.5px; color: var(--text-faint); }
.cv-empty-line.dim { color: var(--text-faint); font-size: 13.5px; }

/* ---------- 菜单 ---------- */

.cv-menu {
  position: absolute; z-index: 40;
  min-width: 200px; max-width: 280px;
  border-radius: 12px;
  background: rgba(var(--float-rgb), .98);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-menu);
  overflow: hidden;
}
.cv-menu[hidden] { display: none; }
.cv-menu-inner { padding: 6px; }
.cv-menu-title {
  padding: 6px 8px 8px; font-size: 12.5px; color: var(--text-faint);
  border-bottom: 1px solid var(--border-soft); margin-bottom: 4px;
}
.cv-menu-item {
  display: flex; align-items: flex-start; gap: 9px; width: 100%;
  padding: 7px 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.cv-menu-item:hover:not(:disabled) { background: rgba(var(--wash-rgb), .07); }
.cv-menu-item:disabled { opacity: .45; cursor: not-allowed; }
.cv-menu-icon {
  width: 20px; height: 20px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 5px; background: rgba(var(--ring-rgb), .1);
  color: var(--cream-dim); font-size: 11px;
}
.cv-menu-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cv-menu-text b { font-size: 13.5px; font-weight: 600; }
.cv-menu-text small { font-size: 12px; color: var(--text-faint); line-height: 1.4; }
.cv-menu-hint {
  padding: 7px 8px 3px; font-size: 12px; color: var(--text-faint);
  border-top: 1px solid var(--border-soft); margin-top: 4px;
}

/* ---------- 大图 / 视频预览 ---------- */

.cv-preview {
  /* 固定到整个窗口，盖住页面外壳（顶栏/侧栏），当一个真正的灯箱用 */
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column;
}
.cv-preview[hidden] { display: none; }
.cv-preview-backdrop {
  position: absolute; inset: 0;
  background: rgba(var(--scrim-rgb), .94);
  backdrop-filter: blur(5px);
}
/* 灯箱的遮罩两套主题都是深色，所以这里的文字也用固定的浅色，
   不能跟主题变量走（否则亮色主题下就是深字压深底）。 */
.cv-preview-bar {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  color: rgba(243, 236, 225, .82); font-size: 12.5px;
}
.cv-preview-name { color: #f7f1e6; font-size: 14.5px; font-weight: 600; max-width: 46vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-preview-meta { color: rgba(243, 236, 225, .58); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cv-preview-grow { flex: 1; }
.cv-preview-bar button {
  padding: 5px 12px; border-radius: 8px;
  border: 1px solid rgba(243, 236, 225, .3); background: transparent;
  color: rgba(243, 236, 225, .86); font-size: 12px; cursor: pointer;
}
.cv-preview-bar button:hover {
  color: #fff; border-color: rgba(243, 236, 225, .62);
  background: rgba(255, 255, 255, .08);
}

.cv-preview-stage {
  position: relative; z-index: 1;
  flex: 1; min-height: 0;
  display: grid; place-items: center;
  overflow: hidden;
  touch-action: none;
}
.cv-preview-media {
  max-width: 92%; max-height: 100%;
  display: grid; place-items: center;
  transform-origin: center center;
  will-change: transform;
}
.cv-preview-media.dragging { cursor: grabbing; }
.cv-preview-media img,
.cv-preview-media video {
  max-width: 100%; max-height: calc(100vh - 140px);
  display: block; border-radius: 8px;
  box-shadow: var(--shadow-photo);
  user-select: none;
  -webkit-user-drag: none;
}
.cv-preview-media.zoomed img,
.cv-preview-media.zoomed video { cursor: grab; }
.cv-preview-audio {
  display: grid; place-items: center; gap: 10px;
  padding: 30px 40px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--border-strong);
  color: var(--cream-dim);
}
.cv-preview-audio span { font-size: 34px; }
.cv-preview-audio b { font-size: 13.5px; font-weight: 600; color: var(--text); }
.cv-preview-audio audio { width: 320px; max-width: 70vw; }
.cv-preview-hint {
  position: relative; z-index: 2;
  padding: 10px 16px 16px; text-align: center;
  color: rgba(243, 236, 225, .55); font-size: 11.5px;
}

/* 贴在图片右上角的关闭按钮（位置由 JS 按图片实际矩形算，缩放/平移后也跟着走） */
.cv-preview-close {
  position: fixed; z-index: 82;
  width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(243, 236, 225, .36);
  background: rgba(20, 17, 14, .58);
  color: #f7f1e6; font-size: 17px; line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
  transition: background .15s, transform .15s, border-color .15s;
}
.cv-preview-close:hover {
  background: rgba(var(--danger-rgb), .92);
  border-color: rgba(255, 255, 255, .55);
  transform: scale(1.06);
}
.cv-preview-close:focus-visible { outline: 2px solid rgba(243, 236, 225, .8); outline-offset: 2px; }
.cv-preview-bar-close { font-size: 14px; }

/* ---------- 确认框 ---------- */

.cv-modal-layer {
  position: absolute; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(var(--scrim-rgb), .62);
  backdrop-filter: blur(2px);
}
.cv-modal-layer[hidden] { display: none; }
.cv-modal-card {
  width: min(420px, calc(100% - 40px));
  padding: 18px 20px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.cv-modal-card h3 { margin: 0 0 10px; font-size: 16px; }
.cv-modal-body { font-size: 13.5px; color: var(--text-dim); line-height: 1.7; }
.cv-modal-body b { color: var(--cream); }
.cv-modal-body .hint { color: var(--text-faint); font-size: 12px; }
.cv-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- 帮助 ---------- */

.cv-help {
  position: absolute; right: 14px; top: 14px; z-index: 45;
  width: min(380px, calc(100% - 28px));
  max-height: calc(100% - 40px); overflow-y: auto;
  border-radius: 12px;
  background: rgba(var(--float-rgb), .98);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.cv-help[hidden] { display: none; }
.cv-help-card { padding: 14px 16px; }
.cv-help-card h3 { margin: 0 0 10px; font-size: 14.5px; }
.cv-help-card h4 { margin: 14px 0 6px; font-size: 13.5px; color: var(--text-dim); }
.cv-help-card table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cv-help-card th {
  text-align: left; font-weight: 500; color: var(--text-dim);
  padding: 4px 8px 4px 0; white-space: nowrap; vertical-align: top;
}
.cv-help-card td { padding: 4px 0; color: var(--text-faint); }
.cv-help-card ul { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text-faint); line-height: 1.7; }

/* ---------- 窄屏 ---------- */

@media (max-width: 900px) {
  .cv-side {
    position: absolute; right: 0; top: 0; bottom: 0; z-index: 6;
    border-right: 0; border-left: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .cv-name { width: 130px; }
  .cv-project { display: none; }
  .cv-tools { bottom: 64px; }
  .cv-mini { display: none; }
}
