/* 智能画布 — EQUAI dark/light theme. */
:root {
  --bg: #0b0b0c;
  --panel: #161619;
  --panel-2: #1e1e22;
  --panel-3: #26262b;
  --line: rgba(255, 255, 255, .12);
  --line-strong: rgba(255, 255, 255, .22);
  --text: #ededeb;
  --text-2: rgba(237, 237, 235, .72);
  --muted: rgba(255, 255, 255, .48);
  --accent: #254eff;
  --accent-rgb: 37, 78, 255;
  --accent-text: #8ea4ff;
  --ok: #5fd68a;
  --ok-rgb: 95, 214, 138;
  --bad: #ff5c60;
  --bad-rgb: 255, 92, 96;
  --warn: #f5c451;
  --t-image: #8ab6ff;
  --t-video: #59c9d4;
  --t-audio: #e8c15c;
  --t-text: #7fd6a0;
  --t-gen: #a48cff;
  --bar: rgba(30, 31, 38, .88);
  --grid-dot: rgba(255, 255, 255, .07);
  --wire: rgba(190, 195, 210, .30);
  --wire-hover: rgba(215, 216, 224, .65);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -18px rgba(0, 0, 0, .85);
  --shadow-pop: 0 16px 40px -16px rgba(0, 0, 0, .9);
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px;
  --sans: "Plus Jakarta Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Inter, system-ui, sans-serif;
  --mono: "DM Mono", "SFMono-Regular", Consolas, monospace;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f3f5f8; --panel: #ffffff; --panel-2: #f6f7fa; --panel-3: #eceff4;
  --line: rgba(26, 43, 65, .14); --line-strong: rgba(26, 43, 65, .26);
  --text: #182433; --text-2: rgba(24, 36, 51, .76); --muted: rgba(24, 36, 51, .55);
  --accent: #315fd8; --accent-rgb: 49, 95, 216; --accent-text: #315fd8;
  --bar: rgba(255, 255, 255, .92); --grid-dot: rgba(24, 36, 51, .12);
  --wire: rgba(60, 72, 96, .32); --wire-hover: rgba(40, 52, 76, .7);
  --shadow-1: 0 1px 2px rgba(20, 30, 50, .08), 0 8px 24px -18px rgba(20, 30, 50, .3);
  --shadow-pop: 0 16px 40px -16px rgba(20, 30, 50, .35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body.cv { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.cv-muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.err { color: var(--bad); }

/* ---------------------------------------------------------- top bar */
.cv-top { position: fixed; z-index: 30; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: linear-gradient(var(--bg), color-mix(in srgb, var(--bg) 0%, transparent)); pointer-events: none; }
.cv-top > * { pointer-events: auto; }
.cv-back { width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r-lg); color: var(--text-2); text-decoration: none; border: 1px solid var(--line); background: var(--bar); }
.cv-back:hover { color: var(--text); border-color: var(--line-strong); }
.cv-mark { height: 18px; opacity: .9; }
html[data-theme="light"] .cv-mark { filter: invert(1); }
.cv-board { position: relative; }
.cv-board-trigger { display: flex; gap: 8px; align-items: center; height: 32px; padding: 0 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--bar); cursor: pointer; backdrop-filter: blur(6px); max-width: 360px; }
.cv-board-trigger #cvBoardName { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-save { height: 26px; padding: 0 10px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); font-size: 12px; cursor: default; }
.cv-save.error, .cv-save.conflict { color: var(--bad); cursor: pointer; background: rgba(var(--bad-rgb), .1); }
.cv-save.saving, .cv-save.dirty { color: var(--text-2); }
.cv-spacer { flex: 1; }
.cv-popover { position: absolute; z-index: 60; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 10px; }
.cv-board-panel { top: 40px; left: 0; width: 360px; display: flex; flex-direction: column; gap: 8px; }
.cv-board-list { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.cv-board-row { display: flex; align-items: center; gap: 2px; border-radius: var(--r-md); }
.cv-board-row:hover, .cv-board-row.current { background: var(--panel-3); }
.cv-board-row .open { flex: 1; display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 10px; text-align: left; border: 0; background: none; padding: 6px; cursor: pointer; min-width: 0; }
.cv-board-row .open img, .cv-board-row .open .cover { grid-row: span 2; width: 44px; height: 32px; object-fit: cover; border-radius: var(--r-sm); background: var(--panel-3); }
.cv-board-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.cv-tray-pill { height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bar); cursor: pointer; font-size: 12px; }
.cv-tray-pill b { color: var(--bad); font-weight: 600; }
.cv-tray { top: 46px; right: 14px; width: 380px; }
.cv-tray-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.cv-tray-tabs button { border: 0; background: none; padding: 4px 10px; border-radius: 999px; color: var(--muted); cursor: pointer; font-size: 12px; }
.cv-tray-tabs button.active { background: var(--panel-3); color: var(--text); }
.cv-tray-list { max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.cv-tray-row { display: grid; grid-template-columns: 28px 1fr auto auto; gap: 8px; align-items: center; padding: 8px; border-radius: var(--r-md); cursor: pointer; }
.cv-tray-row:hover { background: var(--panel-3); }
.cv-tray-row.failed b { color: var(--bad); }
.cv-tray-row.active b { color: var(--accent-text); }

/* ---------------------------------------------------------- viewport */
.cv-viewport { position: fixed; inset: 0; overflow: hidden; outline: none; cursor: grab; touch-action: none; user-select: none;
  background-image: radial-gradient(var(--grid-dot) 0.9px, transparent 1.3px); }
.cv-viewport.grab { cursor: grab; }
.cv-viewport.grabbing { cursor: grabbing; }
.cv-viewport.dropping::after { content: "松手上传到画布"; position: absolute; inset: 12px; border: 2px dashed rgba(var(--accent-rgb), .6); border-radius: 16px; display: grid; place-items: center; font-size: 18px; color: var(--accent-text); background: rgba(var(--accent-rgb), .06); pointer-events: none; }
.cv-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.cv-wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.cv-wire { fill: none; stroke: var(--wire); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.cv-wire.result { stroke-dasharray: none; }
.cv-wire.derive { stroke-dasharray: 5 4; }
.cv-wire.hover { stroke: var(--wire-hover); stroke-width: 2; }
.cv-wire.selected { stroke: rgba(var(--accent-rgb), .8); stroke-width: 2; }
.cv-wire.running { stroke: rgba(var(--accent-rgb), .7); stroke-dasharray: 8 6; animation: cv-flow .9s linear infinite; }
.cv-wire.preview { stroke: rgba(255, 255, 255, .5); stroke-dasharray: 5 4; stroke-width: 1.8; }
.cv-wire.preview.ok { stroke: var(--ok); }
.cv-wire.preview.no { stroke: var(--bad); }
.cv-wire-hit { fill: none; stroke: transparent; stroke-width: 12; vector-effect: non-scaling-stroke; pointer-events: stroke; cursor: pointer; }
@keyframes cv-flow { to { stroke-dashoffset: -28; } }
.cv-overlay { position: absolute; left: 0; top: 0; pointer-events: none; }
.cv-marquee { position: absolute; border: 1px solid rgba(255, 255, 255, .6); background: rgba(255, 255, 255, .06); }
html[data-theme="light"] .cv-marquee { border-color: rgba(24, 36, 51, .5); background: rgba(24, 36, 51, .05); }
.cv-guide { position: absolute; border: 0 dashed #ff4d8a; }
.cv-guide.v { width: 0; border-left-width: calc(1px / var(--zoom, 1)); }
.cv-guide.h { height: 0; border-top-width: calc(1px / var(--zoom, 1)); }
.cv-hint { position: absolute; transform: scale(calc(1 / var(--zoom, 1))); transform-origin: 0 0; white-space: nowrap; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 4px 8px; font-size: 12px; box-shadow: var(--shadow-1); }
.cv-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 28px 36px; border-radius: 16px; border: 1px dashed var(--line-strong); background: var(--panel); cursor: pointer; text-align: center; }
.cv-empty strong { font-size: 18px; }
.cv-empty:hover { border-color: rgba(var(--accent-rgb), .7); }
.cv-lost { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); height: 36px; padding: 0 14px; border-radius: var(--r-lg); border: 0; background: var(--bar); cursor: pointer; backdrop-filter: blur(2px); }

/* ---------------------------------------------------------- nodes */
.cv-node { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; cursor: default; }
.cv-group { cursor: default; }
.cv-node-title { height: 22px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; min-width: 0; }
.cv-node:hover .cv-node-title, .cv-node.selected .cv-node-title { color: var(--text-2); }
.cv-node-title .name { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.cv-node-title .tag { font-size: 11px; padding: 0 5px; border-radius: var(--r-sm); background: var(--panel-3); }
.cv-node-title .tag.gen { color: var(--t-gen); }
.cv-node-title .tag.edit { color: var(--ok); }
.cv-node-title .tag.ratio { color: var(--accent-text); }
.cv-node-title .dims { margin-left: auto; font-size: 11px; }
.dot { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.dot.type-image, .glyph.type-image { background: var(--t-image); }
.dot.type-video, .glyph.type-video { background: var(--t-video); }
.dot.type-audio, .glyph.type-audio { background: var(--t-audio); }
.dot.type-text, .glyph.type-text { background: var(--t-text); }
.dot.type-imagegen, .dot.type-videogen, .dot.type-videoenhance { background: var(--t-gen); border-radius: 50%; }
.glyph { display: grid; place-items: center; width: 100%; height: 100%; color: #10131a; font-weight: 700; font-size: 12px; border-radius: inherit; }
.cv-rename { font: inherit; font-size: 13px; color: var(--text); background: var(--panel-2); border: 1px solid rgba(var(--accent-rgb), .7); border-radius: var(--r-sm); padding: 0 4px; height: 22px; width: 100%; outline: none; }

.cv-node-body { position: relative; flex: 1; border-radius: var(--r-lg); overflow: hidden; background: #15151a; box-shadow: var(--shadow-1); }
html[data-theme="light"] .cv-node-body { background: #e6e9ef; }
.cv-node-body img, .cv-node-body video { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.cv-node.generated .cv-node-body { box-shadow: 0 0 0 1px rgba(var(--accent-rgb), .55), var(--shadow-1); }
.cv-node.selected.cv-asset .cv-node-body { box-shadow: 0 0 0 2px var(--accent), var(--shadow-1); }
.cv-node.preselect .cv-node-body, .cv-node.preselect .cv-gen-card { outline: 1px dashed rgba(215, 216, 224, .5); outline-offset: 3px; }
.cv-node-body.busy::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 2px rgba(var(--accent-rgb), .9); animation: cv-pulse 1.1s ease-in-out infinite; }
.cv-busy-label { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: var(--r-md); background: rgba(13, 13, 18, .78); color: #fff; font-size: 12px; }
@keyframes cv-pulse { 50% { opacity: .35; } }
.cv-badge-duration { position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: var(--r-md); background: rgba(13, 13, 18, .72); color: #fff; font-size: 11px; }
.cv-media-missing { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 12px; border: 1px dashed var(--line-strong); border-radius: inherit; }
.cv-progress { position: absolute; left: 8px; right: 8px; bottom: 8px; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.cv-progress i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.cv-audio { height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 10px; }
.cv-audio audio { width: 100%; height: 32px; }
.cv-wave { display: flex; align-items: center; gap: 3px; height: 30px; }
.cv-wave i { flex: 1; background: var(--t-audio); opacity: .55; border-radius: 1px; }
.cv-wave i:nth-child(3n) { height: 70%; } .cv-wave i:nth-child(3n+1) { height: 40%; } .cv-wave i:nth-child(3n+2) { height: 90%; }
.cv-text-body { padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; background: var(--panel-2); }
.cv-text-body p { margin: 0; color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.cv-text-meta { margin-top: auto; color: var(--muted); font-size: 12px; }
.cv-discard { position: absolute; top: 6px; right: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-md); border: 0; background: rgba(13, 13, 18, .72); color: #fff; font-size: 11px; cursor: pointer; opacity: 0; }
.cv-node:hover .cv-discard { opacity: 1; }
.cv-discard:hover { background: rgba(var(--bad-rgb), .85); }

.cv-port-in { position: absolute; left: -4px; top: calc(30px + (100% - 30px) / 2); width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--muted); opacity: 0; transition: opacity .12s; }
.cv-node:hover .cv-port-in, .cv-node.can-take .cv-port-in { opacity: 1; }
.cv-node.can-take .cv-port-in { background: var(--ok); }
.cv-port-out { position: absolute; right: -38px; top: calc(30px + (100% - 30px) / 2); width: 24px; height: 24px; margin-top: -12px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--text-2);
  display: grid; place-items: center; font-size: 16px; line-height: 1; cursor: crosshair; opacity: 0; transform: scale(min(1.5, calc(1 / var(--zoom, 1)))); transition: opacity .12s; padding: 0; }
.cv-node:hover .cv-port-out, .cv-node.selected .cv-port-out { opacity: 1; }
.cv-port-out:hover { border-color: var(--accent); color: var(--text); }
.cv-node.folded .cv-port-out, .cv-node.folded .cv-port-in { top: 50%; }
.cv-resize { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; cursor: nwse-resize; opacity: 0; background: linear-gradient(135deg, transparent 50%, var(--line-strong) 50%); border-radius: 0 0 var(--r-lg) 0; }
.cv-node:hover .cv-resize { opacity: 1; }
.cv-node.grouped .cv-node-body + .cv-port-out ~ .cv-resize, .cv-node.grouped .cv-resize { display: none; }
.cv-node.drop-ok .cv-gen-card { box-shadow: 0 0 0 2px var(--ok), 0 0 0 7px rgba(var(--ok-rgb), .15); }
.cv-node.drop-no .cv-gen-card { box-shadow: 0 0 0 2px var(--bad), 0 0 0 7px rgba(var(--bad-rgb), .15); }

/* gen card */
.cv-gen-card { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-1); min-height: 0; position: relative; }
.cv-node.selected .cv-gen-card { border-color: transparent; box-shadow: 0 0 0 1.5px var(--accent), var(--shadow-1); }
.cv-node.running .cv-gen-card::before { content: ""; position: absolute; inset: -1.5px; border-radius: 17px; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--cv-angle, 0deg), transparent 0 60%, rgba(var(--accent-rgb), .95) 80%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: cv-spin 3s linear infinite; }
@property --cv-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes cv-spin { to { --cv-angle: 360deg; } }
.cv-node.failed .cv-gen-card { border-color: rgba(var(--bad-rgb), .7); box-shadow: 0 0 0 .5px rgba(var(--bad-rgb), .6), var(--shadow-1); }
.cv-gen-top { display: flex; align-items: center; gap: 6px; height: 36px; }
.cv-ref { position: relative; width: 36px; height: 36px; flex: none; border-radius: var(--r-md); overflow: hidden; background: var(--panel-3); display: grid; place-items: center; border: 0; padding: 0; }
.cv-ref img, .cv-ref video { width: 100%; height: 100%; object-fit: cover; }
.cv-ref b { position: absolute; left: 0; bottom: 0; font-size: 10px; padding: 0 3px; background: rgba(var(--accent-rgb), .9); color: #fff; border-top-right-radius: 4px; }
.cv-ref.more { font-size: 12px; color: var(--text-2); }
.cv-ref.add { cursor: pointer; color: var(--text-2); font-size: 18px; border: 1px dashed var(--line-strong); background: transparent; }
.cv-ref.add:hover { border-color: var(--accent); color: var(--text); }
.cv-ref.tiny { width: 20px; height: 20px; border-radius: 50%; }
.cv-pill { margin-left: auto; height: 20px; padding: 0 8px; display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; font-size: 12px; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.cv-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.cv-pill.running { background: rgba(var(--accent-rgb), .16); color: var(--accent-text); }
.cv-pill.running i { background: var(--accent); animation: cv-pulse 1s ease-in-out infinite; }
.cv-pill.done { background: rgba(var(--accent-rgb), .16); color: var(--accent-text); }
.cv-pill.done i { display: none; }
.cv-pill.failed { background: rgba(var(--bad-rgb), .14); color: var(--bad); }
.cv-pill.failed i { background: var(--bad); }
.cv-icon-btn { width: 24px; height: 24px; display: grid; place-items: center; border-radius: var(--r-md); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; flex: none; }
.cv-icon-btn:hover { background: var(--panel-3); color: var(--text); }
.cv-icon-btn.danger:hover { color: var(--bad); }
.cv-gen-prompt { flex: 1; min-height: 40px; font-size: 14px; line-height: 20px; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; cursor: text; word-break: break-word; }
.cv-gen-line { font-size: 12px; padding: 3px 8px; border-radius: var(--r-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-gen-line.run { color: var(--accent-text); display: flex; align-items: center; gap: 6px; }
.cv-gen-line.run i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: cv-pulse 1s infinite; flex: none; }
.cv-gen-line.fail { color: var(--bad); background: rgba(var(--bad-rgb), .1); white-space: normal; }
.cv-gen-line.warn { color: var(--warn); background: rgba(255, 196, 0, .08); }
.cv-gen-foot { display: flex; align-items: center; gap: 8px; }
.cv-param-chip { height: 30px; max-width: 170px; padding: 0 10px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel-2); color: var(--text-2); font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-param-chip:hover { border-color: var(--line-strong); color: var(--text); }
.cv-price { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cv-run { margin-left: auto; height: 30px; padding: 0 14px; border-radius: var(--r-lg); border: 0; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; }
.cv-run:hover { filter: brightness(1.12); }
.cv-run.waiting { background: rgba(var(--accent-rgb), .18); color: var(--accent-text); font-weight: 500; }
.cv-gen-pill { height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.cv-gen-pill > span:not(.cv-ref) { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.cv-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none !important; }
.cv-status-dot.running { background: var(--accent); animation: cv-pulse 1s infinite; }
.cv-status-dot.failed { background: var(--bad); }
.cv-status-dot.done { background: var(--ok); }
.cv-node.selected .cv-gen-pill { border-color: var(--accent); }

.cv-chip { display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 6px 0 2px; margin: 0 1px; border-radius: var(--r-sm); background: rgba(var(--accent-rgb), .16); color: var(--accent-text); font-size: 12px; vertical-align: middle; white-space: nowrap; user-select: all; }
.cv-chip img, .cv-chip video { width: 16px; height: 16px; border-radius: 3px; object-fit: cover; }
.cv-chip .glyph { width: 16px; height: 16px; font-size: 9px; }
.cv-chip.type-text { background: rgba(127, 214, 160, .15); color: var(--t-text); padding-left: 6px; }
.cv-chip.invalid { background: rgba(var(--bad-rgb), .14); color: var(--bad); padding-left: 6px; }
.cv-chip .x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0 0 4px; }

/* groups */
.cv-group { position: absolute; border-radius: 16px; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 45%, transparent); }
.cv-group.selected { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), .4); }
.cv-group-head { height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: 13px; cursor: grab; }
.cv-group-head .name { font-weight: 600; }
.cv-group-head .cv-mini-btn { margin-left: auto; opacity: 0; }
.cv-group:hover .cv-mini-btn { opacity: 1; }
.cv-group .cv-resize { opacity: 0; }
.cv-group:hover .cv-resize { opacity: 1; }
.cv-mini-btn { height: 22px; padding: 0 8px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--panel-2); font-size: 12px; cursor: pointer; color: var(--text-2); }
.cv-mini-btn:hover { color: var(--text); border-color: var(--line-strong); }

/* ---------------------------------------------------------- bars */
.cv-toolbar, .cv-selbar { position: fixed; z-index: 30; height: 36px; display: flex; align-items: center; gap: 2px; padding: 0 4px; border-radius: var(--r-lg); background: var(--bar); backdrop-filter: blur(6px); border: 1px solid var(--line); box-shadow: var(--shadow-1); transition: opacity .15s; }
.cv-toolbar { left: 14px; bottom: 14px; }
.cv-toolbar.dim { opacity: .6; }
.cv-toolbar.dim:hover { opacity: 1; }
.cv-toolbar button, .cv-selbar button { height: 28px; min-width: 28px; padding: 0 9px; border-radius: var(--r-md); border: 0; background: transparent; cursor: pointer; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.cv-toolbar button:hover, .cv-selbar button:hover { background: var(--panel-3); color: var(--text); }
.cv-toolbar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
#cvZoomLabel { min-width: 54px; font-family: var(--mono); font-size: 12px; }
.cv-selbar { left: 50%; bottom: 60px; transform: translateX(-50%); }
.cv-selbar > span { padding: 0 8px; color: var(--muted); font-size: 12px; }
.cv-selbar button.danger:hover { color: var(--bad); }
.cv-undobar { position: fixed; z-index: 60; left: 50%; bottom: 106px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 6px 0 14px; border-radius: var(--r-lg); background: var(--panel-2); border: 1px solid var(--line); box-shadow: var(--shadow-pop); transition: .18s; font-size: 13px; }
.cv-undobar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.cv-undobar button { height: 26px; padding: 0 10px; border-radius: var(--r-md); border: 0; background: var(--panel-3); cursor: pointer; }
.cv-note { position: fixed; z-index: 60; left: 14px; bottom: 58px; padding: 4px 10px; border-radius: var(--r-md); background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.cv-note.show { opacity: 1; }
.cv-toasts { position: fixed; z-index: 10002; top: 60px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.cv-toast { max-width: min(560px, 90vw); padding: 8px 14px; border-radius: var(--r-lg); background: var(--panel-2); border: 1px solid var(--line); box-shadow: var(--shadow-pop); font-size: 13px; transition: opacity .24s, transform .24s; }
.cv-toast.error { border-color: rgba(var(--bad-rgb), .5); color: var(--bad); }
.cv-toast.out { opacity: 0; transform: translateY(-6px); }

/* ---------------------------------------------------------- menus & dialogs */
.cv-menu { position: fixed; z-index: 10003; width: 260px; max-height: 70vh; overflow: auto; padding: 6px; border-radius: var(--r-lg); background: var(--panel-2); border: 1px solid var(--line); box-shadow: var(--shadow-pop); }
.cv-menu-item, .cv-menu-back { width: 100%; display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border: 0; border-radius: var(--r-md); background: none; cursor: pointer; text-align: left; font-size: 13px; }
.cv-menu-item:hover:not(:disabled), .cv-menu-back:hover { background: var(--panel-3); }
.cv-menu-item:disabled { color: var(--muted); cursor: default; }
.cv-menu-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-menu-item .hint { color: var(--muted); font-size: 12px; }
.cv-menu-item .arrow { color: var(--muted); }
.cv-menu-item.danger { color: var(--bad); }
.cv-menu-back { color: var(--muted); }
.cv-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }
.cv-menu-heading { padding: 6px 10px 2px; font-size: 11px; color: var(--muted); }
.cv-backdrop { position: fixed; inset: 0; z-index: 10001; background: rgba(0, 0, 0, .5); display: grid; place-items: center; padding: 16px; }
.cv-dialog { max-height: calc(100vh - 32px); display: flex; flex-direction: column; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-pop); }
.cv-dialog-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.cv-dialog-head h2 { flex: 1; margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cv-dialog-head h2 .cv-pill { margin-left: 0; }
.cv-dialog-body { padding: 4px 16px 12px; overflow: auto; display: flex; flex-direction: column; gap: 10px; position: relative; }
.cv-dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.cv-dialog-foot > :first-child:not(.cv-btn) { margin-right: auto; }
.cv-btn { height: 32px; padding: 0 14px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; color: var(--text); white-space: nowrap; }
.cv-btn:hover:not(:disabled) { border-color: var(--line-strong); }
.cv-btn:disabled { opacity: .5; cursor: not-allowed; }
.cv-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.cv-btn.primary:hover:not(:disabled) { filter: brightness(1.12); }
.cv-btn.danger { background: rgba(var(--bad-rgb), .9); border-color: transparent; color: #fff; }
.cv-btn.small { height: 26px; padding: 0 10px; font-size: 12px; }
.cv-input { height: 34px; width: 100%; padding: 0 10px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; outline: none; }
.cv-input:focus { border-color: rgba(var(--accent-rgb), .7); }
.cv-input.small { width: 90px; height: 30px; }
.cv-input.title { font-size: 15px; font-weight: 600; background: transparent; border-color: transparent; padding: 0 4px; }
.cv-input.title:hover, .cv-input.title:focus { border-color: var(--line); }
.cv-textarea { width: 100%; min-height: 360px; resize: vertical; padding: 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: 14px/1.6 var(--sans); outline: none; }
.cv-textarea.small { min-height: 56px; }
.cv-inline { display: flex; align-items: center; gap: 8px; }
.cv-section-title { font-size: 12px; color: var(--muted); margin-top: 4px; }
.cv-warn { color: var(--warn); font-size: 12px; margin: 0; }
.cv-problems { color: var(--warn); font-size: 12px; margin-right: auto; }

/* gen dialog */
.cv-refs { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; }
.cv-refs > p { flex-basis: 100%; margin: 0; }
.cv-ref-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cv-ref-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.cv-ref-thumb { position: relative; width: 52px; height: 52px; border-radius: var(--r-md); overflow: hidden; background: var(--panel-3); cursor: pointer; }
.cv-ref-thumb img, .cv-ref-thumb video { width: 100%; height: 100%; object-fit: cover; }
.cv-ref-thumb b { position: absolute; left: 0; bottom: 0; font-size: 10px; padding: 0 4px; background: rgba(0, 0, 0, .7); color: #fff; border-top-right-radius: 4px; }
.cv-ref-thumb .x { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .7); color: #fff; font-size: 12px; line-height: 1; cursor: pointer; opacity: 0; padding: 0; }
.cv-ref-thumb:hover .x { opacity: 1; }
.cv-prompt-wrap { position: relative; }
.cv-prompt-editor { min-height: 96px; max-height: 320px; overflow: auto; padding: 10px 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel-2); font-size: 14px; line-height: 22px; outline: none; white-space: pre-wrap; word-break: break-word; user-select: text; }
.cv-prompt-editor:focus { border-color: rgba(var(--accent-rgb), .7); }
.cv-prompt-editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.cv-mention-panel { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); max-height: 320px; overflow: auto; padding: 10px; border-radius: var(--r-lg); background: var(--panel-2); border: 1px solid var(--line); box-shadow: var(--shadow-pop); }
.cv-mention-head { font-size: 12px; color: var(--muted); margin: 4px 0; }
.cv-mention-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.cv-mention-item { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 4px; border-radius: var(--r-md); border: 1px solid transparent; background: var(--panel-3); cursor: pointer; text-align: left; }
.cv-mention-item img, .cv-mention-item .glyph { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); }
.cv-mention-item .name { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-mention-item b { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; display: none; place-items: center; }
.cv-mention-item.picked { border-color: var(--accent); }
.cv-mention-item.picked b { display: grid; }
.cv-mention-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 12px; }
.cv-params { display: flex; flex-wrap: wrap; gap: 14px 22px; padding: 10px 0; border-top: 1px solid var(--line); }
.cv-field { display: flex; flex-direction: column; gap: 6px; }
.cv-field > label { font-size: 12px; color: var(--muted); }
.cv-field > small { font-size: 11px; }
.cv-seg { display: inline-flex; padding: 2px; border-radius: var(--r-lg); background: var(--panel-2); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.cv-seg button { min-height: 28px; padding: 3px 10px; border-radius: var(--r-md); border: 0; background: none; cursor: pointer; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.cv-seg button small { font-size: 10px; color: var(--muted); }
.cv-seg button.active { background: var(--accent); color: #fff; }
.cv-seg button.active small { color: rgba(255, 255, 255, .8); }
.cv-seg button:disabled { opacity: .5; cursor: not-allowed; }
.cv-ratio-grid { display: flex; flex-wrap: wrap; gap: 4px; max-width: 420px; }
.cv-ratio-grid button { width: 56px; height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 11px; color: var(--text-2); }
.cv-ratio-grid button.active { border-color: var(--accent); color: var(--text); background: rgba(var(--accent-rgb), .14); }
.cv-ratio-glyph { display: block; border: 1.5px solid currentColor; border-radius: 2px; }
.cv-ratio-glyph.auto { border: 0; font-weight: 700; font-size: 12px; }
.cv-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); cursor: pointer; margin-top: 6px; }
.cv-range { display: flex; align-items: center; gap: 10px; }
.cv-range input { width: 200px; accent-color: var(--accent); }
.cv-runs { display: flex; flex-direction: column; gap: 4px; }
.cv-run-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 12px; padding: 6px 8px; border-radius: var(--r-md); background: var(--panel-2); }
.cv-run-row .err { flex-basis: 100%; }
.cv-run-row img.tiny { width: 28px; height: 28px; object-fit: cover; border-radius: var(--r-sm); }
.cv-discarded summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 4px 0; }

/* preview & tools */
.cv-preview-layout { display: grid; grid-template-columns: 1fr 260px; gap: 14px; min-height: 0; }
.cv-preview-stage { display: grid; place-items: center; background: #000; border-radius: var(--r-lg); min-height: 300px; max-height: 72vh; overflow: hidden; }
.cv-preview-stage img, .cv-preview-stage video { max-width: 100%; max-height: 72vh; display: block; }
.cv-preview-stage audio { width: 90%; }
.cv-preview-side { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.cv-info-prompt { white-space: pre-wrap; color: var(--text-2); max-height: 40vh; overflow: auto; }
.cv-markdown { min-height: 360px; max-height: 64vh; overflow: auto; padding: 4px 4px 12px; user-select: text; }
.cv-markdown h2, .cv-markdown h3, .cv-markdown h4 { margin: 14px 0 6px; }
.cv-markdown p { margin: 6px 0; color: var(--text-2); }
.cv-markdown table { border-collapse: collapse; margin: 8px 0; }
.cv-markdown td { border: 1px solid var(--line); padding: 4px 8px; font-size: 13px; }
.cv-crop-stage { display: grid; place-items: center; }
.cv-crop-canvas { max-width: 100%; cursor: crosshair; border-radius: var(--r-md); touch-action: none; }
.cv-cut-player { display: grid; place-items: center; background: #000; border-radius: var(--r-lg); overflow: hidden; }
.cv-cut-player video { max-height: 52vh; max-width: 100%; display: block; }
.cv-cut-player audio { width: 90%; margin: 30px 0; }
.cv-cut-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cv-cut-controls .cv-input.small { width: 140px; }
.cv-cut-timeline { position: relative; height: 112px; border-radius: var(--r-md); background: var(--panel-2); overflow: hidden; cursor: pointer; user-select: none; }
.cv-cut-strip { position: absolute; left: 0; right: 0; top: 0; height: 80px; display: flex; overflow: hidden; opacity: .9; }
.cv-cut-strip canvas { height: 80px; flex: none; }
.cv-cut-marks { position: absolute; inset: 0; }
.cv-cut-seg { position: absolute; top: 80px; height: 32px; border: 0; border-left: 1px solid var(--bg); background: var(--panel-3); color: var(--muted); font-size: 11px; cursor: pointer; }
.cv-cut-seg.keep { background: rgba(var(--accent-rgb), .35); color: #fff; }
.cv-cut-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--warn); pointer-events: none; }
.cv-cut-head { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 4px #000; pointer-events: none; }
.cv-shots { display: flex; flex-direction: column; gap: 8px; }
.cv-shot-row { display: grid; grid-template-columns: 24px 1fr auto auto; gap: 8px; align-items: center; }
.cv-shot-row .cv-input.small { width: 64px; }
.cv-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 60vh; overflow: auto; }
.cv-library-item { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; text-align: left; }
.cv-library-item img, .cv-library-item video, .cv-library-item .glyph { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--r-md); background: var(--panel-3); }
.cv-library-item .name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-library-item .meta { font-size: 11px; color: var(--muted); }
.cv-library-item.picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cv-help { width: 100%; border-collapse: collapse; font-size: 13px; }
.cv-help td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.cv-help td:first-child { color: var(--text-2); white-space: nowrap; font-family: var(--mono); font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .cv-wire.running, .cv-node.running .cv-gen-card::before, .cv-pill.running i { animation: none; }
}
.cv-mode-field { flex-basis: 100%; }
.cv-ref-group.invalid .cv-ref-label { color: var(--bad); }

/* 视频高清: tier picker on the card */
.cv-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cv-tier { height: 30px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel-2); color: var(--text-2); font-size: 12px; cursor: pointer; }
.cv-tier.on { border-color: rgba(var(--accent-rgb), .9); background: rgba(var(--accent-rgb), .14); color: var(--text); }
.cv-tier:disabled { cursor: not-allowed; opacity: .55; }
.cv-tier-copy { cursor: default; min-height: 0; }
