/* ============================================================
   无限画布模式 — 黑底 + 蓝紫(#5010d0)框架
   ============================================================ */
:root {
  --violet: #5010d0;
  --violet-2: #a060f0;
  --violet-soft: rgba(0, 64, 208, 0.16);
  --violet-line: rgba(160, 96, 240, 0.45);
  --node-bg: #111114;
}

/* ---------- 顶部模式切换 ---------- */
.mode-switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border-radius: 999px;
  background: #000;
  border: 1px solid rgba(0, 64, 208, 0.35);
}

.mode-btn {
  position: relative;
  z-index: 2;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  transition: color 0.25s var(--ease);
}

.mode-btn:not(.is-active) {
  color: #9ca3af;
}

.mode-btn.is-active {
  color: #ffffff;
}

.mode-switch__glider {
  position: absolute;
  top: 3px;
  left: 3px;
  height: calc(100% - 6px);
  width: 96px;
  border-radius: 999px;
  background: linear-gradient(90deg, #30b0f0 0%, #a060f0 100%);
  box-shadow: 0 2px 12px rgba(0, 64, 208, 0.6);
  transition: transform 0.3s var(--ease), width 0.3s var(--ease);
}

/* ---------- 模式容器过渡 ---------- */
.workspace {
  transition: opacity 0.32s var(--ease), transform 0.32s var(--ease), filter 0.32s var(--ease);
}

body.is-canvas-mode .workspace {
  opacity: 0;
  transform: translateY(10px) scale(0.99);
  pointer-events: none;
  position: absolute;
  inset: 56px 0 0 0;
  overflow: hidden;
  filter: blur(2px);
}

/* 精简浮动操作栏（旧顶部工具行已迁移至左栏，仅保留 返回/导出） */
.canvas-float-actions {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 24;
  display: flex;
  gap: 8px;
}
.canvas-float-actions .ct-btn {
  background: rgba(10, 10, 10, 0.82);
  border: 1px solid var(--panel-edge);
  color: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.canvas-float-actions .ct-btn:hover {
  border-color: rgba(48, 176, 240, 0.7);
  box-shadow: 0 0 16px rgba(48, 176, 240, 0.22);
  transform: translateY(-1px);
}

.canvas-mode {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #000;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.34s var(--ease), transform 0.34s var(--ease);
}

body.is-canvas-mode .canvas-mode {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ---------- 画布工具栏 ---------- */
.canvas-toolbar {
  flex-shrink: 0;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  background: #000;
  border-bottom: 1px solid rgba(0, 64, 208, 0.35);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.6);
}

.ct-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ct-group--center {
  flex: 1;
  justify-content: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.ct-group--center::-webkit-scrollbar {
  display: none;
}

.ct-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: #cfd8ff;
  background: rgba(0, 64, 208, 0.1);
  border: 1px solid rgba(0, 64, 208, 0.28);
  transition: all 0.2s var(--ease);
}

.ct-btn:hover {
  color: #fff;
  background: rgba(0, 64, 208, 0.28);
  border-color: var(--violet-2);
  box-shadow: 0 0 12px rgba(0, 64, 208, 0.35);
  transform: translateY(-1px);
}

.ct-btn span {
  font-size: 13px;
}

.ct-icon {
  width: 30px;
  padding: 7px 0;
  justify-content: center;
  font-size: 15px;
}

.ct-zoom-label {
  min-width: 54px;
  justify-content: center;
  font-family: var(--font-mono);
}

.ct-btn.is-on {
  background: linear-gradient(180deg, #1080f0, var(--violet));
  color: #fff;
  border-color: var(--violet-2);
  box-shadow: 0 0 14px rgba(0, 64, 208, 0.55);
}

.ct-btn--gold {
  color: #fff;
  background: linear-gradient(135deg, #30b0f0, #a060f0);
  border-color: transparent;
}
.ct-btn--gold:hover {
  color: #fff;
  background: linear-gradient(135deg, #30b0f0 0%, #0040d0 48%, #a060f0 100%);
  box-shadow: 0 4px 16px rgba(160, 96, 240, 0.5);
}

.ct-divider {
  width: 1px;
  height: 22px;
  background: rgba(232, 234, 242, 0.14);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ---------- 画布顶部居中标题 ---------- */
.canvas-title {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  pointer-events: none;
  font-family: var(--font-serif, "Noto Serif SC", serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #ffffff;
  text-shadow:
    0 0 18px rgba(160, 96, 240, 0.55),
    0 0 42px rgba(0, 64, 208, 0.35);
  white-space: nowrap;
  opacity: 0.92;
  user-select: none;
}

/* ---------- 视口 ---------- */
.canvas-viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #050507;
  cursor: grab;
  user-select: none;
}

.canvas-viewport.is-space,
.canvas-viewport.is-panning {
  cursor: grabbing;
}

.canvas-viewport.is-connect {
  cursor: crosshair;
}

/* 自适应网格背景（CSS 变量由 JS 按缩放级别更新） */
.canvas-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, calc(var(--g-op, 0.14) * 0.32)) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, calc(var(--g-op, 0.14) * 0.32)) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, calc(var(--g-op, 0.14) * 0.42)) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, calc(var(--g-op, 0.14) * 0.42)) 1px, transparent 1px);
  background-size:
    var(--g-step, 24px) var(--g-step, 24px),
    var(--g-step, 24px) var(--g-step, 24px),
    var(--g-big, 120px) var(--g-big, 120px),
    var(--g-big, 120px) var(--g-big, 120px);
  background-position: var(--g-x, 0) var(--g-y, 0);
}

/* ---------- 世界层 ---------- */
.canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.node-layer {
  position: absolute;
  top: 0;
  left: 0;
}

.edge-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  overflow: visible;
  pointer-events: none;
}

.edge-path {
  fill: none;
  stroke: url(#edge-gradient);
  stroke-width: 2;
  filter: drop-shadow(0 0 4px rgba(0, 64, 208, 0.7));
}

.edge-path--flow {
  stroke-dasharray: 8 7;
  animation: edge-flow 0.9s linear infinite;
}

@keyframes edge-flow {
  to {
    stroke-dashoffset: -15;
  }
}

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14px;
  pointer-events: stroke;
  cursor: pointer;
}

.edge-group:hover .edge-path {
  stroke-width: 3;
  filter: drop-shadow(0 0 7px rgba(160, 96, 240, 0.95));
}

.edge-del {
  fill: #0d0d12;
  stroke: var(--red);
  stroke-width: 1.4;
  opacity: 0;
  transition: opacity 0.18s;
  cursor: pointer;
  pointer-events: all;
}
.edge-group:hover .edge-del {
  opacity: 1;
}
.edge-del-text {
  fill: var(--red);
  font-size: 11px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: central;
  opacity: 0;
  pointer-events: none;
}
.edge-group:hover .edge-del-text {
  opacity: 1;
}

.edge-temp {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

/* ---------- 节点通用 ---------- */
.cnode {
  position: absolute;
  width: 248px;
  background: linear-gradient(180deg, #16161f, #0f0f16);
  border: 1.4px solid rgba(0, 64, 208, 0.45);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(160, 96, 240, 0.12);
  cursor: grab;
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
  overflow: hidden;
}

.cnode:hover {
  border-color: var(--violet-2);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 64, 208, 0.35), 0 0 22px rgba(0, 64, 208, 0.25);
}

.cnode.is-dragging {
  cursor: grabbing;
  z-index: 50;
}

.cnode.is-selected {
  border-color: var(--violet-2);
  box-shadow: 0 0 0 1.5px var(--violet-2), 0 0 26px rgba(0, 64, 208, 0.65), 0 14px 36px rgba(0, 0, 0, 0.6);
}

.cnode.is-start::before {
  content: "🚩 起点";
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 3;
  font-size: 9px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(245, 166, 35, 0.14);
  border: 1px solid var(--gold-line);
  border-radius: 4px;
  padding: 1px 6px;
}

.cnode__head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 26px 9px 11px;
  background: linear-gradient(90deg, rgba(0, 64, 208, 0.28), rgba(0, 64, 208, 0.06));
  border-bottom: 1px solid rgba(0, 64, 208, 0.25);
}

.cnode__type-icon {
  font-size: 14px;
}

.cnode__title {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: #dce4ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  border-radius: 4px;
  padding: 1px 4px;
}
.cnode__title:focus {
  background: rgba(0, 64, 208, 0.2);
  color: #fff;
  white-space: normal;
}

.cnode__badge {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  color: var(--violet-2);
  border: 1px solid var(--violet-line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* 连线端口 */
.port {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #0d0d12;
  border: 2px solid var(--violet-2);
  z-index: 4;
  transition: all 0.18s var(--ease);
}
.port--in {
  left: -7px;
  cursor: pointer;
}
.port--out {
  right: -7px;
  cursor: crosshair;
}
.port:hover,
.port.is-active {
  background: var(--violet-2);
  box-shadow: 0 0 12px rgba(160, 96, 240, 0.95);
  transform: translateY(-50%) scale(1.3);
}
.port--in.is-target {
  background: #30b0f0;
  border-color: #fff;
  box-shadow: 0 0 16px rgba(0, 64, 208, 1);
  transform: translateY(-50%) scale(1.45);
}

/* ---------- 节点内容区 ---------- */
.cnode__canvas {
  margin: 10px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(0, 64, 208, 0.25);
  position: relative;
}

.cnode__canvas img,
.cnode__canvas video {
  width: 100%;
  display: block;
}
.cnode__canvas video {
  background: #000;
}

.cnode__placeholder {
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #d3e3ff;
  font-size: 11px;
  text-align: center;
  padding: 8px;
  background:
    repeating-linear-gradient(45deg, rgba(0, 64, 208, 0.06) 0 10px, transparent 10px 20px),
    #0b0b12;
}
.cnode__placeholder .ph-icon {
  font-size: 24px;
  opacity: 0.7;
}

/* 节点参数区 */
.cnode__controls {
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.cnode textarea.c-input,
.cnode input.c-input,
.note-body,
.note-title {
  width: 100%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(0, 64, 208, 0.3);
  border-radius: 6px;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 11.5px;
  padding: 7px 9px;
  outline: none;
  resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.cnode textarea.c-input:focus,
.cnode input.c-input:focus,
.note-body:focus,
.note-title:focus {
  border-color: var(--violet-2);
  box-shadow: 0 0 0 2px rgba(0, 64, 208, 0.2);
}
.cnode textarea.c-input {
  min-height: 46px;
  line-height: 1.5;
}
.cnode textarea.c-input::placeholder {
  color: #c4d6ff;
}

.c-seg {
  display: flex;
  gap: 3px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 64, 208, 0.22);
  border-radius: 6px;
  padding: 3px;
}
.c-seg button {
  flex: 1;
  padding: 4px 2px;
  font-size: 10.5px;
  border-radius: 4px;
  color: #dce8ff;
  font-family: var(--font-mono);
  transition: all 0.18s;
}
.c-seg button:hover {
  color: #fff;
}
.c-seg button.is-active {
  color: #fff;
  background: linear-gradient(180deg, #1080f0, var(--violet));
  box-shadow: 0 2px 8px rgba(0, 64, 208, 0.5);
}

.c-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.c-row > .c-seg {
  flex: 1;
}
.c-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: #d8e2ff;
  flex-shrink: 0;
}

.c-gen-btn {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #1080f0, var(--violet));
  box-shadow: 0 3px 12px rgba(0, 64, 208, 0.4);
  transition: all 0.2s var(--ease);
}
.c-gen-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(0, 64, 208, 0.6);
}
.c-gen-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.c-progress {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.c-progress__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--violet), var(--violet-2));
  transition: width 0.15s linear;
}

.c-cost {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--gold);
  white-space: nowrap;
}

.c-upload-row {
  display: flex;
  gap: 6px;
}
.c-upload-row button {
  flex: 1;
  padding: 6px;
  font-size: 10.5px;
  border-radius: 6px;
  color: var(--violet-2);
  background: rgba(0, 64, 208, 0.12);
  border: 1px solid var(--violet-line);
  transition: all 0.18s;
}
.c-upload-row button:hover {
  background: rgba(0, 64, 208, 0.28);
  color: #fff;
}

/* 视频节点输入标识 */
.input-pill {
  font-size: 10px;
  color: var(--violet-2);
  background: rgba(0, 64, 208, 0.14);
  border: 1px solid var(--violet-line);
  border-radius: 999px;
  padding: 2px 8px;
  align-self: flex-start;
  margin: 8px 10px 0;
}

/* ---------- 图片节点 ---------- */
.cnode--image .cnode__canvas {
  margin-bottom: 8px;
}

/* ---------- 备注节点 ---------- */
.cnode--note {
  width: 220px;
  background: rgba(12, 12, 20, 0.82);
  border-color: rgba(0, 64, 208, 0.35);
  border-left: 3px solid var(--violet);
}
.note-title {
  margin: 10px 10px 0;
  width: calc(100% - 20px);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 13px;
  background: transparent;
  border-color: transparent;
  color: #c9d6ff;
}
.note-title:focus {
  background: rgba(0, 64, 208, 0.14);
}
.note-body {
  margin: 4px 10px 10px;
  width: calc(100% - 20px);
  min-height: 64px;
  background: transparent;
  border-color: transparent;
  line-height: 1.6;
  color: #dde6ff;
}
.note-body:focus {
  background: rgba(0, 0, 0, 0.35);
}

/* ---------- 分镜板节点 ---------- */
.cnode--board {
  width: 340px;
}
.board-scene {
  margin: 10px 10px 0;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, rgba(0, 64, 208, 0.55), rgba(0, 64, 208, 0.12));
  border: 1px solid var(--violet-line);
  outline: none;
}
.board-scene:focus {
  box-shadow: 0 0 0 2px rgba(0, 64, 208, 0.35);
}
.board-grid {
  margin: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  min-height: 52px;
}
.board-slot {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 6px;
  overflow: hidden;
  border: 1px dashed rgba(0, 64, 208, 0.4);
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.board-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.board-slot--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d3e3ff;
  font-size: 16px;
}
.board-slot:hover {
  border-color: var(--violet-2);
  box-shadow: inset 0 0 14px rgba(0, 64, 208, 0.2);
}
.board-slot__del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  line-height: 15px;
  text-align: center;
  border-radius: 50%;
  background: rgba(233, 69, 96, 0.9);
  color: #fff;
  font-size: 9px;
  opacity: 0;
  transition: opacity 0.15s;
}
.board-slot:hover .board-slot__del {
  opacity: 1;
}
.board-desc {
  margin: 0 10px 10px;
  width: calc(100% - 20px);
  min-height: 40px;
}

/* 端口接入提示：i2v 已连接输入时高亮 */
.cnode.is-fed {
  border-color: rgba(160, 96, 240, 0.8);
}

/* ---------- 框选 ---------- */
.marquee {
  position: absolute;
  z-index: 60;
  border: 1px solid var(--violet-2);
  background: rgba(0, 64, 208, 0.12);
  border-radius: 3px;
  pointer-events: none;
}

/* ---------- 浮动菜单 ---------- */
.floating-menu {
  position: absolute;
  z-index: 200;
  min-width: 178px;
  padding: 6px;
  border-radius: 10px;
  background: rgba(18, 16, 30, 0.97);
  border: 1px solid var(--violet-line);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.7), 0 0 22px rgba(0, 64, 208, 0.25);
  animation: menu-in 0.18s var(--ease);
}

@keyframes menu-in {
  from { opacity: 0; transform: scale(0.94) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.fm-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: #d8e2ff;
  padding: 4px 10px 7px;
}

.fm-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  color: #cddbffe8;
  text-align: left;
  transition: all 0.15s;
}
.fm-item:hover {
  background: rgba(0, 64, 208, 0.28);
  color: #fff;
}
.fm-item span {
  font-size: 14px;
}
.fm-item kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: #d8e2ff;
  border: 1px solid rgba(232, 234, 242, 0.14);
  border-radius: 4px;
  padding: 1px 5px;
}
.fm-item--danger {
  color: #ff9fb0;
}
.fm-item--danger:hover {
  background: rgba(233, 69, 96, 0.2);
}

/* ---------- HUD / 小地图 ---------- */
.canvas-hud {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.minimap {
  width: 190px;
  height: 118px;
  border-radius: 9px;
  background: rgba(12, 12, 20, 0.88);
  border: 1px solid rgba(0, 64, 208, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.hud-coord {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #d8e2ff;
  background: rgba(12, 12, 20, 0.75);
  border: 1px solid rgba(0, 64, 208, 0.25);
  border-radius: 6px;
  padding: 3px 8px;
}

.canvas-hint {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 40;
  max-width: 52%;
  font-size: 10.5px;
  line-height: 1.7;
  color: #d8e2ff;
  background: rgba(12, 12, 20, 0.7);
  border: 1px solid rgba(0, 64, 208, 0.2);
  border-radius: 8px;
  padding: 7px 11px;
  pointer-events: none;
}

/* 生成中角标脉冲 */
.cnode__rec {
  position: absolute;
  top: 9px;
  left: 11px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  animation: rec-breathe 0.9s ease-in-out infinite;
  opacity: 0;
}
.cnode.is-working .cnode__rec {
  opacity: 1;
}

/* ============================================================
   动态创建组件补充样式（菜单 / HUD / 生成态 / 临时连线）
   ============================================================ */

/* 动态浮动菜单（右键 / 添加节点） */
.ctx-menu {
  position: fixed;
  z-index: 400;
  min-width: 210px;
  padding: 6px;
  border-radius: 10px;
  background: rgba(18, 16, 30, 0.97);
  border: 1px solid var(--violet-line);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.72), 0 0 22px rgba(0, 64, 208, 0.25);
  animation: menu-in 0.18s var(--ease);
  backdrop-filter: blur(8px);
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.ctx-item:hover {
  background: rgba(0, 64, 208, 0.28);
}
.ctx-item__icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.ctx-item__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.ctx-item__text b {
  font-size: 12.5px;
  font-weight: 700;
  color: #dce4ff;
}
.ctx-item__text small {
  font-size: 10px;
  color: #d8e2ff;
}
.ctx-item:hover .ctx-item__text b {
  color: #fff;
}
.ctx-item--danger:hover {
  background: rgba(233, 69, 96, 0.22);
}
.ctx-item--danger:hover .ctx-item__text b {
  color: var(--red);
}
.ctx-item.is-hot {
  position: relative;
}
.ctx-sep {
  height: 1px;
  margin: 5px 8px;
  background: rgba(160, 96, 240, 0.18);
}
.node-type-menu {
  min-width: 230px;
}

/* 拖拽中的临时连线（动态插入世界 SVG） */
.edge-temp-group .edge-temp {
  fill: none;
  stroke: var(--violet-2);
  stroke-width: 2;
  stroke-dasharray: 6 5;
  filter: drop-shadow(0 0 5px rgba(160, 96, 240, 0.8));
  pointer-events: none;
}

/* ---------- 生成态 ---------- */
.cnode__canvas.is-generating {
  border-color: var(--violet-2);
  box-shadow: inset 0 0 22px rgba(0, 64, 208, 0.35);
}
.c-gen-overlay {
  position: relative;
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--violet-2);
  font-size: 11px;
  font-family: var(--font-mono);
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, rgba(0, 64, 208, 0.08) 0 2px, transparent 2px 6px),
    #0b0b12;
}
.c-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--violet-2), transparent);
  box-shadow: 0 0 12px var(--violet-2);
  animation: c-scan 1.1s linear infinite;
}
@keyframes c-scan {
  0% { transform: translateY(0); }
  100% { transform: translateY(calc(160px)); }
}
.c-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 4px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -1px;
  animation: c-spin 0.7s linear infinite;
}
@keyframes c-spin {
  to { transform: rotate(360deg); }
}

/* 飞入到达脉冲 */
.cnode.is-pulse-arrive {
  animation: node-arrive 1.3s var(--ease);
}
@keyframes node-arrive {
  0% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.7); }
  30% { box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.35), 0 0 34px rgba(245, 166, 35, 0.6); }
  100% { box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55); }
}

/* 标题编辑态 */
.cnode__title.is-editing {
  background: rgba(0, 64, 208, 0.25);
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 0 0 1px var(--violet-2);
}

/* ---------- 右下 HUD：缩放控件 + 小地图 ---------- */
.canvas-hud {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  border-radius: 9px;
  background: rgba(14, 13, 24, 0.92);
  border: 1px solid rgba(0, 64, 208, 0.35);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}
.zc-btn {
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #bfd0ff;
  font-family: var(--font-mono);
  transition: all 0.16s;
}
.zc-btn:hover {
  background: rgba(0, 64, 208, 0.3);
  color: #fff;
}
.zc-btn--text {
  font-size: 10.5px;
}
.zc-label {
  min-width: 46px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--violet-2);
  cursor: pointer;
  transition: all 0.16s;
}
.zc-label:hover {
  background: rgba(0, 64, 208, 0.3);
  color: #fff;
}
.zc-sep {
  width: 1px;
  height: 16px;
  background: rgba(160, 96, 240, 0.25);
  margin: 0 3px;
}
.minimap-wrap {
  position: relative;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(0, 64, 208, 0.4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  background: #0a0a12;
}
.minimap {
  display: block;
  width: 190px;
  height: 118px;
}
.minimap-label {
  position: absolute;
  left: 6px;
  top: 4px;
  font-size: 8px;
  letter-spacing: 0.18em;
  color: rgba(160, 96, 240, 0.6);
  font-family: var(--font-mono);
  pointer-events: none;
}

/* 空格平移光标 */
.canvas-viewport.space-panning {
  cursor: grab;
}

/* 工具栏添加按钮强调 */
.ct-add {
  color: #bfd0ff;
}
.ct-add span {
  margin-right: 2px;
}
.ct-add:hover {
  color: #fff;
  border-color: var(--violet-2);
  background: rgba(0, 64, 208, 0.22);
}

/* i2v 节点视频控件收窄 */
.cnode--i2v .cnode__canvas video {
  max-height: 132px;
  object-fit: cover;
}

/* 画布模式下保证计费弹窗 / toast 浮于画布(z-index:20) 之上 */
body.is-canvas-mode .modal {
  z-index: 320;
}
body.is-canvas-mode .toast {
  z-index: 420;
}
body.is-canvas-mode .topbar {
  z-index: 30;
}

/* 响应式：小屏工具栏收纳 */
@media (max-width: 900px) {
  .ct-group:first-child .ct-btn {
    font-size: 11px;
    padding: 7px 8px;
  }
  #btn-back-workbench {
    content-visibility: auto;
  }
  .canvas-hint {
    display: none;
  }
  .minimap,
  .minimap {
    width: 140px;
    height: 88px;
  }
}

/* 窄屏：压缩顶部模式切换按钮字号与内边距，避免与登录/积分重叠 */
@media (max-width: 900px) {
  .mode-switch {
    gap: 2px;
    padding: 3px;
  }
  .mode-btn {
    padding: 6px 12px;
    font-size: 14px;
  }
}
@media (max-width: 600px) {
  .mode-btn {
    padding: 6px 9px;
    font-size: 13px;
  }
}
