        /* HOLYCRAB - TapNow Style AI Workbench */
        :root {
            /* ===== Bioluminescent Forge Theme ===== */
            --bg-primary: #0b0e13;
            --bg-secondary: #101419;
            --bg-tertiary: #171c23;
            --bg-elevated: #1d222a;
            --bg-hover: #22262d;
            --bg-active: #282c34;

            --panel-bg: rgba(16, 20, 25, 0.94);
            --panel-inner: #151a20;
            --panel-soft: #101419;

            --node-bg: rgba(18, 22, 28, 0.76);
            --node-inner: #242a33;
            --node-border: rgba(255,168,79,0.10);
            --node-border-strong: rgba(255,168,79,0.22);
            --node-shadow: 0 18px 40px rgba(0,0,0,0.42), 0 0 18px rgba(255,168,79,0.05), 0 0 0 1px rgba(255,168,79,0.04), inset 0 1px 0 rgba(255,255,255,0.03);
            --node-radius: 18px;
            --node-selected: #ffa84f;

            --text-primary: #f5f6fe;
            --text-secondary: #a9abb2;
            --text-tertiary: #777d87;

            --accent-blue: #ffa84f;
            --accent-blue-hover: #ffb347;
            --accent-purple: #ff9500;
            --accent-soft: rgba(255,168,79,0.14);
            --accent-glow: rgba(255,168,79,0.08);
            --gradient-primary: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);

            --shadow-lg: 0 24px 64px rgba(0,0,0,0.48), 0 0 54px rgba(255,168,79,0.06);
            --radius-lg: 18px;
            --radius-md: 12px;
            --radius-sm: 10px;

            /* Legacy variables for compatibility */
            --border-color: rgba(255,168,79,0.08);
            --dot-color: rgba(255,168,79,0.06);
            --btn-bg: rgba(255, 255, 255, 0.04);
            --btn-hover: rgba(255, 255, 255, 0.08);

            /* Grid */
            --grid-dot-size: 1px;
            --grid-dot-color: rgba(255,168,79,0.06);
            --grid-spacing: 24px;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            height: 100vh;
            overflow: hidden;
            user-select: none;
            position: relative;
        }

        body::before {
            content: "";
            position: fixed;
            top: -200px;
            right: -200px;
            width: 600px;
            height: 600px;
            background: none;
            pointer-events: none;
            z-index: 0;
        }

        body::after {
            content: "";
            position: fixed;
            bottom: -150px;
            left: -150px;
            width: 400px;
            height: 400px;
            background: none;
            pointer-events: none;
            z-index: 0;
        }

        .title,
        .top-menu-item,
        .editor-section-label,
        .upload-label,
        .pbm-header-title,
        .pbm-sidebar-caption,
        .canvas-group-name {
            font-family: 'Manrope', 'Inter', sans-serif;
        }

        /* ===== 顶部栏 ===== */
        .top-bar {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 56px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 24px;
            background: transparent;
            z-index: 1100;
            pointer-events: none;
        }

        .top-left {
            display: flex;
            align-items: center;
            gap: 14px;
            pointer-events: auto;
        }

        .logo-group {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .logo {
            width: 34px;
            height: 34px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            filter: drop-shadow(0 0 10px rgba(255, 168, 79, 0.16));
        }

        .logo svg {
            display: block;
            width: 100%;
            height: 100%;
        }

        .title {
            font-size: 20px;
            font-weight: 800;
            line-height: 1;
            color: #fff;
            letter-spacing: -0.01em;
        }

        .top-center-nav {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            align-items: center;
            gap: 32px;
            pointer-events: auto;
            z-index: 1;
        }

        .top-center-nav-item {
            position: relative;
            height: auto;
            padding: 0;
            border: 0;
            background: transparent;
            color: var(--text-tertiary);
            font-family: 'Manrope', 'Inter', sans-serif;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: color 0.18s ease;
        }

        .top-center-nav-item:hover {
            color: var(--text-primary);
        }

        .top-center-nav-item.active {
            color: #ffa84f;
            font-weight: 600;
        }

        .top-center-nav-item.active::after {
            content: "";
            position: absolute;
            left: 50%;
            bottom: -4px;
            width: 100%;
            height: 2px;
            border-radius: 1px;
            background: var(--gradient-primary);
            transform: translateX(-50%);
        }

        .top-right {
            display: flex;
            align-items: center;
            gap: 2px;
            background: rgba(16, 20, 25, 0.8);
            border: 1px solid rgba(255,255,255,0.04);
            border-radius: 12px;
            padding: 3px 5px;
            backdrop-filter: blur(20px);
            pointer-events: auto !important;
            transition: margin-right 0.25s ease;
            z-index: 1101;
            position: relative;
            box-shadow: 0 0 40px rgba(255,168,79,0.04);
        }

        .top-right-content {
            display: flex;
            align-items: center;
            gap: 2px;
            overflow: hidden;
            max-width: 520px;
            opacity: 1;
            transition: max-width 0.22s ease, opacity 0.18s ease;
        }

        .top-right.is-collapsed {
            padding-right: 3px;
        }

        .top-right.is-collapsed .top-right-content {
            max-width: 0;
            opacity: 0;
            pointer-events: none;
        }

        .top-right-toggle-btn svg {
            transition: transform 0.22s ease;
        }

        .top-right.is-collapsed .top-right-toggle-btn svg {
            transform: rotate(180deg);
        }

        /* 确保顶栏按钮可点击，不被悬浮面板遮挡 */
        .top-right .top-bar-btn {
            pointer-events: auto !important;
            position: relative;
            z-index: 1;
        }

        /* 按钮内部的 span 和 svg 不拦截事件 */
        .top-bar-btn span,
        .top-bar-btn svg {
            pointer-events: none;
        }

        .badge {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            background: rgba(30, 30, 30, 0.8);
            border: 1px solid var(--border-color);
            border-radius: 20px;
            font-size: 13px;
            font-weight: 500;
            color: var(--text-secondary);
        }

        .badge svg {
            width: 14px;
            height: 14px;
        }

        .share-btn {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(30, 30, 30, 0.8);
            border: 1px solid var(--border-color);
            border-radius: 50%;
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.2s;
        }

        .share-btn:hover {
            background: var(--bg-hover);
            color: var(--text-primary);
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #22c55e, #16a34a);
            border: none;
            border-radius: 50%;
            cursor: pointer;
            color: white;
            font-weight: 600;
            font-size: 14px;
        }

        /* ===== 主容器 ===== */
        .main-container {
            display: flex;
            height: 100vh;
            width: 100vw;
            padding-top: 56px;
            position: relative;
            z-index: 1;
        }

        /* ===== 侧边栏收缩按钮 ===== */
        /* ===== 侧边栏收缩按钮 ===== */
        .sidebar-toggle-btn {
            width: 28px;
            height: 44px;
            background: transparent;
            border: none;
            border-radius: 0;
            cursor: pointer;
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.18s ease, color 0.18s ease;
            flex-shrink: 0;
        }

        .sidebar-toggle-btn:hover {
            background: rgba(255,255,255,0.06);
            color: var(--text-primary);
        }

        .sidebar-toggle-btn svg {
            transition: transform 0.22s ease;
            pointer-events: none;
        }

        .sidebar-toggle-btn.collapsed svg {
            transform: none;
        }

        #scriptEditorSidebar.collapsed ~ .canvas-container {
            margin-left: 0;
        }

        /* ===== 剧本编辑器侧边栏（透明容器，视觉由 editor-container 承载）===== */
        .script-editor-sidebar {
            width: 320px;
            background: transparent;
            flex-shrink: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            height: auto;
            max-height: calc(100vh - 56px);
            overflow: hidden;
            transition: width 0.3s ease, opacity 0.3s ease;
            position: relative;
        }

        .script-editor-sidebar.collapsed {
            width: 0;
            opacity: 0;
            overflow: hidden;
            pointer-events: none;
        }

        .script-editor-sidebar.collapsed .sidebar-resize-handle {
            display: none;
        }

        /* ===== resize handle：贴在 editor-container 右边缘 ===== */
        .sidebar-resize-handle {
            position: absolute;
            left: 50%;
            bottom: 6px;
            width: 56px;
            height: 14px;
            transform: translateX(-50%);
            cursor: ns-resize;
            z-index: 20;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .sidebar-resize-handle::after {
            content: '';
            width: 42px;
            height: 4px;
            border-radius: 3px;
            background: rgba(255,255,255,0.14);
            transition: background 0.15s ease, width 0.15s ease;
        }

        .sidebar-resize-handle:hover::after {
            background: rgba(255,255,255,0.22);
            width: 52px;
        }

        .sidebar-resize-handle:active::after {
            background: rgba(255,168,79,0.5);
            width: 56px;
        }

        /* ===== Agent 面板左侧缩放手柄 ===== */
        .sidebar-resize-left {
            left: 0;
            right: auto;
        }

        .sidebar-resize-bottom {
            top: auto;
            right: auto;
        }

        .editor-container {
            background: var(--panel-bg);
            border: 1px solid var(--node-border);
            border-radius: 0 16px 16px 0;
            width: 100%;
            overflow: hidden;
            flex: 1;
            display: flex;
            flex-direction: column;
            box-shadow: var(--shadow-lg);
            min-height: 0;
        }

        /* ===== 左侧悬浮工具栏 ===== */
        .left-sidebar {
            position: fixed;
            left: 20px;
            top: 50%;
            transform: translateY(-50%);
            width: 68px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0;
            padding: 0;
            flex-shrink: 0;
            z-index: 50;
            background: rgba(16, 20, 25, 0.9);
            border: 1px solid rgba(255,255,255,0.04);
            border-radius: 20px;
            box-shadow: 0 0 40px rgba(255,168,79,0.05), 0 8px 32px rgba(0,0,0,0.4);
            backdrop-filter: blur(20px);
            height: auto;
            overflow: hidden;
            transition: left 0.3s ease;
        }

        body.editor-sidebar-open .left-sidebar {
            left: 340px;
        }

        /* 拖拽手柄 */
        .left-sidebar-drag-handle {
            width: 100%;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: grab;
            color: rgba(255,255,255,0.2);
            transition: color 0.15s ease, background 0.15s ease;
            flex-shrink: 0;
        }

        .left-sidebar-drag-handle:hover {
            color: rgba(255,255,255,0.5);
        }

        .left-sidebar-drag-handle svg {
            width: 16px;
            height: 16px;
        }

        .left-sidebar-drag-handle:active {
            cursor: grabbing;
            color: rgba(255,255,255,0.9);
        }

        /* 工具栏图标区域 */
        .left-sidebar-tools {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 2px;
            padding: 4px 0 8px;
            width: 100%;
        }

        /* 分隔线 */
        .left-sidebar-divider {
            width: 32px;
            height: 1px;
            background: rgba(255,255,255,0.04);
            margin: 6px 0;
            flex-shrink: 0;
        }

        /* 收起按钮融入悬浮栏底部 */
        .left-sidebar .sidebar-toggle-btn {
            margin: 0;
            border-radius: 0;
            border-top: 1px solid rgba(255,255,255,0.05);
            width: 100%;
            height: 48px;
            flex-shrink: 0;
            color: var(--text-tertiary);
        }

        .tool-btn {
            width: 44px;
            height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            border-radius: var(--radius-md);
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.2s ease;
            flex-shrink: 0;
        }

        .tool-btn:hover {
            color: var(--text-primary);
            background: rgba(255,255,255,0.06);
        }

        .tool-btn.active,
        .tool-btn.highlight {
            background: var(--gradient-primary);
            color: #000;
            box-shadow: 0 0 20px rgba(255,149,0,0.3);
        }

        .tool-btn svg {
            width: 20px;
            height: 20px;
        }

        .tool-btn.highlight:hover {
            transform: scale(1.05);
            box-shadow: 0 0 25px rgba(255,149,0,0.4);
        }

        .tool-btn.add {
            background: #fff;
            color: #000;
            border-radius: 50%;
        }

        .tool-btn.add:hover {
            background: #e0e0e0;
        }

        .tool-btn.user {
            background: #22c55e;
            color: white;
            font-weight: 600;
            font-size: 13px;
            border-radius: 50%;
        }

        /* ===== 画布容器 ===== */
        .canvas-container {
            flex: 1;
            position: relative;
            overflow: hidden;
            cursor: grab;
            overscroll-behavior: none;
            isolation: isolate;
        }

        .canvas-container::before {
            content: "";
            position: absolute;
            inset: 0;
            pointer-events: none;
            z-index: 0;
            background: none;
        }

        .canvas-container:active {
            cursor: grabbing;
        }

        /* sidebar resize 时强制 canvas 容器重排，防止收缩后面板区域遮挡画布 */
        .canvas-container.sidebar-resizing {
            transform: translateZ(0);
        }

        .canvas-content {
            position: absolute;
            top: 0;
            left: 0;
            width: 999999px;
            height: 999999px;
            transform-origin: 0 0;
            transition: none;
            will-change: transform;
            z-index: 2;
            backface-visibility: hidden;
            -webkit-backface-visibility: hidden;
        }

        #canvasContent {
            z-index: 2 !important;
        }

        /* 点阵网格背景 */
        .dot-grid {
            position: absolute;
            inset: 0;
            width: auto;
            height: auto;
            background-image: radial-gradient(circle, rgba(255,149,0,0.06) var(--grid-dot-size), transparent var(--grid-dot-size));
            background-size: var(--grid-spacing) var(--grid-spacing);
            background-position: var(--grid-offset-x, 0) var(--grid-offset-y, 0);
            pointer-events: none;
            z-index: 0;
        }

        /* ===== 中央提示 ===== */
        .center-prompt {
            position: absolute;
            top: 40%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 13px;
            color: var(--text-primary);
            z-index: 8;
            pointer-events: none;
            padding: 0;
            border-radius: 0;
            background: transparent;
            white-space: nowrap;
        }

        .prompt-icon {
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
            border-radius: 6px;
            color: #000;
            box-shadow: 0 0 16px rgba(255,149,0,0.25);
        }

        .prompt-text {
            font-family: 'Manrope', 'Inter', sans-serif;
            font-size: 14px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .prompt-sub {
            color: var(--text-tertiary);
            font-size: 13px;
            font-family: 'Inter', sans-serif;
        }

        /* ===== 功能按钮组 ===== */
        .action-buttons {
            position: absolute;
            top: calc(40% + 50px);
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            justify-content: center;
            z-index: 8;
            max-width: min(980px, calc(100vw - 240px));
        }

        .action-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            height: auto;
            background: rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.03);
            border-radius: var(--radius-sm);
            color: var(--text-secondary);
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .action-btn:hover {
            background: rgba(255,255,255,0.08);
            color: var(--text-primary);
            box-shadow: 0 0 20px rgba(255,168,79,0.06);
        }

        .action-btn svg {
            width: 14px;
            height: 14px;
        }

        /* ===== 右侧浮动按钮 ===== */
        .right-float {
            position: fixed;
            right: 12px;
            top: 50%;
            transform: translateY(-50%);
            display: flex;
            flex-direction: column;
            gap: 8px;
            z-index: 50;
        }

        .float-btn {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 50%;
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.2s;
        }

        .float-btn:hover {
            background: var(--bg-hover);
            color: var(--text-primary);
        }

        .float-btn.ai {
            background: linear-gradient(135deg, #ffb347, #ff9500);
            border-color: transparent;
            color: white;
            box-shadow: 0 10px 30px rgba(255,168,79,0.24);
        }


        /* ===== 右下角浮动按钮 ===== */
        .fab {
            position: fixed;
            bottom: 16px;
            right: 18px;
            width: 56px;
            height: 56px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(18, 23, 34, 0.92) !important;
            border: 1px solid rgba(255, 255, 255, 0.12) !important;
            border-radius: 50%;
            cursor: pointer;
            color: white;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
            backdrop-filter: blur(12px);
            transition: all 0.2s;
            z-index: 100;
        }

        .fab:hover {
            transform: scale(1.08);
            background: rgba(25, 30, 42, 0.96) !important;
            border-color: rgba(255, 255, 255, 0.22) !important;
        }

        .fab svg,
        .fab svg path,
        .fab svg circle,
        .fab svg ellipse,
        .fab svg line {
            stroke: rgba(255, 255, 255, 0.85) !important;
            fill: none !important;
            width: 28px !important;
            height: 28px !important;
        }

        .fab:hover svg,
        .fab:hover svg path,
        .fab:hover svg circle,
        .fab:hover svg ellipse,
        .fab:hover svg line {
            stroke: rgba(255, 255, 255, 1) !important;
        }

        /* ===== 节点样式 ===== */
        .node {
            position: absolute;
            width: 520px;
            background:
                linear-gradient(180deg, rgba(255,255,255,0.018) 0%, rgba(255,255,255,0) 18%),
                var(--node-bg);
            backdrop-filter: blur(24px) saturate(150%);
            -webkit-backdrop-filter: blur(24px) saturate(150%);
            border: 1px solid var(--node-border);
            border-radius: var(--node-radius);
            overflow: visible;
            box-shadow: var(--node-shadow);
            transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
            /* 节点在连线上方（connections-layer z-index: 0） */
            z-index: 2;
        }

        .node:hover {
            border-color: rgba(255,168,79,0.42);
        }

        /* 项目 restore 期间（和 reveal 之后的短暂缓冲期）禁用一切过渡，
           避免 video metadata 回来后 autoFit 引起的节点尺寸/端口/连线可见跳动 */
        body.is-restoring .node,
        body.is-restoring .node *,
        body.is-restoring .node-port,
        body.is-restoring .connection-path,
        body.is-restoring .connections-layer path {
            transition: none !important;
            animation: none !important;
        }

        /* restore 期间：用 visibility 硬屏蔽所有节点/连线/组框/装饰按钮，
           不论它们被 append 到 DOM 的哪个角落，都一并隐藏。
           visibility 比 opacity 稳：不建 stacking context，无须关心层叠。 */
        /* restore 期间：只把画布本体隐藏，不动顶栏/侧栏/空白态提示。
           #canvasContent、#connectionsLayer 是 #canvasContainer 的直接子元素；
           .node / .static-group / 内部的装饰按钮都是 #canvasContent 的后代，
           因此把这三处都 visibility:hidden 就能兜住。
           不隐藏 #canvasContainer 本身，这样 #centerPrompt / #actionButtons 等空白态提示保持可见。 */
        body.is-restoring #canvasContent,
        body.is-restoring #canvasContent *,
        body.is-restoring #connectionsLayer,
        body.is-restoring #connectionsLayer * {
            visibility: hidden !important;
        }

        /* 拖线过程中抑制普通 hover 发光 - 只让源/目标节点高亮 */
        body.is-connecting .node:hover:not(.connection-source):not(.connection-target-highlight) {
            border-color: var(--node-border);
        }

        .node.is-selected {
            z-index: 3 !important;
        }

        .node.is-dragging {
            z-index: 10 !important;
        }

        /* 平移中降低节点渲染复杂度 */
        body.panning .node {
            will-change: transform;
            transition: none;
        }

        body.hc-canvas-interacting .node,
        body.hc-canvas-interacting .static-group,
        body.hc-canvas-interacting .connections-layer path {
            transition: none !important;
        }

        body.hc-canvas-interacting .connection-path:not(.active) {
            animation-play-state: paused;
        }

        /* Paint optimization during pan/zoom: drop expensive backdrop-filter and
           shadow on non-interacting nodes. backdrop-filter: blur(24px) is one of
           the most expensive paint operations and is the dominant bottleneck for
           100+ node canvases. Selected/dragging nodes keep their visual effects
           because the user is actively engaging with them. */
        body.hc-canvas-interacting .node:not(.is-selected):not(.is-dragging) {
            backdrop-filter: none !important;
            -webkit-backdrop-filter: none !important;
            box-shadow: none !important;
        }

        /* Promote #canvasContent to its own GPU compositor layer during pan/zoom.
           This lets the browser apply the canvas-wide transform as a single GPU
           composite operation instead of re-painting 117 child nodes. Combined
           with the backdrop-filter removal above (which kills stacking contexts
           that would otherwise force per-node paint), this is the biggest single
           win for 100+ node canvases at low zoom levels where every node is in
           the viewport. will-change is scoped to interacting state because
           keeping it always-on would waste GPU memory for the idle canvas. */
        body.hc-canvas-interacting #canvasContent {
            will-change: transform;
        }

        /* Hide expensive in-node sub-elements (video controls bar, tag chips,
           hover buttons) during interaction at low zoom levels — they're too
           small to be useful and each is a separate paint layer. Visibility
           returns the moment hc-canvas-interacting is removed (~50ms after the
           user stops). */
        body.hc-canvas-interacting.hc-canvas-large .node:not(.is-selected):not(.is-dragging) video::-webkit-media-controls {
            display: none !important;
        }

        /* 上传头部 */
        .node-upload-header {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 10px 12px 8px;
            gap: 6px;
        }

        .upload-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 14px;
            background: rgba(255,255,255,0.04);
            border: 0.5px solid rgba(255,168,79,0.10);
            border-radius: 20px;
            color: var(--text-secondary);
            font-family: 'Inter', sans-serif;
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
        }

        .upload-btn:hover {
            background: rgba(255,255,255,0.08);
            border-color: rgba(255,168,79,0.20);
            color: var(--text-primary);
        }

        .upload-label {
            font-family: 'Inter', sans-serif;
            font-size: 11px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--text-secondary);
        }

        /* 图片框 */
        .node-image-box {
            position: relative;
            margin: 0 12px 12px;
            aspect-ratio: 16/9;
            background: linear-gradient(180deg, rgba(255,255,255,0.030) 0%, rgba(255,255,255,0.010) 100%), rgba(28, 33, 40, 0.92);
            border: 0.5px solid var(--node-border);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            width: auto;
            max-width: 100%;
            box-sizing: border-box;
            overflow: hidden;
            flex-shrink: 0;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.035), inset 0 -1px 0 rgba(255,255,255,0.010);
        }

        .image-placeholder {
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-tertiary);
        }

        .side-btn {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-tertiary);
            border: 0.5px solid var(--node-border);
            border-radius: 50%;
            color: var(--text-tertiary);
            font-size: 18px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .side-btn:hover {
            background: var(--bg-active);
            color: var(--text-primary);
        }

        .side-btn.left {
            left: -40px;
        }

        .side-btn.right {
            right: -40px;
        }

        /* 输入区域 */
        .node-input-section {
            background: rgba(14, 18, 24, 0.88);
            border-top: 0.5px solid var(--node-border);
            padding: 16px;
        }

        .input-icon {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--bg-hover);
            border-radius: 8px;
            margin-bottom: 12px;
            color: var(--text-tertiary);
        }

        .node-textarea {
            width: 100%;
            background: transparent;
            border: none;
            color: var(--text-primary);
            font-size: 13px;
            resize: none;
            outline: none;
            font-family: 'Manrope', sans-serif;
            line-height: 1.6;
            margin-bottom: 12px;
        }

        .node-textarea::placeholder {
            color: var(--text-tertiary);
        }

        /* 参数栏 */
        .node-params {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
            margin-bottom: 12px;
        }

        .param-item {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            background: var(--bg-hover);
            border: 0.5px solid rgba(255,168,79,0.08);
            border-radius: 6px;
            font-size: 12px;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s;
        }

        .param-item:hover {
            background: var(--bg-active);
            color: var(--text-primary);
        }

        .param-item.model {
            color: var(--text-primary);
        }

        .param-item.points {
            margin-left: auto;
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 4px 4px 4px 10px;
        }

        .send-btn {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
            border: none;
            border-radius: 6px;
            color: #fff7ec;
            cursor: pointer;
            transition: all 0.2s;
            box-shadow: 0 8px 20px rgba(255,168,79,0.22);
        }

        .send-btn:hover {
            background: linear-gradient(135deg, #ffc163 0%, #ff9f1f 100%);
            transform: translateY(-1px);
            box-shadow: 0 12px 26px rgba(255,168,79,0.28);
        }

        /* 联网搜索开关 */
        .node-toggle {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding-top: 12px;
            border-top: 0.5px solid var(--node-border);
            font-size: 13px;
            color: var(--text-secondary);
        }

        .switch {
            position: relative;
            width: 44px;
            height: 24px;
        }

        .switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(255,255,255,0.10);
            transition: .3s;
            border-radius: 24px;
        }

        .slider:before {
            position: absolute;
            content: "";
            height: 18px;
            width: 18px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: .3s;
            border-radius: 50%;
        }

        input:checked + .slider {
            background-color: #3b82f6;
        }

        input:checked + .slider:before {
            transform: translateX(20px);
        }

        /* 连接点 */
        .node-connector {
            position: absolute;
            width: 12px;
            height: 12px;
            background: var(--bg-tertiary);
            border: 2px solid var(--border-color);
            border-radius: 50%;
            cursor: crosshair;
        }

        .node-connector.input {
            left: -6px;
            top: 40%;
            transform: translateY(-50%);
        }

        .node-connector.output {
            right: -6px;
            top: 40%;
            transform: translateY(-50%);
        }

        /* ===== 响应式 ===== */
        @media (max-width: 768px) {
            .action-buttons {
                flex-direction: column;
                align-items: center;
            }

            .left-sidebar {
                left: 8px;
            }

            .right-float {
                right: 8px;
            }

            .left-sidebar {
                display: none;
            }
        }

        /* ===== 模型配置模态弹窗 ===== */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(4px);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .modal-overlay.active {
            display: flex;
            opacity: 1;
        }

        .modal-container {
            width: 90%;
            max-width: 720px;
            max-height: 85vh;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
            display: flex;
            flex-direction: column;
            transform: scale(0.95);
            transition: transform 0.2s ease;
        }

        .modal-overlay.active .modal-container {
            transform: scale(1);
        }

        .modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 20px;
            height: 56px;
            border-bottom: 1px solid rgba(255,255,255,0.06);
            flex-shrink: 0;
            background: var(--bg-tertiary);
        }

        .modal-header-tabs {
            display: flex;
            gap: 2px;
            align-items: center;
            height: 100%;
        }

        .modal-tab {
            display: flex;
            align-items: center;
            gap: 6px;
            height: 100%;
            padding: 0 16px;
            background: none;
            border: none;
            color: #888;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            position: relative;
            transition: color 0.15s ease;
            white-space: nowrap;
        }

        .modal-tab:hover {
            color: #c0c8d8;
        }

        .modal-tab.active {
            color: #e0e6f0;
        }

        .modal-tab.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 16px;
            right: 16px;
            height: 2px;
            background: #ffa84f;
            border-radius: 2px 2px 0 0;
        }

        .modal-tab svg {
            opacity: 0.6;
            flex-shrink: 0;
        }

        .modal-tab.active svg {
            opacity: 1;
        }

        .modal-close-btn {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            border: none;
            background: transparent;
            color: #888;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s, color 0.15s;
            flex-shrink: 0;
        }

        .modal-close-btn:hover {
            background: rgba(255,255,255,0.08);
            color: #e0e6f0;
        }

        /* Tab 内容切换 */
        .modal-tab-content {
            display: none;
            flex-direction: column;
            flex: 1;
            min-height: 0;
        }

        .modal-tab-content.active {
            display: flex;
        }

        body.api-config-hidden .modal-tab[data-config-tab="api"],
        body.api-config-hidden #configTabApi,
        body.api-config-hidden [data-open-config="api"] {
            display: none !important;
        }

        .modal-title {
            font-size: 18px;
            font-weight: 600;
            color: var(--text-primary);
            margin: 0;
        }

        .modal-close {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.2s;
        }

        .modal-close:hover {
            background: var(--btn-hover);
            color: var(--text-primary);
        }

        .modal-body {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
        }

        .modal-footer {
            padding: 16px 20px;
            background: var(--bg-tertiary);
            border-top: 1px solid var(--border-color);
            display: flex;
            justify-content: flex-end;
        }

        /* 标签页导航 */
        .tab-nav {
            display: flex;
            gap: 8px;
            margin-bottom: 20px;
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 8px;
            flex-wrap: wrap;
        }

        .tab-btn {
            padding: 8px 12px;
            background: transparent;
            border: 1px solid transparent;
            border-radius: 8px;
            color: var(--text-secondary);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .tab-btn:hover {
            background: var(--btn-bg);
            color: var(--text-primary);
        }

        .tab-btn.active {
            background: var(--accent-blue);
            border-color: var(--accent-blue);
            color: white;
        }

        .tab-btn .badge {
            background: rgba(0, 0, 0, 0.3);
            padding: 2px 6px;
            border-radius: 10px;
            font-size: 11px;
            min-width: 18px;
            text-align: center;
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        /* 统一全局配置区域 */
        .global-config-unified {
            background: linear-gradient(135deg, rgba(255,149,0, 0.1), rgba(255,179,71, 0.12));
            border: 2px solid var(--accent-blue);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 24px;
        }

        .global-config-unified .section-title {
            color: var(--accent-blue);
        }

        .global-hint {
            margin-top: 12px;
            font-size: 12px;
            color: var(--text-secondary);
            font-style: italic;
        }

        /* 分类全局配置区域 */
        .global-config {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 20px;
        }

        .section-title {
            font-size: 13px;
            font-weight: 600;
            color: var(--text-secondary);
            margin: 0 0 12px 0;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .global-config-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
        }

        /* 模型列表 */
        .models-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        /* 单个模型配置项 */
        .model-item {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            overflow: hidden;
            transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
        }

        .model-item:hover {
            border-color: #444;
        }

        .model-name {
            padding: 12px 16px;
            font-size: 14px;
            font-weight: 600;
            background: rgba(255, 255, 255, 0.02);
            border-bottom: 1px solid var(--border-color);
        }

        .model-configs {
            padding: 16px;
            display: grid;
            grid-template-columns: 2fr 2fr 2fr auto;
            gap: 12px;
            align-items: end;
        }

        /* 表单组件 */
        .form-group {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .form-group label {
            font-size: 11px;
            font-weight: 500;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .form-input {
            padding: 8px 12px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            color: var(--text-primary);
            font-size: 13px;
            font-family: inherit;
            outline: none;
            transition: all 0.2s;
        }

        .form-input:focus {
            border-color: var(--accent-blue);
            box-shadow: 0 0 0 2px rgba(255,149,0, 0.15);
        }

        .form-input::placeholder {
            color: var(--text-tertiary);
        }

        /* 测试连接按钮 */
        .test-btn {
            padding: 8px 16px;
            background: var(--btn-bg);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            color: var(--text-secondary);
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            white-space: nowrap;
        }

        .test-btn:hover {
            background: var(--btn-hover);
            border-color: #444;
            color: var(--text-primary);
        }

        .test-result {
            margin-left: 8px;
            font-size: 12px;
            font-weight: 500;
        }
        .test-result.success { color: #10b981; }
        .test-result.error { color: #ef4444; }

        /* 文生图模型下拉样式 */
        .model-select {
            background: transparent;
            color: #fff;
            border: none;
            outline: none;
            font-size: inherit;
            cursor: pointer;
            appearance: none;
            padding-right: 18px;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%23aaa" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>');
            background-repeat: no-repeat;
            background-position: right center;
        }
        .model-select option {
            background: #1a1a1a;
            color: #fff;
        }

        /* 底部关闭按钮 */
        .close-btn {
            padding: 10px 24px;
            background: var(--gradient-primary);
            border: none;
            border-radius: 8px;
            color: #fff7ec;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            box-shadow: 0 12px 28px rgba(255,168,79,0.22);
        }

        .close-btn:hover {
            background: linear-gradient(135deg, #ffc163 0%, #ff9f1f 100%);
        }

        /* 响应式适配 */
        @media (max-width: 680px) {
            .global-config-row {
                grid-template-columns: 1fr;
            }

            .model-configs {
                grid-template-columns: 1fr;
            }

            .tab-nav {
                overflow-x: auto;
                flex-wrap: nowrap;
            }

            .modal-container {
                width: 95%;
                max-height: 90vh;
            }
        }

        /* ===== 文生图图片框样式 ===== */
        .node-image-box .image-placeholder {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: var(--text-tertiary);
            width: 100%;
            height: 100%;
            box-sizing: border-box;
            position: absolute;
            inset: 0;
        }

        .node-image-box .image-loading {
            display: none;
            color: var(--text-secondary);
            flex-direction: row;
            align-items: center;
            justify-content: center;
            gap: 12px;
            padding: 12px;
            box-sizing: border-box;
        }

        .node-image-box .image-gen-progress {
            display: flex;
            flex-direction: column;
            gap: 6px;
            min-width: min(170px, 62%);
        }

        .node-image-box .image-gen-progress-label {
            font-size: 11px;
            line-height: 1.2;
            color: rgba(224,230,240,0.92);
        }

        .node-image-box .image-gen-progress-track {
            position: relative;
            width: 100%;
            height: 6px;
            overflow: hidden;
            border-radius: 999px;
            background: rgba(255,255,255,0.08);
        }

        .node-image-box .image-gen-progress-bar {
            width: var(--image-gen-progress, 3%);
            height: 100%;
            border-radius: inherit;
            background: linear-gradient(90deg, rgba(255,168,79,0.18), rgba(255,168,79,0.95), rgba(255,211,138,0.82));
            transition: width 0.35s ease;
        }

        .loading-spinner {
            display: flex;
            align-items: center;
            justify-content: center;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
        }

        /* 画布容器 */
        .canvas-container {
            flex: 1;
            position: relative;
            overflow: hidden;
            cursor: grab;
        }

        /* ===== 创建节点菜单 ===== */
        .create-menu {
            background: rgba(10, 14, 22, 0.97);
            border: 1px solid rgba(255, 255, 255, 0.07);
            border-radius: 14px;
            box-shadow:
                0 22px 56px rgba(0, 0, 0, 0.5),
                inset 0 0 0 1px rgba(255, 255, 255, 0.015);
            min-width: 158px;
            overflow: hidden;
            backdrop-filter: blur(16px);
            padding: 8px;
        }

        .create-menu .menu-title {
            padding: 8px 10px 9px;
            font-size: 12px;
            font-weight: 600;
            color: rgba(237, 242, 251, 0.5);
            background: transparent;
            text-transform: none;
            letter-spacing: 0.2px;
        }

        .create-menu .menu-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 9px 11px;
            color: rgba(237, 242, 251, 0.86);
            font-size: 13px;
            font-weight: 500;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.18s ease;
        }

        .create-menu .menu-item:hover {
            background: rgba(255, 255, 255, 0.04);
            color: #f7faff;
            transform: translateX(2px);
        }

        .create-menu .menu-item.is-danger {
            color: rgba(255, 120, 120, 0.92);
        }

        .create-menu .menu-item.is-danger:hover {
            background: rgba(239, 68, 68, 0.12);
            color: #ffd6d6;
        }

        .create-menu .menu-item svg {
            width: 16px;
            height: 16px;
            opacity: 0.74;
            flex-shrink: 0;
        }

        .canvas-create-menu,
        .connection-drop-menu,
        .sg-drop-menu {
            min-width: 168px;
        }

        /* ===================== */
        /* Agent Panel Styles    */
        /* ===================== */

        .agent-panel {
            position: absolute;
            top: 56px;
            right: 0;
            bottom: 0;
            width: 336px;
            background: linear-gradient(180deg, rgba(16,20,25,0.97), rgba(11,14,19,0.98));
            border: 1px solid rgba(69,72,78,0.22);
            border-radius: 16px 0 0 0;
            display: flex;
            flex-direction: column;
            backdrop-filter: blur(16px);
            box-shadow: 0 18px 54px rgba(0,0,0,0.42), 0 0 40px rgba(255,168,79,0.05);
            z-index: 30;
            overflow: hidden;
            transition: all 0.25s ease;
        }

        .agent-panel.hidden {
            opacity: 0;
            pointer-events: none;
            transform: translateX(24px);
        }

        .agent-panel-header {
            height: 48px;
            padding: 0 12px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid rgba(69,72,78,0.18);
            flex-shrink: 0;
            background: linear-gradient(180deg, rgba(16,20,25,0.9), rgba(16,20,25,0.56));
        }

        .agent-panel-title {
            font-family: 'Manrope', 'Inter', sans-serif;
            font-size: 13px;
            font-weight: 700;
            color: #f5f1ea;
            letter-spacing: 0.02em;
        }

        .agent-panel-actions {
            display: flex;
            gap: 6px;
        }

        .agent-icon-btn {
            height: 30px;
            padding: 0 10px;
            border: 1px solid rgba(69,72,78,0.24);
            border-radius: 8px;
            background: rgba(34,38,45,0.86);
            color: #d8dbe2;
            cursor: pointer;
        }

        .agent-icon-btn:hover {
            background: rgba(40,44,52,0.96);
            border-color: rgba(255,168,79,0.2);
            color: #fff7ec;
        }

        .agent-icon-btn:hover {
            background: rgba(255,255,255,0.08);
        }

        .agent-toolbar {
            padding: 10px 12px 9px;
            display: flex;
            gap: 6px;
            border-bottom: 1px solid rgba(69,72,78,0.18);
            flex-wrap: nowrap;
            background:
                linear-gradient(180deg, rgba(29,34,42,0.72), rgba(16,20,25,0.48));
        }

        .agent-select {
            flex: 1;
            min-width: 92px;
            height: 32px;
            border-radius: 7px;
            border: 1px solid rgba(69,72,78,0.22);
            background: rgba(29,34,42,0.92);
            color: #f3efe8;
            padding: 0 8px;
            outline: none;
            font-size: 12px;
        }

        .agent-select.small {
            flex: 0 0 78px;
        }

        .agent-select-native-hidden {
            display: none !important;
        }

        .agent-select-shell {
            position: relative;
            flex: 1;
            min-width: 0;
        }

        .agent-select-shell.small {
            flex: 0 0 72px;
        }

        .agent-select-shell.is-model {
            flex: 1.4;
        }

        .agent-select-shell.is-preset {
            flex: 0.9;
        }

        .agent-select-shell.is-language {
            flex: 0 0 72px;
        }

        .agent-select-trigger {
            width: 100%;
            height: 32px;
            padding: 0 26px 0 10px;
            border-radius: 9px;
            border: 1px solid rgba(69,72,78,0.24);
            background: linear-gradient(180deg, rgba(34,38,45,0.96), rgba(29,34,42,0.96));
            color: #f2f3f5;
            font-size: 11px;
            font-weight: 600;
            text-align: left;
            cursor: pointer;
            transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            letter-spacing: 0.01em;
        }

        .agent-select-trigger:hover,
        .agent-select-shell.is-open .agent-select-trigger {
            border-color: rgba(255,168,79,0.3);
            box-shadow: 0 0 0 1px rgba(255,168,79,0.12), 0 10px 24px rgba(0,0,0,0.18);
            background: linear-gradient(180deg, rgba(40,44,52,0.98), rgba(34,38,45,0.98));
        }

        .agent-select-trigger::after {
            content: '';
            position: absolute;
            right: 10px;
            top: 50%;
            width: 7px;
            height: 7px;
            border-right: 1.25px solid rgba(255,247,236,0.75);
            border-bottom: 1.25px solid rgba(255,247,236,0.75);
            transform: translateY(-65%) rotate(45deg);
            transition: transform 0.16s ease;
            pointer-events: none;
        }

        .agent-select-shell.is-open .agent-select-trigger::after {
            transform: translateY(-30%) rotate(-135deg);
        }

        .agent-select-menu {
            position: absolute;
            left: 0;
            top: calc(100% + 8px);
            min-width: 100%;
            padding: 6px;
            border-radius: 14px;
            border: 1px solid rgba(69,72,78,0.24);
            background: linear-gradient(180deg, rgba(29,34,42,0.98), rgba(16,20,25,0.98));
            box-shadow: 0 22px 48px rgba(0,0,0,0.42), 0 0 42px rgba(255,168,79,0.05);
            backdrop-filter: blur(16px);
            display: none;
            z-index: 80;
            max-height: 320px;
            overflow: auto;
        }

        .agent-select-shell.is-model .agent-select-menu {
            min-width: 184px;
        }

        .agent-select-shell.is-open .agent-select-menu {
            display: block;
        }

        .agent-select-menu::-webkit-scrollbar {
            width: 6px;
        }

        .agent-select-menu::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.12);
            border-radius: 999px;
        }

        .agent-select-option {
            width: 100%;
            min-height: 30px;
            padding: 7px 9px;
            border: 0;
            border-radius: 9px;
            background: transparent;
            color: #d8dbe2;
            font-size: 11px;
            font-weight: 500;
            text-align: left;
            line-height: 1.25;
            cursor: pointer;
            transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
            white-space: normal;
            word-break: break-word;
        }

        .agent-select-option:hover {
            background: rgba(255,168,79,0.08);
            color: #fff7ec;
        }

        .agent-select-option.is-selected {
            background: linear-gradient(135deg, rgba(255,179,71,0.18), rgba(255,149,0,0.2));
            color: #fff7ec;
            box-shadow: inset 0 0 0 1px rgba(255,168,79,0.24);
        }

        .agent-send-top-btn {
            height: 34px;
            padding: 0 12px;
            border: none;
            border-radius: 8px;
            background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
            color: #fff7ec;
            cursor: pointer;
            box-shadow: 0 10px 24px rgba(255,168,79,0.22);
        }

        .agent-send-top-btn:hover {
            background: linear-gradient(135deg, #ffc163 0%, #ff9f1f 100%);
        }

        .agent-messages {
            flex: 1 1 auto;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 14px 14px 8px 14px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            min-height: 200px;
            user-select: text;
            -webkit-user-select: text;
        }

        /* ★ 滚动条默认隐藏，hover 或有内容溢出时显示 */
        .agent-messages::-webkit-scrollbar {
            width: 6px;
        }

        .agent-messages::-webkit-scrollbar-track {
            background: transparent;
        }

        .agent-messages::-webkit-scrollbar-thumb {
            background: transparent;
            border-radius: 3px;
            transition: background 0.2s;
        }

        .agent-messages:hover::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.15);
        }

        .agent-messages::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.25);
        }

        .agent-empty {
            margin: auto;
            color: rgba(255,255,255,0.24);
            font-size: 13px;
            letter-spacing: 0.04em;
        }

        .agent-msg {
            max-width: 88%;
            padding: 10px 12px;
            border-radius: 12px;
            line-height: 1.6;
            white-space: pre-wrap;
            word-break: break-word;
            font-size: 13px;
            user-select: text;
            -webkit-user-select: text;
            cursor: text;
        }

        .agent-msg.user {
            align-self: flex-end;
            background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
            color: #fff7ec;
            border-bottom-right-radius: 4px;
            box-shadow: 0 10px 24px rgba(255,168,79,0.16);
        }

        .agent-msg.assistant {
            align-self: flex-start;
            background: linear-gradient(180deg, rgba(34,38,45,0.84), rgba(29,34,42,0.84));
            color: #edf2fb;
            border-bottom-left-radius: 4px;
            border: 1px solid rgba(69,72,78,0.18);
        }

        .agent-msg.system {
            align-self: center;
            background: rgba(255,255,255,0.04);
            color: #9fb0d4;
            font-size: 12px;
        }

        /* ===== Agent 消息气泡包装层（含复制按钮）===== */
        .agent-msg-wrapper {
            display: flex;
            align-items: flex-end;
            gap: 6px;
            max-width: 100%;
            user-select: text;
            -webkit-user-select: text;
        }

        .agent-msg-wrapper.user {
            flex-direction: row-reverse;
            align-self: flex-end;
        }

        .agent-msg-wrapper.assistant,
        .agent-msg-wrapper.system {
            flex-direction: row;
            align-self: flex-start;
        }

        .agent-msg-wrapper .agent-msg {
            max-width: 100%;
        }

        /* 复制按钮：默认隐藏，悬停父级时显示 */
        .agent-msg-copy-btn {
            flex-shrink: 0;
            opacity: 0;
            transition: opacity 0.15s;
            background: rgba(255,255,255,0.07);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 6px;
            padding: 5px 6px;
            cursor: pointer;
            color: #9fb0d4;
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 1;
            margin-bottom: 2px;
        }

        .agent-msg-wrapper:hover .agent-msg-copy-btn {
            opacity: 1;
        }

        .agent-msg-copy-btn:hover {
            background: rgba(255,255,255,0.12);
            color: #e0e6f0;
        }

        /* 文件消息样式 */
        .agent-msg-file {
            max-width: 260px;
        }

        .agent-file-header {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 12px;
            font-weight: 600;
            margin-bottom: 6px;
            color: #c8d8f0;
        }

        .agent-file-preview {
            font-size: 11px;
            color: #7a8da8;
            line-height: 1.5;
            max-height: 80px;
            overflow: hidden;
            white-space: pre-wrap;
            word-break: break-all;
        }

        /* 右键菜单 */
        .agent-ctx-menu {
            background: #1e2738;
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 8px;
            padding: 4px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.4);
            min-width: 140px;
        }

        .agent-ctx-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 7px 10px;
            border-radius: 5px;
            font-size: 13px;
            color: #c8d8f0;
            cursor: pointer;
        }

        .agent-ctx-item:hover {
            background: rgba(255,255,255,0.08);
        }

        /* ===== Agent 附件引用栏 ===== */
        .agent-attachments-bar {
            display: none;
            flex-wrap: wrap;
            gap: 8px;
            padding: 8px 12px 0;
        }
        .agent-attachments-bar.has-attachments {
            display: flex;
        }
        .agent-attach-item {
            position: relative;
            border-radius: 8px;
            overflow: hidden;
            border: 1px solid rgba(69,72,78,0.22);
            background: rgba(34,38,45,0.72);
            cursor: pointer;
            flex-shrink: 0;
        }
        .agent-attach-item img {
            display: block;
            width: 56px;
            height: 56px;
            object-fit: cover;
            border-radius: 7px;
        }
        .agent-attach-file {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 8px;
            max-width: 160px;
            cursor: default;
        }
        .agent-attach-file-icon {
            flex-shrink: 0;
            color: rgba(160,185,230,0.7);
        }
        .agent-attach-file-name {
            font-size: 11px;
            color: #a8bdd8;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 110px;
        }
        .agent-attach-media {
            width: 48px;
            height: 48px;
            border-radius: 8px;
            background: rgba(255,255,255,0.05);
            cursor: default;
        }
        .agent-attach-media .agent-attach-media-preview {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: inherit;
            background: rgba(10,14,24,0.92);
        }
        .agent-attach-media-badge {
            position: absolute;
            left: 4px;
            bottom: 4px;
            display: inline-flex;
            align-items: center;
            gap: 2px;
            padding: 2px 4px;
            border-radius: 999px;
            background: rgba(10,14,24,0.72);
            color: rgba(235,241,252,0.95);
            font-size: 6px;
            line-height: 1;
            backdrop-filter: blur(10px);
            pointer-events: none;
        }
        .agent-attach-media-badge svg {
            width: 8px;
            height: 8px;
        }
        .agent-attach-remove {
            position: absolute;
            top: 4px;
            right: 4px;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: rgba(14,18,28,0.88);
            border: 1px solid rgba(255,255,255,0.15);
            color: rgba(200,210,230,0.9);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 1;
            transition: background 0.15s ease, transform 0.15s ease;
            z-index: 5;
        }
        .agent-attach-remove:hover {
            background: rgba(255,80,80,0.8);
            transform: scale(1.06);
        }

        .agent-input-area {
            display: flex;
            flex-direction: column;
            border-top: 1px solid rgba(69,72,78,0.18);
            flex-shrink: 0;
            margin-top: 2px;
            background: linear-gradient(180deg, rgba(16,20,25,0.7), rgba(11,14,19,0.92));
        }

        /* ===== Agent 输入区域顶部滑块 ===== */
        .agent-input-resize-bar {
            height: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            cursor: ns-resize;
            flex-shrink: 0;
            width: 100%;
        }

        .agent-input-resize-bar:hover {
            background: rgba(255,255,255,0.03);
        }

        .agent-resize-handle-inner {
            width: 50px;
            height: 4px;
            background: rgba(255,255,255,0.15);
            border-radius: 2px;
            transition: all 0.2s;
        }

        .agent-input-resize-bar:hover .agent-resize-handle-inner {
            background: rgba(255,255,255,0.3);
            width: 60px;
            height: 4px;
        }

        .agent-input-resize-bar.is-resizing {
            background: rgba(255,179,71,0.08);
        }

        .agent-input-resize-bar.is-resizing .agent-resize-handle-inner {
            background: rgba(255,179,71,0.6);
            width: 70px;
        }

        /* 对话框区域可调整高度 */
        .agent-input-main {
            padding: 8px 12px 4px;
            background: rgba(255,255,255,0.015);
            min-height: 80px;
            max-height: 400px;
            overflow: hidden;
        }

        /* ★ 输入框滚动条：内容溢出时才显示，更细 */
        .agent-input-main::-webkit-scrollbar {
            width: 4px;
        }

        .agent-input-main::-webkit-scrollbar-track {
            background: transparent;
        }

        .agent-input-main::-webkit-scrollbar-thumb {
            background: transparent;
            border-radius: 2px;
        }

        .agent-input-main:hover::-webkit-scrollbar-thumb,
        .agent-input-main:focus-within::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.12);
        }

        .agent-input-main::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.2);
        }

        .agent-input {
            width: 100%;
            min-height: 46px;
            max-height: 300px;
            height: 100%;
            resize: none;
            border-radius: 10px;
            border: 1px solid rgba(69,72,78,0.22);
            background: linear-gradient(180deg, rgba(29,34,42,0.98), rgba(24,28,35,0.98));
            color: #f2f3f5;
            padding: 10px 12px;
            outline: none;
            font-size: 13px;
            line-height: 1.5;
            overflow-y: auto;
            overscroll-behavior: contain;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
            /* Firefox 滚动条 */
            scrollbar-width: thin;
            scrollbar-color: rgba(255,255,255,0.18) transparent;
        }

        /* WebKit 滚动条：可见但轻盈，支持鼠标滚轮 */
        .agent-input::-webkit-scrollbar {
            width: 8px;
        }

        .agent-input::-webkit-scrollbar-track {
            background: transparent;
            border-radius: 4px;
            margin: 4px 0;
        }

        .agent-input::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.14);
            border-radius: 4px;
            border: 2px solid transparent;
            background-clip: padding-box;
            min-height: 24px;
        }

        .agent-input:hover::-webkit-scrollbar-thumb,
        .agent-input:focus::-webkit-scrollbar-thumb {
            background: rgba(255,168,79,0.35);
            background-clip: padding-box;
        }

        .agent-input::-webkit-scrollbar-thumb:hover {
            background: rgba(255,168,79,0.55);
            background-clip: padding-box;
        }

        .agent-input:focus {
            border-color: rgba(255,168,79,0.4);
            box-shadow: 0 0 0 1px rgba(255,168,79,0.15);
        }

        /* 功能栏 */
        .agent-input-toolbar {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 12px 8px;
            background: rgba(255,255,255,0.015);
        }

        .agent-tool-btn {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255,255,255,0.04);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 8px;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.15s;
        }

        .agent-tool-btn svg {
            width: 20px;
            height: 20px;
        }

        .agent-tool-btn:hover {
            background: rgba(40,44,52,0.96);
            border-color: rgba(255,168,79,0.2);
            color: var(--text-primary);
        }

        .agent-toolbar-spacer {
            flex: 1;
        }

        .agent-send-btn {
            width: 46px;
            height: 46px;
            border: none;
            border-radius: 10px;
            background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
            color: #fff7ec;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s;
            box-shadow: 0 12px 28px rgba(255,168,79,0.24);
        }

        .agent-send-btn svg {
            width: 20px;
            height: 20px;
        }

        .agent-send-btn:hover {
            background: linear-gradient(135deg, #ffc163 0%, #ff9f1f 100%);
            transform: translateY(-1px);
            box-shadow: 0 16px 34px rgba(255,168,79,0.3);
        }

        .agent-send-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }


        .agent-typing {
            align-self: flex-start;
            color: #93a0be;
            font-size: 12px;
            padding: 0 4px;
        }

        .agent-fab {
            z-index: 40;
        }

        body.agent-open .agent-fab {
            display: none !important;
            opacity: 0 !important;
            pointer-events: none !important;
        }

        /* ===================== */
        /* Media Upload Nodes     */
        /* ===================== */

        .media-upload-box,
        .text-node-body {
            width: 260px;
            min-height: 220px;
            background: linear-gradient(180deg, rgba(255,255,255,0.030) 0%, rgba(255,255,255,0.012) 100%), rgba(28, 33, 40, 0.88);
            border: 0.5px solid rgba(255,168,79,0.08);
            border-radius: 18px;
            padding: 18px;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            gap: 12px;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.035), inset 0 -1px 0 rgba(255,255,255,0.012);
        }

        .upload-main-btn {
            align-self: center;
            min-width: 96px;
            height: 34px;
            border-radius: 10px;
            border: 0.5px solid rgba(255,168,79,0.18);
            background: rgba(255,255,255,0.03);
            color: var(--text-primary);
            cursor: pointer;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
        }

        .upload-main-btn:hover {
            background: rgba(255,168,79,0.10);
            border-color: rgba(255,168,79,0.30);
        }

        .upload-tip {
            text-align: center;
            color: var(--text-secondary);
            font-size: 12px;
            line-height: 1.6;
        }

        .upload-subtip {
            text-align: center;
            color: var(--text-tertiary);
            font-size: 11px;
            line-height: 1.5;
        }

        .image-upload-box.dragover,
        .video-upload-box.dragover {
            outline: 1px dashed rgba(255,168,79,0.68);
            background: rgba(255,168,79,0.08);
        }

        .image-preview-list {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;
            margin-top: 8px;
        }

        .image-preview-item {
            background: rgba(255,255,255,0.04);
            border: 0.5px solid rgba(255,168,79,0.08);
            border-radius: 10px;
            overflow: hidden;
            min-height: 72px;
        }

        .image-preview-thumb {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .image-preview-video {
            min-height: 72px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-secondary);
            font-size: 12px;
            padding: 10px;
            text-align: center;
        }

        .text-node-textarea {
            width: 100%;
            min-height: 240px;
            border: none;
            outline: none;
            resize: none;
            background: transparent;
            color: var(--text-primary);
            font-family: 'Manrope', sans-serif;
            font-size: 13px;
            line-height: 1.6;
        }

        .video-upload-top {
            display: flex;
            justify-content: center;
            margin-top: 4px;
        }

        .video-icon-btn {
            width: 48px;
            height: 48px;
            border-radius: 14px;
            border: 0.5px solid rgba(255,168,79,0.12);
            background: rgba(255,255,255,0.04);
            color: rgba(255,205,142,0.82);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
        }

        .video-frame-header {
            margin-top: 6px;
            display: flex;
            justify-content: space-between;
            color: var(--text-secondary);
            font-size: 12px;
        }

        .video-frame-box {
            margin-top: 4px;
            min-height: 160px;
            border-radius: 12px;
            border: 0.5px solid rgba(255,168,79,0.10);
            background: rgba(255,255,255,0.03);
            padding: 12px;
        }

        .video-frame-empty {
            color: var(--text-tertiary);
            font-size: 12px;
            text-align: center;
            margin-top: 48px;
        }

        .video-frame-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
        }

        .video-frame-item {
            height: 72px;
            border-radius: 10px;
            background: rgba(255,255,255,0.06);
            color: rgba(255,255,255,0.65);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
        }

        /* ===================== */
        /* Node Auto-Size Styles  */
        /* ===================== */

        .node.node-auto {
        width: auto !important;
        min-width: unset !important;
        max-width: none !important;
        height: auto !important;
        }

        .node.node-image-upload {
        width: 420px !important;
        min-height: 260px;
        }

        .node.node-text-input {
        width: 380px !important;
        min-height: 240px;
        }

        .node.node-video-upload {
        width: 420px !important;
        min-height: 300px;
        }

        .node.node-image-gen:not(.node-manual-resized) {
        width: 420px !important;
        min-height: 260px;
        }

        .node.node-storyboard {
        width: 420px !important;
        min-height: 260px;
        }

        .node.node-asset-extraction {
        width: 420px !important;
        min-height: 260px;
        }

        .node.node-multi-grid {
        width: 420px !important;
        min-height: 260px;
        }

        /* 用户手动拉伸后，不再被默认宽高覆盖 */
        .node.node-manual-resized.node-image-upload,
        .node.node-manual-resized.node-text-input,
        .node.node-manual-resized.node-video-upload,
        .node.node-manual-resized.node-image-gen,
        .node.node-manual-resized.node-storyboard,
        .node.node-manual-resized.node-asset-extraction,
        .node.node-manual-resized.node-multi-grid {
        width: var(--node-manual-width) !important;
        height: var(--node-manual-height) !important;
        max-width: none !important;
        min-width: 0 !important;
        }

        .node-image-upload .media-upload-box,
        .node-video-upload .media-upload-box,
        .node-text-input .text-node-body {
        width: 100%;
        box-sizing: border-box;
        }

        .node-text-input .text-node-textarea {
        min-height: 220px;
        }

        .node-video-upload .video-frame-box {
        min-height: 150px;
        }

        .node-image-upload .image-preview-list {
        width: 100%;
        }

        .media-upload-box,
        .text-node-body {
        min-height: auto !important;
        }

        /* ===================== */
        /* Node Port Styles       */
        /* ===================== */

        .node-with-ports {
        position: relative;
        }

        /* node-port base dot — overridden below with full hover button effect */

        /* ===================== */
        /* Unified Node Appearance */
        /* ===================== */

        .node-image-upload,
        .node-text-input,
        .node-video-upload {
        border-radius: var(--node-radius) !important;
        border: 1px solid var(--node-border);
        background: var(--node-bg) !important;
        box-shadow: var(--node-shadow);
        overflow: visible;
        }

        .node-image-upload .node-upload-header,
        .node-text-input .node-upload-header,
        .node-video-upload .node-upload-header {
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        font-size: 12px;
        border-bottom: 1px solid var(--border-color);
        }

        .node-image-upload .media-upload-box,
        .node-video-upload .media-upload-box,
        .node-text-input .text-node-body {
        background: transparent;
        border-radius: 0 0 var(--node-radius) var(--node-radius);
        padding: 18px;
        }

        /* ===================== */
        /* Node Selection State    */
        /* ===================== */
        /* 选中状态统一样式 */
        /* ===================== */

        .node.is-selected {
            outline: none;
            border-color: rgba(255,168,79,0.78);
            box-shadow:
                0 0 0 1px rgba(255,168,79,0.5),
                0 0 0 4px rgba(255,168,79,0.18),
                0 18px 46px rgba(0,0,0,0.5),
                0 0 30px rgba(255,168,79,0.16);
        }

        /* ===================== */
        /* Marquee Selection      */
        /* ===================== */
        .marquee-selection {
        position: absolute;
        border: 1px solid rgba(255,168,79, 0.9);
        background: rgba(255,168,79, 0.14);
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
        pointer-events: none;
        z-index: 30;
        }

        /* ===================== */
        /* Node Visual Polish      */
        /* ===================== */

        .node-image-upload .upload-label,
        .node-text-input .upload-label,
        .node-video-upload .upload-label {
        letter-spacing: 0.5px;
        }

        .node-image-upload .upload-main-btn,
        .node-video-upload .upload-main-btn {
        margin-top: 4px;
        }

        .node-text-input .text-node-textarea {
        padding-top: 4px;
        }

        /* ===================== */
        /* SVG Connection Layer   */
        /* ===================== */
        .connections-layer {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        overflow: visible;
        pointer-events: none;
        z-index: 1 !important;
        }

        .connection-path {
        fill: none;
        stroke: url(#connectionGradientSoft);
        stroke-width: var(--connection-stroke-width, 1.5);
        stroke-linecap: round;
        stroke-linejoin: round;
        vector-effect: non-scaling-stroke;
        stroke-dasharray: var(--connection-dasharray, 6 4);
        animation: var(--connection-animation, connectionFlow 15s linear infinite);
        opacity: var(--connection-opacity, 0.96);
        }

        .connection-path.active,
        .connection-path:hover {
        stroke: url(#connectionGradientActive);
        stroke-width: var(--connection-hover-stroke-width, 2);
        stroke-dasharray: none;
        filter: drop-shadow(0 0 8px rgba(255,168,79,0.34));
        }

        .connections-layer.is-distant-line-mode .connection-path {
        stroke: rgba(255, 178, 88, 0.42);
        filter: none;
        }

        .connections-layer.is-distant-line-mode .connection-path.active,
        .connections-layer.is-distant-line-mode .connection-path:hover {
        stroke: rgba(255, 190, 116, 0.56);
        filter: none;
        }

        @keyframes connectionFlow {
        from {
            stroke-dashoffset: 100;
        }
        to {
            stroke-dashoffset: 0;
        }
        }

        /* ===================== */
        /* Unified Node Theme    */
        /* ===================== */
        .node-theme-unified {
        background: var(--node-bg);
        backdrop-filter: blur(24px) saturate(150%);
        -webkit-backdrop-filter: blur(24px) saturate(150%);
        border: 0.5px solid var(--node-border);
        box-shadow: var(--node-shadow);
        border-radius: var(--node-radius);
        color: var(--text-primary);
        }

        .node-theme-unified .node-upload-header {
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        font-family: 'Inter', sans-serif;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        border-bottom: 0.5px solid var(--border-color);
        box-shadow: inset 0 -1px 0 rgba(255,255,255,0.015);
        }

        .node-theme-unified.is-selected {
        outline: none;
        border-color: rgba(255,168,79,0.56);
        box-shadow:
            0 0 0 1px rgba(255,168,79,0.38),
            0 0 0 3px rgba(255,168,79,0.10),
            0 0 28px rgba(255,168,79,0.14),
            var(--node-shadow);
        }

        .node-theme-unified textarea,
        .node-theme-unified .text-node-textarea {
        color: var(--text-primary);
        background: transparent;
        }

        .node-theme-unified textarea::placeholder,
        .node-theme-unified .text-node-textarea::placeholder {
        color: var(--text-tertiary);
        }

        /* ===================== */
        /* Inherited Prompt Display */
        /* ===================== */
        .node-inherited-prompt {
        display: none;
        margin: 0 12px 10px 12px;
        padding: 8px 10px;
        min-height: 34px;
        background: rgba(255,255,255,0.03);
        border: 0.5px solid rgba(255,168,79,0.14);
        border-radius: 8px;
        font-size: 12px;
        line-height: 1.2;
        color: var(--text-secondary);
        align-items: center;
        }

        .node-inherited-label {
        display: none;
        }

        .node-inherited-text {
        display: block;
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #f3f5fa;
        font-size: 12px;
        }

        /* ===================== */
        /* Connection Ports       */
        /* ===================== */
        .node-with-ports {
        position: absolute;
        overflow: visible;
        }

        /* ===================== */
        /* Port Visibility System */
        /* ===================== */

        /* 默认完全隐藏 */
        /* ===================== */
        /* Connection Ports - Stable Final */
        /* ===================== */

        .node-with-ports {
        position: absolute;
        overflow: visible;
        }

        /* --- 端口 & 删除按钮 — 左10px圆点 + 右侧透明底 + 只高亮左侧接收端口 --- */
        /* --- 端口始终可点击（不依赖节点选中状态）--- */
        .node-port {
            pointer-events: auto !important;
            opacity: 0 !important;
            transition: opacity 0.2s ease !important;
        }

        .node-delete-btn {
            opacity: 0 !important;
            pointer-events: none !important;
            transition: opacity 0.2s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease !important;
        }

        /* --- 节点 hover / 选中 / 连线时 显示 --- */
        /* 拖线时只有源节点和目标节点的端口可见，其他节点端口保持隐藏 */
        .node:hover .node-port,
        .node:hover .node-delete-btn,
        .node.is-selected .node-port,
        .node.is-selected .node-delete-btn,
        body.is-connecting .node.connection-source .node-port,
        body.is-connecting .node.connection-target-highlight .node-port {
            opacity: 1 !important;
            pointer-events: auto !important;
        }

        /* 拖线时，非源/非目标节点即使 hover 也不显示端口（避免鼠标扫过时亮起） */
        body.is-connecting .node:hover:not(.connection-source):not(.connection-target-highlight) .node-port,
        body.is-connecting .node:hover:not(.connection-source):not(.connection-target-highlight) .node-delete-btn {
            opacity: 0 !important;
        }

        .node-port.snap-target,
        .node.connection-target-highlight .node-port {
            opacity: 1 !important;
            pointer-events: auto !important;
        }

        /* --- 端口基础 --- */
        .node-port {
            position: absolute !important;
            top: 50% !important;
            border-radius: 999px !important;
            background: transparent !important;
            border: 1.5px solid rgba(255, 168, 79, 0.28) !important;
            color: rgba(255, 205, 142, 0.72) !important;
            z-index: 9999 !important;
            cursor: crosshair !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            box-shadow: none !important;
            visibility: visible !important;
            transform: translateY(-50%) !important;
        }

        /* 左侧端口 - 20px 圆点（完全外置） */
        .node-port-left {
            left: -10px !important;
            right: auto !important;
            width: 20px !important;
            height: 20px !important;
            background: rgba(255, 168, 79, 0.12) !important;
            transform: translateX(-50%) translateY(-50%) !important;
            box-shadow: 0 0 0 1px rgba(255,168,79,0.08), inset 0 1px 0 rgba(255,255,255,0.06) !important;
        }

        .node-port-left::after {
            display: none !important;
        }

        /* 左侧接收高亮（只高亮小圆点） */
        .node-port-left:hover,
        .node-port-left.snap-target,
        .node.connection-target-highlight .node-port-left {
            border-color: rgba(255,179,71, 0.8) !important;
            background: rgba(255,179,71, 0.3) !important;
            box-shadow: 0 0 0 3px rgba(255,179,71, 0.15) !important, 0 0 12px rgba(255,168,79,0.32) !important;
            width: 20px !important;
            height: 20px !important;
            transform: translateX(-50%) translateY(-50%) !important;
        }

        /* 右侧端口 - 45px + 号 + 10% 白底（往右移 30px） */
        .node-port-right {
            right: -50px !important;
            left: auto !important;
            width: 45px !important;
            height: 45px !important;
            background: rgba(255, 168, 79, 0.12) !important;
            transform: translateX(50%) translateY(-50%) !important;
            box-shadow: 0 0 0 1px rgba(255, 168, 79, 0.12), inset 0 1px 0 rgba(255,255,255,0.06), 0 0 12px rgba(255,168,79,0.14), 0 10px 24px rgba(0, 0, 0, 0.20) !important;
        }

        .node-port-right::after {
            content: '+' !important;
            position: static !important;
            display: block !important;
            width: auto !important;
            height: auto !important;
            border: none !important;
            background: none !important;
            box-shadow: none !important;
            font-size: 25px !important;
            font-weight: 400 !important;
            line-height: 1 !important;
            color: inherit !important;
            opacity: 1 !important;
            transform: none !important;
            pointer-events: none !important;
        }

        /* 扩大右侧热区 */
        .node-port-right::before {
            content: '' !important;
            position: absolute !important;
            top: -18px !important;
            left: -18px !important;
            right: -18px !important;
            bottom: -18px !important;
            border-radius: 999px !important;
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
        }

        .node-port-right:hover {
            border-color: rgba(255,179,71, 0.8) !important;
            color: rgba(255, 255, 255, 0.95) !important;
            box-shadow: 0 0 0 3px rgba(255,179,71, 0.12) !important, 0 0 22px rgba(255,168,79,0.36) !important, 0 14px 30px rgba(0, 0, 0, 0.24) !important;
            background: rgba(255, 168, 79, 0.20) !important;
            width: 45px !important;
            height: 45px !important;
            transform: translateX(50%) translateY(-50%) !important;
        }

        body.selection-group-active .node.is-selected .node-port-right {
            opacity: 0 !important;
            pointer-events: none !important;
            box-shadow: none !important;
        }

        body.selection-group-active .node.is-selected .node-port-left,
        body.selection-group-active .node.is-selected .node-delete-btn {
            opacity: 0 !important;
            pointer-events: none !important;
            box-shadow: none !important;
        }

        /* 拖线时只高亮源节点和目标节点的端口，其他节点端口保持基础样式 */
        body.is-connecting .node.connection-source .node-port,
        body.is-connecting .node.connection-target-highlight .node-port {
            border-color: rgba(255,179,71, 0.7) !important;
            color: rgba(255, 255, 255, 0.8) !important;
            box-shadow: 0 0 0 2px rgba(255,168,79,0.08), 0 0 14px rgba(255,168,79,0.16) !important;
        }

        .node-port.port-near {
            border-color: rgba(200, 215, 240, 0.6) !important;
        }

        /* --- 移除整个节点的接收高亮 --- */
        .node.connection-target-highlight {
            border-color: rgba(255,149,0, 0.3) !important;
            box-shadow: 0 0 0 1px rgba(255,149,0, 0.2) !important;
        }
        .image-main-preview {
        width: 100%;
        height: 190px;
        border-radius: 14px;
        border: 1px solid rgba(255,255,255,0.08);
        background: rgba(255,255,255,0.03);
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        margin-bottom: 12px;
        }

        .image-main-empty {
        color: rgba(219,231,255,0.35);
        font-size: 12px;
        }

        .image-main-preview-img,
        .image-main-preview-video {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        }

        /* ===================== */
        /* Video Main Preview    */
        /* ===================== */
        .video-main-preview {
        width: 100%;
        height: 180px;
        border-radius: 14px;
        border: 1px solid rgba(255,255,255,0.08);
        background: rgba(255,255,255,0.03);
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        margin-bottom: 12px;
        }

        .video-main-empty {
        color: rgba(219,231,255,0.35);
        font-size: 12px;
        }

        .video-main-player {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        }

        /* ===================== */
        /* Unified Node Widths   */
        /* ===================== */
        .node-image-upload,
        .node-text-input,
        .node-video-upload,
        .node-image-gen,
        .node-storyboard,
        .node-asset-extraction,
        .node-multi-grid {
        background: var(--node-bg) !important;
        border: 1px solid var(--node-border) !important;
        border-radius: var(--node-radius) !important;
        box-shadow: var(--node-shadow) !important;
        color: var(--text-primary);
        }

        .node-image-upload,
        .node-text-input,
        .node-video-upload {
            width: 390px !important;
        }

        .node-image-gen,
        .node-storyboard,
        .node-asset-extraction,
        .node-multi-grid {
            width: 410px !important;
        }

        /* ===================== */
        /* Agent Header Icon Btns */
        /* ===================== */
        .agent-header-icon-btn {
            position: relative;
            width: 30px;
            height: 30px;
            min-width: 30px;
            min-height: 30px;
            border-radius: 8px;
            border: 1px solid rgba(255, 255, 255, 0.06);
            background: rgba(255, 255, 255, 0.035);
            color: #d9deea;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
            padding: 0;
        }

        .agent-header-icon-btn:hover {
            background: rgba(255, 255, 255, 0.07);
            border-color: rgba(255,168,79,0.18);
            color: #fff7ec;
        }

        .agent-header-icon-btn:active {
            background: rgba(255, 255, 255, 0.18);
            transform: scale(0.92);
            color: #fff;
        }

        .agent-header-icon-btn svg,
        .agent-header-icon-btn svg * {
            pointer-events: none;
        }

        .agent-header-icon-btn svg {
            width: 14px;
            height: 14px;
        }

        .agent-panel-actions {
            display: flex;
            gap: 4px;
            align-items: center;
        }

        /* Agent 面板左侧缩放手柄 */
        .agent-resize-handle {
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 6px;
            cursor: ew-resize;
            z-index: 10;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s ease;
        }

        .agent-resize-handle::after {
            content: '';
            width: 3px;
            height: 40px;
            border-radius: 3px;
            background: rgba(255,255,255,0.08);
            transition: background 0.15s ease, height 0.15s ease;
        }

        .agent-resize-handle:hover::after {
            background: rgba(255,255,255,0.22);
            height: 56px;
        }

        .agent-resize-handle:active::after {
            background: rgba(255,168,79,0.5);
            height: 64px;
        }

        .fab.agent-fab {
            width: 44px !important;
            height: 44px !important;
            background: linear-gradient(135deg, #ff9500 0%, #e07800 100%) !important;
            border: 1px solid rgba(255,168,79,0.26) !important;
            box-shadow: 0 8px 20px rgba(255, 168, 79, 0.22),
                        0 0 18px rgba(255,149,0,0.14),
                        0 4px 12px rgba(0, 0, 0, 0.24) !important;
            padding: 0 !important;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .fab.agent-fab:hover {
            transform: translateY(-2px) scale(1.05);
            box-shadow: 0 10px 28px rgba(255, 168, 79, 0.28),
                        0 0 24px rgba(255,149,0,0.18),
                        0 6px 16px rgba(0, 0, 0, 0.28) !important;
            background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%) !important;
        }

        .fab.agent-fab:active {
            transform: translateY(0) scale(1.02);
        }

        .fab.agent-fab svg {
            width: 18px !important;
            height: 18px !important;
            display: block;
        }

        body.agent-open .agent-fab {
            display: none !important;
            opacity: 0 !important;
            pointer-events: none !important;
        }

        /* ===================== */
        /* Unified Node Tags      */
        /* ===================== */

        /* 节点顶部标签统一暗色 */
        .node-tag {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 4px 10px;
            border-radius: 6px;
            font-size: 11px;
            font-weight: 500;
            background: rgba(255, 255, 255, 0.06) !important;
            color: var(--text-secondary) !important;
            border: 1px solid rgba(255, 255, 255, 0.08);
        }

        /* 节点头部区域统一 */
        .node-image-gen .node-upload-header,
        .node-storyboard .node-upload-header,
        .node-asset-extraction .node-upload-header,
        .node-multi-grid .node-upload-header {
            height: 34px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-secondary);
            font-size: 12px;
            border-bottom: 1px solid var(--border-color);
            background: transparent;
        }

        /* 节点输入区域统一暗色 */
        .node-image-gen .node-input-section,
        .node-storyboard .node-input-section,
        .node-asset-extraction .node-input-section,
        .node-multi-grid .node-input-section {
            background: transparent;
            border-top: 1px solid rgba(255, 255, 255, 0.06);
        }

        /* 节点内部按钮统一暗色 */
        .node-image-gen .param-item,
        .node-storyboard .param-item,
        .node-asset-extraction .param-item,
        .node-multi-grid .param-item {
            background: rgba(255, 255, 255, 0.06);
            color: var(--text-secondary);
            border: none;
        }

        .node-image-gen .param-item:hover,
        .node-storyboard .param-item:hover,
        .node-asset-extraction .param-item:hover,
        .node-multi-grid .param-item:hover {
            background: rgba(255, 255, 255, 0.10);
            color: var(--text-primary);
        }

        /* 发送/生成按钮保持暗色 */
        .node-image-gen .send-btn,
        .node-storyboard .send-btn,
        .node-asset-extraction .send-btn,
        .node-multi-grid .send-btn {
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-secondary);
        }

        .node-image-gen .send-btn:hover,
        .node-storyboard .send-btn:hover,
        .node-asset-extraction .send-btn:hover,
        .node-multi-grid .send-btn:hover {
            background: rgba(255, 255, 255, 0.14);
            color: var(--text-primary);
        }

        /* 节点内所有文本区域 */
        .node-image-gen .node-textarea,
        .node-storyboard .node-textarea,
        .node-asset-extraction .node-textarea,
        .node-multi-grid .node-textarea {
            background: transparent;
            color: var(--text-primary);
        }

        /* 开关栏统一 */
        .node-image-gen .node-toggle,
        .node-storyboard .node-toggle,
        .node-asset-extraction .node-toggle,
        .node-multi-grid .node-toggle {
            border-top-color: rgba(255, 168, 79, 0.10);
            color: var(--text-secondary);
        }

        /* 图片框统一 */
        .node-image-gen .node-image-box {
            background: rgba(255, 255, 255, 0.03);
            border-color: rgba(255, 168, 79, 0.10);
            width: auto !important;
            max-width: calc(100% - 24px) !important;
            aspect-ratio: 16 / 10;
            overflow: hidden;
            box-sizing: border-box;
            /* 硬性上限：防止任何代码路径（包括老快照没 cap）把 imageBox 拉超 280px
               撑破节点边界。所有 JS 设的 aspect-ratio/height 都受此 !important 约束。*/
            max-height: 280px !important;
        }

        /* 图片框内部元素自适应 */
        .node-image-gen .node-image-box .image-placeholder,
        .node-image-gen .node-image-box .image-loading {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .node-image-gen .node-image-box img,
        .node-image-gen .node-image-box video {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
            border-radius: 8px;
        }

        /* 手动缩放后，图片框填充剩余空间 */
        .node.node-manual-resized.node-image-gen {
            display: flex;
            flex-direction: column;
            overflow: visible;
        }

        .node.node-manual-resized.node-image-gen .node-upload-header {
            flex-shrink: 0;
        }

        .node.node-manual-resized.node-image-gen .node-image-box {
            flex: 1 1 auto;
            min-height: 80px;
            aspect-ratio: unset !important;
            margin: 8px 12px !important;
        }

        .node.node-manual-resized.node-image-gen .node-input-section {
            flex-shrink: 0;
        }

        /* 统一 input-icon 背景 */
        .node-image-gen .input-icon,
        .node-storyboard .input-icon,
        .node-asset-extraction .input-icon,
        .node-multi-grid .input-icon {
            background: rgba(255, 255, 255, 0.06);
        }

        /* 统一 upload-btn 暗色 */
        .node-image-gen .upload-btn,
        .node-storyboard .upload-btn,
        .node-asset-extraction .upload-btn,
        .node-multi-grid .upload-btn {
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.08);
            color: var(--text-secondary);
        }

        .node-image-gen .upload-btn:hover,
        .node-storyboard .upload-btn:hover,
        .node-asset-extraction .upload-btn:hover,
        .node-multi-grid .upload-btn:hover {
            background: rgba(255, 255, 255, 0.10);
            color: var(--text-primary);
        }

        /* 统一 upload-label */
        .node-image-gen .upload-label,
        .node-storyboard .upload-label,
        .node-asset-extraction .upload-label,
        .node-multi-grid .upload-label {
            color: var(--text-secondary);
        }

        /* ===============================
        ImageGen 新版节点 UI
        =============================== */

        /* 比例选择栏 */
        .imagen-ratio-bar {
            display: flex;
            gap: 4px;
            margin-top: 8px;
            flex-wrap: wrap;
        }

        .ratio-chip {
            display: flex;
            align-items: center;
            gap: 3px;
            padding: 3px 8px;
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 6px;
            color: var(--text-tertiary);
            font-size: 11px;
            cursor: pointer;
            transition: all 0.15s;
        }

        .ratio-chip:hover {
            background: rgba(255,255,255,0.08);
            color: var(--text-secondary);
        }

        .ratio-chip.active {
            background: rgba(102,126,234,0.2);
            border-color: rgba(102,126,234,0.5);
            color: #a3b8ff;
        }

        /* 底部操作栏 */
        .imagen-bottom-bar {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid rgba(255,255,255,0.06);
        }

        .imagen-model-select-wrap {
            flex-shrink: 0;
        }

        .imagen-model-select {
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 6px;
            color: var(--text-secondary);
            font-size: 12px;
            padding: 4px 8px;
            cursor: pointer;
            min-width: 100px;
        }

        .imagen-model-select:focus {
            outline: none;
            border-color: rgba(102,126,234,0.5);
        }

        .imagen-chip-group {
            display: flex;
            gap: 6px;
            flex: 1;
        }

        .imagen-selector {
            display: flex;
            background: rgba(255,255,255,0.04);
            border-radius: 6px;
            overflow: hidden;
            border: 1px solid rgba(255,255,255,0.08);
        }

        .imagen-sel-btn {
            background: transparent;
            border: none;
            color: var(--text-tertiary);
            font-size: 11px;
            padding: 4px 8px;
            cursor: pointer;
            transition: all 0.15s;
            white-space: nowrap;
        }

        .imagen-sel-btn:hover {
            background: rgba(255,255,255,0.06);
            color: var(--text-secondary);
        }

        .imagen-sel-btn.active {
            background: rgba(102,126,234,0.25);
            color: #a3b8ff;
        }

        /* 生成按钮（螃蟹） */
        .imagen-generate-btn {
            width: 30px;
            height: 30px;
            min-width: 30px;
            min-height: 30px;
            border-radius: 8px;
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.10);
            color: var(--text-secondary);
            box-shadow: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            margin-left: auto;
            padding: 0;
            transition: all 0.15s ease;
        }

        .imagen-generate-btn:hover {
            background: rgba(255,255,255,0.12);
            color: var(--text-primary);
            border-color: rgba(255,255,255,0.18);
            transform: none;
            box-shadow: none;
        }

        .imagen-generate-btn:active {
            transform: scale(0.92);
        }

        /* =============================== */
        /* Script Editor Sidebar - Rebuilt  */
        /* =============================== */

        /* 标签页导航 */
        .editor-tab-nav {
            display: flex;
            align-items: center;
            gap: 0;
            padding: 0;
            border-bottom: 1px solid rgba(255,255,255,0.06);
            background: rgba(255,255,255,0.02);
            flex-shrink: 0;
            overflow-x: auto;
        }

        .editor-tab-btn {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding: 12px 4px 10px;
            background: transparent;
            border: none;
            border-bottom: 2px solid transparent;
            color: var(--text-tertiary);
            font-size: 11px;
            cursor: pointer;
            transition: all 0.15s ease;
            white-space: nowrap;
            min-width: 0;
        }

        .editor-tab-btn:hover {
            color: var(--text-secondary);
            background: rgba(255,255,255,0.03);
        }

        .editor-tab-btn.active {
            color: var(--text-primary);
            border-bottom-color: var(--text-primary);
        }

        .editor-tab-btn svg {
            width: 18px;
            height: 18px;
            flex-shrink: 0;
        }

        /* 标签页内容 */
        .editor-tab-content {
            display: none;
            flex: 1;
            overflow-y: auto;
            padding: 16px;
            flex-direction: column;
            gap: 16px;
            min-height: 0;
        }

        .editor-tab-content.active {
            display: flex;
        }

        /* project tab 不需要 padding，由 proj-list 自己控制 */
        .editor-tab-content[data-editor-tab="project"] {
            padding: 0;
            overflow: hidden;
            flex: 1;
            min-height: 0;
        }

        #projectPanelRoot {
            display: flex;
            flex-direction: column;
            gap: 16px;
            flex: 1;
            min-height: 0;
            padding: 16px;
            overflow: hidden;
        }

        #projectPanelRoot .editor-section {
            flex-shrink: 0;
        }

        #projectPanelRoot .editor-section:last-child {
            flex: 1;
            min-height: 0;
            overflow: hidden;
        }

        .project-panel-toolbar {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 10px 8px;
            margin: -16px -16px 2px;
            border-bottom: 1px solid rgba(255,255,255,0.06);
            flex-shrink: 0;
        }

        .project-panel-toolbar-primary,
        .project-panel-toolbar-secondary,
        .project-panel-toolbar-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            height: 32px;
            border-radius: 8px;
            font-size: 12px;
            font-family: inherit;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .project-panel-toolbar-primary {
            flex: 1;
            padding: 0 12px;
            background: rgba(255,168,79,0.14);
            border: 1px solid rgba(255,168,79,0.28);
            color: rgba(190,219,255,0.92);
        }

        .project-panel-toolbar-primary:hover {
            background: rgba(255,168,79,0.22);
            border-color: rgba(255,168,79,0.46);
            color: #eaf3ff;
        }

        .project-panel-toolbar-secondary {
            padding: 0 12px;
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.08);
            color: var(--text-secondary);
            white-space: nowrap;
        }

        .project-panel-toolbar-secondary:hover {
            background: rgba(255,255,255,0.1);
            color: var(--text-primary);
        }

        .project-panel-toolbar-icon {
            width: 32px;
            flex-shrink: 0;
            padding: 0;
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.08);
            color: rgba(255,255,255,0.52);
        }

        .project-panel-toolbar-icon:hover {
            background: rgba(255,255,255,0.1);
            color: rgba(255,255,255,0.82);
        }

        /* 通用区段 */
        .editor-section {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .editor-section-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .editor-section-label {
            font-size: 13px;
            font-weight: 500;
            color: var(--text-secondary);
        }

        /* 链接按钮 */
        .editor-link-btn {
            background: none;
            border: none;
            color: var(--accent-blue);
            font-size: 12px;
            cursor: pointer;
            padding: 0;
        }

        .editor-link-btn:hover {
            text-decoration: underline;
        }

        /* 文本域 */
        .editor-textarea {
            width: 100%;
            min-height: 140px;
            padding: 12px;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 10px;
            color: var(--text-primary);
            font-size: 13px;
            font-family: inherit;
            line-height: 1.6;
            resize: vertical;
            outline: none;
            transition: border-color 0.2s;
        }

        .editor-textarea:focus {
            border-color: rgba(255,255,255,0.18);
        }

        .editor-textarea::placeholder {
            color: var(--text-tertiary);
        }

        /* 行布局 */
        .editor-row {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
        }

        /* 图标 + 文字标签 */
        .editor-icon-label {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 13px;
            color: var(--text-secondary);
            white-space: nowrap;
            flex-shrink: 0;
        }

        .editor-icon-label svg {
            width: 14px;
            height: 14px;
            opacity: 0.7;
        }

        /* 下拉选择 */
        .editor-select {
            flex: 1;
            height: 34px;
            padding: 0 10px;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 13px;
            font-family: inherit;
            outline: none;
            cursor: pointer;
            appearance: none;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="%239aa6bf" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>');
            background-repeat: no-repeat;
            background-position: right 10px center;
            padding-right: 28px;
        }

        .editor-select option {
            background: var(--bg-secondary);
            color: var(--text-primary);
        }

        /* 数字输入 */
        .editor-number-input {
            width: 56px;
            height: 34px;
            padding: 0 8px;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 13px;
            font-family: inherit;
            text-align: center;
            outline: none;
        }

        .editor-number-input:focus {
            border-color: rgba(255,255,255,0.18);
        }

        /* 操作按钮 */
        .editor-action-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            height: 34px;
            padding: 0 14px;
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 8px;
            color: var(--text-secondary);
            font-size: 13px;
            font-family: inherit;
            cursor: pointer;
            transition: all 0.15s ease;
            white-space: nowrap;
        }

        .editor-action-btn:hover {
            background: rgba(255,255,255,0.10);
            color: var(--text-primary);
        }

        .editor-action-btn.accent {
            background: var(--accent-blue);
            border-color: var(--accent-blue);
            color: #fff;
        }

        .editor-action-btn.accent:hover {
            background: var(--accent-blue-hover);
        }

        .editor-action-btn.full {
            width: 100%;
            justify-content: center;
        }

        .editor-action-btn svg {
            width: 14px;
            height: 14px;
            flex-shrink: 0;
        }

        .editor-action-btn.flex-1 {
            flex: 1;
            justify-content: center;
        }

        /* 资产分组 */
        .editor-asset-group {
            display: flex;
            flex-direction: column;
            gap: 0;
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 10px;
            overflow: hidden;
        }

        .editor-asset-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 14px;
            font-size: 13px;
            color: var(--text-secondary);
            border-bottom: 1px solid rgba(255,255,255,0.04);
        }

        .editor-asset-row:last-child {
            border-bottom: none;
        }

        .editor-icon-plus {
            width: 24px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 6px;
            color: var(--text-secondary);
            font-size: 16px;
            cursor: pointer;
            transition: all 0.15s;
        }

        .editor-icon-plus:hover {
            background: rgba(255,255,255,0.10);
            color: var(--text-primary);
        }

        /* 空状态提示 */
        .editor-empty-hint {
            color: var(--text-tertiary);
            font-size: 12px;
            text-align: center;
            padding: 32px 16px;
        }

        .editor-list-empty {
            min-height: 120px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .project-panel-card {
            display: flex;
            flex-direction: column;
            gap: 10px;
            padding: 14px;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 12px;
            width: 100%;
            color: var(--text-primary);
            text-align: left;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .project-panel-card:hover,
        .project-panel-card:focus-visible {
            background: rgba(255,255,255,0.06);
            border-color: rgba(255,255,255,0.14);
            outline: none;
        }

        .project-panel-card.is-selected,
        .project-panel-item.is-selected {
            background: rgba(255,168,79,0.08);
            border-color: rgba(255,168,79,0.28);
            box-shadow: inset 0 0 0 1px rgba(255,168,79,0.08);
        }

        .project-panel-name {
            font-size: 15px;
            font-weight: 600;
            display: inline-block;
            flex: 0 1 auto;
            width: fit-content;
            max-width: 100%;
            align-self: flex-start;
            color: var(--text-primary);
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            cursor: text;
        }

        .project-panel-meta {
            font-size: 12px;
            color: var(--text-tertiary);
        }

        .project-panel-card-actions {
            display: flex;
            align-items: center;
            gap: 2px;
            margin-top: 2px;
        }

        .project-panel-action-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 20px;
            height: 20px;
            padding: 0;
            border: none;
            border-radius: 4px;
            background: transparent;
            box-shadow: none;
            appearance: none;
            -webkit-appearance: none;
            color: rgba(255,255,255,0.28);
            cursor: pointer;
            transition: color 0.12s ease, background 0.12s ease, transform 0.12s ease;
        }

        .project-panel-action-btn svg {
            width: 12px;
            height: 12px;
        }

        .project-panel-action-btn:hover,
        .project-panel-action-btn:focus-visible {
            color: rgba(255,255,255,0.72);
            background: rgba(255,255,255,0.06);
            outline: none;
        }

        .project-panel-action-btn:active {
            transform: translateY(1px);
        }

        .project-panel-action-btn.danger:hover,
        .project-panel-action-btn.danger:focus-visible {
            color: rgba(255,120,120,0.92);
            background: rgba(239,68,68,0.12);
        }

        .project-panel-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            overscroll-behavior: contain;
            padding-right: 4px;
        }

        .project-panel-item {
            display: flex;
            flex-direction: column;
            gap: 4px;
            width: 100%;
            padding: 12px 14px;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 10px;
            color: var(--text-primary);
            text-align: left;
            cursor: pointer;
            transition: all 0.15s ease;
            font-family: inherit;
        }

        .project-panel-item-main {
            display: flex;
            flex-direction: column;
            gap: 4px;
            width: 100%;
            padding: 0;
            background: none;
            border: none;
            color: inherit;
            text-align: left;
            cursor: pointer;
        }

        .project-panel-item:hover,
        .project-panel-item:focus-visible {
            background: rgba(255,255,255,0.06);
            border-color: rgba(255,255,255,0.14);
            outline: none;
        }

        .project-panel-item-actions {
            display: flex;
            gap: 8px;
            margin-top: 6px;
        }

        .project-panel-item-actions .editor-action-btn {
            flex: 1;
            justify-content: center;
            min-width: 0;
        }

        .project-panel-item-name-row {
            display: flex;
            align-items: center;
            gap: 8px;
            min-width: 0;
            cursor: default;
        }

        .project-panel-item-name {
            display: inline-block;
            flex: 0 1 auto;
            width: fit-content;
            max-width: 100%;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            cursor: text;
        }

        .project-panel-name-input {
            width: 100%;
            min-width: 0;
            padding: 1px 5px;
            border-radius: 4px;
            border: 1px solid rgba(255,168,79,0.35);
            background: rgba(255,168,79,0.12);
            color: rgba(255,255,255,0.92);
            font-size: 12px;
            font-weight: 500;
            font-family: inherit;
            outline: none;
        }

        .project-panel-card .project-panel-name-input {
            font-size: 15px;
            font-weight: 600;
        }

        .project-panel-pin-badge {
            flex-shrink: 0;
            padding: 2px 6px;
            border-radius: 999px;
            background: rgba(255,168,79,0.14);
            border: 1px solid rgba(255,168,79,0.24);
            color: rgba(188,219,255,0.9);
            font-size: 10px;
            line-height: 1.2;
        }

        .proj-ctx-menu {
            position: fixed;
            min-width: 220px;
            padding: 8px 0;
            background: rgba(20,24,34,0.98);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 14px;
            box-shadow: 0 16px 36px rgba(0,0,0,0.38);
            backdrop-filter: blur(18px);
            z-index: 3000;
        }

        .proj-ctx-item {
            width: 100%;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 16px;
            background: transparent;
            border: none;
            color: rgba(235,240,248,0.92);
            font-size: 13px;
            font-family: inherit;
            text-align: left;
            cursor: pointer;
            transition: background 0.12s ease, color 0.12s ease;
        }

        .proj-ctx-item:hover {
            background: rgba(255,255,255,0.06);
        }

        .proj-ctx-item.danger:hover {
            background: rgba(239,68,68,0.12);
            color: rgba(255,120,120,0.96);
        }

        .proj-ctx-item svg {
            flex-shrink: 0;
            opacity: 0.72;
        }

        .proj-ctx-divider {
            height: 1px;
            margin: 6px 12px;
            background: rgba(255,255,255,0.08);
        }

        .sidebar-stat-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 10px;
        }

        .sidebar-stat-card {
            display: flex;
            flex-direction: column;
            gap: 4px;
            padding: 12px;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 10px;
        }

        .sidebar-stat-value {
            font-size: 20px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .sidebar-stat-label {
            font-size: 12px;
            color: var(--text-tertiary);
        }

        .sidebar-mini-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .sidebar-mini-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            padding: 12px;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 10px;
        }

        .sidebar-mini-item-main {
            display: flex;
            flex-direction: column;
            gap: 4px;
            min-width: 0;
        }

        .sidebar-mini-item-title {
            font-size: 13px;
            font-weight: 500;
            color: var(--text-primary);
        }

        .sidebar-mini-item-meta {
            font-size: 12px;
            color: var(--text-tertiary);
            word-break: break-word;
        }

        .project-panel-item-name {
            font-size: 13px;
            font-weight: 500;
            color: var(--text-primary);
        }

        .project-panel-item-meta {
            font-size: 12px;
            color: var(--text-tertiary);
        }

        /* ===================== */
        /* 节点紧凑适配模式       */
        /* 目标：主界面不变，只缩小节点体积 */
        /* ===================== */

        /* 1) 统一缩小节点宽度 */
        .node-image-upload,
        .node-text-input,
        .node-video-upload {
            width: 320px !important;
        }

        .node-image-gen,
        .node-storyboard,
        .node-asset-extraction,
        .node-multi-grid {
            width: 340px !important;
        }

        /* 2) 缩小头部高度 */
        .node-image-gen .node-upload-header,
        .node-storyboard .node-upload-header,
        .node-asset-extraction .node-upload-header,
        .node-multi-grid .node-upload-header,
        .node-image-upload .node-upload-header,
        .node-text-input .node-upload-header,
        .node-video-upload .node-upload-header {
            height: 28px !important;
            font-size: 11px !important;
        }

        /* 3) 缩小主预览区域 */
        .image-main-preview {
            height: 140px !important;
            margin-bottom: 8px !important;
            border-radius: 12px !important;
        }

        .video-main-preview {
            height: 132px !important;
            margin-bottom: 8px !important;
            border-radius: 12px !important;
        }

        .node-image-box {
            margin: 0 12px 12px !important;
            border-radius: 10px !important;
            width: auto !important;
            max-width: 100% !important;
        }

        /* 4) 输入区整体收紧 */
        .node-input-section,
        .node-image-upload .media-upload-box,
        .node-video-upload .media-upload-box,
        .node-text-input .text-node-body {
            padding: 12px !important;
        }

        /* 5) 输入图标和文本缩小 */
        .input-icon {
            width: 30px !important;
            height: 30px !important;
            margin-bottom: 8px !important;
            border-radius: 7px !important;
        }

        .node-textarea,
        .text-node-textarea {
            font-size: 13px !important;
            line-height: 1.45 !important;
            margin-bottom: 8px !important;
        }

        .text-node-textarea {
            min-height: 180px !important;
        }

        /* 6) 继承提示条更紧凑 */
        .node-inherited-prompt {
            margin: 0 12px 10px 12px !important;
            padding: 8px 10px !important;
            min-height: 34px !important;
            background: rgba(255,255,255,0.03) !important;
            border: 1px solid rgba(255,255,255,0.14) !important;
            border-radius: 8px !important;
        }

        /* 7) 参数栏收紧 */
        .node-params {
            gap: 6px !important;
            margin-bottom: 8px !important;
        }

        .param-item {
            padding: 5px 8px !important;
            font-size: 11px !important;
            border-radius: 6px !important;
        }

        /* 8) 发送按钮缩小 */
        .send-btn {
            width: 28px !important;
            height: 28px !important;
            border-radius: 6px !important;
        }

        /* 9) toggle 区域更紧凑 */
        .node-toggle {
            padding-top: 8px !important;
            font-size: 12px !important;
        }

        /* 10) 开关尺寸微缩 */
        .switch {
            width: 40px !important;
            height: 22px !important;
        }

        .slider:before {
            width: 16px !important;
            height: 16px !important;
            left: 3px !important;
            bottom: 3px !important;
        }

        input:checked + .slider:before {
            transform: translateX(18px) !important;
        }

        /* 11) 上传节点内部区域压缩 */
        .media-upload-box,
        .text-node-body {
            gap: 10px !important;
            border-radius: 14px !important;
        }

        /* 12) 上传按钮缩小 */
        .upload-main-btn,
        .upload-btn {
            min-width: unset !important;
            height: 30px !important;
            padding: 0 10px !important;
            font-size: 12px !important;
            border-radius: 8px !important;
        }

        /* 13) 图片/视频预览缩小 */
        .video-frame-box {
            min-height: 110px !important;
            padding: 10px !important;
        }

        .video-frame-item {
            height: 58px !important;
            font-size: 11px !important;
        }

        .image-preview-item {
            min-height: 58px !important;
        }

        /* 14) port 样式已迁移到上方主样式块，此处注释保留占位 */
        /* 15) 整体阴影和圆角略收，视觉更利落 */
        .node,
        .node-theme-unified,
        .node-image-upload,
        .node-text-input,
        .node-video-upload,
        .node-image-gen,
        .node-storyboard,
        .node-asset-extraction,
        .node-multi-grid {
            border-radius: 14px !important;
            box-shadow: 0 10px 28px rgba(0,0,0,0.34) !important;
        }

        /* ===================== */
        /* Node Context Menu      */
        /* ===================== */
        .node-context-menu {
            /* 节点右键菜单对齐 .create-menu 的尺寸与配色（背景/边框/圆角/内边距/min-width 全从 .create-menu 继承） */
            z-index: 9999;
        }

        /* 连线hover高亮 */
        .connections-layer {
            pointer-events: none;
        }

        .connections-layer path[style*="pointer-events"] {
            pointer-events: stroke;
        }

        /* ===================== */
        /* Image Main Preview - 完整显示 */
        /* ===================== */
        .image-main-preview {
            width: 100%;
            min-height: 120px;
            max-height: none;
            height: auto;
            border-radius: 14px;
            border: 1px solid rgba(255,255,255,0.08);
            background: rgba(255,255,255,0.03);
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            margin-bottom: 12px;
        }

        .image-main-preview-img {
            width: 100%;
            height: auto;
            max-width: 100%;
            object-fit: contain;
            display: block;
            border-radius: 12px;
        }

        .image-main-preview-video {
            width: 100%;
            height: auto;
            max-width: 100%;
            object-fit: contain;
            display: block;
            border-radius: 12px;
        }

        .image-preview-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
            gap: 8px;
            margin-top: 8px;
        }

        .image-preview-item {
            background: rgba(255,255,255,0.04);
            border-radius: 10px;
            overflow: hidden;
            aspect-ratio: 1;
            position: relative;
        }

        .image-preview-thumb {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .video-main-preview {
            width: 100%;
            min-height: 120px;
            max-height: none;
            height: auto;
            border-radius: 14px;
            border: 1px solid rgba(255,255,255,0.08);
            background: rgba(255,255,255,0.03);
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            margin-bottom: 12px;
        }

        .video-main-player {
            width: 100%;
            height: auto;
            max-width: 100%;
            object-fit: contain;
            display: block;
            border-radius: 12px;
        }

        /* ===================== */
        /* Scissor Button        */
        /* ===================== */
        .conn-scissor-btn {
            position: fixed;
            width: 28px;
            height: 28px;
            background: rgba(15, 19, 28, 0.96);
            border: 1px solid rgba(255,255,255,0.10);
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
            z-index: 9999;
            transform: translate(-50%, -50%) scale(0.92);
            backdrop-filter: blur(10px);
            color: #c9d3e7;
            padding: 0;
        }

        .conn-scissor-btn.visible {
            opacity: 1;
            pointer-events: auto;
            transform: translate(-50%, -50%) scale(1);
        }

        .conn-scissor-btn:hover {
            background: rgba(239, 68, 68, 0.14);
            border-color: rgba(239, 68, 68, 0.55);
            color: #ff8c8c;
        }

        .conn-scissor-btn svg {
            width: 14px;
            height: 14px;
            pointer-events: none;
        }

        body.is-slicing,
        body.is-slicing * {
            cursor: crosshair !important;
        }

        /* ===================== */
        /* Single media mode     */
        /* ===================== */
        .node-image-upload .media-upload-box,
        .node-video-upload .media-upload-box {
            min-height: 220px;
        }

        .node-single-image,
        .node-single-video {
            width: 100%;
            min-height: 220px;
            border-radius: 14px;
            overflow: hidden;
            position: relative;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.06);
        }

        .node-single-image-img,
        .node-single-video-player {
            width: 100%;
            height: 100%;
            min-height: 220px;
            display: block;
            object-fit: contain;
            background: #0d1118;
        }

        .node-image-overlay,
        .node-video-overlay {
            position: absolute;
            top: 10px;
            right: 10px;
            display: flex;
            gap: 8px;
        }

        .node-image-replace-btn,
        .node-video-replace-btn {
            width: 32px;
            height: 32px;
            border: 1px solid rgba(255,255,255,0.12);
            background: rgba(12,15,20,0.82);
            color: #e8eefc;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            backdrop-filter: blur(8px);
            transition: all 0.15s ease;
        }

        .node-image-replace-btn:hover,
        .node-video-replace-btn:hover {
            background: rgba(255,168,79,0.18);
            border-color: rgba(255,168,79,0.45);
            color: #fff;
        }

        .media-upload-box.is-dragover {
            outline: 1px solid rgba(255,168,79,0.6);
            box-shadow: inset 0 0 0 1px rgba(255,168,79,0.25);
        }

        /* ===================== */
        /* Unified Node Widths - 移除固定宽度限制，让 resize 更流畅 */
        /* ===================== */

        /* ===================== */
        /* Text Node Styling      */
        /* ===================== */
        .node-text-input .node-upload-header {
            justify-content: center;
            height: 30px !important;
            font-size: 12px !important;
            color: var(--text-secondary);
        }

        .node-text-input .text-node-body {
            padding: 14px 14px 12px 14px !important;
        }

        .node-text-input .text-node-textarea {
            min-height: 210px !important;
        }

        /* ===================== */
        /* Node Resize - 统一边框系统 */
        /* ===================== */

        .node {
        position: absolute;
        transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
        will-change: transform;
        }

        .node.is-alt-detaching {
            transform: scale(0.65);
            box-shadow:
                0 10px 28px rgba(0,0,0,0.34),
                0 0 0 1px rgba(255,160,50,0.22);
            opacity: 0.96;
        }

        /* 端口在最上层 */
        .node-port {
            z-index: 9999 !important;
        }

        /* 视频节点内容区域不触发 resize */
        .node-video .video-preview,
        .node-video .video-upload-area,
        .node-video .video-controls {
            pointer-events: auto;
            z-index: 15;
        }

        /* ===================== */
        /* Delete Button  ×号 + 10% 白底  */
        /* ===================== */
        .node-delete-btn {
            position: absolute !important;
            top: -17px !important;
            right: -17px !important;
            width: 35px !important;
            height: 35px !important;
            border-radius: 999px !important;
            background: rgba(255, 168, 79, 0.12) !important;
            border: 1.5px solid rgba(255, 168, 79, 0.28) !important;
            color: rgba(255, 205, 142, 0.72) !important;
            font-size: 20px !important;
            line-height: 35px !important;
            z-index: 9999 !important;
            cursor: pointer !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            box-shadow: 0 0 0 1px rgba(255, 168, 79, 0.10), 0 0 12px rgba(255,168,79,0.14), 0 10px 24px rgba(0, 0, 0, 0.22) !important;
            visibility: visible !important;
            transform: none !important;
            padding: 0 !important;
        }

        /* 扩大删除按钮热区 */
        .node-delete-btn::before {
            content: '' !important;
            position: absolute !important;
            top: -10px !important;
            left: -10px !important;
            right: -10px !important;
            bottom: -10px !important;
            border-radius: 999px !important;
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
        }

        .node-delete-btn:hover {
            border-color: rgba(255,179,71, 0.8) !important;
            color: rgba(255, 255, 255, 0.95) !important;
            box-shadow: 0 0 0 3px rgba(255,179,71, 0.12) !important, 0 0 18px rgba(255,168,79,0.30) !important, 0 14px 30px rgba(0, 0, 0, 0.24) !important;
            background: rgba(255, 168, 79, 0.20) !important;
            width: 35px !important;
            height: 35px !important;
            top: -17px !important;
            right: -17px !important;
            font-size: 20px !important;
            line-height: 35px !important;
        }

        /* ===================== */
        /* Resize State          */
        /* ===================== */
        .node.is-resizing {
            user-select: none;
            border-color: rgba(255,168,79,0.85);
            box-shadow:
                0 0 0 1px rgba(255,168,79,0.6),
                0 0 0 4px rgba(255,168,79,0.22),
                0 16px 42px rgba(0,0,0,0.45),
                0 0 35px rgba(255,168,79,0.2);
        }

        /* 正在 resize 时，端口保持可见 */
        .node.is-resizing .node-port {
            opacity: 1 !important;
            pointer-events: auto !important;
        }

        /* 让内容区跟随拉伸 - 统一所有节点为 flex 布局 */
        .node {
        display: flex;
        flex-direction: column;
        overflow: visible;
        }

        .node .node-upload-header {
        flex-shrink: 0;
        }

        .node .media-upload-box,
        .node .text-node-body,
        .node .node-input-section,
        .node .node-body {
        flex: 1 1 auto;
        min-height: 0;
        height: auto;
        box-sizing: border-box;
        }

        .node.node-text-input .text-node-textarea {
        width: 100%;
        resize: none;
        box-sizing: border-box;
        }

        .node.node-image-upload .media-upload-box,
        .node.node-video-upload .media-upload-box {
        width: 100%;
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden;
        }

        .node.node-image-upload .node-single-image,
        .node.node-video-upload .node-single-video,
        .node.node-video-upload .video-workflow-shell,
        .node.node-video-upload .video-workflow-composer.is-preview-only,
        .node.node-video-upload .video-workflow-preview {
        width: 100%;
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden;
        }

        .node.node-image-upload .node-single-image-img,
        .node.node-video-upload .node-single-video-player,
        .node.node-video-upload .video-main-player {
        width: 100%;
        height: 100% !important;
        min-height: 0 !important;
        object-fit: contain;
        display: block;
        }

        /* ===================== */
        /* Zoom HUD              */
        /* ===================== */
        .zoom-hud {
        position: fixed;
        left: 50%;
        top: calc(100% - 88px);
        transform: translate(-50%, -50%) scale(0.92);
        min-width: 72px;
        height: 34px;
        padding: 0 12px;
        border-radius: 999px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(12, 16, 24, 0.88);
        border: 1px solid rgba(255,255,255,0.10);
        color: rgba(245,248,255,0.96);
        font-size: 13px;
        font-weight: 600;
        letter-spacing: 0.02em;
        box-shadow:
            0 12px 32px rgba(0,0,0,0.34),
            0 0 0 1px rgba(255,255,255,0.04) inset;
        backdrop-filter: blur(10px);
        pointer-events: none;
        opacity: 0;
        z-index: 300;
        transition:
            opacity 0.18s ease,
            transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
        }

        .zoom-hud.visible {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
        }

        /* ===================== */
        /* 悬浮面板基础样式 */
        /* ===================== */
        .floating-panel {
            position: fixed;
            z-index: 900;
            background: var(--bg-secondary, #121722);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 14px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.04);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            resize: none !important;
            min-width: 280px;
            min-height: 200px;
            max-width: 90vw;
            max-height: 90vh;
            backdrop-filter: blur(16px);
        }

        /* 悬浮面板顶部拖拽栏 */
        .floating-panel-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 14px;
            background: rgba(255,255,255,0.03);
            border-bottom: 1px solid rgba(255,255,255,0.06);
            cursor: grab;
            user-select: none;
            flex-shrink: 0;
        }

        .floating-panel-header:active {
            cursor: grabbing;
        }

        .floating-panel-title {
            font-size: 13px;
            font-weight: 600;
            color: var(--text-primary, #fff);
        }

        .floating-panel-actions {
            display: flex;
            gap: 6px;
        }

        .floating-panel-btn {
            width: 32px;
            height: 32px;
            min-width: 32px;
            min-height: 32px;
            border-radius: 6px;
            border: none;
            background: transparent;
            color: var(--text-secondary, #888);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s ease;
            position: relative;
        }

        .floating-panel-btn::before {
            content: '';
            position: absolute;
            inset: -4px;
            border-radius: 10px;
            z-index: -1;
        }

        .floating-panel-btn:hover {
            background: rgba(255,255,255,0.1);
            color: var(--text-primary, #fff);
        }

        /* 悬浮面板内容区 */
        .floating-panel-body {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            display: flex;
            flex-direction: column;
            min-height: 0;
        }

        /* =====================
        悬浮面板 Resize 手柄
        ===================== */
        .floating-panel {
            overflow: visible;
        }

        /* --- 四边手柄 --- */
        .resize-handle {
            position: absolute;
            z-index: 20;
        }

        .resize-edge-right {
            top: 8px;
            right: -3px;
            width: 6px;
            bottom: 8px;
        }

        .resize-edge-left {
            top: 8px;
            left: -3px;
            width: 6px;
            bottom: 8px;
        }

        .resize-edge-bottom {
            left: 8px;
            right: 8px;
            bottom: -3px;
            height: 6px;
        }

        .resize-edge-top {
            left: 8px;
            right: 8px;
            top: -3px;
            height: 6px;
        }

        /* --- 四角手柄 --- */
        .resize-corner-br {
            right: -4px;
            bottom: -4px;
            width: 16px;
            height: 16px;
        }

        .resize-corner-bl {
            left: -4px;
            bottom: -4px;
            width: 16px;
            height: 16px;
        }

        .resize-corner-tr {
            right: -4px;
            top: -4px;
            width: 16px;
            height: 16px;
        }

        .resize-corner-tl {
            left: -4px;
            top: -4px;
            width: 16px;
            height: 16px;
        }

        /* hover 时边缘高亮反馈 */
        .resize-edge-right:hover,
        .resize-edge-left:hover {
            background: linear-gradient(90deg, transparent, rgba(255, 168, 79, 0.3), transparent);
        }

        .resize-edge-top:hover,
        .resize-edge-bottom:hover {
            background: linear-gradient(180deg, transparent, rgba(255, 168, 79, 0.3), transparent);
        }

        .resize-corner-br:hover,
        .resize-corner-bl:hover,
        .resize-corner-tr:hover,
        .resize-corner-tl:hover {
            background: radial-gradient(circle, rgba(255, 168, 79, 0.3), transparent);
        }

        /* --- 右下角可视化指示图标 --- */
        .resize-indicator {
            position: absolute;
            right: 4px;
            bottom: 4px;
            width: 14px;
            height: 14px;
            pointer-events: none;
            opacity: 0.4;
            transition: opacity 0.2s;
            z-index: 15;
        }

        .floating-left-panel:hover .resize-indicator,
        .floating-right-panel:hover .resize-indicator,
        .floating-panel:hover .resize-indicator {
            opacity: 0.8;
        }

        /* 左侧悬浮面板特定样式 */
        .floating-left-panel {
            left: 80px;
            top: 60px;
            width: 400px;
            height: 560px;
        }

        /* 右侧悬浮 Agent 面板特定样式 */
        .floating-agent-panel {
            right: 60px;
            top: 60px;
            width: 320px;
            height: 620px;
        }

        .floating-resize-edge {
            position: absolute;
            z-index: 18;
            background: transparent;
        }

        .floating-resize-bottom {
            left: 16px;
            right: 16px;
            bottom: -4px;
            height: 10px;
            cursor: ns-resize;
        }

        .floating-resize-bottom-left,
        .floating-resize-bottom-right {
            bottom: -4px;
            width: 18px;
            height: 18px;
        }

        .floating-resize-bottom-left {
            left: -4px;
            cursor: nesw-resize;
        }

        .floating-resize-bottom-right {
            right: -4px;
            cursor: nwse-resize;
        }

        .floating-resize-bottom-left::after,
        .floating-resize-bottom-right::after,
        .floating-resize-bottom::after {
            content: "";
            position: absolute;
            border-radius: 999px;
            background: rgba(255,255,255,0.08);
            opacity: 0;
            transition: opacity 0.18s ease, background 0.18s ease;
        }

        .floating-resize-bottom-left::after,
        .floating-resize-bottom-right::after {
            width: 10px;
            height: 10px;
            border: 2px solid rgba(255,255,255,0.12);
            border-top: none;
            border-radius: 0 0 10px 0;
            background: transparent;
            bottom: 3px;
        }

        .floating-resize-bottom-left::after {
            left: 3px;
            border-right: none;
            border-radius: 0 0 0 10px;
        }

        .floating-resize-bottom-right::after {
            right: 3px;
        }

        .floating-resize-bottom::after {
            left: 50%;
            bottom: 2px;
            width: 72px;
            height: 4px;
            transform: translateX(-50%);
        }

        .floating-panel:hover .floating-resize-edge::after {
            opacity: 1;
        }

        .floating-resize-edge:hover::after {
            background: rgba(255,255,255,0.22);
        }

        .floating-resize-bottom-left:hover::after,
        .floating-resize-bottom-right:hover::after {
            background: transparent;
            border-color: rgba(255,255,255,0.24);
        }

        /* 悬浮面板里的编辑器容器 */
        .floating-panel-body .editor-container {
            border-radius: 0;
            border: none;
            box-shadow: none;
            background: transparent;
        }

        /* 悬浮面板里的 tab nav 紧贴顶部 */
        .floating-panel-body .editor-tab-nav {
            border-radius: 0;
            position: sticky;
            top: 0;
            z-index: 5;
            background: rgba(14, 18, 27, 0.98);
        }

        /* ===== 存储管理页面样式 ===== */
        .storage-section {
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 16px;
        }

        .storage-section-header {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 16px;
        }

        .storage-section-header h3 {
            font-size: 15px;
            font-weight: 600;
            color: #4ecb71;
            margin: 0;
        }

        .storage-section-header svg {
            color: #4ecb71;
            flex-shrink: 0;
        }

        .storage-badge {
            font-size: 11px;
            padding: 2px 8px;
            border-radius: 10px;
            font-weight: 500;
        }

        .storage-badge.enabled {
            background: rgba(78,203,113,0.12);
            color: #4ecb71;
        }

        .storage-badge.disabled {
            background: rgba(255,100,100,0.12);
            color: #ff6464;
        }

        .storage-field-row {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 12px;
        }

        .storage-field-row label {
            font-size: 13px;
            color: #888;
            white-space: nowrap;
            min-width: 100px;
        }

        .storage-btn-row {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .storage-hint {
            font-size: 12px;
            color: #666;
            margin-top: 10px;
            line-height: 1.6;
        }

        /* 内存信息 */
        .memory-info {
            margin-bottom: 16px;
        }

        .memory-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 6px 0;
            font-size: 13px;
            color: #aaa;
        }

        .memory-value {
            color: #4ecb71;
            font-weight: 600;
            font-size: 13px;
        }

        .memory-bar {
            height: 6px;
            background: rgba(255,255,255,0.06);
            border-radius: 3px;
            margin: 6px 0 12px;
            overflow: hidden;
        }

        .memory-bar-fill {
            height: 100%;
            background: linear-gradient(90deg, #4ecb71, #36a85c);
            border-radius: 3px;
            transition: width 0.3s ease;
        }

        /* 通用按钮 */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.15s, transform 0.1s;
            white-space: nowrap;
        }

        .btn:active {
            transform: scale(0.97);
        }

        .btn-success {
            background: #22a352;
            color: #fff;
            border: none;
        }

        .btn-success:hover {
            background: #1d8f47;
        }

        .btn-danger {
            background: #dc3545;
            color: #fff;
            border: none;
        }

        .btn-danger:hover {
            background: #c82333;
        }

        .btn-outline {
            background: transparent;
            color: #ccc;
            border: 1px solid rgba(255,255,255,0.12);
        }

        .btn-outline:hover {
            background: rgba(255,255,255,0.06);
        }

        .btn-danger-outline {
            color: #ff6464;
            border-color: rgba(255,100,100,0.25);
        }

        .btn-danger-outline:hover {
            background: rgba(255,100,100,0.08);
        }

        .btn-block {
            width: 100%;
        }

        .btn-primary {
            background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
            color: #fff7ec;
            border: none;
        }

        .btn-primary:hover {
            background: linear-gradient(135deg, #ffc163 0%, #ff9f1f 100%);
        }

        /* Toggle 开关 */
        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 36px;
            height: 20px;
        }

        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(255,255,255,0.1);
            border-radius: 20px;
            transition: background 0.2s;
        }

        .toggle-slider::before {
            content: '';
            position: absolute;
            width: 16px;
            height: 16px;
            left: 2px;
            bottom: 2px;
            background: white;
            border-radius: 50%;
            transition: transform 0.2s;
        }

        .toggle-switch input:checked + .toggle-slider {
            background: #ffa84f;
        }

        .toggle-switch input:checked + .toggle-slider::before {
            transform: translateX(16px);
        }

        .zoom-hud {
            display: none !important;
        }

        /* ===== 顶栏右侧按钮组 ===== */
        .top-bar-btn {
            display: flex;
            align-items: center;
            gap: 5px;
            height: 30px;
            padding: 0 10px;
            background: rgba(255,255,255,0.025);
            border: 1px solid transparent;
            border-radius: 6px;
            color: #a9abb2;
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
            white-space: nowrap;
        }

        .top-bar-btn:hover {
            background: rgba(255,255,255,0.05);
            border-color: rgba(255,168,79,0.14);
            color: #f5f1ea;
            transform: translateY(-1px);
        }

        .top-bar-btn.active {
            background: rgba(255,168,79,0.12);
            border-color: rgba(255,168,79,0.18);
            color: #ffb347;
        }

        .top-bar-btn svg {
            width: 14px;
            height: 14px;
            flex-shrink: 0;
        }

        .top-bar-btn.zoom-display {
            font-variant-numeric: tabular-nums;
            min-width: 62px;
            justify-content: center;
        }

        .top-bar-divider {
            width: 1px;
            height: 18px;
            background: rgba(255,255,255,0.06);
            margin: 0 2px;
            flex-shrink: 0;
        }

        .top-account {
            position: relative;
            flex-shrink: 0;
        }

        .top-account-trigger {
            display: inline-flex;
            align-items: center;
            gap: 7px;
            height: 30px;
            max-width: 190px;
            padding: 0 8px 0 3px;
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 999px;
            background: rgba(255,255,255,0.03);
            color: var(--text-primary);
            cursor: pointer;
            transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
        }

        .top-account-trigger:hover,
        .top-account.is-open .top-account-trigger {
            background: rgba(255,255,255,0.06);
            border-color: rgba(255,168,79,0.20);
            transform: translateY(-1px);
        }

        .top-account-avatar {
            width: 24px;
            height: 24px;
            display: grid;
            place-items: center;
            border-radius: 50%;
            background: linear-gradient(135deg, rgba(255,179,71,0.96), rgba(255,149,0,0.96));
            color: rgba(20,16,10,0.94);
            font-size: 10px;
            font-weight: 800;
            letter-spacing: 0;
            box-shadow: 0 0 12px rgba(255,168,79,0.16);
            flex-shrink: 0;
        }

        .top-account-name {
            min-width: 0;
            max-width: 118px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 12px;
            font-weight: 500;
            color: rgba(245,246,254,0.88);
        }

        .top-account-chevron {
            width: 12px;
            height: 12px;
            color: var(--text-tertiary);
            transition: transform 0.15s ease;
            flex-shrink: 0;
        }

        .top-account.is-open .top-account-chevron {
            transform: rotate(180deg);
        }

        .top-account-menu {
            position: fixed;
            top: 48px;
            right: 24px;
            width: 238px;
            padding: 8px;
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 14px;
            background: rgba(16, 20, 25, 0.97);
            box-shadow: 0 18px 44px rgba(0,0,0,0.42), 0 0 30px rgba(255,149,0,0.04);
            backdrop-filter: blur(16px);
            z-index: 10000;
            pointer-events: auto;
            opacity: 1;
            transform: translateY(0);
            transition: opacity 0.15s ease, transform 0.15s ease;
        }

        .top-account-menu.hidden {
            opacity: 0;
            pointer-events: none;
            transform: translateY(-6px);
        }

        .top-account-menu-header {
            display: flex;
            flex-direction: column;
            gap: 4px;
            padding: 10px 10px 9px;
        }

        .top-account-menu-label {
            font-size: 11px;
            font-weight: 400;
            color: var(--text-tertiary);
        }

        .top-account-menu-header strong {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: rgba(245,246,254,0.86);
            font-size: 12px;
            font-weight: 500;
        }

        .top-account-menu-header small {
            color: rgba(46, 160, 67, 0.78);
            font-size: 11px;
            font-weight: 400;
        }

        .top-account-profile {
            display: flex;
            flex-direction: column;
            gap: 6px;
            margin: 0 4px 7px;
            padding: 9px 10px;
            border: 1px solid rgba(255,255,255,0.05);
            border-radius: 10px;
            background: rgba(255,255,255,0.025);
        }

        .top-account-profile-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            min-height: 20px;
            font-size: 11px;
            color: var(--text-tertiary);
        }

        .top-account-profile-row strong {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: rgba(245,246,254,0.78);
            font-size: 11px;
            font-weight: 500;
            text-align: right;
        }

        .top-account-usage {
            display: flex;
            flex-direction: column;
            gap: 7px;
            margin: 0 4px 7px;
            padding: 9px 10px 10px;
            border: 1px solid rgba(255,255,255,0.05);
            border-radius: 10px;
            background: rgba(255,255,255,0.018);
        }

        .top-account-redeem-entry {
            width: calc(100% - 8px);
            min-height: 34px;
            display: grid;
            grid-template-columns: 16px minmax(0, 1fr) auto;
            align-items: center;
            gap: 8px;
            margin: 0 4px 7px;
            padding: 8px 10px;
            border: 1px solid rgba(255,168,79,0.12);
            border-radius: 10px;
            background: rgba(255,168,79,0.035);
            color: rgba(245,246,254,0.78);
            cursor: pointer;
            text-align: left;
            transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
        }

        .top-account-redeem-entry:hover {
            border-color: rgba(255,168,79,0.24);
            background: rgba(255,168,79,0.065);
            color: rgba(245,246,254,0.90);
        }

        .top-account-redeem-entry svg {
            color: rgba(255,180,82,0.82);
        }

        .top-account-redeem-entry span {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 11px;
            font-weight: 500;
        }

        .top-account-redeem-entry small {
            color: var(--text-tertiary);
            font-size: 10px;
            font-weight: 400;
        }

        .top-redeem-modal {
            position: fixed;
            inset: 0;
            display: grid;
            place-items: center;
            padding: 24px;
            background: rgba(0,0,0,0.54);
            backdrop-filter: blur(10px);
            z-index: 10020;
            pointer-events: auto;
        }

        .top-redeem-modal.hidden {
            display: none;
        }

        .top-redeem-panel {
            position: relative;
            width: min(320px, calc(100vw - 48px));
            padding: 18px;
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 16px;
            background: rgba(17, 21, 27, 0.98);
            box-shadow: 0 22px 70px rgba(0,0,0,0.52), 0 0 46px rgba(255,149,0,0.06);
        }

        .top-redeem-close {
            position: absolute;
            top: 10px;
            right: 10px;
            width: 28px;
            height: 28px;
            display: grid;
            place-items: center;
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 8px;
            background: rgba(255,255,255,0.03);
            color: var(--text-tertiary);
            cursor: pointer;
        }

        .top-redeem-close:hover {
            color: var(--text-primary);
            background: rgba(255,255,255,0.06);
        }

        .top-redeem-title-row {
            display: flex;
            align-items: center;
            gap: 11px;
            padding-right: 28px;
            margin-bottom: 16px;
        }

        .top-redeem-icon {
            width: 34px;
            height: 34px;
            display: grid;
            place-items: center;
            border-radius: 11px;
            background: linear-gradient(135deg, rgba(255,180,82,0.98), rgba(255,136,24,0.98));
            color: rgba(22,16,9,0.96);
            box-shadow: 0 10px 24px rgba(255,149,0,0.18);
            flex-shrink: 0;
        }

        .top-redeem-title-row h2 {
            margin: 0;
            color: rgba(245,246,254,0.92);
            font-size: 16px;
            font-weight: 600;
            letter-spacing: 0;
            line-height: 1.2;
        }

        .top-redeem-title-row span:not(.top-redeem-icon) {
            display: block;
            margin-top: 4px;
            color: var(--text-tertiary);
            font-size: 11px;
            font-weight: 400;
        }

        .top-redeem-form {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .top-redeem-form label {
            color: rgba(245,246,254,0.78);
            font-size: 11px;
            font-weight: 500;
        }

        .top-redeem-form input {
            width: 100%;
            height: 38px;
            padding: 0 11px;
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 9px;
            background: rgba(5,8,12,0.45);
            color: rgba(245,246,254,0.88);
            font-size: 13px;
            font-weight: 400;
            outline: none;
        }

        .top-redeem-form input:focus {
            border-color: rgba(255,168,79,0.34);
            box-shadow: 0 0 0 3px rgba(255,168,79,0.08);
        }

        .top-redeem-message {
            min-height: 16px;
            color: var(--text-tertiary);
            font-size: 11px;
            line-height: 1.45;
        }

        .top-redeem-message.is-success {
            color: rgba(46,160,67,0.86);
        }

        .top-redeem-message.is-error {
            color: rgba(255,107,107,0.88);
        }

        .top-redeem-actions {
            display: grid;
            grid-template-columns: 1fr 1.45fr;
            gap: 8px;
            margin-top: 4px;
        }

        .top-redeem-actions button {
            height: 36px;
            border-radius: 9px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 500;
            transition: opacity 0.12s ease, transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
        }

        .top-redeem-actions button:disabled {
            cursor: default;
            opacity: 0.52;
        }

        .top-redeem-secondary {
            border: 1px solid rgba(255,255,255,0.07);
            background: rgba(255,255,255,0.025);
            color: rgba(245,246,254,0.72);
        }

        .top-redeem-secondary:hover {
            background: rgba(255,255,255,0.055);
            color: rgba(245,246,254,0.88);
        }

        .top-redeem-primary {
            border: 1px solid rgba(255,168,79,0.20);
            background: linear-gradient(135deg, rgba(255,179,71,0.92), rgba(255,127,24,0.92));
            color: rgba(20,16,10,0.96);
            box-shadow: 0 10px 26px rgba(255,149,0,0.14);
        }

        .top-redeem-primary:hover {
            transform: translateY(-1px);
        }

        .top-account-usage-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            color: var(--text-tertiary);
            font-size: 11px;
        }

        .top-account-usage-head button {
            padding: 0;
            border: 0;
            background: transparent;
            color: rgba(255, 170, 64, 0.76);
            cursor: pointer;
            font-size: 11px;
            font-weight: 500;
        }

        .top-account-usage-head button:hover {
            color: rgba(255, 190, 92, 0.90);
        }

        .top-account-usage-list {
            display: flex;
            flex-direction: column;
            gap: 6px;
            max-height: 148px;
            overflow: auto;
            scrollbar-width: thin;
            scrollbar-color: rgba(255,255,255,0.12) transparent;
        }

        .top-account-usage-list::-webkit-scrollbar {
            width: 5px;
        }

        .top-account-usage-list::-webkit-scrollbar-track {
            background: transparent;
        }

        .top-account-usage-list::-webkit-scrollbar-thumb {
            border-radius: 999px;
            background: rgba(255,255,255,0.12);
        }

        .top-account-usage-list::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.18);
        }

        .top-account-usage-item {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 2px 8px;
            padding: 7px 0 0;
            border-top: 1px solid rgba(255,255,255,0.045);
        }

        .top-account-usage-item:first-child {
            padding-top: 0;
            border-top: 0;
        }

        .top-account-usage-main {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: rgba(245,246,254,0.76);
            font-size: 11px;
            font-weight: 500;
        }

        .top-account-usage-cost {
            color: rgba(245,246,254,0.80);
            font-size: 11px;
            font-weight: 500;
            text-align: right;
        }

        .top-account-usage-meta {
            grid-column: 1 / -1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: var(--text-tertiary);
            font-size: 10px;
        }

        .top-account-usage-empty {
            color: var(--text-tertiary);
            font-size: 11px;
        }

        .top-account-menu-item {
            width: 100%;
            display: flex;
            align-items: center;
            gap: 9px;
            padding: 9px 10px;
            border: 0;
            border-radius: 9px;
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            font-size: 12px;
            font-weight: 500;
            text-align: left;
            transition: background 0.12s ease, color 0.12s ease;
        }

        .top-account-menu-item svg {
            width: 14px;
            height: 14px;
            flex-shrink: 0;
        }

        .top-account-menu-item:hover {
            background: rgba(255,255,255,0.06);
            color: var(--text-primary);
        }

        .top-account-menu-item.danger:hover {
            background: rgba(220,50,50,0.12);
            color: #ff9b9b;
        }

        /* ===== 顶栏菜单 ===== */
        .top-menu-group {
            position: relative;
            margin-left: 6px;
        }

        .top-menu-trigger {
            width: 18px;
            height: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            color: rgba(119, 125, 135, 0.92);
            cursor: pointer;
            border-radius: 0;
            transition: color 0.12s, transform 0.15s;
        }

        .top-menu-trigger:hover {
            color: var(--text-primary);
        }

        .top-menu-trigger svg {
            width: 14px;
            height: 14px;
            stroke-width: 2.1;
        }

        .top-menu-trigger.open {
            transform: rotate(180deg);
            color: var(--text-primary);
        }

        /* 下拉菜单 */
        .top-menu-dropdown {
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            min-width: 220px;
            background: rgba(16, 20, 25, 0.96);
            border: 1px solid rgba(255,255,255,0.05);
            border-radius: 14px;
            padding: 6px;
            box-shadow: 0 18px 44px rgba(0,0,0,0.42), 0 0 30px rgba(255,149,0,0.04);
            backdrop-filter: blur(16px);
            z-index: 1100;
            opacity: 1;
            transform: translateY(0);
            transition: opacity 0.15s ease, transform 0.15s ease;
        }

        .top-menu-dropdown.hidden {
            opacity: 0;
            pointer-events: none;
            transform: translateY(-6px);
        }

        @media (max-width: 1180px) {
            .top-center-nav {
                display: none;
            }
        }

        .top-menu-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 9px 12px;
            font-size: 13px;
            color: var(--text-secondary);
            border-radius: 8px;
            cursor: pointer;
            transition: background 0.12s, color 0.12s;
        }

        .top-menu-item:hover {
            background: rgba(255,168,79,0.10);
            color: var(--text-primary);
        }

        .top-menu-item svg {
            width: 14px;
            height: 14px;
            min-width: 14px;
            min-height: 14px;
            opacity: 0.85;
            color: var(--text-secondary);
            stroke: currentColor;
            fill: none;
            flex-shrink: 0;
            display: inline-block;
            vertical-align: middle;
        }

        .top-menu-item:hover svg {
            opacity: 1;
            color: var(--accent-blue);
        }

        .top-menu-shortcut {
            margin-left: auto;
            font-size: 11px;
            color: var(--text-tertiary);
            font-weight: 400;
        }

        /* 子菜单触发项 */
        .top-menu-has-sub {
            position: relative;
        }

.top-menu-sub {
    display: none;
    position: absolute;
    left: calc(100% + 4px);
    top: -6px;
    min-width: 238px;
    background: rgba(16, 20, 25, 0.96);
    border: 0.5px solid rgba(255,168,79,0.10);
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 18px 44px rgba(0,0,0,0.42), 0 0 28px rgba(255,149,0,0.06);
    backdrop-filter: blur(18px) saturate(140%);
    z-index: 1200;
}

        .top-menu-has-sub:hover .top-menu-sub {
            display: block;
        }

        .top-menu-sub .top-menu-item {
            padding: 8px 12px;
            font-size: 12px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .top-menu-sub-more {
            padding: 6px 12px;
            font-size: 11px;
            color: rgba(255,255,255,0.3);
            cursor: pointer;
            border-radius: 6px;
            transition: background 0.12s;
        }

        .top-menu-sub-more:hover {
            background: rgba(255,255,255,0.06);
            color: rgba(255,255,255,0.5);
        }

        .top-menu-project-empty {
            padding: 12px;
            color: var(--text-secondary);
            font-size: 12px;
        }

        .top-menu-project-item {
            display: none;
        }

.top-menu-project-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    border: 0.5px solid transparent;
}

.top-menu-project-row:hover {
    background: rgba(255,168,79,0.10);
    border-color: rgba(255,168,79,0.14);
}

        .top-menu-project-row:focus-visible {
            box-shadow: 0 0 0 1px rgba(255,168,79,0.5);
            border-radius: 6px;
            outline: none;
        }

        .top-menu-project-line {
            display: flex;
            align-items: center;
            gap: 8px;
        }

.top-menu-project-inline-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
        }

.top-menu-project-inline-badge {
    padding: 2px 7px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
    color: rgba(20, 16, 10, 0.92);
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.top-menu-project-inline-meta {
    font-size: 11px;
    color: var(--text-tertiary);
}

        .top-menu-project-actions {
            display: none;
        }

        .top-menu-project-btn {
            border: 1px solid rgba(255,255,255,0.08);
            background: rgba(255,255,255,0.04);
            color: var(--text-secondary);
            font-size: 11px;
            line-height: 1;
            padding: 6px 8px;
            border-radius: 6px;
            cursor: pointer;
            transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
        }

        .top-menu-project-btn:hover {
            background: rgba(255,255,255,0.08);
            color: var(--text-primary);
            border-color: rgba(255,255,255,0.14);
        }

        .top-menu-project-btn.danger:hover {
            background: rgba(220, 60, 60, 0.12);
            color: #ff9b9b;
            border-color: rgba(220, 60, 60, 0.24);
        }

        .top-menu-divider {
            height: 1px;
            background: rgba(255,255,255,0.05);
            margin: 4px 8px;
        }

        /* ===== 缩略图导航小地图 ===== */
        .canvas-minimap {
            position: fixed;
            bottom: 16px;
            left: 16px;
            right: auto;
            width: 220px;
            height: 150px;
            background: rgba(13, 17, 26, 0.92);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 10px;
            z-index: 150;
            backdrop-filter: blur(14px);
            box-shadow: 0 6px 24px rgba(0,0,0,0.35);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            transition: opacity 0.2s ease, transform 0.2s ease;
        }

        .canvas-minimap.hidden {
            opacity: 0;
            pointer-events: none;
            transform: translateY(8px);
        }

        .minimap-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 4px 8px;
            border-bottom: 1px solid rgba(255,255,255,0.04);
            flex-shrink: 0;
            height: 24px;
        }

        .minimap-title {
            font-size: 10px;
            font-weight: 500;
            color: var(--text-tertiary);
            letter-spacing: 0;
        }

        .minimap-close-btn {
            width: 18px;
            height: 18px;
            border: none;
            background: transparent;
            color: var(--text-tertiary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 4px;
            transition: background 0.12s, color 0.12s;
            padding: 0;
        }

        .minimap-close-btn:hover {
            background: rgba(255,255,255,0.08);
            color: var(--text-primary);
        }

        .minimap-canvas {
            flex: 1 1 0;
            width: 100%;
            height: auto;
            min-height: 0;
            display: block;
            cursor: pointer;
            image-rendering: auto;
            touch-action: none;
            user-select: none;
        }

        .minimap-canvas.is-dragging {
            cursor: grabbing;
        }

        /* 视窗框 */
        .minimap-viewport {
            position: absolute;
            border: 1.5px solid rgba(255,168,79,0.6);
            background: rgba(255,168,79,0.05);
            border-radius: 2px;
            pointer-events: none;
            transition: none;
        }

        /* 节点在小地图上的高亮点 */
        .minimap-node-dot {
            position: absolute;
            border-radius: 2px;
            pointer-events: none;
        }

        .minimap-node-dot.has-image {
            background: #4ecb71;
            box-shadow: 0 0 4px rgba(78,203,113,0.5);
        }

        .minimap-node-dot.default {
            background: rgba(255,255,255,0.3);
        }

        /* ===== 全局自定义滚动条 ===== */

        /* Webkit (Chrome, Safari, Edge) */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
        }

        ::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.10);
            border-radius: 10px;
            border: 1px solid transparent;
            background-clip: content-box;
            transition: background 0.2s;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.20);
            border-radius: 10px;
            background-clip: content-box;
        }

        ::-webkit-scrollbar-thumb:active {
            background: rgba(255,255,255,0.28);
            background-clip: content-box;
        }

        ::-webkit-scrollbar-corner {
            background: transparent;
        }

        /* 编辑器内部滚动条略宽一点 */
        .editor-container::-webkit-scrollbar,
        .floating-panel-body::-webkit-scrollbar,
        .modal-body::-webkit-scrollbar,
        .agent-messages::-webkit-scrollbar {
            width: 5px;
        }

        .editor-container::-webkit-scrollbar-thumb,
        .floating-panel-body::-webkit-scrollbar-thumb,
        .modal-body::-webkit-scrollbar-thumb,
        .agent-messages::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.08);
            border-radius: 10px;
        }

        .editor-container::-webkit-scrollbar-thumb:hover,
        .floating-panel-body::-webkit-scrollbar-thumb:hover,
        .modal-body::-webkit-scrollbar-thumb:hover,
        .agent-messages::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.16);
        }

        /* 隐藏轨道背景，鼠标悬停容器时才微微显示 */
        .editor-container::-webkit-scrollbar-track,
        .floating-panel-body::-webkit-scrollbar-track,
        .modal-body::-webkit-scrollbar-track,
        .agent-messages::-webkit-scrollbar-track {
            background: transparent;
            margin: 8px 0;
        }

        /* Firefox */
        * {
            scrollbar-width: thin;
            scrollbar-color: rgba(255,255,255,0.10) transparent;
        }

        /* 悬浮面板内部 - 确保滚动条不突兀 */
        .floating-panel {
            overflow: hidden; /* 外层不滚动 */
        }

        .floating-panel-body {
            overflow-y: auto;
            overflow-x: hidden;
        }

        /* 编辑器标签内容滚动 */
        .editor-tab-content {
            overflow-y: auto;
            overflow-x: hidden;
        }

        /* textarea 的滚动条 */
        textarea::-webkit-scrollbar {
            width: 4px !important;
            height: 4px !important;
        }

        textarea::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.15) !important;
            border-radius: 2px !important;
        }

        textarea::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.25) !important;
        }

        /* =====================
        ImageGen Chip 控件
        ===================== */

        /* 隐藏旧的 ratio bar */
        .imagen-ratio-bar {
            display: none !important;
        }

        /* Bottom bar with chip group */
        .imagen-bottom-bar {
            display: flex;
            align-items: center;
            gap: 3px;
            margin-top: 0;
            padding-top: 0;
            border-top: none;
        }

        .imagen-chip-group {
            display: flex;
            gap: 3px;
            flex: 1;
            flex-wrap: nowrap;
            overflow: visible;
        }

        /* Chip toggle container */
        .imagen-chip-toggle {
            position: relative;
            flex-shrink: 0;
        }

        /* Chip trigger button */
        .imagen-chip-trigger {
            height: 26px;
            padding: 0 8px;
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 6px;
            color: var(--text-secondary);
            font-size: 11px;
            cursor: pointer;
            transition: all 0.15s;
            white-space: nowrap;
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .imagen-chip-trigger:hover {
            background: rgba(255,255,255,0.09);
            border-color: rgba(255,255,255,0.18);
            color: var(--text-primary);
        }

        /* Chip dropdown panel */
        .imagen-chip-dropdown {
            position: absolute;
            bottom: calc(100% + 6px);
            left: 0;
            display: none;
            min-width: 100%;
            max-height: 240px;
            background: var(--bg-elevated);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 10px;
            padding: 4px;
            box-shadow: 0 12px 40px rgba(0,0,0,0.5);
            z-index: 9000;
            overflow-y: auto;
            overflow-x: hidden;
            overscroll-behavior: contain;
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
        }

        .imagen-chip-dropdown::-webkit-scrollbar {
            width: 8px;
        }

        .imagen-chip-dropdown::-webkit-scrollbar-track {
            background: transparent;
        }

        .imagen-chip-dropdown::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.16);
            border-radius: 999px;
        }

        .imagen-chip-dropdown::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.24);
        }

        /* Open state */
        .imagen-chip-toggle.open .imagen-chip-dropdown {
            display: block;
            animation: chipDropIn 0.12s ease-out;
        }

        .node.node-image-gen.imagegen-chip-open {
            z-index: 13000 !important;
            overflow: visible !important;
        }

        .node.node-image-gen.imagegen-chip-open .node-input-section {
            z-index: 13000;
        }

        .node.node-image-gen.imagegen-chip-open .imagen-bottom-bar,
        .node.node-image-gen.imagegen-chip-open .imagen-chip-toggle.open {
            position: relative;
            z-index: 13100;
        }

        .node.node-image-gen.imagegen-chip-open .imagen-chip-toggle.open .imagen-chip-dropdown {
            z-index: 13200;
        }

        @keyframes chipDropIn {
            from { opacity: 0; transform: translateY(4px) scale(0.98); }
            to   { opacity: 1; transform: translateY(0) scale(1); }
        }

        /* Chip option items */
        .imagen-chip-option {
            display: flex;
            align-items: center;
            gap: 5px;
            height: 30px;
            padding: 0 10px;
            background: none;
            border: none;
            border-radius: 6px;
            color: var(--text-secondary);
            font-size: 12px;
            cursor: pointer;
            transition: all 0.1s;
            white-space: nowrap;
            width: 100%;
            text-align: left;
        }

        .imagen-chip-option:hover {
            background: rgba(255,255,255,0.08);
            color: var(--text-primary);
        }

        .imagen-chip-option.active {
            background: rgba(255,168,79,0.18);
            color: #ffb347;
        }

        /* Generate button in chip bar */
        .imagen-generate-btn {
            width: 36px !important;
            height: 36px !important;
            min-width: 36px !important;
            border-radius: 10px !important;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .imagen-generate-btn svg {
            width: 22px !important;
            height: 22px !important;
        }

        /* Ratio icon in dropdown */
        .dropdown-ratio .imagen-chip-option {
            min-width: 80px;
        }

        .ratio-icon {
            flex-shrink: 0;
            opacity: 0.7;
        }

        /* Inline dropdown (resolution/count) */
        .dropdown-inline {
            min-width: 60px;
        }

        textarea::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.14);
        }

        /* ★ 节点内螃蟹 icon */
        .node-icon {
            flex-shrink: 0;
            opacity: 0.75;
        }

        /* =============================== */
        /* Image Gen Node Fixes           */
        /* =============================== */

        /* ★ 比例下拉 — 默认隐藏，打开时单行横排 */
        .dropdown-ratio {
            flex-direction: row !important;
            flex-wrap: nowrap !important;
            gap: 2px !important;
            min-width: auto !important;
            max-width: none !important;
            width: max-content !important;
            padding: 4px 6px !important;
            overflow-x: auto !important;
            overflow-y: hidden !important;
        }

        .dropdown-ratio .imagen-chip-option {
            width: auto !important;
            min-width: auto !important;
            padding: 0 7px !important;
            height: 26px !important;
            font-size: 11px !important;
            flex-shrink: 0 !important;
            white-space: nowrap !important;
        }

        /* 打开时才显示为 flex */
        .imagen-chip-toggle[data-chip="ratio"].open .imagen-chip-dropdown {
            display: flex !important;
        }

        /* 定位：在 ratio 按钮正上方弹出，无位移动画 */
        .imagen-chip-toggle[data-chip="ratio"] {
            position: relative;
        }

        .imagen-chip-toggle[data-chip="ratio"] .imagen-chip-dropdown {
            bottom: 100% !important;
            top: auto !important;
            left: 50% !important;
            right: auto !important;
            transform: translateX(-50%) !important;
            margin-bottom: 4px !important;
        }

        /* 打开时才显示为 flex */
        .imagen-chip-toggle[data-chip="ratio"].open .imagen-chip-dropdown {
            display: flex !important;
        }

        /* ★ 左上角 Logo — 白色描边 */
        .logo:hover {
            filter: drop-shadow(0 0 8px rgba(255, 168, 79, 0.2));
        }

        /* ★ AI绘图节点顶部螃蟹 icon — 白色描边 */
        .node-image-gen .node-icon,
        .node-image-gen .node-icon path,
        .node-image-gen .node-icon circle,
        .node-image-gen .node-icon ellipse,
        .node-image-gen .node-icon line {
            stroke: rgba(255, 255, 255, 0.75) !important;
            fill: none !important;
        }

        .node-image-gen:hover .node-icon,
        .node-image-gen:hover .node-icon path,
        .node-image-gen:hover .node-icon circle,
        .node-image-gen:hover .node-icon ellipse,
        .node-image-gen:hover .node-icon line {
            stroke: rgba(255, 255, 255, 0.95) !important;
        }

        /* ★ node-image-gen 生成按钮螃蟹 icon — 白色描边 */
        .node-image-gen .imagen-generate-btn {
            color: rgba(255, 255, 255, 0.85) !important;
        }

        .node-image-gen .imagen-generate-btn:hover {
            color: rgba(255, 255, 255, 1) !important;
        }

        /* ===================== */
        /* 图片放大预览模态框      */
        /* ===================== */
        #image-preview-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.88);
            z-index: 9999;
            display: none;
            justify-content: center;
            align-items: center;
        }

        #image-preview-container {
            position: relative;
            max-width: 70%;
            max-height: 68%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #image-preview-img {
            display: block;
            max-width: 100%;
            max-height: 66vh;
            object-fit: contain;
            border-radius: 8px;
            transition: transform 0.2s ease;
            cursor: zoom-out;
        }

        #image-preview-close {
            position: fixed;
            top: 56px;
            right: 20px;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: rgba(255,255,255,0.08);
            color: rgba(255,255,255,0.85);
            border: 1px solid rgba(255,255,255,0.15);
            cursor: pointer;
            font-size: 18px;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s, color 0.15s;
            z-index: 10000;
        }

        #image-preview-close:hover {
            background: rgba(255,255,255,0.18);
            color: #fff;
        }

        .image-preview-toolbar-left {
            position: fixed;
            top: 56px;
            left: 20px;
            display: flex;
            gap: 8px;
            z-index: 10000;
        }

        .image-preview-tool-btn {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: rgba(255,255,255,0.08);
            color: rgba(255,255,255,0.85);
            border: 1px solid rgba(255,255,255,0.15);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.15s, color 0.15s;
            padding: 0;
        }

        .image-preview-tool-btn:hover {
            background: rgba(255,255,255,0.18);
            color: #fff;
        }

        .image-preview-info-panel {
            position: fixed;
            top: 96px;
            left: 20px;
            min-width: 180px;
            background: rgba(20,20,22,0.92);
            color: #fff;
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 8px;
            padding: 10px 14px;
            font-size: 13px;
            z-index: 10000;
            box-shadow: 0 4px 18px rgba(0,0,0,0.45);
        }

        .image-preview-info-row {
            display: flex;
            justify-content: space-between;
            gap: 16px;
            padding: 4px 0;
        }

        .image-preview-info-label {
            color: rgba(255,255,255,0.55);
        }

        .image-preview-info-value {
            color: rgba(255,255,255,0.95);
            font-weight: 500;
        }
        /* 单图节点悬停时显示替换按钮（已有结构保留，仅确保行为） */
        .node-single-image-img {
            cursor: zoom-in;
        }

        /* ★ 修复2: 去除文生图节点底部空白 */
        /* ★ 修复3: AI绘图节点缩放后布局 */
        /* ★ 修复：AI绘图节点缩放时图片区域优先 */
        .node.node-image-gen:not(.node-manual-resized) {
            display: flex;
            flex-direction: column;
            width: 420px !important;
            min-height: var(--image-gen-node-min-height, 280px) !important;
            height: var(--image-gen-node-height, auto) !important;
            overflow: visible;
        }

        .node-image-gen .node-upload-header {
            flex-shrink: 0;
            height: 28px;
        }

        .node-image-gen .node-image-box {
            flex: 1 1 auto;
            min-height: 140px !important;
            margin: 8px 12px !important;
            overflow: hidden;
            aspect-ratio: 16/9;
        }

        .node-image-gen .node-input-section {
            flex: 0 0 auto;
            min-height: 0;
            padding: 10px 12px 8px !important;
            overflow: visible;
            position: relative;
            z-index: 10;
        }

        /* 手动缩放后 */
        .node.node-manual-resized.node-image-gen {
            display: flex;
            flex-direction: column;
        }

        .node.node-manual-resized.node-image-gen .node-image-box {
            flex: 1 1 auto;
            min-height: 100px !important;
            aspect-ratio: unset !important;
        }

        .node.node-manual-resized.node-image-gen .node-input-section {
            flex: 0 0 auto;
            min-height: 0;
            max-height: none;
        }

        /* 确保图片/占位符填充 */
        .node-image-gen .node-image-box .image-placeholder,
        .node-image-gen .node-image-box .image-loading,
        .node-image-gen .node-image-box img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        /* textarea 自适应 */
.node-image-gen .node-textarea {
    min-height: 60px;
    max-height: 104px;
    box-sizing: border-box;
    resize: none;
    scrollbar-gutter: stable;
}

        .node-image-gen .node-textarea::-webkit-scrollbar {
            width: 8px !important;
            height: 0 !important;
        }

        .node-image-gen .node-textarea::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.025) !important;
            border-radius: 999px !important;
            margin: 0 !important;
        }

        .node-image-gen .node-textarea::-webkit-scrollbar-thumb {
            min-height: 24px;
            background: rgba(255, 255, 255, 0.18) !important;
            border-radius: 999px !important;
        }

        /* 底部栏紧凑 */
        .imagen-bottom-bar {
            margin-top: 6px;
            padding-top: 6px;
        }

        /* ===== 图片上传节点 — 纯图片展示模式 ===== */
        .node-image-upload {
            width: 420px !important;
            min-height: 280px !important;
            padding: 0 !important;
        }

        .node-image-upload .node-upload-header {
            display: none !important;
        }

        .node-image-upload .media-upload-box {
            width: 100%;
            height: 100%;
            min-height: 280px;
            padding: 0 !important;
            background: rgba(255,255,255,0.02);
            border-radius: var(--node-radius);
            position: relative;
        }

        /* 未导入时的占位 */
        .node-image-upload .media-upload-box:not(:has(.node-single-image)) {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 12px;
            padding: 24px !important;
            border: 1px dashed rgba(255,255,255,0.12);
        }

        /* 导入后的纯图片展示 */
        .node-single-image {
            width: 100%;
            height: 100%;
            min-height: 280px;
            position: relative;
            border-radius: var(--node-radius);
            overflow: hidden;
            background: #0d1118;
        }

        .node-single-image-img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            display: block;
            cursor: zoom-in;
        }

        /* 替换按钮 — 默认隐藏，hover 时显示在左上角 */
        .node-image-overlay {
            position: absolute;
            top: 12px;
            left: 12px;
            opacity: 0;
            transition: opacity 0.2s ease;
            pointer-events: none;
        }

        .node-single-image:hover .node-image-overlay {
            opacity: 1;
            pointer-events: auto;
        }

        .node-image-replace-btn {
            width: 36px;
            height: 36px;
            border: 1px solid rgba(255,255,255,0.16);
            background: rgba(12,15,20,0.88);
            color: #e8eefc;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            backdrop-filter: blur(10px);
            transition: all 0.18s ease;
        }

        .node-image-replace-btn:hover {
            background: rgba(255,168,79,0.22);
            border-color: rgba(255,168,79,0.5);
            color: #fff;
            transform: scale(1.08);
        }

        /* ===== 媒体导入后隐藏节点边框/背景 ===== */
        .node-image-upload[data-media-mode="image"],
        .node-image-upload[data-media-mode="video"] {
            border: none !important;
            background: transparent !important;
            padding: 0 !important;
            box-shadow: none !important;
        }

        /* ===== 视频节点纯展示模式 ===== */
        .node-video-upload[data-media-mode="video"] {
            border: none !important;
            background: transparent !important;
            padding: 0 !important;
            box-shadow: none !important;
        }

        /* 视频悬停显示替换按钮 */
        .node-single-video {
            width: 100%;
            height: 100%;
            min-height: 280px;
            position: relative;
            border-radius: var(--node-radius);
            overflow: hidden;
            background: #0d1118;
        }

        .node-single-video-player {
            width: 100%;
            height: 100%;
            object-fit: contain;
            display: block;
        }

        .node-single-video-player::-webkit-media-controls-enclosure,
        .node-single-video-player::-webkit-media-controls-panel,
        .video-main-player::-webkit-media-controls-enclosure,
        .video-main-player::-webkit-media-controls-panel {
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .node-video-upload:hover .node-single-video-player::-webkit-media-controls-enclosure,
        .node-video-upload:hover .node-single-video-player::-webkit-media-controls-panel,
        .node-video-upload:hover .video-main-player::-webkit-media-controls-enclosure,
        .node-video-upload:hover .video-main-player::-webkit-media-controls-panel,
        .node-video-upload.is-selected .node-single-video-player::-webkit-media-controls-enclosure,
        .node-video-upload.is-selected .node-single-video-player::-webkit-media-controls-panel,
        .node-video-upload.is-selected .video-main-player::-webkit-media-controls-enclosure,
        .node-video-upload.is-selected .video-main-player::-webkit-media-controls-panel,
        .node-single-video:hover .node-single-video-player::-webkit-media-controls-enclosure,
        .node-single-video:hover .node-single-video-player::-webkit-media-controls-panel,
        .video-workflow-preview:hover .video-main-player::-webkit-media-controls-enclosure,
        .video-workflow-preview:hover .video-main-player::-webkit-media-controls-panel {
            opacity: 1;
        }

        /* Step C (2026-05-12): block native video controls from intercepting
           pointer events on un-selected nodes. Without this, mousedown on a
           video lands on the controls strip — node selection / drag-start is
           delayed, producing the "mouse sticks to the node" sensation
           reported on canvases with many video nodes. The first click on an
           un-selected video selects the node; once selected, subsequent
           clicks reach the controls so playback/scrub still work. */
        .node-single-video-player,
        .video-main-player {
            pointer-events: none;
        }

        .node-video-upload.is-selected .node-single-video-player,
        .node-video-upload.is-selected .video-main-player {
            pointer-events: auto;
        }

        /* Belt-and-suspenders: while the canvas is actively being interacted
           with (pan / drag / zoom — see hc-canvas-interacting in
           core/performance.js, 350ms OFF hysteresis), video controls stay
           out of the way even on a selected node, so a drag started from on
           top of the video flies as smoothly as one started from the chrome. */
        body.hc-canvas-interacting .node-single-video-player,
        body.hc-canvas-interacting .video-main-player {
            pointer-events: none !important;
        }

        .node-video-overlay {
            position: absolute;
            top: 8px;
            left: 8px;
            right: auto;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease;
            z-index: 30;
            display: flex;
            gap: 8px;
        }

        .node-video-replace-btn {
            width: 28px;
            height: 28px;
            border: 1px solid rgba(255,255,255,0.10);
            background: rgba(0,0,0,0.5);
            color: rgba(255,255,255,0.7);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
        }

        .node-video-replace-btn svg {
            width: 16px;
            height: 16px;
        }

        .node-video-upload:hover .node-video-overlay,
        .node-video-upload.is-selected .node-video-overlay,
        .node-single-video:hover .node-video-overlay {
            opacity: 1;
            pointer-events: auto;
        }

        .node-video-replace-btn:hover {
            background: rgba(255,168,79,0.22);
            border-color: rgba(255,168,79,0.5);
            color: #fff;
            transform: scale(1.08);
        }

        .node-video-fullscreen-btn {
            position: absolute;
            right: 14px;
            bottom: 35px;
            width: 24px;
            height: 24px;
            border: 1px solid rgba(255,255,255,0.10);
            background: rgba(0,0,0,0.5);
            color: rgba(255,255,255,0.72);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            transition: opacity 0.2s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
            opacity: 0;
            pointer-events: none;
            z-index: 30;
        }

        .node-video-fullscreen-btn svg {
            width: 16px;
            height: 16px;
        }

        .node-video-upload:hover .node-video-fullscreen-btn,
        .node-video-upload.is-selected .node-video-fullscreen-btn,
        .node-single-video:hover .node-video-fullscreen-btn {
            opacity: 1;
            pointer-events: auto;
        }

        .node-video-fullscreen-btn:hover {
            background: rgba(255,168,79,0.22);
            border-color: rgba(255,168,79,0.5);
            color: #fff;
            transform: scale(1.08);
        }

        /* 视频节点隐藏顶部栏 */
        .node-video-upload[data-media-mode="video"] .node-upload-header {
            display: none !important;
        }

        .node-video-upload[data-media-mode="video"] .media-upload-box {
            width: 100%;
            height: 100%;
            min-height: 280px;
            padding: 0 !important;
        }

        /* ★ 导入媒体后节点自适应 */
        .node-image-upload[data-media-mode="image"]:not([data-is-crop-node="true"]):not(.node-manual-resized),
        .node-image-upload[data-media-mode="video"]:not([data-is-crop-node="true"]):not(.node-manual-resized) {
            width: auto !important;
            min-width: 200px !important;
            max-width: 480px !important;
            height: auto !important;
            min-height: auto !important;
        }

        .node-image-upload[data-media-mode] .media-upload-box {
            min-height: auto !important;
            height: auto !important;
            padding: 0 !important;
        }

        .node-image-upload[data-is-crop-node="true"] .media-upload-box {
            min-height: 0 !important;
            height: 100% !important;
        }

        .node-image-upload[data-is-crop-node="true"] .node-single-image {
            min-height: 0 !important;
            height: 100% !important;
        }

        .node-image-upload[data-is-crop-node="true"] .node-single-image-img {
            width: 100% !important;
            height: 100% !important;
            min-height: 0 !important;
            display: block;
            object-fit: contain;
        }

        .node-image-upload:not([data-is-crop-node="true"]) .node-single-image,
        .node-video-upload:not([data-is-crop-node="true"]) .node-single-video {
            min-height: auto !important;
        }

        .node-image-upload:not([data-is-crop-node="true"]) .node-single-image-img,
        .node-video-upload:not([data-is-crop-node="true"]) .node-single-video-player {
            width: 100% !important;
            height: auto !important;
            min-height: auto !important;
            display: block;
            object-fit: contain;
        }

        .node-video-upload[data-media-mode="video"]:not(.node-manual-resized) {
            width: auto !important;
            min-width: 240px !important;
            max-width: 480px !important;
            height: auto !important;
            min-height: auto !important;
        }

        .node-video-upload[data-media-mode] .media-upload-box {
            min-height: auto !important;
            height: auto !important;
            padding: 0 !important;
        }

        /* ===== 连接线剪刀模式 ===== */

        /* 线条 hover 高亮 */
        .connection-line:hover,
        .connection-path:hover {
            stroke: #ff9500 !important;
            stroke-width: var(--connection-hover-stroke-width, 2) !important;
            filter: drop-shadow(0 0 4px rgba(255, 168, 79, 0.6));
        }

        /* 剪刀图标 */
        .scissors-indicator {
            position: fixed;
            width: 32px;
            height: 32px;
            pointer-events: none;
            z-index: 10000;
            opacity: 0;
            transition: opacity 0.15s, transform 0.15s;
            filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
        }

        .scissors-indicator.visible {
            opacity: 1;
            transform: scale(1.1);
        }

        /* 剪刀模式光标 */
        body.scissors-mode,
        body.scissors-mode * {
            cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="white" stroke="black" stroke-width="1" d="M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3z"/></svg>') 12 12, crosshair !important;
        }

        /* 被标记为待删除的线条 */
        .connection-line.marked-for-deletion,
        .connection-path.marked-for-deletion {
            stroke: #ff4444 !important;
            stroke-width: var(--connection-delete-stroke-width, 2.5) !important;
            stroke-dasharray: 8, 4 !important;
            opacity: 0.7 !important;
            animation: dash-animation 0.5s linear infinite;
        }

        @keyframes dash-animation {
            to {
                stroke-dashoffset: -12;
            }
        }

        /* 剪刀轨迹线 */
        .scissors-trail {
            position: fixed;
            pointer-events: none;
            z-index: 9999;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
        }

        .scissors-trail line {
            stroke: #ff4444;
            stroke-width: 2;
            stroke-dasharray: 4, 4;
            opacity: 0.6;
        }

        /* =============================================
        连接目标节点 - 左侧边缘高亮反馈
        ============================================= */

        .node.connection-target-highlight {
            border-color: rgba(255,168,79, 0.5) !important;
            box-shadow:
                -4px 0 16px rgba(255,168,79, 0.2),
                0 0 0 1px rgba(255,168,79, 0.3),
                0 12px 40px rgba(0, 0, 0, 0.45) !important;
            transition: border-color 0.15s ease, box-shadow 0.15s ease;
        }

        .node.connection-target-highlight .node-port-left {
            opacity: 1 !important;
            visibility: visible !important;
            pointer-events: auto !important;
            transform: translateX(-50%) translateY(-50%) scale(1.2) !important;
            background: rgba(255,179,71, 0.9) !important;
            border-color: #fff !important;
            box-shadow:
                0 0 0 6px rgba(255,179,71, 0.15),
                0 0 16px rgba(255,179,71, 0.3) !important;
        }

        /* 连接源节点 - 右侧边缘高亮反馈（镜像 target 样式） */
        .node.connection-source {
            border-color: rgba(255,168,79, 0.5) !important;
            box-shadow:
                4px 0 16px rgba(255,168,79, 0.2),
                0 0 0 1px rgba(255,168,79, 0.3),
                0 12px 40px rgba(0, 0, 0, 0.45) !important;
            transition: border-color 0.15s ease, box-shadow 0.15s ease;
        }

        /* =============================================
        历史记录面板样式
        ============================================= */

        /* ===== 侧边弹出面板 ===== */
        .history-side-panel {
            position: fixed;
            left: 84px;
            width: 380px;
            height: 520px;
            max-height: 80vh;
            background: rgba(13, 17, 26, 0.96);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 14px;
            z-index: 950;
            backdrop-filter: blur(16px);
            box-shadow: 0 12px 48px rgba(0,0,0,0.5);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            transition: left 0.3s ease, opacity 0.15s ease, transform 0.15s ease;
        }

        body.editor-sidebar-open .history-side-panel {
            left: 404px;
        }

        .history-side-panel.hidden {
            opacity: 0;
            pointer-events: none;
            transform: translateX(-8px);
        }

        .history-side-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 12px;
            border-bottom: 1px solid rgba(255,255,255,0.06);
            flex-shrink: 0;
        }

        .history-side-tabs {
            display: flex;
            gap: 2px;
        }

        .history-side-tab {
            padding: 5px 10px;
            background: transparent;
            border: none;
            border-radius: 6px;
            color: var(--text-tertiary);
            font-size: 12px;
            cursor: pointer;
            transition: all 0.12s;
            white-space: nowrap;
        }

        .history-side-tab:hover {
            color: var(--text-secondary);
            background: rgba(255,255,255,0.04);
        }

        .history-side-tab.active {
            color: var(--text-primary);
            background: rgba(255,255,255,0.08);
        }

        .history-tab-count {
            font-size: 10px;
            opacity: 0.6;
            margin-left: 2px;
        }

        .history-expand-btn {
            width: 28px;
            height: 28px;
            border: none;
            background: rgba(255,255,255,0.04);
            border-radius: 6px;
            color: var(--text-tertiary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.12s;
        }

        .history-expand-btn:hover {
            background: rgba(255,255,255,0.10);
            color: var(--text-primary);
        }

        .history-side-body {
            flex: 1;
            overflow-y: auto;
            padding: 8px;
        }

        /* ===== 悬浮大面板 ===== */
        .history-floating-panel {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.6);
            z-index: 1200;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: opacity 0.2s ease;
        }

        .history-floating-panel.hidden {
            opacity: 0;
            pointer-events: none;
        }

        /* 重新布局：侧边栏 + 主内容在一个容器中 */
        .history-floating-panel {
            display: flex;
            padding: 40px;
            gap: 0;
        }

        .history-float-sidebar {
            width: 180px;
            background: rgba(18, 22, 32, 0.98);
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 14px 0 0 14px;
            border-right: none;
            padding: 16px 0;
            display: flex;
            flex-direction: column;
            gap: 4px;
            flex-shrink: 0;
        }

        .history-float-sidebar-title {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-tertiary);
            padding: 8px 16px 12px;
            letter-spacing: 0.3px;
        }

        .history-float-nav {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 10px 16px;
            background: transparent;
            border: none;
            color: var(--text-secondary);
            font-size: 13px;
            cursor: pointer;
            transition: all 0.12s;
            text-align: left;
            width: 100%;
        }

        .history-float-nav:hover {
            background: rgba(255,255,255,0.04);
            color: var(--text-primary);
        }

        .history-float-nav.active {
            background: rgba(255,168,79,0.10);
            color: #ffb347;
        }

        .history-nav-count {
            margin-left: auto;
            font-size: 11px;
            opacity: 0.5;
            background: rgba(255,255,255,0.06);
            padding: 1px 6px;
            border-radius: 10px;
        }

        .history-float-main {
            flex: 1;
            max-width: 900px;
            max-height: 80vh;
            background: rgba(13, 17, 26, 0.98);
            border: 1px solid rgba(255,255,255,0.06);
            border-radius: 0 14px 14px 0;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .history-float-toolbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            border-bottom: 1px solid rgba(255,255,255,0.06);
            flex-shrink: 0;
        }

        .history-float-title {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .history-float-controls {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .history-zoom-control {
            display: flex;
            align-items: center;
            gap: 6px;
            color: var(--text-tertiary);
        }

        .history-zoom-slider {
            -webkit-appearance: none;
            width: 80px;
            height: 4px;
            background: rgba(255,255,255,0.1);
            border-radius: 2px;
            outline: none;
        }

        .history-zoom-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #fff;
            cursor: pointer;
            box-shadow: 0 2px 6px rgba(0,0,0,0.3);
        }

        .history-sort-btn,
        .history-close-btn {
            width: 32px;
            height: 32px;
            border: 1px solid rgba(255,255,255,0.08);
            background: rgba(255,255,255,0.04);
            border-radius: 8px;
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.12s;
        }

        .history-sort-btn:hover,
        .history-close-btn:hover {
            background: rgba(255,255,255,0.10);
            color: var(--text-primary);
        }

        .history-sort-btn.is-ascending svg {
            transform: rotate(180deg);
        }

        .history-float-body {
            flex: 1;
            overflow-y: auto;
            padding: 12px 16px;
        }

        /* ===== 通用网格 ===== */
        .history-grid {
            display: grid;
            gap: 6px;
            margin-bottom: 12px;
        }

        .history-grid-side {
            grid-template-columns: repeat(3, 1fr);
        }

        .history-date-label {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-secondary);
            padding: 8px 4px 6px;
        }

        /* ===== 历史项 ===== */
        .history-item {
            position: relative;
            border-radius: 8px;
            overflow: hidden;
            aspect-ratio: 1;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.06);
            cursor: pointer;
            transition: border-color 0.12s, transform 0.12s;
        }

        .history-item:hover {
            border-color: rgba(255,168,79,0.3);
            transform: scale(1.02);
        }

        .history-thumb {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .history-thumb-placeholder {
            color: rgba(255,255,255,0.15);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* 收藏按钮 */
        .history-fav-btn {
            position: absolute;
            top: 4px;
            right: 4px;
            width: 24px;
            height: 24px;
            border: none;
            background: rgba(0,0,0,0.5);
            border-radius: 50%;
            color: rgba(255,255,255,0.6);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: opacity 0.12s, color 0.12s;
            backdrop-filter: blur(4px);
        }

        .history-item:hover .history-fav-btn {
            opacity: 1;
        }

        .history-item.is-favorite .history-fav-btn {
            opacity: 1;
            color: #fbbf24;
        }

        .history-fav-btn:hover {
            color: #fbbf24 !important;
        }

        /* 历史记录选中状态 */
        .history-item.selected {
            outline: 2px solid rgba(255,168,79,0.8) !important;
            outline-offset: -2px;
            background: rgba(255,168,79,0.1) !important;
        }

        /* 框选框 */
        .history-selection-box {
            position: absolute;
            border: 1.5px solid rgba(255,168,79,0.6);
            background: rgba(255,168,79,0.1);
            pointer-events: none;
            z-index: 1000;
        }

        /* 空状态 */
        .history-empty {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 200px;
            color: var(--text-tertiary);
            font-size: 13px;
        }

        /* ===== 右键菜单 ===== */
        .history-context-menu {
            position: fixed;
            min-width: 160px;
            background: rgba(18, 23, 34, 0.96);
            border: 1px solid rgba(255,255,255,0.10);
            border-radius: 10px;
            padding: 6px;
            box-shadow: 0 8px 30px rgba(0,0,0,0.5);
            backdrop-filter: blur(16px);
            z-index: 9999;
        }

        .history-context-menu.hidden {
            display: none;
        }

        .history-ctx-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            font-size: 13px;
            color: var(--text-secondary);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.1s;
        }

        .history-ctx-item:hover {
            background: rgba(255,168,79,0.10);
            color: var(--text-primary);
        }

        /* ===== 预览覆盖层 ===== */
        .history-preview-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.88);
            z-index: 9998;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .history-preview-overlay.hidden {
            display: none;
        }

        .history-preview-container {
            position: relative;
            max-width: 90%;
            max-height: 90%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .history-preview-placeholder {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: rgba(255,255,255,0.2);
            transition: transform 0.2s ease;
        }

        .history-preview-close {
            position: absolute;
            top: -36px;
            right: 0;
            width: 28px;
            height: 28px;
            border-radius: 50%;
            background: rgba(255,255,255,0.9);
            color: #111;
            border: none;
            cursor: pointer;
            font-size: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* =============================================
        文字节点快捷连接按钮
        ============================================= */

        .text-node-quick-actions {
            position: absolute;
            right: -145px;
            top: 50%;
            transform: translateY(-50%);
            width: 86px;
            height: 160px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 8px;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease 0.15s;
            z-index: 100;
            padding-left: 30px; /* 透明热区 */
        }

        .node-text-input:hover .text-node-quick-actions,
        .node-text-input.is-selected .text-node-quick-actions,
        .text-node-quick-actions:hover {
            opacity: 1;
            pointer-events: auto;
            transition: opacity 0.2s ease 0s;
        }

        .node-text-input:not(:hover) .text-node-quick-actions:not(:hover) {
            transition: opacity 0.25s ease 1.2s;
        }

        .node-text-input.has-outgoing-connection .text-node-quick-actions {
            opacity: 0 !important;
            pointer-events: none !important;
        }

        .quick-action-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 1px solid rgba(255,255,255,0.12);
            background: rgba(18, 23, 34, 0.95);
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
            backdrop-filter: blur(12px);
            box-shadow: 0 4px 16px rgba(0,0,0,0.3);
            position: relative;
            flex-shrink: 0;
        }

        .quick-action-btn::before {
            content: attr(data-tooltip);
            position: absolute;
            left: calc(100% + 10px);
            white-space: nowrap;
            padding: 5px 12px;
            background: rgba(18, 23, 34, 0.98);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 6px;
            font-size: 12px;
            color: var(--text-primary);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease;
        }

        .quick-action-btn:hover::before {
            opacity: 1;
            transition-delay: 0.3s;
        }

        .quick-action-btn:hover {
            background: rgba(255,168,79,0.15);
            border-color: rgba(255,168,79,0.5);
            color: #ffb347;
            transform: scale(1.15);
            box-shadow: 0 6px 24px rgba(255,168,79,0.3);
        }

        .quick-action-btn:active {
            transform: scale(0.95);
        }

        .quick-action-btn svg {
            width: 18px;
            height: 18px;
        }

        @keyframes quickConnectPulse {
            0%, 100% { opacity: 0.4; }
            50% { opacity: 1; }
        }

        .quick-action-btn.is-connecting {
            animation: quickConnectPulse 0.6s ease-in-out;
            border-color: rgba(255,168,79,0.7);
            background: rgba(255,168,79,0.25);
            box-shadow: 0 0 20px rgba(255,168,79,0.5);
        }

        @keyframes quickActionSlideIn {
            from { opacity: 0; transform: translateX(-8px) scale(0.8); }
            to { opacity: 1; transform: translateX(0) scale(1); }
        }

        .node-text-input:hover .text-node-quick-actions .quick-action-btn:nth-child(1) {
            animation: quickActionSlideIn 0.2s ease-out 0.05s both;
        }
        .node-text-input:hover .text-node-quick-actions .quick-action-btn:nth-child(2) {
            animation: quickActionSlideIn 0.2s ease-out 0.1s both;
        }
        .node-text-input:hover .text-node-quick-actions .quick-action-btn:nth-child(3) {
            animation: quickActionSlideIn 0.2s ease-out 0.15s both;
        }

        /* =============================================
        图片节点右键菜单
        ============================================= */

        .node-text-input:hover .text-node-quick-actions .quick-action-btn:nth-child(4) {
            animation: quickActionSlideIn 0.2s ease-out 0.2s both;
        }

        .image-node-context-menu {
            position: fixed;
            /* 媒体右键菜单对齐 .create-menu 尺寸（保留 .create-menu 的 min-width: 188px） */
            z-index: 20001;
            opacity: 0;
            pointer-events: none;
            overflow: visible;
            transition: opacity 0.15s ease;
        }

        .image-node-context-menu.visible {
            opacity: 1;
            pointer-events: auto;
        }

        .image-node-context-menu .menu-title {
            margin-bottom: 2px;
        }

        .image-node-context-menu .menu-divider {
            height: 1px;
            background: rgba(255,255,255,0.08);
            margin: 5px 7px;
        }

        .image-node-context-menu .menu-item {
            /* 尺寸/内边距/字号完全继承 .create-menu .menu-item，这里只保留定位基础 */
            position: relative;
        }

        .image-node-context-menu .menu-item.has-submenu {
            padding-right: 30px;
        }

        .image-node-context-menu .menu-item.has-submenu::after {
            content: '';
            position: absolute;
            right: 12px;
            top: 50%;
            width: 7px;
            height: 7px;
            border-right: 1.5px solid currentColor;
            border-bottom: 1.5px solid currentColor;
            transform: translateY(-50%) rotate(-45deg);
            opacity: 0.55;
        }

        .image-node-context-menu .menu-item.has-submenu::before {
            content: '';
            position: absolute;
            right: -14px;
            top: 0;
            width: 14px;
            height: 100%;
        }

        .image-node-context-menu .menu-submenu {
            position: absolute;
            left: calc(100% + 8px);
            top: -6px;
            min-width: 140px;
            padding: 8px;
            border-radius: 14px;
            border: 1px solid rgba(255, 255, 255, 0.07);
            background: rgba(10, 14, 22, 0.97);
            backdrop-filter: blur(16px);
            box-shadow:
                0 22px 56px rgba(0, 0, 0, 0.5),
                inset 0 0 0 1px rgba(255, 255, 255, 0.015);
            opacity: 0;
            pointer-events: none;
            z-index: 1;
            transition: opacity 0.12s ease;
        }

        .image-node-context-menu .menu-item.has-submenu:hover > .menu-submenu {
            opacity: 1;
            pointer-events: auto;
        }

        .image-ctx-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            font-size: 13px;
            color: var(--text-secondary);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.12s;
            position: relative;
        }

        .image-ctx-item:hover {
            background: rgba(255,168,79,0.10);
            color: var(--text-primary);
        }

        .image-ctx-item svg {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
            opacity: 0.8;
        }

        .image-ctx-item:hover svg {
            opacity: 1;
        }

        .image-ctx-item.has-submenu::after {
            content: '';
            position: absolute;
            right: 12px;
            width: 6px;
            height: 6px;
            border-right: 1.5px solid currentColor;
            border-bottom: 1.5px solid currentColor;
            transform: rotate(-45deg);
            opacity: 0.5;
        }

        .image-ctx-divider {
            height: 1px;
            background: rgba(255,255,255,0.06);
            margin: 4px 8px;
        }

        /* 子菜单 */
        .image-ctx-submenu {
            position: absolute;
            left: 100%;
            top: -6px;
            min-width: 140px;
            background: rgba(18, 23, 34, 0.98);
            border: 1px solid rgba(255,255,255,0.10);
            border-radius: 10px;
            padding: 6px;
            box-shadow: 0 8px 30px rgba(0,0,0,0.5);
            backdrop-filter: blur(16px);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.12s ease;
        }

        /* 父项左侧加一块透明热区，防止鼠标移向子菜单时断开 hover */
        .image-ctx-item.has-submenu::before {
            content: '';
            position: absolute;
            right: -12px;
            top: 0;
            width: 12px;
            height: 100%;
        }

        .image-ctx-item.has-submenu:hover > .image-ctx-submenu {
            opacity: 1;
            pointer-events: auto;
        }

        /* =============================================
        图片节点快捷连接按钮 — 竖排布局
        ============================================= */

        .image-node-quick-actions {
            position: absolute;
            right: -145px;
            top: 50%;
            transform: translateY(-50%);
            width: 56px;
            height: auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 6px;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease 0.15s;
            z-index: 100;
        }

        .node-image-upload:hover .image-node-quick-actions,
        .node-image-upload.is-selected .image-node-quick-actions,
        .image-node-quick-actions:hover {
            opacity: 1;
            pointer-events: auto;
            transition: opacity 0.2s ease 0s;
        }

        .node-image-upload:not(:hover) .image-node-quick-actions:not(:hover) {
            transition: opacity 0.3s ease 0.4s;
        }

        .node-image-upload.has-outgoing-connection .image-node-quick-actions {
            opacity: 0 !important;
            pointer-events: none !important;
        }

        /* 不再需要 arc 容器的相对定位 */
        .image-quick-actions-arc {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
        }

        .image-quick-action-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 1px solid rgba(255,255,255,0.12);
            background: rgba(18, 23, 34, 0.95);
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
            backdrop-filter: blur(12px);
            box-shadow: 0 4px 16px rgba(0,0,0,0.3);
            position: relative;
            flex-shrink: 0;
        }

        /* 清除旧的绝对定位 */
        .image-quick-action-btn[data-action="text"],
        .image-quick-action-btn[data-action="image-gen"],
        .image-quick-action-btn[data-action="video"],
        .image-quick-action-btn[data-action="agent"],
        .image-quick-action-btn[data-action="compare"] {
            position: relative;
            top: auto;
            bottom: auto;
            left: auto;
            right: auto;
            transform: none;
        }

        .image-quick-action-btn::before {
            content: attr(data-tooltip);
            position: absolute;
            left: calc(100% + 10px);
            white-space: nowrap;
            padding: 5px 12px;
            background: rgba(18, 23, 34, 0.98);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 6px;
            font-size: 12px;
            color: var(--text-primary);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease;
        }

        .image-quick-action-btn:hover::before {
            opacity: 1;
            transition-delay: 0.3s;
        }

        .image-quick-action-btn:hover {
            background: rgba(255,168,79,0.15);
            border-color: rgba(255,168,79,0.5);
            color: #ffb347;
            transform: scale(1.15);
            box-shadow: 0 6px 24px rgba(255,168,79,0.3);
        }

        .image-quick-action-btn svg {
            width: 18px;
            height: 18px;
        }

        .image-quick-action-btn.is-connecting {
            animation: quickConnectPulse 0.6s ease-in-out;
            border-color: rgba(255,168,79,0.7);
            background: rgba(255,168,79,0.25);
        }

        /* 入场动画 */
        .node-image-upload:hover .image-quick-actions-arc .image-quick-action-btn:nth-child(1) {
            animation: quickActionSlideIn 0.2s ease-out 0.05s both;
        }
        .node-image-upload:hover .image-quick-actions-arc .image-quick-action-btn:nth-child(2) {
            animation: quickActionSlideIn 0.2s ease-out 0.1s both;
        }
        .node-image-upload:hover .image-quick-actions-arc .image-quick-action-btn:nth-child(3) {
            animation: quickActionSlideIn 0.2s ease-out 0.15s both;
        }
        .node-image-upload:hover .image-quick-actions-arc .image-quick-action-btn:nth-child(4) {
            animation: quickActionSlideIn 0.2s ease-out 0.2s both;
        }
        .node-image-upload:hover .image-quick-actions-arc .image-quick-action-btn:nth-child(5) {
            animation: quickActionSlideIn 0.2s ease-out 0.25s both;
        }

    /* =============================================
    连线高亮和选中状态
    ============================================= */
    .connection-path.connection-highlighted {
        stroke: var(--connection-highlight-stroke, var(--accent-blue)) !important;
        stroke-width: var(--connection-hover-stroke-width, 2) !important;
        filter: var(--connection-highlight-filter, drop-shadow(0 0 6px rgba(255,168,79,0.4)));
        transition: stroke 0.15s, stroke-width 0.15s;
    }

    .connections-layer.is-distant-line-mode .connection-path.connection-highlighted {
        stroke: rgba(255, 190, 116, 0.58) !important;
        filter: none !important;
    }

    /* 连线弹出菜单样式 */
    .connection-drop-menu {
        min-width: 160px;
        animation: none;
    }

/* =============================================
   配置弹窗 - 新版卡片式布局
   ============================================= */

.modal-body .tab-nav,
.modal-body .tab-btn,
.modal-body .tab-content,
.modal-body .global-config-unified,
.modal-body .global-config,
.modal-body .models-list,
.modal-body .model-item {
    display: none !important;
}

.config-top-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    padding-bottom: 0;
    flex-wrap: wrap;
}

.config-top-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(29,34,42,0.92);
    border: 1px solid rgba(69,72,78,0.2);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.config-top-tab:hover {
    background: rgba(40,44,52,0.96);
    color: var(--text-primary);
}

.config-top-tab.active {
    background: var(--gradient-primary);
    border-color: rgba(255,168,79,0.4);
    color: #fff7ec;
}

.config-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(0,0,0,0.2);
    color: inherit;
}

.config-top-tab.active .config-tab-count {
    background: rgba(255,255,255,0.2);
}

.config-global-section {
    background: rgba(16,20,25,0.78);
    border: 1px solid rgba(69,72,78,0.18);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 24px;
}

.config-global-row {
    margin-bottom: 14px;
}

.config-global-row:last-of-type {
    margin-bottom: 0;
}

.config-global-row label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.config-hint-inline {
    font-weight: 400;
    color: var(--text-tertiary);
    text-transform: none;
    letter-spacing: 0;
    font-size: 11px;
}

.config-global-input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    background: var(--bg-primary);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'SF Mono', 'Consolas', monospace;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.config-global-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(255,168,79,0.12);
}

.config-global-input::placeholder {
    color: var(--text-tertiary);
    font-family: inherit;
}

.config-key-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.config-key-wrap .config-global-input {
    padding-right: 44px;
}

.config-eye-btn {
    position: absolute;
    right: 4px;
    width: 36px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
}

.config-eye-btn:hover {
    background: rgba(255,255,255,0.10);
    color: var(--text-primary);
}

.config-global-hint {
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.5;
}

.config-tab-panel {
    display: none;
}

.config-tab-panel.active {
    display: block;
}

.config-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.model-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.model-card:hover {
    border-color: rgba(255,255,255,0.14);
}

.model-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.model-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.model-card-tag {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.tag-chat { background: rgba(255,149,0,0.12); color: #ffb347; }
.tag-image { background: rgba(16,185,129,0.12); color: #34d399; }
.tag-video { background: rgba(245,158,11,0.12); color: #fbbf24; }
.tag-music { background: rgba(139,92,246,0.12); color: #a78bfa; }
.tag-tools { background: rgba(236,72,153,0.12); color: #f472b6; }

.model-card-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.model-field {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-field label {
    flex-shrink: 0;
    width: 80px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.model-field-input {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    background: var(--bg-primary);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'SF Mono', 'Consolas', monospace;
    outline: none;
    transition: border-color 0.15s;
}

.model-field-input:focus {
    border-color: rgba(255,168,79,0.5);
    box-shadow: 0 0 0 1px rgba(255,168,79,0.1);
}

.model-field-input::placeholder {
    color: var(--text-tertiary);
    font-family: inherit;
    font-size: 12px;
}

.model-field-key-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.model-field-key-wrap .model-field-input {
    flex: 1;
    padding-right: 38px;
}

.config-eye-btn-sm {
    position: absolute;
    right: 3px;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    opacity: 0.5;
}

.config-eye-btn-sm:hover {
    opacity: 1;
    background: rgba(255,255,255,0.06);
}

.model-card-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 6px;
}

.test-link {
    font-size: 12px;
    color: var(--accent-blue);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.12s;
}

.test-link:hover {
    color: var(--accent-blue-hover);
    text-decoration: underline;
}

.test-status-text {
    font-size: 12px;
    font-weight: 500;
}

.test-status-text.success { color: #10b981; }
.test-status-text.error { color: #ef4444; }

/* =============================================
   节点内 Toast 提示（替代 alert）
   ============================================= */

.node-toast {
    position: absolute;
    left: 50%;
    bottom: -12px;
    transform: translate(-50%, 100%) scale(0.95);
    z-index: 200;
    max-width: 360px;
    min-width: 200px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.node-toast.node-toast-in {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 100%) scale(1);
}

.node-toast.node-toast-out {
    opacity: 0;
    transform: translate(-50%, 100%) scale(0.95);
}

.node-toast-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    font-size: 12px;
    line-height: 1.6;
    margin-top: 8px;
}

.node-toast-text {
    flex: 1;
    word-break: break-word;
}

.node-toast-close {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: none;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
}

.node-toast-close:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* 错误类型 — 红色调 */
.node-toast-error .node-toast-content {
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

/* 警告类型 — 黄色调 */
.node-toast-warn .node-toast-content {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fcd34d;
}

/* 信息类型 — 蓝色调 */
.node-toast-info .node-toast-content {
    background: rgba(255,149,0, 0.12);
    border: 1px solid rgba(255,179,71, 0.3);
    color: #ffd6a1;
}

/* 成功类型 — 绿色调 */
.node-toast-success .node-toast-content {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: #6ee7b7;
}

/* =============================================
   AI绘图节点 — 上游媒体缩略图栏
   ============================================= */

.imagen-media-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 8px 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.imagen-media-bar.media-bar-in {
    opacity: 1;
    transform: translateY(0);
}

.imagen-media-bar.media-bar-out {
    opacity: 0;
    transform: translateY(-4px);
}

.media-bar-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 2px;
}

.media-bar-items {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 0;
}

/* 滚动条隐藏 */
.media-bar-items::-webkit-scrollbar {
    height: 0;
}

.media-bar-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    transition: all 0.15s ease;
    min-width: 56px;
}

.media-bar-item.text-vision-thumb {
    gap: 4px;
    padding: 12px 4px 2px;
    background: transparent;
    border: 0;
    box-shadow: none;
    min-width: 56px;
}

.media-bar-thumb-preview {
    border: 0;
    padding: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.media-bar-disconnect {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border: 1px solid rgba(255, 168, 79, 0.38);
    border-radius: 999px;
    background: rgba(17, 19, 26, 0.92);
    color: rgba(255, 214, 168, 0.95);
    font-size: 11px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    transform: scale(0.92);
}

.media-bar-item:hover .media-bar-disconnect,
.media-bar-item:focus-within .media-bar-disconnect {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.media-bar-disconnect:hover {
    border-color: rgba(255, 120, 120, 0.7);
    background: rgba(63, 18, 18, 0.96);
    color: rgba(255, 230, 230, 0.96);
}

.media-bar-tag.text-vision-thumb-label-btn {
    max-width: 64px;
}

.media-bar-item:hover {
    background: rgba(255,168,79,0.10);
    border-color: rgba(255,168,79,0.3);
    transform: translateY(-1px);
}

.media-bar-item:active {
    transform: scale(0.95);
}

.media-bar-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-bar-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-bar-placeholder {
    color: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-bar-tag {
    font-size: 10px;
    color: var(--text-tertiary);
    white-space: nowrap;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-bar-item:hover .media-bar-tag {
    color: #ffb347;
}

.node-image-gen .imagen-media-bar {
    opacity: 1;
    transform: none;
}

/* =============================================
   @ Mention 自动补全弹窗
   ============================================= */

.mention-popup {
    position: fixed;
    z-index: 9500;
    background: rgba(18, 23, 34, 0.98);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.55);
    backdrop-filter: blur(16px);
    max-height: 260px;
    overflow-y: auto;
    display: none;
    min-width: 200px;
}

.mention-popup-header {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    padding: 6px 10px 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.mention-popup-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.1s ease;
}

.mention-popup-item:hover,
.mention-popup-item.is-active {
    background: rgba(255,168,79,0.12);
}

.mention-popup-thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mention-popup-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mention-popup-placeholder {
    color: rgba(255,255,255,0.2);
}

.mention-popup-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.mention-popup-tag {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.mention-popup-item.is-active .mention-popup-tag {
    color: #ffb347;
}

.mention-popup-type {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* @ 弹窗滚动条 */
.mention-popup::-webkit-scrollbar {
    width: 4px;
}

.mention-popup::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 2px;
}

/* =============================================
   textarea 中的 @ 引用标签样式提示
   ============================================= */

/* 让 textarea 中的 @引用 有视觉提示 — 通过 CSS 无法直接实现 */
/* 但可以在 placeholder 中提示用户 */
.node-image-gen .node-textarea::placeholder {
    color: var(--text-tertiary);
}

/* 有上游媒体连接时，textarea placeholder 变化 */
.node-image-gen .imagen-media-bar ~ .node-textarea::placeholder {
    /* 无法动态改 placeholder 文字，但 JS 中可改 */
}

/* =============================================
   修复: 悬浮按钮 — 最终版
   1. 鼠标离开后 1.5s 消失
   2. 右移 5px（增加间距）
   3. 热区保持可点击
   ============================================= */

/* 清除上一轮的 !important 覆盖 */
.node-text-input:not(:hover) .text-node-quick-actions:not(:hover),
.node-image-upload:not(:hover) .image-node-quick-actions:not(:hover),
.node-text-input:not(:hover):not(:focus-within) .text-node-quick-actions:not(:hover),
.node-image-upload:not(:hover):not(:focus-within) .image-node-quick-actions:not(:hover) {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.21s ease 1.05s, pointer-events 0s linear 1.05s !important;
}

/* 节点 hover 或选中时立即显示 */
.node-text-input:hover .text-node-quick-actions,
.node-text-input.is-selected .text-node-quick-actions,
.node-image-upload:hover .image-node-quick-actions,
.node-image-upload.is-selected .image-node-quick-actions {
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: opacity 0.15s ease 0s !important;
}

/* 按钮容器自身被 hover 时保持显示 */
.text-node-quick-actions:hover,
.image-node-quick-actions:hover {
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: opacity 0.1s ease 0s !important;
}

/* 文字节点 — 在端口外侧（-130px = 端口外 + 间距）+ 热区 */
.text-node-quick-actions {
    right: -145px !important;
    padding-left: 20px !important;
    width: 70px !important;
}

/* 图片节点 — 在端口外侧 + 热区 */
.image-node-quick-actions {
    right: -145px !important;
    padding-left: 20px !important;
    width: 70px !important;
}



        /* ===== 文字节点视觉分析模式 ===== */

        /* 头部容器 */
        .text-vision-header {
            display: flex;
            flex-direction: column;
            gap: 7px;
            width: 100%;
            padding: 2px 0 2px;
        }

        /* 标题行 */
        .text-vision-title {
            font-size: 12px;
            font-weight: 600;
            color: #6fa3ff;
            letter-spacing: 0.02em;
            display: flex;
            align-items: center;
        }

        /* 控件行 */
        .text-vision-controls {
            display: flex;
            align-items: center;
            gap: 6px;
            width: 100%;
        }

        /* 模型选择下拉 */
        .text-vision-model-select {
            flex: 1;
            min-width: 0;
            height: 28px;
            border-radius: 6px;
            border: 1px solid rgba(255,255,255,0.10);
            background: rgba(20, 24, 38, 0.9);
            color: #c8d4f0;
            font-size: 11px;
            padding: 0 8px;
            outline: none;
            cursor: pointer;
        }

        /* 预设选择下拉 */
        .text-vision-preset-select {
            flex: 0 0 88px;
            height: 28px;
            border-radius: 6px;
            border: 1px solid rgba(255,255,255,0.10);
            background: rgba(20, 24, 38, 0.9);
            color: #c8d4f0;
            font-size: 11px;
            padding: 0 6px;
            outline: none;
            cursor: pointer;
        }

        /* 运行按钮 */
        .text-vision-run-btn {
            flex: 0 0 auto;
            height: 28px;
            padding: 0 11px;
            border: none;
            border-radius: 6px;
            background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
            color: #fff7ec;
            font-size: 11px;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 4px;
            transition: background 0.15s;
            white-space: nowrap;
        }

        .text-vision-run-btn:hover {
            background: linear-gradient(135deg, #ffc163 0%, #ff9f1f 100%);
        }

        .text-vision-run-btn:disabled {
            background: #2a3a5a;
            color: rgba(255,255,255,0.4);
            cursor: not-allowed;
        }

        /* 节点运行中 — 蓝色边框脉动 */
        .node-vision-running {
            outline: 2px solid rgba(47, 109, 246, 0.7) !important;
            outline-offset: 2px;
            animation: visionPulse 1.2s ease-in-out infinite;
        }

        @keyframes visionPulse {
            0%, 100% { outline-color: rgba(47, 109, 246, 0.4); }
            50%       { outline-color: rgba(47, 109, 246, 0.9); }
        }

        /* 运行成功 — 绿色闪烁 */
        .node-vision-done {
            outline: 2px solid rgba(52, 211, 153, 0.8) !important;
            outline-offset: 2px;
            transition: outline-color 0.4s ease;
        }

        /* 激活视觉模式时让头部背景略有区分 */
        .node[data-vision-mode="1"] .node-upload-header {
            background: rgba(30, 50, 90, 0.45);
            border-bottom: 1px solid rgba(111, 163, 255, 0.15);
        }

        /* ===================== */
        /* Node Resize Handles   */
        /* ===================== */
        .node-resize-handle {
            position: absolute;
            background: transparent;
            border: none;
            z-index: 25;
            opacity: 0;
            pointer-events: auto;
            transition: opacity 0.2s ease;
        }

        /* 节点 hover 或选中时显示 */
        .node:hover .node-resize-handle,
        .node.is-selected .node-resize-handle {
            opacity: 1;
        }

        /* 正在 resize 时隐藏手柄避免干扰 */
        .node.is-resizing .node-resize-handle {
            opacity: 0;
        }

        /* 四角手柄 - 调整到边框内侧，增大热区 */
        .node-resize-handle.rh-tl { top: 0; left: 0; width: 16px; height: 16px; cursor: nwse-resize; }
        .node-resize-handle.rh-tr { top: 0; right: 0; width: 16px; height: 16px; cursor: nesw-resize; }
        .node-resize-handle.rh-bl { bottom: 0; left: 0; width: 16px; height: 16px; cursor: nesw-resize; }
        .node-resize-handle.rh-br { bottom: 0; right: 0; width: 16px; height: 16px; cursor: nwse-resize; }

        /* 四边手柄 - 调整到边框内侧 */
        .node-resize-handle.rh-t { top: 0; left: 16px; right: 16px; height: 8px; cursor: ns-resize; }
        .node-resize-handle.rh-b { bottom: 0; left: 16px; right: 16px; height: 8px; cursor: ns-resize; }
        .node-resize-handle.rh-l { left: 0; top: 16px; bottom: 16px; width: 8px; cursor: ew-resize; }
        .node-resize-handle.rh-r { right: 0; top: 16px; bottom: 16px; width: 8px; cursor: ew-resize; }

        /* hover 时四角显示小圆点指示 */
        .node-resize-handle.rh-tl::after,
        .node-resize-handle.rh-tr::after,
        .node-resize-handle.rh-bl::after,
        .node-resize-handle.rh-br::after {
            content: '';
            position: absolute;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: rgba(180, 195, 225, 0.6);
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            transition: background 0.2s ease, transform 0.2s ease;
        }

        .node-resize-handle:hover::after {
            background: rgba(255,179,71, 0.9);
            transform: translate(-50%, -50%) scale(1.4);
        }

        .agent-msg-img-row{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end;margin-bottom:4px;}
        .agent-msg-img-thumb{width:72px;height:72px;object-fit:cover;border-radius:8px;border:1.5px solid rgba(255,255,255,0.12);cursor:pointer;transition:transform 0.15s ease,border-color 0.15s ease;}
        .agent-msg-video-thumb{background:#05070a;}
        .agent-msg-img-thumb:hover{transform:scale(1.05);border-color:rgba(255,179,71,0.6);}/* =============================================
   历史记录面板增强样式
   ============================================= */

/* 选中状态 */
.history-item.history-selected {
    outline: 2px solid rgba(255,168,79,0.8) !important;
    outline-offset: -2px;
    background: rgba(255,168,79,0.12) !important;
    border-color: rgba(255,168,79,0.4) !important;
}

.history-item.history-selected .history-fav-btn {
    opacity: 1 !important;
}

/* 框选框 */
.history-selection-box {
    position: absolute;
    border: 1.5px solid rgba(255,168,79,0.6);
    background: rgba(255,168,79,0.08);
    pointer-events: none;
    z-index: 100;
    border-radius: 2px;
}

/* 缩略图媒体填充 */
.history-thumb-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}

/* ===== 悬浮大面板重构 - 左右对齐 ===== */

.history-floating-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.history-floating-panel.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 内部 wrapper — 可 resize */
.history-float-wrapper {
    display: flex;
    width: 80vw;
    max-width: 1100px;
    height: 75vh;
    max-height: 800px;
    min-width: 500px;
    min-height: 350px;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
}

/* 左侧导航 — 与右侧等高对齐 */
.history-float-sidebar {
    width: 180px;
    min-width: 160px;
    background: rgba(18, 22, 32, 0.98);
    border: 1px solid rgba(255,255,255,0.06);
    border-right: none;
    border-radius: 14px 0 0 14px;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

/* 右侧主内容 — 与左侧等高 */
.history-float-main {
    flex: 1;
    background: rgba(13, 17, 26, 0.98);
    border: 1px solid rgba(255,255,255,0.06);
    border-left: none;
    border-radius: 0 14px 14px 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.history-float-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

/* ===== 侧边面板尺寸固定（切换tab不变大小）===== */

.history-side-panel {
    width: 380px;
    height: 350px;
    max-height: 80vh;
    min-width: 280px;
    min-height: 200px;
    overflow: visible; /* 让 resize handle 溢出 */
}

.history-side-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 0;
}

/* ===== 右键菜单删除项红色 ===== */
.history-ctx-item[data-action="delete"] {
    color: rgba(239,68,68,0.85) !important;
}

.history-ctx-item[data-action="delete"]:hover {
    background: rgba(239,68,68,0.10) !important;
    color: rgba(239,68,68,1) !important;
}

.history-ctx-item[data-action="delete"] svg {
    stroke: rgba(239,68,68,0.85) !important;
}

/* =============================================
   接口配置弹窗 — 只改内部模型配置区域
   顶部三个 Tab（接口配置/存储管理/关于）完全不动
   ============================================= */

/* 弹窗稍微大一点 */
#configModal .modal-container {
    max-width: 780px !important;
    width: 92vw !important;
    max-height: 88vh !important;
}

/* body 背景统一 */
#configTabApi .modal-body {
    padding: 20px 24px !important;
}

/* ===== 分类 Tab（Chat/Image/Video...）===== */
.config-top-tabs {
    display: flex !important;
    gap: 6px !important;
    margin-bottom: 20px !important;
    padding: 0 !important;
    flex-wrap: wrap !important;
}

.config-top-tab {
    padding: 6px 14px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    border-radius: 6px !important;
    gap: 5px !important;
    background: rgba(255,255,255,0.02) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    color: rgba(255,255,255,0.62) !important;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease !important;
}

.config-top-tab:hover {
    color: rgba(255,255,255,0.84) !important;
    background: rgba(255,255,255,0.05) !important;
    border-color: rgba(255,255,255,0.12) !important;
}

.config-top-tab.active {
    background: rgba(119,95,71,0.52) !important;
    border-color: rgba(255,196,129,0.22) !important;
    color: rgba(255,247,239,0.96) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06) !important;
}

.config-tab-count {
    min-width: 18px !important;
    height: 17px !important;
    font-size: 11px !important;
    padding: 0 5px !important;
    border-radius: 8px !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    background: rgba(255,255,255,0.04) !important;
    color: inherit !important;
}

.config-top-tab.active .config-tab-count {
    background: rgba(255,255,255,0.08) !important;
    border-color: rgba(255,255,255,0.12) !important;
}

/* ===== 全局配置区 ===== */
.config-global-section {
    padding: 16px 0 !important;
    margin-bottom: 8px !important;
    border-radius: 0 !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid rgba(255,255,255,0.04) !important;
}

.config-global-row {
    margin-bottom: 12px !important;
}

.config-global-row:last-of-type {
    margin-bottom: 0 !important;
}

.config-global-row label {
    display: block !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    margin-bottom: 6px !important;
    color: rgba(255,255,255,0.35) !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
}

.config-hint-inline {
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-size: 11px !important;
    color: rgba(255,255,255,0.25) !important;
}

.config-global-input {
    height: 42px !important;
    padding: 0 14px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
    background: rgba(255,255,255,0.04) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
}

.config-global-input:focus {
    border-color: rgba(255,168,79,0.4) !important;
    box-shadow: 0 0 0 1px rgba(255,168,79,0.1) !important;
}

.config-global-hint {
    margin-top: 8px !important;
    font-size: 11px !important;
    color: rgba(255,255,255,0.25) !important;
}

.config-key-wrap .config-global-input {
    padding-right: 44px !important;
}

.config-eye-btn {
    width: 34px !important;
    height: 32px !important;
    right: 4px !important;
    border-radius: 6px !important;
    color: rgba(255,255,255,0.3) !important;
}

.config-eye-btn:hover {
    color: rgba(255,255,255,0.7) !important;
    background: rgba(255,255,255,0.06) !important;
}

/* =============================================
   模型卡片 — 竖排紧凑风格
   ============================================= */

.config-cards-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

.model-card {
    background: rgba(255,255,255,0.02) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    transition: border-color 0.15s ease !important;
}

.model-card:hover {
    border-color: rgba(255,255,255,0.10) !important;
}

/* 卡片头部 */
.model-card-header {
    padding: 12px 16px 8px !important;
    border-bottom: none !important;
}

.model-card-name {
    font-size: 14px !important;
    font-weight: 600 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

/* 绿色圆点 */
.model-card-name::before {
    content: '' !important;
    display: inline-block !important;
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background: #4ecb71 !important;
    flex-shrink: 0 !important;
    box-shadow: 0 0 6px rgba(78,203,113,0.4) !important;
}

#configTabApi .model-card-tag {
    padding: 3px 10px !important;
    border-radius: 5px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    background: rgba(255,255,255,0.04) !important;
    color: rgba(255,255,255,0.58) !important;
    box-shadow: none !important;
}

#configTabApi .tag-chat {
    background: rgba(212,179,137,0.10) !important;
    border-color: rgba(212,179,137,0.18) !important;
    color: #d9bb96 !important;
}

#configTabApi .tag-image {
    background: rgba(118,190,160,0.10) !important;
    border-color: rgba(118,190,160,0.16) !important;
    color: #9ed6bb !important;
}

#configTabApi .tag-video {
    background: rgba(206,168,103,0.10) !important;
    border-color: rgba(206,168,103,0.18) !important;
    color: #dbbf88 !important;
}

#configTabApi .tag-music {
    background: rgba(152,138,201,0.10) !important;
    border-color: rgba(152,138,201,0.16) !important;
    color: #bbb1ea !important;
}

#configTabApi .tag-tools {
    background: rgba(190,134,163,0.10) !important;
    border-color: rgba(190,134,163,0.16) !important;
    color: #dcabc7 !important;
}

/* 卡片内容 — 竖排 */
.model-card-body {
    padding: 4px 16px 14px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

/* 字段 — label左 + input右 */
.model-field {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
}

.model-field label {
    flex-shrink: 0 !important;
    width: 72px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: rgba(255,255,255,0.35) !important;
    letter-spacing: 0.3px !important;
    text-transform: uppercase !important;
    text-align: right !important;
    opacity: 1 !important;
}

.model-field-input {
    flex: 1 !important;
    height: 36px !important;
    padding: 0 12px !important;
    font-size: 13px !important;
    border-radius: 7px !important;
    background: rgba(255,255,255,0.04) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
}

.model-field-input:focus {
    border-color: rgba(255,168,79,0.35) !important;
    box-shadow: 0 0 0 1px rgba(255,168,79,0.08) !important;
}

.model-field-input::placeholder {
    font-size: 12px !important;
    color: rgba(255,255,255,0.18) !important;
}

.model-field-key-wrap {
    flex: 1 !important;
}

.model-field-key-wrap .model-field-input {
    padding-right: 34px !important;
}

.config-eye-btn-sm {
    width: 28px !important;
    height: 28px !important;
    right: 3px !important;
    font-size: 13px !important;
    color: rgba(255,255,255,0.25) !important;
    opacity: 1 !important;
}

.config-eye-btn-sm:hover {
    color: rgba(255,255,255,0.6) !important;
    background: rgba(255,255,255,0.06) !important;
}

/* 测试连接 — 右对齐 */
.model-card-actions {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 2px 16px 0 0 !important;
    justify-content: flex-end !important;
}

.test-link {
    font-size: 12px !important;
    color: rgba(255,168,79,0.7) !important;
}

.test-link:hover {
    color: rgba(255,168,79,1) !important;
}

.test-status-text {
    font-size: 11px !important;
}

/* ===== 底部按钮栏 ===== */
#configTabApi .modal-footer {
    padding: 12px 20px !important;
}

#configTabApi .modal-footer .btn {
    height: 36px !important;
    padding: 0 18px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
    .model-field {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .model-field label {
        width: auto !important;
        text-align: left !important;
    }
}

/* =============================================
   接口配置 — 测试状态左右分离
   ============================================= */

/* 测试连接区域 — 左右布局 */
.model-card-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important; /* 左右分布 */
    padding: 2px 16px 0 88px !important; /* 左侧与 label 对齐 */
    gap: 12px !important;
}

/* 左侧：连接状态 */
.test-status-text {
    font-size: 11px !important;
    flex-shrink: 0 !important;
}

/* 右侧：测试连接按钮 */
.test-link {
    font-size: 12px !important;
    color: rgba(255,168,79,0.7) !important;
    margin-left: auto !important; /* 推到最右侧 */
}

/* =============================================
   存储管理 — 卡片式布局
   ============================================= */

/* 卡片容器 */
.storage-card {
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.storage-card:hover {
    border-color: rgba(255,255,255,0.10);
}

.storage-card:last-child {
    margin-bottom: 0;
}

/* 卡片头部 */
.storage-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.storage-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.storage-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.storage-badge-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.storage-status-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 10px;
}

.storage-status-badge.enabled {
    background: rgba(78,203,113,0.10);
    color: #4ecb71;
}

.storage-status-badge.disabled {
    background: rgba(255,100,100,0.10);
    color: #ff6464;
}

.storage-hint-right {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* 卡片内容 */
.storage-card-body {
    padding: 14px 18px 16px;
}

/* 字段 */
.storage-field {
    margin-bottom: 12px;
}

.storage-field label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.storage-path-display {
    display: flex;
    align-items: center;
    gap: 0;
}

.storage-path-input {
    width: 100%;
    height: 40px;
    padding: 0 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'SF Mono', 'Consolas', monospace;
    outline: none;
    cursor: text;
    transition: border-color 0.15s;
}
.storage-path-input:focus {
    border-color: rgba(255,168,79,0.4);
    background: rgba(255,255,255,0.05);
}

.storage-path-input::placeholder {
    color: var(--text-tertiary);
    font-family: inherit;
}

/* 按钮行 */
.storage-btn-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* 通用按钮基础 */
.storage-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    border: none;
    font-family: inherit;
}

.storage-btn:active {
    transform: scale(0.97);
}

.storage-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* 主色按钮（绿色） */
.storage-btn-primary {
    background: #22a352;
    color: #fff;
}

.storage-btn-primary:hover {
    background: #1d8f47;
}

/* 轮廓按钮 */
.storage-btn-outline {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-secondary);
}

.storage-btn-outline:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.18);
}

/* 强调色按钮（蓝色） */
.storage-btn-accent {
    background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
    color: #fff7ec;
}

.storage-btn-accent:hover {
    background: linear-gradient(135deg, #ffc163 0%, #ff9f1f 100%);
}

/* 危险按钮（红色） */
.storage-btn-danger {
    background: #dc3545;
    color: #fff;
}

.storage-btn-danger:hover {
    background: #c82333;
}

/* 危险柔和按钮 */
.storage-btn-danger-subtle {
    background: rgba(255,100,100,0.08);
    border: 1px solid rgba(255,100,100,0.15);
    color: rgba(255,100,100,0.8);
}

.storage-btn-danger-subtle:hover {
    background: rgba(255,100,100,0.15);
    color: #ff6464;
}

/* 危险图标按钮 */
.storage-btn-danger-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,100,100,0.08);
    border: 1px solid rgba(255,100,100,0.15);
    border-radius: 8px;
    color: rgba(255,100,100,0.8);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.storage-btn-danger-icon:hover {
    background: rgba(255,100,100,0.18);
    color: #ff4444;
    border-color: rgba(255,100,100,0.35);
}

/* 全宽按钮 */
.storage-btn-full {
    flex: 1;
    justify-content: center;
}

/* 提示文字 */
.storage-hint {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.7;
}

/* 内联行 */
.storage-inline-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.storage-inline-label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.storage-inline-hint {
    font-size: 12px;
    color: var(--text-tertiary);
}

.storage-number-input {
    width: 64px;
    height: 36px;
    padding: 0 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'SF Mono', 'Consolas', monospace;
    text-align: center;
    outline: none;
}

.storage-number-input:focus {
    border-color: rgba(255,168,79,0.4);
}

/* 开关 Toggle */
.storage-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.storage-toggle input {
    display: none;
}

.storage-toggle-slider {
    position: relative;
    width: 38px;
    height: 22px;
    background: rgba(255,255,255,0.1);
    border-radius: 22px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.storage-toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.storage-toggle input:checked + .storage-toggle-slider {
    background: #ffa84f;
}

.storage-toggle input:checked + .storage-toggle-slider::before {
    transform: translateX(16px);
}

.storage-toggle-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* 内存管理 */
.storage-memory-section {
    margin-bottom: 14px;
}

.storage-memory-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.storage-memory-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.storage-memory-value {
    font-size: 13px;
    font-weight: 600;
    color: #4ecb71;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.storage-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.storage-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ecb71, #36a85c);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* 存储统计 */
.storage-stats-grid {
    display: flex;
    gap: 0;
    margin-bottom: 14px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    overflow: hidden;
}

.storage-stat-item {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
}

.storage-stat-item + .storage-stat-item {
    border-left: 1px solid rgba(255,255,255,0.06);
}

.storage-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.storage-stat-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

/* 导出行 */
.storage-export-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* =============================================
   视觉分析模式 — 布局优化（覆盖旧样式）
   ============================================= */

/* 激活视觉模式时头部高度自适应 */
.node[data-vision-mode="1"] .node-upload-header {
    height: auto !important;
    min-height: 28px !important;
    padding: 8px 12px !important;
    background: rgba(30, 50, 90, 0.35) !important;
    border-bottom: 1px solid rgba(111, 163, 255, 0.12) !important;
}

/* 头部整体 */
.text-vision-header {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
    padding: 0 !important;
}

/* 标题行 */
.text-vision-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.text-vision-title {
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #6fa3ff !important;
    display: flex !important;
    align-items: center !important;
    white-space: nowrap !important;
}

/* 控件行 — 关键修复：不换行，缩小控件 */
.text-vision-controls {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    width: 100% !important;
    min-width: 0 !important;
}

/* 模型选择 — 缩小，截断长名称 */
.text-vision-model-select {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 120px !important;
    height: 26px !important;
    border-radius: 5px !important;
    border: 1px solid rgba(255,255,255,0.10) !important;
    background: rgba(20, 24, 38, 0.9) !important;
    color: #c8d4f0 !important;
    font-size: 11px !important;
    padding: 0 4px !important;
    outline: none !important;
    cursor: pointer !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 24 24" fill="none" stroke="%23888" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: right 4px center !important;
    padding-right: 16px !important;
}

/* 预设选择 — 固定宽度 */
.text-vision-preset-select {
    flex: 0 0 auto !important;
    width: 80px !important;
    height: 26px !important;
    border-radius: 5px !important;
    border: 1px solid rgba(255,255,255,0.10) !important;
    background: rgba(20, 24, 38, 0.9) !important;
    color: #c8d4f0 !important;
    font-size: 11px !important;
    padding: 0 4px !important;
    outline: none !important;
    cursor: pointer !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 24 24" fill="none" stroke="%23888" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: right 4px center !important;
    padding-right: 16px !important;
}

/* 运行按钮 — 紧凑 */
.text-vision-run-btn {
    flex: 0 0 auto !important;
    height: 26px !important;
    padding: 0 10px !important;
    border: none !important;
    border-radius: 5px !important;
    background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%) !important;
    color: #fff7ec !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 3px !important;
    transition: background 0.15s !important;
    white-space: nowrap !important;
}

.text-vision-run-btn:hover {
    background: linear-gradient(135deg, #ffc163 0%, #ff9f1f 100%) !important;
}

.text-vision-run-btn:disabled {
    background: #2a3a5a !important;
    color: rgba(255,255,255,0.4) !important;
    cursor: not-allowed !important;
}

/* select option 背景 */
.text-vision-model-select option,
.text-vision-preset-select option {
    background: #1a1f2e;
    color: #c8d4f0;
}

/* =============================================
   自定义代理节点 — Agent Node
   ============================================= */

.node.node-agent:not(.node-manual-resized) {
    width: 600px !important;
    min-width: 600px !important;
    height: 860px !important;
    min-height: 860px !important;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.node-agent .agent-section-port {
    z-index: 15 !important;
    left: -10px !important;
}

.node-agent .agent-section-port-meta {
    top: 51px !important;
}

.node-agent .agent-section-port-user {
    top: 248px !important;
}

.node-agent .node-upload-header {
    height: 30px !important;
    font-size: 12px !important;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* 节点主体 */
.agent-node-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
}

.agent-node-body::-webkit-scrollbar { width: 4px; }
.agent-node-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ===== 区块通用 ===== */
.agent-section {
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.agent-section:last-child {
    border-bottom: none;
}

.agent-section-output {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.agent-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px 6px;
    flex-wrap: wrap;
    min-height: 36px;
}

.agent-section-header > * {
    min-width: 0;
}

.agent-section-meta .agent-section-header {
    display: grid;
    grid-template-columns: auto auto minmax(72px, 1fr) minmax(0, auto) minmax(0, auto) auto;
    align-items: center;
    gap: 6px;
}

.agent-section-user .agent-section-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 6px;
}

.agent-section-output .agent-section-header {
    display: grid;
    grid-template-columns: auto minmax(72px, 1fr) auto;
    align-items: center;
    gap: 6px;
}

.node-agent[data-agent-width-tier="narrow"] .agent-section-meta .agent-section-header,
.node-agent[data-agent-width-tier="compact"] .agent-section-meta .agent-section-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.node-agent[data-agent-width-tier="narrow"] .agent-section-meta .agent-section-dot,
.node-agent[data-agent-width-tier="compact"] .agent-section-meta .agent-section-dot,
.node-agent[data-agent-width-tier="narrow"] .agent-section-meta .agent-section-label,
.node-agent[data-agent-width-tier="compact"] .agent-section-meta .agent-section-label {
    order: 0;
}

.node-agent[data-agent-width-tier="narrow"] .agent-section-meta .agent-collapse-btn,
.node-agent[data-agent-width-tier="compact"] .agent-section-meta .agent-collapse-btn {
    order: 1;
    margin-left: auto;
}

.node-agent[data-agent-width-tier="narrow"] .agent-section-meta .agent-node-select-shell,
.node-agent[data-agent-width-tier="compact"] .agent-section-meta .agent-node-select-shell {
    order: 2;
    flex: 1 1 100%;
}

.node-agent[data-agent-width-tier="narrow"] .agent-section-meta .agent-chip-btn,
.node-agent[data-agent-width-tier="compact"] .agent-section-meta .agent-chip-btn {
    order: 3;
    flex: 1 1 calc(50% - 3px);
    max-width: none;
}

.node-agent[data-agent-width-tier="compact"] .agent-section-user .agent-section-header,
.node-agent[data-agent-width-tier="compact"] .agent-section-output .agent-section-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.node-agent[data-agent-width-tier="compact"] .agent-section-output .agent-node-select-shell {
    flex: 1 1 100%;
    order: 2;
}

.node-agent[data-agent-width-tier="compact"] .agent-section-output .agent-collapse-btn {
    order: 1;
}

.agent-section-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.agent-section-dot.meta { background: #888; }
.agent-section-dot.user { background: #888; }
.agent-section-dot.output { background: #888; display: inline-block; margin-right: 4px; }

.agent-section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-right: 4px;
    min-width: 0;
}

.agent-section-label-inline {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 0;
}

.agent-section-content {
    padding: 0 14px 10px;
}

.agent-section-output .agent-section-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.agent-textarea-wrapper {
    position: relative;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.025);
    border-radius: 8px;
    padding: 8px 12px 16px;
}

.agent-output-wrapper {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-bottom: 14px;
}

.agent-textarea-resizer {
    position: absolute;
    left: 50%;
    bottom: 6px;
    width: 52px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    transform: translateX(-50%);
    cursor: ns-resize;
    transition: background 0.12s ease, transform 0.12s ease;
}

.node-agent .agent-textarea-resizer {
    display: none !important;
    pointer-events: none !important;
}

.agent-textarea-resizer:hover {
    background: rgba(255,179,71, 0.42);
    transform: translateX(-50%) scaleX(1.04);
}

/* 收起状态 */
.agent-section.is-collapsed .agent-section-content,
.agent-section.is-collapsed .agent-lib-panel {
    display: none !important;
}

.agent-section.is-collapsed .agent-collapse-btn svg {
    transform: rotate(-90deg);
}

/* ===== 模型选择 ===== */
.agent-node-model-select {
    display: none !important;
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    visibility: hidden !important;
}

.agent-node-model-select option {
    background: #1a1f2e;
    color: #c8d4f0;
}

.agent-node-select-native-hidden {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
}

.agent-node-select-shell {
    position: relative;
    display: inline-flex;
    flex: 1 1 72px;
    min-width: 0;
    max-width: none;
}

.agent-node-select-trigger {
    width: 100%;
    height: 26px;
    border-radius: 7px;
    border: 0.5px solid rgba(255,168,79,0.12);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%),
        rgba(20, 24, 30, 0.92);
    color: #d6d8de;
    font-family: "Inter", sans-serif;
    font-size: 11px;
    font-weight: 600;
    padding: 0 24px 0 8px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.agent-node-select-trigger::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 8px;
    width: 8px;
    height: 8px;
    border-right: 1.8px solid rgba(255,255,255,0.42);
    border-bottom: 1.8px solid rgba(255,255,255,0.42);
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
    transition: transform 0.18s ease, border-color 0.15s ease;
}

.agent-node-select-trigger:hover,
.agent-node-select-shell.is-open .agent-node-select-trigger {
    border-color: rgba(255,168,79,0.28);
    background:
        linear-gradient(180deg, rgba(255,179,71,0.08) 0%, rgba(255,255,255,0.01) 100%),
        rgba(20, 24, 30, 0.96);
    color: #fff4dc;
}

.agent-node-select-shell.is-open .agent-node-select-trigger::after {
    transform: translateY(-30%) rotate(225deg);
    border-color: rgba(255,188,96,0.88);
}

.agent-node-select-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: max-content;
    min-width: 100%;
    max-width: 240px;
    max-height: 240px;
    padding: 6px;
    border-radius: 12px;
    background: rgba(16, 20, 25, 0.96);
    border: 0.5px solid rgba(255,168,79,0.10);
    box-shadow: 0 18px 40px rgba(0,0,0,0.42), 0 0 22px rgba(255,149,0,0.06);
    backdrop-filter: blur(18px) saturate(145%);
    overflow-y: auto;
    z-index: 60;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.agent-node-select-shell.is-open .agent-node-select-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.agent-node-select-menu::-webkit-scrollbar {
    width: 6px;
}

.agent-node-select-menu::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(255,168,79,0.22);
}

.agent-node-select-option {
    display: block;
    width: 100%;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #d7d9df;
    font-family: "Inter", sans-serif;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.agent-node-select-option:hover {
    background: rgba(255,168,79,0.12);
    color: #fff4dc;
}

.agent-node-select-option.is-selected {
    background: linear-gradient(135deg, rgba(255,179,71,0.24) 0%, rgba(255,149,0,0.16) 100%);
    color: #fff4dc;
    box-shadow: inset 0 0 0 0.5px rgba(255,179,71,0.26);
}

/* ===== 芯片按钮 ===== */
.agent-chip-btn {
    height: 26px;
    padding: 0 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 5px;
    color: var(--text-tertiary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-chip-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    border-color: rgba(255,255,255,0.18);
}

.agent-chip-btn.is-active {
    background: rgba(255,168,79,0.12);
    border-color: rgba(255,168,79,0.3);
    color: #ffb347;
}

/* 收起按钮 */
.agent-collapse-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.12s;
    margin-left: auto;
    flex-shrink: 0;
}

.agent-collapse-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.agent-collapse-btn svg {
    transition: transform 0.2s ease;
}

/* ===== 文本输入 ===== */
.agent-meta-textarea,
.agent-user-textarea {
    width: 100%;
    min-height: 80px;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.6;
    font-family: inherit;
    padding: 4px 0;
    overflow-y: auto;
}

.agent-meta-textarea::placeholder,
.agent-user-textarea::placeholder {
    color: var(--text-tertiary);
    font-size: 12px;
}

/* ===== 库面板 ===== */
.agent-lib-panel {
    margin: 0 14px 8px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    position: relative;
    z-index: 8;
    pointer-events: auto;
}

.agent-lib-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
}

.agent-lib-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.agent-lib-count { font-weight: 600; }
.agent-skill-count { font-weight: 600; }

.agent-lib-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.agent-lib-action-btn {
    height: 26px;
    padding: 0 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 5px;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.agent-lib-action-btn:hover {
    background: rgba(255,255,255,0.10);
    color: var(--text-primary);
}

/* 库网格 */
.agent-lib-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.agent-lib-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
}

.agent-lib-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100px;
    font-weight: 500;
}

.agent-lib-item-btn {
    min-width: 38px;
    height: 22px;
    border: none;
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 11px;
    transition: all 0.1s;
    flex-shrink: 0;
    padding: 0 6px;
    white-space: nowrap;
}

.agent-lib-item-btn:hover {
    background: rgba(255,255,255,0.10);
    color: var(--text-primary);
}

.agent-lib-item-btn.delete:hover {
    color: #ff6464;
}

/* 新建表单 */
.agent-lib-new-form {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
}

.agent-lib-new-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.agent-lib-name-input {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    margin-bottom: 6px;
    font-family: inherit;
}

.agent-lib-name-input::placeholder,
.agent-lib-content-input::placeholder {
    color: var(--text-tertiary);
}

.agent-lib-content-input {
    width: 100%;
    min-height: 72px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
    margin-bottom: 8px;
}

.agent-lib-new-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ===== 输出区域 ===== */
.agent-output-area {
    flex: 1 1 auto;
    min-height: 120px;
    padding: 8px 0;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    position: relative;
    overflow-y: auto;
    outline: none;
    cursor: text;
}

.agent-output-area.is-empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
    font-size: 12px;
    pointer-events: none;
}

.agent-output-area.is-loading {
    padding: 0;
    cursor: default;
}

.agent-output-progress {
    height: 100%;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.agent-output-progress-bar {
    position: relative;
    width: min(220px, 78%);
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,0.08);
}

.agent-output-progress-bar::before {
    content: "";
    position: absolute;
    inset: 0;
    width: 42%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(255,168,79,0.2), rgba(255,168,79,0.95), rgba(255,168,79,0.2));
    animation: agent-progress-slide 1.15s ease-in-out infinite;
}

.agent-output-progress-label {
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
}

.agent-user-media-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.agent-ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 180px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.045);
    color: var(--text-secondary);
    cursor: grab;
    user-select: none;
}

.agent-ref-chip.dragging {
    opacity: 0.45;
}

.agent-ref-chip.is-drop-before {
    box-shadow: inset 2px 0 0 rgba(255,179,71,0.9);
}

.agent-ref-chip.is-drop-after {
    box-shadow: inset -2px 0 0 rgba(255,179,71,0.9);
}

.agent-ref-thumb {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.agent-ref-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.agent-ref-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: rgba(0,0,0,0.28);
    pointer-events: none;
}

.agent-ref-thumb.video::before,
.agent-ref-thumb.text::before {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 14px 14px;
    opacity: 0.7;
}

.agent-ref-thumb.video::before {
    content: none;
}

.agent-ref-thumb.text::before {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23c8d4f0" stroke-width="1.8"><path d="M5 7h14"/><path d="M5 12h14"/><path d="M5 17h9"/></svg>');
}

.agent-ref-thumb.video {
    position: relative;
}

.agent-ref-video-badge {
    position: absolute;
    right: 2px;
    bottom: 2px;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(0,0,0,0.68);
    color: #f3f6ff;
    font-size: 8px;
    line-height: 1.2;
    letter-spacing: 0.02em;
    pointer-events: none;
}

@keyframes agent-progress-slide {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(260%);
    }
}

.agent-ref-text {
    font-size: 11px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-output-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 4px 0 0;
    display: flex;
    align-items: center;
}

.agent-edit-menu {
    position: fixed;
    min-width: 120px;
    padding: 6px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(20,24,38,0.96);
    box-shadow: 0 18px 40px rgba(0,0,0,0.32);
    z-index: 3000;
}

.agent-edit-menu button {
    width: 100%;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    text-align: left;
    padding: 0 10px;
    font-size: 12px;
    cursor: pointer;
}

.agent-edit-menu button:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

/* ===== 底部运行栏 ===== */
.agent-node-footer {
    flex-shrink: 0;
    padding: 0 14px 12px;
    flex-shrink: 0;
}

.agent-node-run-btn {
    width: 100%;
    height: 40px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.agent-node-run-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.22);
}

.agent-node-run-btn:active {
    transform: scale(0.98);
}

.agent-node-run-btn.is-running {
    background: rgba(255,168,79,0.12);
    border-color: rgba(255,168,79,0.4);
    color: #ffb347;
    pointer-events: none;
}

.agent-node-footer-hint {
    font-size: 10px;
    color: var(--text-tertiary);
    text-align: center;
    margin-top: 6px;
}

/* 上游媒体引用栏 */
.agent-user-media-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.agent-user-media-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    cursor: pointer;
    transition: border-color 0.12s;
    flex-shrink: 0;
}

.agent-user-media-thumb:hover {
    border-color: rgba(255,168,79,0.4);
}

.agent-user-media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ===== 节点宽度/尺寸 ===== */
/* agent 节点宽度已在上方统一定义为 520px */

.node.node-manual-resized.node-agent {
    width: var(--node-manual-width) !important;
    height: var(--node-manual-height) !important;
}

/* ===== 运行中动画 ===== */
@keyframes agentRunPulse {
    0%, 100% { border-color: rgba(255,168,79,0.3); }
    50% { border-color: rgba(255,168,79,0.7); }
}

.node-agent.is-running {
    animation: agentRunPulse 1.5s ease-in-out infinite;
}

.node-agent.is-done {
    border-color: rgba(52, 211, 153, 0.6) !important;
    transition: border-color 0.4s ease;
}

/* =============================================
   视觉分析 — 缩略图栏
   ============================================= */

.text-vision-media-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 6px 0 2px;
    align-items: center;
    min-height: 20px;
}

.text-vision-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.text-vision-thumb img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.12);
    cursor: pointer;
    transition: border-color 0.12s;
}

.text-vision-thumb img:hover {
    border-color: rgba(255,168,79,0.5);
}

.text-vision-thumb-label {
    font-size: 9px;
    color: var(--text-tertiary);
}

.text-vision-no-media {
    font-size: 11px;
    color: rgba(255,180,60,0.7);
    padding: 2px 0;
}

/* =============================================
   图片裁切系统
   ============================================= */

/* 弹窗遮罩 */
.crop-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 32000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cropFadeIn 0.2s ease;
}

@keyframes cropFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.crop-modal-panel {
    width: 90vw;
    max-width: 1200px;
    height: 85vh;
    max-height: 800px;
    background: #1a1d24;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.crop-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255,255,255,0.06);
    color: var(--text-tertiary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
}

.crop-modal-close:hover {
    background: rgba(255,255,255,0.12);
    color: var(--text-primary);
}

/* 主体 */
.crop-modal-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* 左：工作区 */
.crop-workspace {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-width: 0;
    overflow: hidden;
    background: #111318;
}

.crop-canvas-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    user-select: none;
    cursor: crosshair;
}

.crop-canvas-container img {
    display: block;
    max-width: 100%;
    max-height: calc(85vh - 140px);
    object-fit: contain;
    pointer-events: none;
}

/* 裁切覆盖层 */
.crop-overlay {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

/* 裁切区域框 */
.crop-region {
    position: absolute;
    border: 2px solid rgba(52, 211, 153, 0.8);
    background: rgba(52, 211, 153, 0.08);
    cursor: move;
    box-sizing: border-box;
    transition: border-color 0.1s, background 0.1s;
}

.crop-region.is-selected {
    border-color: rgba(52, 211, 153, 1);
    background: rgba(52, 211, 153, 0.12);
    z-index: 5;
}

.crop-region:hover {
    border-color: rgba(52, 211, 153, 1);
}

/* 区域编号标签 */
.crop-region-label {
    position: absolute;
    top: -20px;
    left: 0;
    background: rgba(52, 211, 153, 0.9);
    color: #000;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    pointer-events: none;
    white-space: nowrap;
}

/* 区域删除按钮 */
.crop-region-delete {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    background: #e53e3e;
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.12s;
    z-index: 10;
}

.crop-region:hover .crop-region-delete,
.crop-region.is-selected .crop-region-delete {
    opacity: 1;
}

/* 四角拖拽手柄 */
.crop-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 2px solid rgba(52, 211, 153, 1);
    border-radius: 2px;
    z-index: 6;
}

.crop-handle-tl { top: -5px; left: -5px; cursor: nw-resize; }
.crop-handle-tr { top: -5px; right: -5px; cursor: ne-resize; }
.crop-handle-bl { bottom: -5px; left: -5px; cursor: sw-resize; }
.crop-handle-br { bottom: -5px; right: -5px; cursor: se-resize; }

/* 右：侧边栏 */
.crop-sidebar {
    width: 200px;
    flex-shrink: 0;
    border-left: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    background: #1a1d24;
}

.crop-sidebar-title {
    padding: 16px 14px 10px;
    font-size: 13px;
    font-weight: 600;
    color: #e53e3e;
}

.crop-region-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px 10px;
}

.crop-region-list::-webkit-scrollbar { width: 4px; }
.crop-region-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.crop-region-empty {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 10px 4px;
}

/* 侧边栏区域条目 */
.crop-region-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    cursor: pointer;
    transition: all 0.1s;
    font-size: 12px;
    color: var(--text-secondary);
}

.crop-region-item:hover {
    background: rgba(255,255,255,0.05);
}

.crop-region-item.is-active {
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.4);
    color: #34d399;
}

.crop-region-item-info {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.crop-region-item-idx {
    font-weight: 700;
    flex-shrink: 0;
}

.crop-region-item-size {
    font-size: 11px;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crop-region-item-del {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: #e53e3e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 13px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.1s;
}

.crop-region-item-del:hover {
    opacity: 1;
    background: rgba(229, 62, 62, 0.12);
}

/* 底部 */
.crop-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    gap: 12px;
    flex-wrap: wrap;
}

.crop-ratio-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.crop-ratio-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-right: 4px;
}

.crop-ratio-chip {
    height: 28px;
    padding: 0 10px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    color: var(--text-tertiary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
}

.crop-ratio-chip:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
}

.crop-ratio-chip.is-active {
    background: rgba(255,168,79,0.15);
    border-color: rgba(255,168,79,0.4);
    color: #ffb347;
    font-weight: 600;
}

.crop-modal-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.crop-action-btn {
    height: 36px;
    padding: 0 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.12s;
    white-space: nowrap;
}

.crop-cancel-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-secondary);
}

.crop-cancel-btn:hover {
    background: rgba(255,255,255,0.10);
}

.crop-confirm-btn {
    background: rgba(52, 211, 153, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.4);
    color: #34d399;
}

.crop-confirm-btn:hover {
    background: rgba(52, 211, 153, 0.25);
}

.crop-confirm-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 正在绘制新区域时的临时框 */
.crop-drawing-rect {
    position: absolute;
    border: 2px dashed rgba(52, 211, 153, 0.7);
    background: rgba(52, 211, 153, 0.06);
    pointer-events: none;
    box-sizing: border-box;
}

/* =============================================
   修复：Agent 来源提示
   ============================================= */

.text-node-agent-hint,
.image-gen-agent-hint {
    display: none;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: rgba(255,168,79, 0.8);
    padding: 2px 6px;
    background: rgba(255,168,79, 0.08);
    border-radius: 4px;
    margin-left: auto;
}

.text-node-agent-hint svg,
.image-gen-agent-hint svg {
    flex-shrink: 0;
}

/* 连接线剪刀按钮优化 */
.connection-delete-btn {
    position: absolute;
    width: 24px;
    height: 24px;
    background: rgba(229, 62, 62, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.12s;
    pointer-events: auto;
}

.connection-delete-btn:hover {
    background: rgba(229, 62, 62, 1);
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.4);
}

/* =============================================
   Group System
   ============================================= */

:root {
    --group-color-0: #ffa84f;
    --group-color-1: #22c55e;
    --group-color-2: #f59e0b;
    --group-color-3: #ef4444;
    --group-color-4: #8b5cf6;
    --group-color-5: #06b6d4;
}

.canvas-group-frame {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.canvas-group-outline {
    position: absolute;
    inset: 34px 0 0;
    border-radius: 16px;
    border: 1px solid rgba(255,168,79, 0.28);
    background: rgba(255,168,79, 0.04);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

.canvas-group-frame.is-active .canvas-group-outline {
    border-color: rgba(255,168,79, 0.55);
    background: rgba(255,168,79, 0.08);
}

.canvas-group-header {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
}

.canvas-group-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.12);
}

.canvas-group-name {
    min-width: 48px;
    max-width: 180px;
    border: none;
    outline: none;
    background: transparent;
    color: rgba(237, 242, 251, 0.88);
    font-size: 12px;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 6px;
    pointer-events: auto;
}

.canvas-group-name:hover,
.canvas-group-name:focus {
    background: rgba(255,255,255,0.06);
}

.canvas-group-count {
    margin-left: auto;
    font-size: 11px;
    color: rgba(154, 166, 191, 0.8);
    white-space: nowrap;
}

.canvas-group-ungroup {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    color: rgba(237, 242, 251, 0.86);
    cursor: pointer;
    pointer-events: auto;
    font-size: 16px;
    line-height: 1;
}

.canvas-group-ungroup:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
}

.selection-group-toolbar-lite {
    position: fixed;
    z-index: 2000;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(18, 23, 34, 0.94);
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    backdrop-filter: blur(14px);
}

.selection-group-action {
    height: 30px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,168,79, 0.28);
    background: rgba(255,168,79, 0.12);
    color: #fff7ec;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.selection-group-action:hover {
    background: rgba(255,168,79, 0.2);
}
.node-video-upload {
    width: 420px !important;
    min-height: 420px !important;
}

.node-video-upload .node-upload-header {
    justify-content: flex-start;
    padding-left: 12px;
}

.node-video-upload .upload-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.node-video-upload .video-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
}

.node-video-upload .video-upload-label svg {
    opacity: 0.72;
    flex-shrink: 0;
}

.node-video-upload .video-upload-label span {
    line-height: 1;
}

.node-video-upload .video-workflow-shell {
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    border-radius: 16px;
    background: rgba(255,255,255,0.02);
    flex: 1 1 auto;
}

.video-workflow-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 18px;
    padding: 18px 18px 22px;
}

.video-workflow-empty-head {
    display: flex;
    align-items: center;
}

.video-workflow-empty-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.video-workflow-option-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-workflow-option {
    display: flex;
    align-items: center;
    gap: 0;
    width: auto;
    align-self: flex-start;
    padding: 5px 0;
    border-radius: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.18s ease;
    font-size: 13px;
    font-weight: 500;
}

.video-workflow-option:hover,
.video-workflow-option.is-active {
    color: #fff;
    background: transparent;
    border-color: transparent;
}

.video-workflow-tab:hover,
.video-workflow-tab.is-active {
    border-color: rgba(255,168,79,0.45);
    background: rgba(255,168,79,0.14);
    color: #fff;
}

.video-workflow-option-icon {
    display: none;
}

.video-workflow-composer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 0 0 auto;
}

.video-workflow-preview {
    min-height: 0;
    flex: 1 1 auto;
    aspect-ratio: 16 / 9;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    background: rgba(255,255,255,0.025);
    overflow: hidden;
    position: relative;
}

.video-workflow-preview-empty {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
}

.video-main-player {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: block;
    object-fit: cover;
    background: #090c12;
}

.video-workflow-preview.is-generating {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01)),
        #090c12 !important;
}

.video-workflow-preview.is-generating .video-main-player {
    opacity: 0 !important;
    visibility: hidden !important;
}

.video-workflow-progress {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 16px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(14,18,27,0.82), rgba(16,20,29,0.92));
    border: 1px solid rgba(255,168,79,0.18);
    backdrop-filter: blur(8px);
}

.video-workflow-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.video-workflow-progress-label {
    font-size: 11px;
    color: rgba(224,230,240,0.92);
    letter-spacing: 0.02em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-workflow-cancel-btn {
    flex: 0 0 auto;
    height: 22px;
    min-width: 42px;
    padding: 0 9px;
    border-radius: 7px;
    border: 1px solid rgba(255,118,118,0.38);
    background: rgba(255,80,80,0.12);
    color: rgba(255,230,230,0.94);
    font-size: 11px;
    line-height: 20px;
    cursor: pointer;
}

.video-workflow-cancel-btn:hover {
    background: rgba(255,80,80,0.2);
    border-color: rgba(255,138,138,0.55);
}

.video-workflow-cancel-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.video-workflow-cancel-btn[hidden] {
    display: none !important;
}

.video-workflow-progress-track {
    position: relative;
    width: 100%;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
}

.video-workflow-progress-bar {
    position: absolute;
    inset: 0 auto 0 -35%;
    width: 35%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(255,168,79,0.12), rgba(255,168,79,0.95), rgba(255,211,138,0.8));
    animation: videoWorkflowLoading 1.2s ease-in-out infinite;
}

.video-workflow-progress.is-determinate .video-workflow-progress-bar {
    inset: 0 auto 0 0;
    width: var(--video-workflow-progress, 3%);
    animation: none;
    transition: width 0.35s ease;
}

@keyframes videoWorkflowLoading {
    0% { transform: translateX(0%); }
    100% { transform: translateX(320%); }
}

.video-workflow-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 14px 14px;
    border-radius: 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
}

.video-workflow-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.video-workflow-tab {
    padding: 7px 12px;
    border-radius: 11px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.video-workflow-refbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 8px;
}

.video-workflow-ref {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    max-width: 100%;
    padding: 3px 7px 3px 3px;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
    cursor: pointer;
}

.video-workflow-ref.text-vision-thumb {
    position: relative;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 0;
    padding: 12px 4px 2px;
    border: 0;
    background: transparent;
}

.video-workflow-ref-thumb {
    position: relative;
    width: 18px;
    height: 18px;
    overflow: hidden;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.video-workflow-ref-thumb img,
.video-workflow-ref-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-workflow-ref-thumb-glyph {
    color: var(--text-secondary);
    font-size: 9px;
    font-weight: 700;
}

.video-workflow-ref-badge {
    position: absolute;
    right: 4px;
    bottom: 4px;
    padding: 1px 4px;
    border-radius: 999px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 9px;
    line-height: 1.4;
}

.video-workflow-ref-label {
    max-width: 78px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    color: var(--text-primary);
}

.video-workflow-ref-preview {
    border: 0;
    padding: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.video-workflow-prompt {
    width: 100%;
    min-height: 96px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.02);
    color: var(--text-primary);
    resize: vertical;
    outline: none;
}

.video-workflow-prompt::placeholder {
    color: var(--text-tertiary);
}

.video-workflow-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.video-workflow-toolbar {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    flex: 1;
    align-items: center;
    min-width: 0;
}

.video-workflow-config-trigger,
.video-workflow-model-trigger {
    height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
    outline: none;
    font-size: 11px;
}

.video-workflow-model-toggle {
    position: relative;
    min-width: 0;
    width: 146px;
    flex: 1 1 146px;
}

.video-workflow-model-trigger {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
}

.video-workflow-model-trigger.is-open {
    border-color: rgba(255,168,79,0.4);
    background: rgba(255,168,79,0.12);
}

.video-workflow-model-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-workflow-model-caret {
    color: var(--text-secondary);
    font-size: 9px;
}

.video-workflow-model-dropdown {
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    width: 100%;
    min-width: 100%;
    max-height: 220px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg-elevated);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    z-index: 9000;
    backdrop-filter: blur(12px);
    pointer-events: auto;
}

.video-workflow-model-option {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    width: 100%;
    min-height: 30px;
    padding: 6px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.video-workflow-model-option:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.video-workflow-model-option.is-disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.video-workflow-model-option.is-disabled:hover {
    background: transparent;
    color: var(--text-secondary);
}

.video-workflow-model-option-main {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-workflow-model-option-reason {
    margin-top: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(214, 219, 230, 0.72);
    font-size: 10px;
    line-height: 1.2;
}

.video-workflow-model-option.is-mode-suggested .video-workflow-model-option-reason {
    color: rgba(255, 179, 71, 0.86);
}

.video-workflow-model-option.is-active {
    background: rgba(255,168,79,0.18);
    color: #ffb347;
}

.video-workflow-model {
    min-width: 0;
    width: 146px;
    flex: 1 1 146px;
}

.video-workflow-config-wrap {
    position: relative;
    flex: 1 1 168px;
    min-width: 0;
}

.video-workflow-config-trigger {
    width: 100%;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
}

.video-workflow-config-trigger.is-open {
    border-color: rgba(255,168,79,0.4);
    background: rgba(255,168,79,0.12);
}

.video-workflow-config-summary {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.1px;
}

.video-workflow-config-caret {
    color: var(--text-secondary);
    font-size: 9px;
    transform: translateY(-0.5px);
}

.video-workflow-config-panel {
    position: absolute;
    left: 50%;
    right: auto;
    bottom: calc(100% + 10px);
    z-index: 22000;
    width: 320px;
    transform: translateX(-50%);
    padding: 14px;
    border-radius: 16px;
    background: rgba(23, 29, 41, 0.98);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 18px 50px rgba(0,0,0,0.42);
    backdrop-filter: blur(18px);
    overscroll-behavior: contain;
}

.video-workflow-config-section + .video-workflow-config-section {
    margin-top: 12px;
}

.video-workflow-config-title {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.video-workflow-config-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.video-workflow-duration-track {
    --duration-fade-left-alpha: 1;
    --duration-fade-right-alpha: 1;
    width: 100%;
    height: 34px;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0;
    overflow-x: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    user-select: none;
    touch-action: none;
    cursor: grab;
    padding: 3px 4px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.055);
    box-sizing: border-box;
    -webkit-mask-image: linear-gradient(
        90deg,
        rgba(0,0,0,var(--duration-fade-left-alpha)) 0,
        #000 18px,
        #000 calc(100% - 18px),
        rgba(0,0,0,var(--duration-fade-right-alpha)) 100%
    );
    mask-image: linear-gradient(
        90deg,
        rgba(0,0,0,var(--duration-fade-left-alpha)) 0,
        #000 18px,
        #000 calc(100% - 18px),
        rgba(0,0,0,var(--duration-fade-right-alpha)) 100%
    );
}

.video-workflow-duration-track.can-scroll-left {
    --duration-fade-left-alpha: 0.24;
}

.video-workflow-duration-track.can-scroll-right {
    --duration-fade-right-alpha: 0.24;
}

.video-workflow-duration-track.is-dragging {
    cursor: grabbing;
}

.video-workflow-duration-track::-webkit-scrollbar {
    display: none;
}

.video-workflow-duration-single .video-workflow-config-option {
    flex: 1 1 auto;
}

.video-workflow-duration-track .video-workflow-config-option {
    flex: 0 0 42px;
    min-width: 42px;
    height: 28px;
    padding: 0 6px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: rgba(243, 245, 250, 0.58);
    box-shadow: none;
}

.video-workflow-duration-track .video-workflow-config-option:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.86);
}

.video-workflow-duration-track .video-workflow-config-option.is-active {
    background: rgba(255,255,255,0.13);
    color: #fff;
    border-color: transparent;
}

.video-workflow-config-option {
    min-width: 44px;
    height: 30px;
    padding: 0 10px;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.18s ease;
}

.video-workflow-config-option:hover,
.video-workflow-config-option.is-active {
    border-color: rgba(255,168,79,0.4);
    background: rgba(255,168,79,0.16);
    color: #fff;
}

.video-workflow-config-option.is-disabled,
.video-workflow-config-option.is-disabled:hover {
    opacity: 0.38;
    cursor: not-allowed;
    border-color: rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
}

.video-workflow-mode-option {
    flex: 1 1 0;
    min-width: 96px;
}

.video-workflow-start-end-strip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 2px;
}

.video-workflow-start-end-slot {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 56px;
}

.video-workflow-start-end-slot .video-workflow-ref-remove {
    top: 10px !important;
    right: 2px !important;
}

.video-workflow-start-end-label {
    color: var(--text-secondary);
    font-size: 10px;
    line-height: 1;
}

.video-workflow-start-end-slot.is-empty {
    opacity: 0.58;
}

.video-workflow-start-end-swap {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(255,168,79,0.2);
    background: rgba(255,255,255,0.05);
    color: rgba(255,211,138,0.9);
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
    transition: all 0.18s ease;
}

.video-workflow-start-end-swap:hover:not(:disabled) {
    border-color: rgba(255,168,79,0.42);
    background: rgba(255,168,79,0.16);
    color: #fff;
}

.video-workflow-start-end-swap:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.video-workflow-generate-btn {
    align-self: center;
}

.video-workflow-generate-btn:hover {
    transform: translateY(-1px);
}

.node-video-upload .video-workflow-generate-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 10px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.node-video-upload .video-workflow-generate-btn svg {
    width: 22px !important;
    height: 22px !important;
}

.node-video-upload .video-workflow-card {
    gap: 10px;
    padding: 10px 12px 12px;
}

.node-video-upload .video-workflow-refbar {
    gap: 6px;
}

.node-video-upload .video-workflow-prompt {
    min-height: 88px;
}

/* =============================================
   Text Node Redesign - Empty State + Edit Mode
   ============================================= */

.node-text-input {
    width: 380px !important;
    min-height: 320px !important;
}

.node-text-input .node-upload-header {
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 0 14px !important;
    gap: 8px !important;
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
    background: transparent !important;
}

.node-text-input .upload-label {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--text-secondary) !important;
}

.node-text-input .upload-label .text-node-header-icon {
    opacity: 0.6;
}

.node-text-input .text-node-body {
    position: relative;
    padding: 0 !important;
    background: transparent !important;
    border-radius: 0 0 var(--node-radius) var(--node-radius) !important;
    min-height: 280px !important;
    display: flex;
    flex-direction: column;
}

.text-node-hint {
    display: block;
    width: 100%;
    padding: 2px 0 14px;
    text-align: center;
    color: #777d87;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    pointer-events: none;
}

.text-node-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    height: 100%;
    min-height: 280px;
    padding: 24px 24px 20px;
}

.text-node-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 0 20px;
}

.text-node-empty-icon svg {
    opacity: 0.25;
    color: var(--text-tertiary);
}

.text-node-empty-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    align-self: flex-start;
    font-weight: 500;
}

.text-node-option-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.text-node-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 8px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.18s ease;
    text-align: left;
}

.text-node-option:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.text-node-option-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: all 0.18s ease;
}

.text-node-option:hover .text-node-option-icon {
    background: rgba(255,168,79,0.12);
    border-color: rgba(255,168,79,0.25);
    color: #ffb347;
}

.text-node-option-icon svg {
    width: 14px;
    height: 14px;
}

.text-node-body .text-node-textarea {
    display: none;
    width: 100% !important;
    min-height: 280px !important;
    border: none !important;
    outline: none !important;
    resize: none !important;
    background: transparent !important;
    color: var(--text-primary) !important;
    font-family: 'Manrope', sans-serif !important;
    font-size: 14px !important;
    line-height: 1.7 !important;
    padding: 16px 18px !important;
    flex: 1;
    pointer-events: none;
}

.text-node-body.is-editing .text-node-empty-state,
.text-node-body.has-content .text-node-empty-state,
.text-node-body.is-manual-mode .text-node-empty-state,
.text-node-body.is-connection-mode .text-node-empty-state {
    display: none !important;
}

.text-node-body.is-editing .text-node-textarea,
.text-node-body.has-content .text-node-textarea,
.text-node-body.is-manual-mode .text-node-textarea,
.text-node-body.is-connection-mode .text-node-textarea {
    display: block !important;
}

.node-text-input.is-editing .text-node-textarea,
.text-node-body.is-editing .text-node-textarea,
.node[data-vision-mode="1"] .text-node-textarea {
    pointer-events: auto !important;
}

.text-node-body.is-manual-mode .text-node-textarea {
    pointer-events: none;
}

.text-node-body.is-connection-mode .text-node-textarea {
    pointer-events: none;
}

.node[data-vision-mode="1"] .text-node-empty-state,
.node[data-vision-mode="1"] .text-node-body .text-node-empty-state {
    display: none !important;
}

.node[data-vision-mode="1"] .text-node-hint,
.text-node-body.is-editing .text-node-hint,
.text-node-body.has-content .text-node-hint,
.text-node-body.is-manual-mode .text-node-hint,
.text-node-body.is-connection-mode .text-node-hint {
    display: none !important;
}

.node[data-vision-mode="1"] .text-node-body .text-node-textarea {
    display: block !important;
}

/* =============================================
   Text Node External Label + Port Refinements
   ============================================= */

.node-external-label {
    position: absolute;
    top: -28px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
}

.node-external-label svg {
    opacity: 0.5;
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.node.is-selected .node-external-label {
    color: var(--text-primary);
}

.node.is-selected .node-external-label svg {
    opacity: 0.8;
}

.seedance-compliance-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #36c5ff;
    line-height: 1;
    pointer-events: none;
}

.seedance-compliance-badge svg {
    width: 13px;
    height: 13px;
    opacity: 1;
}

.seedance-compliance-badge.is-checking {
    color: #39c8ff;
    animation: seedanceCompliancePulse 1s ease-in-out infinite;
}

.seedance-compliance-badge.is-pass {
    color: #38d47a;
}

.seedance-compliance-badge.is-warn {
    color: #f6b94b;
}

.seedance-compliance-badge.is-fail {
    color: #ff6b6b;
}

.seedance-compliance-text {
    font-size: 12px;
    font-weight: 600;
}

@keyframes seedanceCompliancePulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

.node-text-input:not([data-vision-mode="1"]) .node-upload-header {
    display: none !important;
}

.node-text-input .text-node-body {
    border-radius: var(--node-radius) !important;
}

.node-text-input[data-vision-mode="1"] .node-external-label {
    display: none;
}

.node-text-input[data-vision-mode="1"] .node-upload-header {
    display: flex !important;
}

.node-port-left {
    left: -10px !important;
    right: auto !important;
    width: 16px !important;
    height: 16px !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.20) !important;
    transform: translateX(-50%) translateY(-50%) !important;
    box-shadow: none !important;
}

.node-port-left::after {
    display: none !important;
}

.node-port-left:hover,
.node-port-left.snap-target,
.node.connection-target-highlight .node-port-left {
    border-color: rgba(255,179,71, 0.8) !important;
    background: rgba(255,179,71, 0.25) !important;
    box-shadow: 0 0 0 3px rgba(255,179,71, 0.12) !important, 0 0 10px rgba(255,168,79,0.25) !important;
    width: 16px !important;
    height: 16px !important;
    transform: translateX(-50%) translateY(-50%) !important;
}

.node-port-right {
    right: var(--port-base-right, -50px) !important;
    --port-follow-x: 0px;
    --port-follow-y: 0px;
    transform: translateX(50%) translateY(-50%) translate(var(--port-follow-x), var(--port-follow-y)) !important;
}

.node-port-right:hover {
    transform: translateX(50%) translateY(-50%) translate(var(--port-follow-x), var(--port-follow-y)) !important;
}

/* =============================================
   Image Node - Empty State + Upload Hover
   ============================================= */

.node-image-upload .node-upload-header,
.node[data-node-type="image"] .node-upload-header {
    display: none !important;
}

.node-video-upload .node-upload-header {
    display: none !important;
}

.node-image-upload .image-node-body {
    position: relative;
    padding: 0 !important;
    background: transparent !important;
    border-radius: var(--node-radius) !important;
    min-height: 280px !important;
    display: flex;
    flex-direction: column;
}

.node.node-image-upload {
    position: absolute;
}

.node-image-upload .media-upload-box.image-upload-box {
    width: 100%;
    min-height: 280px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: var(--node-radius) !important;
    overflow: hidden;
}

.image-node-upload-btn {
    position: absolute;
    top: -44px;
    left: 50% !important;
    right: auto !important;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 10;
    backdrop-filter: blur(8px);
    transform: translateX(-50%) !important;
    margin: 0 !important;
}

.image-node-upload-btn svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.node.node-image-upload:hover .image-node-upload-btn:not([style*="display: none"]),
.node.node-image-upload.is-selected .image-node-upload-btn:not([style*="display: none"]) {
    opacity: 1;
    pointer-events: auto;
}

.node-image-upload[data-has-media="1"] .image-node-upload-btn {
    display: none !important;
}

.node-image-upload[data-has-media="1"] .image-node-empty-state {
    display: none !important;
}

/* =============================================
   Text Vision Mode - Golden Glass Theme
   ============================================= */

.node[data-vision-mode="1"] .node-upload-header {
    height: auto !important;
    min-height: 30px !important;
    padding: 10px 12px 8px !important;
    position: relative !important;
    z-index: 8 !important;
    overflow: visible !important;
    background: linear-gradient(180deg, rgba(24, 28, 34, 0.82), rgba(19, 23, 29, 0.72)) !important;
    border-bottom: 0.5px solid rgba(255,168,79,0.10) !important;
    backdrop-filter: blur(20px) saturate(145%) !important;
}

.node[data-vision-mode="1"] .text-node-body {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.node[data-vision-mode="1"] .text-node-textarea {
    display: block !important;
    margin: 0 12px !important;
    width: calc(100% - 24px) !important;
    min-height: 96px !important;
    max-height: 110px !important;
    padding: 14px 16px !important;
    border: 0.5px solid rgba(255,168,79,0.08) !important;
    border-radius: 12px !important;
    background: linear-gradient(180deg, rgba(14, 18, 24, 0.88), rgba(12, 16, 22, 0.82)) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03) !important;
    color: var(--text-primary) !important;
    font-family: 'Manrope', sans-serif !important;
    font-size: 13px !important;
    line-height: 1.7 !important;
    position: relative !important;
    z-index: 1 !important;
    resize: none !important;
}

.node[data-vision-mode="1"] .text-node-textarea::placeholder {
    color: #777d87 !important;
}

.text-vision-header {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 0 !important;
    position: relative !important;
    z-index: 8 !important;
}

.text-vision-top-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
}

.text-vision-title {
    color: #ffcf8a !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
}

.text-vision-controls {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    min-width: 0 !important;
    position: relative !important;
    z-index: 9 !important;
}

.text-vision-model-select,
.text-vision-preset-select {
    height: 30px !important;
    border-radius: 8px !important;
    border: 0.5px solid rgba(255,168,79,0.10) !important;
    background: linear-gradient(180deg, rgba(24, 28, 34, 0.96), rgba(17, 21, 27, 0.94)) !important;
    color: var(--text-primary) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    outline: none !important;
    cursor: pointer !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03) !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="9" height="9" viewBox="0 0 24 24" fill="none" stroke="%23a9abb2" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    padding: 0 28px 0 10px !important;
}

.text-vision-select-native-hidden {
    display: none !important;
}

.text-vision-select-shell {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    z-index: 1;
}

.text-vision-select-shell.is-preset {
    flex: 0 0 auto;
    width: 94px;
}

.text-vision-select-trigger {
    position: relative;
    width: 100%;
    height: 30px;
    border-radius: 8px;
    border: 0.5px solid rgba(255,168,79,0.10);
    background: linear-gradient(180deg, rgba(24, 28, 34, 0.96), rgba(17, 21, 27, 0.94));
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    padding: 0 28px 0 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.text-vision-select-trigger::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    width: 7px;
    height: 7px;
    border-right: 1.25px solid rgba(169,171,178,0.9);
    border-bottom: 1.25px solid rgba(169,171,178,0.9);
    transform: translateY(-65%) rotate(45deg);
    transition: transform 0.16s ease;
    pointer-events: none;
}

.text-vision-select-trigger:hover,
.text-vision-select-shell.is-open .text-vision-select-trigger {
    border-color: rgba(255,168,79,0.24);
    box-shadow: 0 0 0 1px rgba(255,168,79,0.08), inset 0 1px 0 rgba(255,255,255,0.04);
}

.text-vision-select-shell.is-open .text-vision-select-trigger::after {
    transform: translateY(-30%) rotate(-135deg);
}

.text-vision-select-shell.is-open {
    z-index: 40;
}

.text-vision-select-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 50;
    display: none;
    min-width: 100%;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
    border-radius: 14px;
    border: 0.5px solid rgba(255,168,79,0.10);
    background: linear-gradient(180deg, rgba(24, 28, 34, 0.98), rgba(14, 18, 24, 0.98));
    backdrop-filter: blur(22px) saturate(145%);
    box-shadow: 0 18px 42px rgba(0,0,0,0.42), 0 0 0 1px rgba(255,168,79,0.05) inset;
}

.text-vision-select-shell.is-open .text-vision-select-menu {
    display: block;
}

.text-vision-select-menu::-webkit-scrollbar {
    width: 6px;
}

.text-vision-select-menu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 999px;
}

.text-vision-select-option {
    width: 100%;
    min-height: 30px;
    padding: 7px 9px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #d8dbe2;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.text-vision-select-option:hover {
    background: rgba(255,168,79,0.08);
    color: #fff7ec;
}

.text-vision-select-option.is-selected {
    background: linear-gradient(135deg, rgba(255,179,71,0.18), rgba(255,149,0,0.20));
    color: #fff7ec;
    box-shadow: inset 0 0 0 1px rgba(255,168,79,0.24);
}

.text-vision-model-select {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 142px !important;
}

.text-vision-preset-select {
    flex: 0 0 auto !important;
    width: 94px !important;
}

.text-vision-model-select:hover,
.text-vision-model-select:focus,
.text-vision-preset-select:hover,
.text-vision-preset-select:focus {
    border-color: rgba(255,168,79,0.24) !important;
    box-shadow: 0 0 0 1px rgba(255,168,79,0.08), inset 0 1px 0 rgba(255,255,255,0.04) !important;
}

.text-vision-model-select option,
.text-vision-preset-select option {
    background: #171b22 !important;
    color: #f5f6fe !important;
}

.text-vision-run-btn {
    flex: 0 0 auto !important;
    height: 30px !important;
    padding: 0 12px !important;
    border: none !important;
    border-radius: 8px !important;
    background: linear-gradient(135deg, #FFB347, #FF9500) !important;
    color: #16110a !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    box-shadow: 0 10px 24px rgba(255,149,0,0.18), 0 0 0 1px rgba(255,255,255,0.05) inset !important;
    transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease !important;
}

.text-vision-run-btn:hover {
    transform: translateY(-1px) !important;
    filter: brightness(1.03) !important;
    box-shadow: 0 14px 28px rgba(255,149,0,0.22), 0 0 0 1px rgba(255,255,255,0.06) inset !important;
}

.text-vision-run-btn svg {
    width: 10px !important;
    height: 10px !important;
    fill: currentColor !important;
}

.text-vision-run-btn:disabled {
    background: rgba(255,255,255,0.08) !important;
    color: rgba(255,255,255,0.42) !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
    transform: none !important;
    filter: none !important;
}

.text-vision-media-bar {
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    min-height: 28px !important;
    padding: 2px 0 0 !important;
}

.text-vision-thumb {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
    position: relative !important;
    padding-top: 12px !important;
}

.text-vision-thumb img {
    width: 48px !important;
    height: 48px !important;
    object-fit: cover !important;
    border-radius: 10px !important;
    border: 0.5px solid rgba(255,168,79,0.14) !important;
    box-shadow: 0 6px 18px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.03) !important;
    transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease !important;
}

.text-vision-thumb img:hover {
    border-color: rgba(255,179,71,0.32) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 10px 22px rgba(0,0,0,0.34), 0 0 0 1px rgba(255,168,79,0.08) !important;
}

.text-vision-thumb-preview {
    border: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
}

.text-vision-thumb-label {
    color: var(--text-tertiary) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 9px !important;
    font-weight: 500 !important;
}

.text-vision-thumb-label-btn {
    border: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    cursor: pointer !important;
}

.text-vision-thumb-label-btn:hover {
    color: #ffb347 !important;
}

.text-vision-thumb.is-text-source {
    align-items: center !important;
    justify-content: center !important;
    min-width: 56px !important;
    padding: 12px 10px 7px !important;
    border-radius: 999px !important;
    border: 0.5px solid rgba(255,168,79,0.14) !important;
    background: linear-gradient(180deg, rgba(28, 32, 39, 0.96), rgba(20, 24, 31, 0.92)) !important;
    box-shadow: 0 8px 18px rgba(0,0,0,0.20) !important;
}

.text-vision-thumb-text {
    color: #ffcf8a !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    white-space: nowrap !important;
}

.text-vision-source-remove {
    position: absolute !important;
    top: 1px !important;
    right: 2px !important;
    width: 12px !important;
    height: 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    color: rgba(255,196,120,0.82) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    box-shadow: none !important;
    z-index: 2 !important;
}

.text-vision-source-remove:hover {
    color: #ffd9a4 !important;
    transform: scale(1.05) !important;
}

.node-agent .agent-ref-remove,
.node-agent .agent-ref-preview,
.node-agent .agent-ref-label {
    position: relative;
    z-index: 4 !important;
    pointer-events: auto !important;
}

.text-vision-no-media {
    color: rgba(255,207,138,0.72) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    padding: 2px 0 !important;
}

.text-vision-output-wrap {
    position: relative !important;
    margin: 0 12px 12px !important;
}

.text-vision-output {
    margin: 0 !important;
    min-height: 120px !important;
    max-height: 260px !important;
    padding: 14px 16px 40px !important;
    border: 0.5px solid rgba(255,168,79,0.08) !important;
    border-radius: 12px !important;
    background: linear-gradient(180deg, rgba(14, 18, 24, 0.88), rgba(12, 16, 22, 0.82)) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03) !important;
    color: var(--text-primary) !important;
    font-family: 'Manrope', sans-serif !important;
    font-size: 13px !important;
    line-height: 1.7 !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(255,179,71,0.35) transparent !important;
    cursor: text !important;
}

.text-vision-output::-webkit-scrollbar {
    width: 6px !important;
}

.text-vision-output::-webkit-scrollbar-track {
    background: transparent !important;
}

.text-vision-output::-webkit-scrollbar-thumb {
    background: rgba(255,179,71,0.28) !important;
    border-radius: 999px !important;
}

.text-vision-output::-webkit-scrollbar-thumb:hover {
    background: rgba(255,179,71,0.42) !important;
}

.text-vision-output.is-empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
}

.text-vision-output-copy,
.agent-msg-copy-btn,
.agent-msg-edit-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 9px !important;
    background: rgba(27,31,40,0.78) !important;
    color: #aeb9cf !important;
    line-height: 1 !important;
    cursor: pointer !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(4px) !important;
    transition: opacity 0.16s ease, transform 0.16s ease, background 0.16s ease, color 0.16s ease, border-color 0.16s ease !important;
    backdrop-filter: blur(10px) !important;
}

.text-vision-output-copy {
    position: absolute !important;
    right: 12px !important;
    bottom: 10px !important;
}

.text-vision-output-wrap:hover .text-vision-output-copy,
.text-vision-output-wrap:focus-within .text-vision-output-copy,
.agent-msg-wrapper:hover .agent-msg-copy-btn,
.agent-msg-wrapper:hover .agent-msg-edit-btn,
.agent-msg-wrapper:focus-within .agent-msg-copy-btn,
.agent-msg-wrapper:focus-within .agent-msg-edit-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
}

.text-vision-output-copy:hover,
.agent-msg-copy-btn:hover,
.agent-msg-edit-btn:hover {
    background: rgba(42,47,58,0.94) !important;
    border-color: rgba(255,255,255,0.16) !important;
    color: #eef3ff !important;
}

.text-vision-output-copy.is-copied,
.agent-msg-copy-btn.is-copied {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
    background: rgba(255,179,71,0.16) !important;
    border-color: rgba(255,179,71,0.28) !important;
    color: #ffe7c5 !important;
}

.agent-msg-actions {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.text-output-context-menu {
    position: fixed;
    z-index: 12000;
    min-width: 120px;
    display: none;
    padding: 6px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(18, 23, 34, 0.98);
    box-shadow: 0 12px 32px rgba(0,0,0,0.35);
    backdrop-filter: blur(14px);
}

.text-output-context-menu.visible {
    display: block;
}

.agent-image-context-menu {
    min-width: 148px;
}

.text-output-context-item {
    width: 100%;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    text-align: left;
    padding: 0 10px;
    cursor: pointer;
}

.text-output-context-item:hover {
    background: rgba(255,168,79,0.10);
    color: var(--text-primary);
}

.node-vision-running {
    outline: 1px solid rgba(255,179,71,0.58) !important;
    outline-offset: 2px !important;
    animation: textVisionGoldPulse 1.25s ease-in-out infinite !important;
}

@keyframes textVisionGoldPulse {
    0%, 100% {
        outline-color: rgba(255,179,71,0.34);
        box-shadow: 0 0 0 1px rgba(255,168,79,0.18), 0 0 18px rgba(255,168,79,0.08), var(--node-shadow);
    }
    50% {
        outline-color: rgba(255,179,71,0.74);
        box-shadow: 0 0 0 1px rgba(255,168,79,0.28), 0 0 26px rgba(255,168,79,0.18), var(--node-shadow);
    }
}

.node-vision-done {
    outline: 1px solid rgba(255,179,71,0.74) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px rgba(255,168,79,0.22), 0 0 26px rgba(255,168,79,0.16), var(--node-shadow) !important;
    transition: outline-color 0.35s ease, box-shadow 0.35s ease !important;
}

.node-image-upload .image-node-upload-btn[style*="display: none"] {
    opacity: 0 !important;
    pointer-events: none !important;
}

.image-node-upload-btn:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.18);
    color: var(--text-primary);
}

.image-node-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 280px;
    padding: 24px 24px 20px;
}

.image-node-import-hint {
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 2px 0 0;
}

.image-node-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 0 20px;
}

.image-node-empty-icon svg {
    opacity: 0.25;
    color: var(--text-tertiary);
}

.image-node-empty-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    align-self: flex-start;
    font-weight: 500;
}

.image-node-option-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.image-node-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 8px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.18s ease;
    text-align: left;
}

.image-node-option:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.image-node-option:active {
    background: rgba(255,255,255,0.08);
}

.image-node-option-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: all 0.18s ease;
}

.image-node-option:hover .image-node-option-icon {
    background: rgba(255,168,79,0.12);
    border-color: rgba(255,168,79,0.25);
    color: #ffb347;
}

.image-node-option-icon svg {
    width: 14px;
    height: 14px;
}

.node-image-upload .node-image-box {
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    aspect-ratio: 16 / 9;
    border-radius: var(--node-radius) !important;
}

.node-image-upload[data-image-ready-state="1"] .node-image-box {
    margin: 12px 12px 14px !important;
    aspect-ratio: 16 / 9 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.node-image-upload[data-image-ready-state="1"] .media-upload-box,
.node-image-upload[data-image-ready-state="1"] .image-upload-box {
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.node-image-upload[data-image-ready-state="1"] .image-placeholder {
    width: 100%;
    height: 100%;
    flex-direction: column;
    gap: 10px;
    color: rgba(210, 216, 228, 0.52);
    background: transparent !important;
    border: none !important;
}

.node-image-upload[data-image-ready-state="1"] .image-placeholder svg {
    width: 34px;
    height: 34px;
    opacity: 0.75;
}

.node-image-upload[data-image-ready-state="1"] .image-placeholder::after {
    content: "双击导入图片";
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    color: rgba(210, 216, 228, 0.46);
    letter-spacing: 0.01em;
}

.image-node-body.has-image .image-node-empty-state {
    display: none !important;
}

.image-node-body.has-image .node-image-box {
    display: block !important;
}

.node-image-upload[data-media-mode="image"] {
    min-height: 0 !important;
}

.node-image-upload[data-media-mode="image"] .image-node-body {
    min-height: 0 !important;
    height: auto !important;
    display: block !important;
}

.node-image-upload[data-media-mode="image"] .media-upload-box,
.node-image-upload[data-media-mode="image"] .image-upload-box {
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
}

.node-image-upload[data-media-mode="image"] .node-single-image {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
}

.node-image-upload[data-media-mode="image"] .node-single-image-img {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    object-fit: contain !important;
}

.node-video-upload[data-media-mode="video"] {
    min-height: 0 !important;
}

.node-video-upload[data-media-mode="video"] .video-workflow-shell,
.node-video-upload[data-media-mode="video"] .media-upload-box,
.node-video-upload[data-media-mode="video"] .video-upload-box {
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
}

.node-video-upload[data-media-mode="video"] .video-workflow-preview,
.node-video-upload[data-media-mode="video"] .node-single-video {
    min-height: 0 !important;
    height: auto !important;
    background: #0d1118 !important;
}

.node-video-upload[data-media-mode="video"] .video-main-player,
.node-video-upload[data-media-mode="video"] .node-single-video-player {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    display: block !important;
    object-fit: contain !important;
}

.node[data-resize-locked="1"] .node-resize-handle {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* =============================================
   Video Node External Label + Compact Empty State
   ============================================= */

.node-video-upload .video-workflow-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 280px;
    padding: 24px 24px 20px !important;
}

.video-workflow-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 0 20px;
    height: auto;
    border-radius: 0;
    background: transparent;
    color: var(--text-tertiary);
    margin-bottom: 0;
}

.video-workflow-empty-icon svg {
    width: 40px;
    height: 40px;
    opacity: 0.25;
}

.node-video-upload .video-upload-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    color: var(--text-secondary);
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
}

.node-video-upload .video-upload-trigger svg {
    width: 13px;
    height: 13px;
    opacity: 0.6;
}

.node-video-upload .upload-label,
.node-video-upload .video-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-family: 'Manrope', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
}

.node-video-upload .video-upload-label svg {
    width: 13px;
    height: 13px;
    opacity: 0.6;
    flex-shrink: 0;
}

.video-node-upload-btn {
    position: absolute;
    top: -44px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,168,79,0.12);
    background: rgba(255,255,255,0.06);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    z-index: 12;
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.video-node-upload-btn:hover {
    background: rgba(255,255,255,0.10);
    border-color: rgba(255,168,79,0.22);
    color: var(--text-primary);
}

.node-video-upload:hover .video-node-upload-btn,
.node-video-upload.is-selected .video-node-upload-btn {
    opacity: 1;
    pointer-events: auto;
}

.node-video-upload[data-media-mode="video"] .video-node-upload-btn {
    display: none !important;
}

.video-node-upload-btn svg {
    width: 14px;
    height: 14px;
    opacity: 0.76;
}

.video-workflow-empty-head {
    width: 100%;
    margin-bottom: 16px;
}

.video-workflow-empty-label {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.video-workflow-quick-head {
    justify-content: flex-start !important;
    margin: 20px 0 2px !important;
    text-align: left !important;
}

.video-workflow-quick-head .video-workflow-empty-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.video-workflow-option-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 2px;
}

.video-workflow-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 8px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.18s ease;
    text-align: left;
}

.video-workflow-option:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.video-workflow-option svg {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    color: var(--text-secondary);
    opacity: 0.75;
    padding: 6px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255,255,255,0.08);
    box-sizing: border-box;
}

.video-workflow-option span {
    flex: 1;
}

.node-video-upload .media-upload-box.video-upload-box {
    border-radius: var(--node-radius) !important;
}

/* 修复视频节点空状态底部重叠框 */
.node-video-upload .video-workflow-shell ~ .media-upload-box,
.node-video-upload .video-workflow-shell ~ .node-body-extra {
    display: none !important;
}

/* video-workflow-shell 与 media-upload-box 实际是同一个容器时，收掉额外占位 */
.node-video-upload .media-upload-box.video-upload-box.video-workflow-shell {
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
}

.node-video-upload .media-upload-box.video-upload-box:has(.video-workflow-shell) {
    background: transparent !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

/* =============================================
   Video Generation Expand Mode
   ============================================= */

.node-video-upload {
    overflow: visible !important;
}

.node-video-upload[data-media-mode="video"] {
    border: 1px solid rgba(255, 168, 79, 0.22) !important;
    background: rgba(16, 20, 25, 0.74) !important;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.42),
        0 0 24px rgba(255, 168, 79, 0.08),
        inset 0 0 0 1px rgba(255, 255, 255, 0.03) !important;
    padding: 0 !important;
}

.node-video-upload.video-generation-expanded {
    min-height: 590px !important;
}

.node-video-upload .media-upload-box.video-upload-box.video-workflow-shell {
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: visible !important;
    flex: 1 1 auto !important;
}

.node-video-upload .video-workflow-composer {
    display: none;
    gap: 14px;
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
}

.node-video-upload .video-workflow-composer.is-preview-only {
    display: flex !important;
}

.node-video-upload .video-workflow-composer.is-preview-only .video-workflow-card {
    display: none !important;
}

.node-video-upload.video-generation-expanded .video-workflow-composer {
    display: flex !important;
}

.node-video-upload .video-workflow-preview {
    min-height: 228px;
    border-radius: calc(var(--node-radius) - 2px);
    border: 1px solid rgba(255, 168, 79, 0.08);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)),
        rgba(11, 14, 19, 0.88);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.node-video-upload .video-workflow-preview-empty {
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.02em;
}

.node-video-upload .video-main-player {
    width: 100%;
    height: 100%;
    min-height: 228px;
    object-fit: cover;
    border-radius: calc(var(--node-radius) - 4px);
}

.node-video-upload .video-workflow-card {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 10px 8px 8px;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    flex: 1 1 auto;
    min-height: 0;
}

.node-video-upload.video-generation-expanded .video-workflow-card {
    display: flex !important;
}

.node-video-upload .video-workflow-tabs,
.node-video-upload .video-workflow-refbar,
.node-video-upload .video-workflow-bottom,
.node-video-upload .video-workflow-model-trigger,
.node-video-upload .video-workflow-config-trigger {
    font-family: 'Inter', sans-serif;
}

.node-video-upload .video-workflow-tab {
    min-height: 32px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.node-video-upload .video-workflow-tab:hover {
    border-color: rgba(255, 179, 71, 0.28);
    background: rgba(255, 179, 71, 0.12);
    color: #fff4df;
}

.node-video-upload .video-workflow-tab.is-active {
    border-color: rgba(255, 179, 71, 0.38);
    background: linear-gradient(135deg, #FFB347, #FF9500);
    color: #140b00;
    box-shadow: 0 10px 22px rgba(255, 149, 0, 0.24);
}

.node-video-upload .video-workflow-refbar {
    gap: 8px;
    min-height: 0;
}

.node-video-upload .video-workflow-inherited-prompt {
    margin: 0;
    min-height: 30px;
    padding: 7px 10px;
    border-radius: 8px;
    box-sizing: border-box;
}

.node-video-upload .video-workflow-ref {
    min-height: 30px;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    border: 1px solid rgba(255, 168, 79, 0.14);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.node-video-upload .video-workflow-ref.text-vision-thumb {
    min-height: 0;
    padding: 12px 4px 2px;
    border-radius: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
}

.node-video-upload .video-workflow-ref-thumb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 0.5px solid rgba(255,168,79,0.14);
    box-shadow: 0 6px 18px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.03);
    background: rgba(255,255,255,0.04);
}

.node-video-upload .video-workflow-ref-preview:hover .video-workflow-ref-thumb {
    border-color: rgba(255,179,71,0.32);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0,0,0,0.34), 0 0 0 1px rgba(255,168,79,0.08);
}

.node-video-upload .video-workflow-ref-thumb-glyph {
    color: #140b00;
    background: linear-gradient(135deg, rgba(255, 179, 71, 0.96), rgba(255, 149, 0, 0.92));
    font-size: 14px;
}

.node-video-upload .video-workflow-ref-label {
    max-width: 120px;
    font-size: 11px;
    color: var(--text-primary);
}

.node-video-upload .video-workflow-ref-remove {
    top: 1px !important;
    right: 2px !important;
}

.node-video-upload .video-workflow-start-end-slot .video-workflow-ref-remove {
    top: 14px !important;
    right: 4px !important;
}

.node-video-upload .video-workflow-prompt {
    min-height: 168px;
    border-radius: 16px;
    border: 1px solid rgba(255, 168, 79, 0.1);
    background: rgba(7, 10, 15, 0.6);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        inset 0 0 0 1px rgba(255, 255, 255, 0.015);
    color: var(--text-primary);
    font-family: 'Manrope', sans-serif;
    font-size: 14px;
    line-height: 1.65;
    resize: none;
    flex: 1 1 auto;
}

.node-video-upload .video-workflow-prompt::placeholder {
    color: rgba(214, 219, 230, 0.52);
}

.node-video-upload .video-workflow-bottom {
    align-items: center;
    gap: 8px;
    padding-top: 0;
    margin-top: auto;
}

.node-video-upload .video-workflow-toolbar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: nowrap;
}

.node-video-upload .video-workflow-model-toggle,
.node-video-upload .video-workflow-config-wrap {
    min-width: 0;
}

.node-video-upload .video-workflow-model-toggle {
    width: 156px;
    flex: 0 0 156px;
    max-width: 156px;
}

.node-video-upload .video-workflow-config-wrap {
    flex: 1 1 0;
    min-width: 132px;
    max-width: none;
}

.node-video-upload .video-workflow-model-trigger,
.node-video-upload .video-workflow-config-trigger {
    min-height: 34px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.node-video-upload .video-workflow-model-trigger,
.node-video-upload .video-workflow-config-trigger {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0 10px;
}

.node-video-upload .video-workflow-model-value,
.node-video-upload .video-workflow-config-summary {
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0;
}

.node-video-upload .video-workflow-model-value,
.node-video-upload .video-workflow-config-summary {
    flex: 1 1 auto;
    min-width: 0;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.node-video-upload .video-workflow-config-summary {
    white-space: nowrap;
}

.node-video-upload .video-workflow-generate-btn {
    background: linear-gradient(135deg, #FFB347 0%, #FF9500 100%) !important;
    color: #140b00 !important;
    border: 1px solid rgba(255, 179, 71, 0.28) !important;
    box-shadow: 0 14px 28px rgba(255, 149, 0, 0.24) !important;
    flex: 0 0 34px;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    margin-left: 2px;
}

.node-video-upload .video-workflow-generate-btn:hover {
    background: linear-gradient(135deg, #ffc163 0%, #ff9f1f 100%) !important;
    color: #140b00 !important;
}

/* =============================================
   Storyboard / Asset / Multi-Grid Glass Theme
   ============================================= */

.node-storyboard,
.node-asset-extraction,
.node-multi-grid {
    background: rgba(16, 20, 25, 0.7) !important;
    border: 0.5px solid rgba(255, 168, 79, 0.08) !important;
    border-radius: 16px !important;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.4),
        0 0 18px rgba(255, 168, 79, 0.06),
        inset 0 0 0 1px rgba(255, 255, 255, 0.02) !important;
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
}

.node-storyboard .node-body,
.node-asset-extraction .node-body,
.node-multi-grid .node-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.node-storyboard .node-upload-header,
.node-asset-extraction .node-upload-header,
.node-multi-grid .node-upload-header {
    min-height: 36px;
    padding: 8px 12px 0;
    align-items: center;
    justify-content: space-between;
    border-bottom: none !important;
    background: transparent !important;
}

.node-storyboard .upload-btn,
.node-asset-extraction .upload-btn,
.node-multi-grid .upload-btn {
    height: 28px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 0.5px solid rgba(255, 168, 79, 0.1) !important;
    border-radius: 20px !important;
    color: #a9abb2 !important;
    font-family: 'Inter', sans-serif;
    font-size: 12px !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.node-storyboard .upload-btn:hover,
.node-asset-extraction .upload-btn:hover,
.node-multi-grid .upload-btn:hover {
    background: rgba(255, 255, 255, 0.07) !important;
    border-color: rgba(255, 168, 79, 0.18) !important;
    color: #d8dae0 !important;
}

.node-storyboard .upload-label,
.node-asset-extraction .upload-label,
.node-multi-grid .upload-label {
    color: #a9abb2 !important;
    font-family: 'Inter', sans-serif;
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.node-storyboard .node-input-section,
.node-asset-extraction .node-input-section,
.node-multi-grid .node-input-section {
    padding: 8px 12px 12px !important;
    background: transparent !important;
    border-top: none !important;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.node-storyboard .input-icon,
.node-asset-extraction .input-icon,
.node-multi-grid .input-icon {
    width: 30px !important;
    height: 30px !important;
    margin-bottom: 10px !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border: none !important;
    color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.node-storyboard .input-icon svg,
.node-asset-extraction .input-icon svg,
.node-multi-grid .input-icon svg {
    stroke: rgba(255, 255, 255, 0.3) !important;
}

.node-storyboard .node-textarea,
.node-asset-extraction .node-textarea,
.node-multi-grid .node-textarea {
    width: 100%;
    min-height: 120px;
    max-height: none;
    flex: 1 1 auto;
    margin-bottom: 12px !important;
    padding: 12px 14px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border: none !important;
    border-radius: 12px !important;
    color: var(--text-primary) !important;
    font-family: 'Manrope', sans-serif !important;
    font-size: 13px !important;
    line-height: 1.6 !important;
    resize: none;
    box-sizing: border-box;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.025),
        inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.node-storyboard .node-textarea::placeholder,
.node-asset-extraction .node-textarea::placeholder,
.node-multi-grid .node-textarea::placeholder {
    color: #777d87 !important;
}

.node-storyboard .node-params,
.node-asset-extraction .node-params,
.node-multi-grid .node-params {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0 !important;
}

.node-storyboard .param-item,
.node-asset-extraction .param-item,
.node-multi-grid .param-item {
    min-height: 30px;
    padding: 0 10px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 0.5px solid rgba(255, 168, 79, 0.08) !important;
    border-radius: 8px !important;
    color: #a9abb2 !important;
    font-family: 'Inter', sans-serif;
    font-size: 12px !important;
    font-weight: 500 !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.node-storyboard .param-item:hover,
.node-asset-extraction .param-item:hover,
.node-multi-grid .param-item:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 168, 79, 0.14) !important;
    color: #d0d3da !important;
}

.node-storyboard .param-item.points,
.node-asset-extraction .param-item.points,
.node-multi-grid .param-item.points {
    margin-left: auto;
    padding: 0 4px 0 10px !important;
    gap: 8px;
}

.node-storyboard .send-btn,
.node-asset-extraction .send-btn,
.node-multi-grid .send-btn {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    border-radius: 8px !important;
    background: linear-gradient(135deg, #FFB347, #FF9500) !important;
    border: none !important;
    color: #140b00 !important;
    box-shadow: 0 10px 22px rgba(255, 149, 0, 0.22) !important;
}

.node-storyboard .send-btn svg,
.node-asset-extraction .send-btn svg,
.node-multi-grid .send-btn svg {
    stroke: currentColor !important;
}

.node-storyboard .send-btn:hover,
.node-asset-extraction .send-btn:hover,
.node-multi-grid .send-btn:hover {
    background: linear-gradient(135deg, #ffc163, #ff9f1f) !important;
    color: #140b00 !important;
    transform: translateY(-1px);
}

/* Fix: keep selection frame aligned with actual node content height */
.node.node-text-input,
.node.node-image-upload,
.node.node-video-upload,
.node.node-image-gen {
    height: auto !important;
}

.text-node-empty-state,
.image-node-empty-state {
    min-height: 0 !important;
}

.node-text-input .text-node-body,
.node-image-upload .image-node-body {
    overflow: hidden;
}

.node.node-manual-resized {
    height: var(--node-manual-height) !important;
    min-height: 0 !important;
}

/* Default node border boost: keep selected highlight untouched */
.node.node-text-input:not(.is-selected),
.node.node-image-upload:not(.is-selected),
.node.node-video-upload:not(.is-selected),
.node.node-image-gen:not(.is-selected),
.node.node-agent:not(.is-selected),
.node.node-storyboard:not(.is-selected),
.node.node-asset-extraction:not(.is-selected),
.node.node-multi-grid:not(.is-selected) {
    border-color: rgba(255, 168, 79, 0.35) !important;
    box-shadow:
        0 0 0 1px rgba(255, 168, 79, 0.10),
        0 10px 30px rgba(0,0,0,0.38) !important;
}

.node.node-text-input:not(.is-selected) .node-upload-header,
.node.node-image-upload:not(.is-selected) .node-upload-header,
.node.node-video-upload:not(.is-selected) .node-upload-header,
.node.node-image-gen:not(.is-selected) .node-upload-header,
.node.node-agent:not(.is-selected) .node-upload-header,
.node.node-storyboard:not(.is-selected) .node-upload-header,
.node.node-asset-extraction:not(.is-selected) .node-upload-header,
.node.node-multi-grid:not(.is-selected) .node-upload-header {
    border-bottom-color: rgba(255, 168, 79, 0.10) !important;
}

/* Connection pulse effect: validated from console prototype */
@property --border-angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

@keyframes electricBorderSpin {
    from { --border-angle: 0deg; }
    to { --border-angle: 360deg; }
}

@keyframes portElectric {
    0% {
        box-shadow: 0 0 4px rgba(255,179,71,0.3), 0 0 8px rgba(255,168,79,0.15) !important;
        transform: translateX(-50%) translateY(-50%) scale(1) !important;
    }
    100% {
        box-shadow: 0 0 8px rgba(255,179,71,0.6), 0 0 20px rgba(255,168,79,0.3), 0 0 30px rgba(255,168,79,0.1) !important;
        transform: translateX(-50%) translateY(-50%) scale(1.15) !important;
    }
}

@keyframes activeDash {
    from { stroke-dashoffset: 100; }
    to { stroke-dashoffset: 0; }
}

.node.connection-target-highlight {
    border-color: transparent !important;
    box-shadow: 0 12px 40px rgba(0,0,0,0.45) !important;
    position: relative;
}

.node.connection-target-highlight::before {
    content: "" !important;
    position: absolute !important;
    inset: -2px !important;
    border-radius: var(--node-radius) !important;
    border: none !important;
    background: conic-gradient(
        from var(--border-angle, 0deg),
        transparent 0%,
        transparent 25%,
        rgba(255,168,79,0.1) 30%,
        rgba(255,179,71,0.9) 35%,
        rgba(255,220,150,1) 37%,
        rgba(255,179,71,0.9) 39%,
        rgba(255,168,79,0.1) 44%,
        transparent 50%,
        transparent 75%,
        rgba(255,168,79,0.08) 80%,
        rgba(255,140,50,0.6) 84%,
        rgba(255,200,120,0.8) 86%,
        rgba(255,140,50,0.6) 88%,
        rgba(255,168,79,0.08) 92%,
        transparent 100%
    ) !important;
    padding: 1.5px !important;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0) !important;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0) !important;
    -webkit-mask-composite: xor !important;
    mask-composite: exclude !important;
    animation: electricBorderSpin 2.7s linear infinite !important;
    z-index: 5 !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

.node.connection-target-highlight::after {
    content: "" !important;
    position: absolute !important;
    inset: -6px !important;
    border-radius: var(--node-radius) !important;
    background: conic-gradient(
        from var(--border-angle, 0deg),
        transparent 0%,
        transparent 30%,
        rgba(255,168,79,0.08) 34%,
        rgba(255,168,79,0.15) 37%,
        rgba(255,168,79,0.08) 40%,
        transparent 45%,
        transparent 80%,
        rgba(255,168,79,0.06) 84%,
        rgba(255,168,79,0.1) 86%,
        rgba(255,168,79,0.06) 88%,
        transparent 92%
    ) !important;
    padding: 6px !important;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0) !important;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0) !important;
    -webkit-mask-composite: xor !important;
    mask-composite: exclude !important;
    animation: electricBorderSpin 2.7s linear infinite !important;
    z-index: 4 !important;
    pointer-events: none !important;
    filter: blur(4px) !important;
    cursor: auto !important;
}

.node.connection-target-highlight .node-port-left {
    animation: portElectric 1.08s ease-in-out infinite alternate !important;
    border-color: rgba(255,179,71,0.9) !important;
    background: rgba(255,179,71,0.4) !important;
}

.node.is-selected {
    box-shadow: 0 0 0 1.5px rgba(255,168,79,0.55), 0 0 20px rgba(255,168,79,0.12), 0 8px 32px rgba(0,0,0,0.4) !important;
}

.node.is-selected::before {
    border-color: rgba(255,168,79,0.5) !important;
    box-shadow: inset 0 0 0 1px rgba(255,168,79,0.1) !important;
}

.connection-path.active {
    stroke: rgba(255,179,71,0.35) !important;
    stroke-width: var(--connection-stroke-width, 1.5) !important;
    stroke-dasharray: var(--connection-active-dasharray, 6 4) !important;
    stroke-linecap: round !important;
    filter: none !important;
    animation: var(--connection-active-animation, activeDash 10.8s linear infinite) !important;
}

.connection-path {
    stroke-width: var(--connection-stroke-width, 1.5) !important;
    stroke-linecap: round !important;
}

.connection-path.connection-highlighted,
.connection-path:hover {
    stroke-width: var(--connection-hover-stroke-width, 2) !important;
}

.pulse-runner-glow,
.pulse-runner-core {
    pointer-events: none;
}

.pulse-runner-glow {
    stroke-width: var(--connection-runner-glow-width, 5.2);
}

.pulse-runner-core {
    stroke-width: var(--connection-runner-core-width, 2);
}

.node.node-video-upload[data-media-mode="video"] {
    min-height: 0 !important;
    height: auto !important;
}

.node.node-video-upload[data-media-mode="video"] .video-workflow-shell,
.node.node-video-upload[data-media-mode="video"] .video-workflow-composer,
.node.node-video-upload[data-media-mode="video"] .video-workflow-composer.is-preview-only,
.node.node-video-upload[data-media-mode="video"] .video-workflow-preview,
.node.node-video-upload[data-media-mode="video"] .media-upload-box,
.node.node-video-upload[data-media-mode="video"] .video-upload-box,
.node.node-video-upload[data-media-mode="video"] .node-single-video {
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
}

.node.node-video-upload[data-media-mode="video"] .video-workflow-preview {
    aspect-ratio: var(--video-workflow-preview-ratio, 16 / 9);
    overflow: hidden !important;
    background: #05070a !important;
    flex: 0 0 auto !important;
}

.node.node-video-upload[data-media-mode="video"] .video-workflow-preview .video-main-player {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    object-fit: contain !important;
    background: #000 !important;
}

.node.node-video-upload[data-media-mode="video"] .node-single-video-player {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    object-fit: contain !important;
}

/* Video workflow: generated media stays inside a stable 16:9 preview frame. */
.node.node-video-upload.video-generation-expanded[data-media-mode="video"] .video-workflow-preview {
    min-height: 0 !important;
    aspect-ratio: var(--video-workflow-preview-ratio, 16 / 9) !important;
    overflow: hidden !important;
    flex: 0 0 auto !important;
}

.node.node-video-upload.video-generation-expanded[data-media-mode="video"] .video-main-player {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    object-fit: contain !important;
}

.node.node-video-upload.video-generation-expanded[data-media-mode="video"] .video-workflow-card {
    flex: 0 0 auto !important;
}

.node.node-video-upload.video-generation-expanded[data-media-mode="video"] .video-workflow-composer,
.node.node-video-upload.video-generation-expanded[data-media-mode="video"] .video-workflow-shell {
    height: auto !important;
    flex: 0 0 auto !important;
}

.asset-library-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.66);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1900;
}

.asset-library-overlay.hidden {
    display: none;
}

.asset-library-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.asset-library-panel {
    width: min(1120px, 88vw);
    height: min(680px, 78vh);
    position: relative;
    display: flex;
    flex-direction: column;
    background: #13181f;
    border: 1px solid rgba(255, 168, 79, 0.1);
    border-radius: 20px;
    box-shadow: 0 20px 56px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(255, 168, 79, 0.03);
    overflow: hidden;
    transform: scale(0.96) translateY(8px);
    transition: transform 0.22s ease;
}

.asset-library-overlay.active .asset-library-panel {
    transform: scale(1) translateY(0);
}

.asset-library-header,
.asset-library-toolbar,
.asset-library-footer {
    flex-shrink: 0;
}

.asset-library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px 13px;
    background: #1b2027;
    border-bottom: 1px solid rgba(255, 168, 79, 0.045);
}

.asset-library-header-copy {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.asset-library-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: rgba(245, 246, 254, 0.96);
}

.asset-library-subtitle {
    margin: 0;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.34);
}

.asset-library-close-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.48);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.asset-library-close-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(245, 246, 254, 0.96);
}

.asset-library-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 22px;
    border-bottom: 1px solid rgba(255, 168, 79, 0.06);
    background: #141920;
}

.asset-library-tabs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.asset-library-tab {
    height: 30px;
    padding: 0 14px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.52);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.asset-library-tab:hover {
    background: rgba(255, 168, 79, 0.06);
    color: #ffe0b3;
}

.asset-library-tab.active {
    background: rgba(255, 168, 79, 0.12);
    border-color: rgba(255, 168, 79, 0.18);
    color: #ffd697;
}

.asset-library-toolbar-meta {
    font-size: 11px;
    color: rgba(255, 206, 139, 0.42);
}

.asset-library-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 16px 20px;
}

.asset-library-grid {
    display: grid;
    gap: 14px;
}

.asset-library-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.asset-library-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 168, 79, 0.2);
    background: rgba(255, 168, 79, 0.05);
}

.asset-library-card-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #0d1117;
    overflow: hidden;
}

.asset-library-card-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.asset-library-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 12px 12px;
}

.asset-library-card-type,
.asset-library-card-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.52);
}

.asset-library-card-type {
    color: rgba(255, 232, 201, 0.9);
    font-weight: 600;
}

.asset-library-empty {
    height: 100%;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    color: rgba(255, 220, 176, 0.46);
}

.asset-library-empty-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 168, 79, 0.12);
    background: rgba(255, 168, 79, 0.04);
}

.asset-library-empty-title {
    font-size: 16px;
    font-weight: 700;
    color: rgba(255, 220, 176, 0.9);
}

.asset-library-empty-text {
    max-width: 420px;
    font-size: 12px;
    line-height: 1.65;
}

.asset-library-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 18px;
    border-top: 1px solid rgba(255, 168, 79, 0.06);
    background: #171c23;
}

.asset-library-zoom {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 168, 79, 0.08);
    background: rgba(255, 168, 79, 0.03);
    color: rgba(255, 214, 151, 0.6);
}

.asset-library-zoom-slider {
    width: 120px;
}

.asset-library-upload-btn {
    height: 34px;
    padding: 0 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(255, 149, 0, 0.22);
    transition: transform 0.15s ease, filter 0.15s ease;
}

.asset-library-upload-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.asset-library-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.asset-library-scope-btn,
.asset-library-sort-btn,
.asset-library-filter-btn,
.asset-library-ghost-btn,
.asset-library-zoom-btn {
    border: 1px solid rgba(255, 168, 79, 0.08);
    background: rgba(255, 168, 79, 0.03);
    color: rgba(255, 215, 158, 0.76);
    transition: all 0.15s ease;
}

.asset-library-scope-btn,
.asset-library-sort-btn {
    height: 32px;
    padding: 0 11px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.asset-library-scope-btn:hover,
.asset-library-sort-btn:hover,
.asset-library-filter-btn:hover,
.asset-library-ghost-btn:hover,
.asset-library-zoom-btn:hover {
    background: rgba(255, 168, 79, 0.08);
    color: #ffe0b3;
}

.asset-library-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 20px;
    border-bottom: 1px solid rgba(255, 168, 79, 0.06);
    background: #141920;
}

.asset-library-filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.asset-library-filter-btn {
    height: 28px;
    padding: 0 11px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.asset-library-filter-btn.active {
    background: rgba(255, 168, 79, 0.12);
    border-color: rgba(255, 168, 79, 0.16);
    color: #ffd697;
}

.asset-library-grid {
    gap: 12px;
}

.asset-library-card {
    gap: 8px;
}

.asset-library-card-thumb {
    aspect-ratio: 1 / 1;
}

.asset-library-card-type {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-library-footer-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.asset-library-ghost-btn,
.asset-library-zoom-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

@media (max-width: 1100px) {
    .asset-library-panel {
        width: min(96vw, 1120px);
        height: min(78vh, 680px);
    }

    .asset-library-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .asset-library-sort-btn {
        align-self: flex-end;
    }
}

/* Asset Library doc-aligned structure */
.asset-library-overlay#assetLibraryModal {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.asset-library-overlay#assetLibraryModal.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.asset-library-header-left,
.asset-library-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.asset-header-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.asset-header-icon-btn,
.asset-zoom-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.025);
    color: rgba(255, 255, 255, 0.62);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.asset-header-icon-btn:hover,
.asset-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(245, 246, 254, 0.96);
}

.asset-header-icon-btn.is-active,
.asset-zoom-btn.is-active {
    background: rgba(255, 168, 79, 0.1);
    color: rgba(255, 190, 118, 0.96);
}

.asset-zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.asset-zoom-slider-wrap {
    width: 78px;
    display: flex;
    align-items: center;
    padding: 0 2px;
}

.asset-zoom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 2px;
    background: linear-gradient(
      to right,
      rgba(255, 255, 255, 0.38) 0%,
      rgba(255, 255, 255, 0.38) var(--asset-zoom-fill, 50%),
      rgba(255, 255, 255, 0.14) var(--asset-zoom-fill, 50%),
      rgba(255, 255, 255, 0.14) 100%
    );
    border-radius: 999px;
    outline: none;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.asset-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f5f6fe;
    border: 2px solid #1b2027;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.asset-zoom-slider::-moz-range-track {
    height: 2px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
}

.asset-zoom-slider::-moz-range-progress {
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.38);
}

.asset-zoom-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f5f6fe;
    border: 2px solid #1b2027;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.asset-sort-select {
    position: relative;
}

.asset-sort-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 110px;
    padding: 4px 0;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 168, 79, 0.08);
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 20;
    overflow: hidden;
}

.asset-sort-dropdown.show {
    display: block;
}

.asset-sort-option {
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.asset-sort-option:hover {
    background: rgba(255, 168, 79, 0.06);
    color: var(--text-primary);
}

.asset-sort-option.is-active {
    color: var(--accent-blue);
    background: rgba(255, 168, 79, 0.08);
}

.asset-library-chapter-select {
    position: relative;
}

.asset-chapter-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.asset-chapter-trigger:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(245, 246, 254, 0.96);
}

.asset-chapter-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 220px;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 168, 79, 0.08);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    display: none;
    z-index: 20;
}

.asset-chapter-dropdown.show {
    display: block;
}

.asset-chapter-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.asset-chapter-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-blue);
    background: var(--accent-soft);
    padding: 2px 8px;
    border-radius: 10px;
}

.asset-chapter-option {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    text-align: left;
}

.asset-chapter-option:hover {
    background: rgba(255, 168, 79, 0.04);
    color: var(--text-primary);
}

.asset-chapter-option.is-active {
    color: var(--accent-blue);
    border-left: 3px solid var(--accent-blue);
    background: rgba(255, 168, 79, 0.08);
    padding-left: 13px;
}

.asset-library-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 20px;
    height: 40px;
    border-bottom: 1px solid rgba(255, 168, 79, 0.05);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.asset-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: none;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.asset-tab:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.asset-tab.is-active {
    color: #fff;
    background: rgba(255, 168, 79, 0.08);
    border-color: rgba(255, 168, 79, 0.12);
}

.asset-library-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: block;
}

.asset-empty-icon {
    color: var(--text-tertiary);
    opacity: 0.28;
    margin-bottom: 6px;
}

.asset-empty-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.asset-empty-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.34);
    margin: 0;
    line-height: 1.6;
}

.asset-library-grid {
    display: grid;
    width: 100%;
    align-content: start;
    gap: 12px;
}

.asset-card {
    padding: 0;
    border: 1px solid rgba(255, 168, 79, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
    text-align: left;
}

.asset-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 168, 79, 0.2);
    background: rgba(255, 168, 79, 0.05);
}

.asset-card-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #0d1117;
    overflow: hidden;
}

.asset-card-thumb-audio {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background:
        radial-gradient(circle at top, rgba(255, 168, 79, 0.12), transparent 55%),
        linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
}

.asset-card-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.asset-card-audio-glyph {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 168, 79, 0.12);
    border: 1px solid rgba(255, 168, 79, 0.18);
    color: rgba(255, 224, 179, 0.94);
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.asset-card-audio-ext {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(255, 232, 201, 0.78);
}

.asset-card-meta {
    padding: 10px 10px 12px;
}

.asset-card-name {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 232, 201, 0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-card-sub {
    margin-top: 4px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
}

.asset-drop-hint {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(255, 168, 79, 0.45);
    border-radius: 20px;
    background: rgba(11, 14, 19, 0.78);
    backdrop-filter: blur(4px);
    z-index: 15;
    pointer-events: none;
    animation: asset-drop-pulse 1.6s ease-in-out infinite;
}

.asset-drop-hint.active {
    display: flex;
}

.asset-drop-hint-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    color: rgba(255, 224, 179, 0.94);
}

.asset-drop-hint-title {
    font-size: 15px;
    font-weight: 700;
    color: rgba(255, 224, 179, 0.98);
}

.asset-drop-hint-sub {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.56);
}

@keyframes asset-drop-pulse {
    0%, 100% { border-color: rgba(255, 168, 79, 0.35); }
    50% { border-color: rgba(255, 168, 79, 0.7); }
}

.asset-library-footer {
    display: flex;
    justify-content: flex-end;
    padding: 10px 18px;
    border-top: 1px solid rgba(255, 168, 79, 0.045);
    background: #171c23;
}

.asset-upload-btn {
    height: 30px;
    padding: 0 14px;
    border: none;
    border-radius: 9px;
    background: linear-gradient(135deg, #ffb347 0%, #ff9500 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(255, 149, 0, 0.16);
}

/* Image Gen @ Reference Autocomplete */
.imagen-ref-autocomplete {
    position: fixed;
    width: auto;
    min-width: 200px;
    max-width: 320px;
    max-height: 240px;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 168, 79, 0.18);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.48), 0 0 24px rgba(255, 168, 79, 0.08);
    z-index: 24000;
    display: none;
}

.imagen-ref-autocomplete::-webkit-scrollbar {
    width: 6px;
}

.imagen-ref-autocomplete::-webkit-scrollbar-thumb {
    background: rgba(255, 168, 79, 0.24);
    border-radius: 3px;
}

.ref-autocomplete-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid rgba(255, 168, 79, 0.06);
}

.ref-autocomplete-item:last-child {
    border-bottom: none;
}

.ref-autocomplete-item:hover {
    background: rgba(255, 168, 79, 0.08);
}

.ref-autocomplete-item.active:not(:hover) {
    background: rgba(255, 168, 79, 0.06);
}

.ref-autocomplete-item:active {
    background: rgba(255, 168, 79, 0.12);
}

.ref-autocomplete-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ref-autocomplete-thumb img,
.ref-autocomplete-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prompt-ref-token-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 22px;
    margin: 0 0 6px 0;
}

.prompt-ref-token {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 128px;
    height: 22px;
    padding: 2px 7px 2px 3px;
    border: 1px solid rgba(42, 224, 168, 0.22);
    border-radius: 999px;
    background: rgba(42, 224, 168, 0.08);
    color: #4af1bb;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.prompt-ref-token:hover {
    border-color: rgba(42, 224, 168, 0.38);
    background: rgba(42, 224, 168, 0.13);
}

.prompt-ref-token-thumb {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    overflow: hidden;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.prompt-ref-token-thumb img,
.prompt-ref-token-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prompt-ref-token-placeholder {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.72);
}

.prompt-ref-token-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prompt-inline-token-editor {
    position: relative;
    width: 100%;
}

.prompt-inline-token-editor > textarea {
    position: relative;
    z-index: 1;
}

.prompt-inline-token-editor.has-inline-ref-tokens:not(.is-editing):not(.is-typing) > textarea {
    color: transparent !important;
    text-shadow: none !important;
    caret-color: transparent;
}

.prompt-inline-token-editor.has-inline-ref-tokens:not(.is-editing):not(.is-typing) > textarea::selection {
    color: transparent;
    background: transparent;
}

.prompt-inline-token-layer {
    position: absolute;
    z-index: 2;
    inset: 0;
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden;
    pointer-events: none;
}

.prompt-inline-token-editor.is-editing .prompt-inline-token-layer,
.prompt-inline-token-editor.is-typing .prompt-inline-token-layer {
    display: none;
}

.prompt-inline-text {
    pointer-events: none;
}

.prompt-inline-unit.is-selected {
    background: rgba(45, 123, 255, 0.72);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(121, 174, 255, 0.42);
}

.prompt-inline-text.is-selected {
    border-radius: 3px;
}

.prompt-inline-token.is-selected {
    background: rgba(45, 123, 255, 0.72);
    border-color: rgba(158, 198, 255, 0.92);
    color: #fff;
}

.prompt-inline-token.is-selected .prompt-ref-token-label {
    color: #fff;
}

.prompt-inline-token {
    max-width: 136px;
    height: 22px;
    margin: 0 2px;
    vertical-align: -4px;
    pointer-events: auto;
}

.prompt-inline-fake-caret {
    position: absolute;
    z-index: 5;
    width: 1px;
    min-height: 16px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 8px rgba(255, 168, 79, 0.5);
    pointer-events: none;
    animation: prompt-inline-caret-blink 1s steps(1, end) infinite;
}

.prompt-inline-caret-marker {
    display: inline-block;
    width: 0;
    height: 1.45em;
    vertical-align: -0.22em;
}

@keyframes prompt-inline-caret-blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.ref-autocomplete-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 168, 79, 0.4);
}

.ref-autocomplete-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ref-autocomplete-main {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.ref-autocomplete-hint {
    font-size: 11px;
    color: var(--accent-blue);
    opacity: 0.7;
}

.node-image-gen .node-image-box img.generated-image-preview,
.node-image-gen .node-image-box #generatedImage {
    object-fit: contain !important;
    background: #05070a !important;
    cursor: zoom-in;
}

/* Image-gen nodes can gain reference bars/tokens after creation. Keep the
   generated preview in a fixed 16:9 frame so portrait results do not stretch
   the canvas node; the full image remains available from the preview overlay. */
.node.node-image-gen {
    display: flex !important;
    flex-direction: column !important;
    width: 420px !important;
    min-width: 420px !important;
    max-width: 420px !important;
    height: var(--image-gen-node-height, auto) !important;
    min-height: var(--image-gen-node-min-height, 280px) !important;
    overflow: visible !important;
}

.node.node-image-gen > :not(.node-port):not(.node-delete-btn) {
    flex-shrink: 0 !important;
}

#canvasContent > #imageGenNode {
    display: none !important;
}

.node.node-image-gen .node-image-box {
    width: calc(100% - 24px) !important;
    max-width: calc(100% - 24px) !important;
    flex: 0 0 auto !important;
    height: var(--image-gen-preview-height, 223px) !important;
    min-height: var(--image-gen-preview-height, 223px) !important;
    max-height: var(--image-gen-preview-height, 223px) !important;
    margin: 8px 12px !important;
    aspect-ratio: 16 / 9 !important;
    overflow: hidden !important;
}

.node.node-image-gen .node-input-section,
.node.node-image-gen .imagen-bottom-bar,
.node.node-image-gen .imagen-media-bar,
.node.node-image-gen .prompt-inline-token-editor {
    flex-shrink: 0;
}

/* Tiny-zoom LOD: when the user is zoomed out below 20% (typically full-canvas
   overview where 100+ nodes are all in viewport), hide interactive widgets and
   chrome details that aren't legible at that size anyway. Keeps the main image
   thumbnail, node frame, title label, ports, and delete button visible — the
   node remains identifiable. Paint cost drops because video controls UI,
   textareas, buttons, tags, and config panels stop participating in render. */
body.hc-canvas-tiny-lod .node textarea,
body.hc-canvas-tiny-lod .canvas-node textarea,
body.hc-canvas-tiny-lod .node input:not([type="hidden"]):not([type="file"]),
body.hc-canvas-tiny-lod .canvas-node input:not([type="hidden"]):not([type="file"]),
body.hc-canvas-tiny-lod .node select,
body.hc-canvas-tiny-lod .canvas-node select,
body.hc-canvas-tiny-lod .node button:not(.node-delete-btn),
body.hc-canvas-tiny-lod .canvas-node button:not(.node-delete-btn) {
    visibility: hidden !important;
    pointer-events: none !important;
}

/* tiny-LOD 用 display:none 让节点真正变小（只剩主图/视频区域）。
   组框 bounds 在 LOD 切换前后由 static_group_system.js 的 LOD guard 冻结，
   不会因为节点 ResizeObserver 触发而塌缩。
   优于 visibility:hidden 的占位方式：用户不再看到大块黑色控件区。
   视频节点扩展：.video-workflow-refbar（引用素材区）+ .video-workflow-prompt
   （prompt textarea）+ .node-video-fullscreen-btn，让视频节点也只剩 video
   元素本身。 */
body.hc-canvas-tiny-lod .node .video-workflow-config-panel,
body.hc-canvas-tiny-lod .canvas-node .video-workflow-config-panel,
body.hc-canvas-tiny-lod .node .video-workflow-mode-option,
body.hc-canvas-tiny-lod .canvas-node .video-workflow-mode-option,
body.hc-canvas-tiny-lod .node .video-workflow-refbar,
body.hc-canvas-tiny-lod .canvas-node .video-workflow-refbar,
body.hc-canvas-tiny-lod .node .node-video-fullscreen-btn,
body.hc-canvas-tiny-lod .canvas-node .node-video-fullscreen-btn,
body.hc-canvas-tiny-lod .node .imagen-bottom-bar,
body.hc-canvas-tiny-lod .canvas-node .imagen-bottom-bar,
body.hc-canvas-tiny-lod .node .imagen-media-bar,
body.hc-canvas-tiny-lod .canvas-node .imagen-media-bar,
body.hc-canvas-tiny-lod .node .node-input-section,
body.hc-canvas-tiny-lod .canvas-node .node-input-section,
body.hc-canvas-tiny-lod .node .node-tag,
body.hc-canvas-tiny-lod .canvas-node .node-tag,
body.hc-canvas-tiny-lod .node .node-chip,
body.hc-canvas-tiny-lod .canvas-node .node-chip,
body.hc-canvas-tiny-lod .node .node-image-overlay,
body.hc-canvas-tiny-lod .canvas-node .node-image-overlay,
body.hc-canvas-tiny-lod .node .node-video-overlay,
body.hc-canvas-tiny-lod .canvas-node .node-video-overlay {
    display: none !important;
}

/* tiny-LOD all-in fallback: 所有 textarea/input/select 和非删除按钮移出视区。
   覆盖未在上面 enumerate 的 class（例如视频节点底部 prompt 文字、ref label 等）。
   保留 .node-delete-btn 让用户仍能删除节点。
   用 position:absolute + left:-99999px 而非 display:none —— 元素脱离 flex 流让节点变小
   （效果跟 display:none 一致），但浏览器保留它们的渲染状态。display:none 在 textarea
   内含富文本/chip 时切换回 display 浏览器会跳过重渲染，导致放大后 textarea 内容遮挡
   需要点击才显示的 bug。 */
body.hc-canvas-tiny-lod .node textarea,
body.hc-canvas-tiny-lod .canvas-node textarea,
body.hc-canvas-tiny-lod .node input:not([type="hidden"]):not([type="file"]),
body.hc-canvas-tiny-lod .canvas-node input:not([type="hidden"]):not([type="file"]),
body.hc-canvas-tiny-lod .node select,
body.hc-canvas-tiny-lod .canvas-node select,
body.hc-canvas-tiny-lod .node button:not(.node-delete-btn),
body.hc-canvas-tiny-lod .canvas-node button:not(.node-delete-btn),
body.hc-canvas-tiny-lod .node .prompt-inline-token-editor,
body.hc-canvas-tiny-lod .canvas-node .prompt-inline-token-editor,
body.hc-canvas-tiny-lod .node .prompt-inline-token-layer,
body.hc-canvas-tiny-lod .canvas-node .prompt-inline-token-layer {
    position: absolute !important;
    left: -99999px !important;
    top: 0 !important;
    width: 1px !important;
    height: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

body.hc-canvas-tiny-lod .node video::-webkit-media-controls,
body.hc-canvas-tiny-lod .canvas-node video::-webkit-media-controls {
    display: none !important;
}

/* tiny-LOD 绘图/视频节点收缩到"只剩预览框"：
   在缩到 20% 以下的全画布视图里，绘图节点（.node-image-gen）和视频节点
   （.node-video-upload 内的 .video-workflow-shell）即便没有预览图也会渲染：
     · 预览框内的占位图标 + 引导文字（"等待生成..." / "选中节点后在下方配置并生成"）
     · 预览框下面的 prompt textarea / 词库按钮 / 配置 chip / 生成按钮等
   这些元素在 tiny-LOD 完全看不清，只会让空节点比有图节点显得"内容多"。
   全部收掉，让空节点和有图节点视觉一致——都只剩一个预览框。

   Block 1：隐藏预览框内的空状态占位（.image-placeholder/.image-loading/
   .video-workflow-preview-empty）。父预览框靠 aspect-ratio 维持形状不会塌。
*/
body.hc-canvas-tiny-lod .node .image-placeholder,
body.hc-canvas-tiny-lod .canvas-node .image-placeholder,
body.hc-canvas-tiny-lod .node .image-loading,
body.hc-canvas-tiny-lod .canvas-node .image-loading,
body.hc-canvas-tiny-lod .node .video-workflow-preview-empty,
body.hc-canvas-tiny-lod .canvas-node .video-workflow-preview-empty {
    display: none !important;
}

/* Block 2 + Block 3 合并（v5）：visibility:hidden + height:0 折叠（不再用 position:absolute）。

   绘图节点：.node-image-box 之后所有 sibling（.node-input-section / 无 class 内联 padding
   包装 div / .agent-lib-panel）
   视频节点：.video-workflow-empty + .video-workflow-card

   ⚠️ 为什么选 visibility:hidden + height:0 而不是 display:none 也不是 position:absolute：

   一、display:none（v3 用的）：浏览器把元素从 render tree 拿掉，包含的富文本 textarea
       （.node-textarea / .video-workflow-prompt 都带 @图片1 token chip 的 inline 富
       内容）的 layout/paint 状态被丢弃。tiny-LOD 退出后 display:block 重新进入，
       浏览器跳过对这种富文本框的重渲染——结果就是用户看到的"文字被黑遮罩盖住，
       点一下节点才显示"。

   二、position:absolute + left:-99999px（v4 用的）：理论上能保留 render 状态，但
       它把 .node-input-section / .video-workflow-card 变成了 textarea 的新 containing
       block——tiny-LOD 退出时 absolute → static 切换，textarea 的 containing block
       又变回 .node。富文本 textarea 在 containing block 切换时浏览器仍可能跳过 inline
       chip 的 repaint。实测仍然遮罩。

   三、visibility:hidden + height:0（v5 当前）：元素**始终在 normal flow** 里、**始终
       是 display:block 状态**、**positioning 没动**。只是 visible=hidden 跳过 paint，
       height=0 + padding/margin/border=0 + overflow:hidden 让它占 0 像素。tiny-LOD
       退出时只 visible 从 hidden→inherit，height 从 0→auto，**没有 display 或 position
       的切换**，textarea 的 containing block 和 render tree 位置都没动过，inline chip
       的 layout 也连续维持，浏览器没理由跳过重绘。

   display: block !important 用来压住既有的 `.node-input-section { display: none }` 全局
   规则（line ~16150），让 visibility:hidden 真正生效。 */
body.hc-canvas-tiny-lod .node-image-gen .node-image-box ~ *,
body.hc-canvas-tiny-lod .canvas-node.node-image-gen .node-image-box ~ *,
body.hc-canvas-tiny-lod .node .video-workflow-empty,
body.hc-canvas-tiny-lod .canvas-node .video-workflow-empty,
body.hc-canvas-tiny-lod .node .video-workflow-card,
body.hc-canvas-tiny-lod .canvas-node .video-workflow-card {
    display: block !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* Block 4：覆盖 image-gen / video 节点的 inline height —— 让 .node 外壳跟着内容塌缩。
   根因：[core/node-base.js:560-564] resetNodeSize 在创建节点时给 .node 设了 inline
   style="height: 520px"（image-gen）/ "height: 380px"（video）。Block 2/3 把内部内容
   全 display:none 之后，外壳因为 inline height 还在原高度撑着，下半部分就显示为一块
   空白的深色矩形（.node 本身的 background）。
   用 !important 把 height/min-height 改成 auto/0，让 .node 自动收缩到 visible 内容
   （顶部 label + 预览框）的高度。height: auto 优先级低于 inline style，但加 !important
   后 CSS 可以战胜 inline style。
   组框 bounds 在 LOD 切换由 static_group_system.js 的 LOD guard 冻结，节点 height
   变化不会触发 ResizeObserver 让组框塌；连接线 anchor 跟着 .node 几何走，tiny-LOD 下
   连线本来就细到几乎不可见，位移视觉无感。 */
body.hc-canvas-tiny-lod .node-image-gen,
body.hc-canvas-tiny-lod .canvas-node.node-image-gen,
body.hc-canvas-tiny-lod .node-video-upload,
body.hc-canvas-tiny-lod .canvas-node.node-video-upload {
    height: auto !important;
    min-height: 0 !important;
}

/* Medium-zoom LOD (20% ≤ zoom < 35%): rules follow below. */

/* Medium LOD v6: minimal stable optimizations.
   1. Strip heavy paint ops (backdrop-filter, box-shadow, transition) globally
      on the node subtree — this is the biggest paint win and visually safe.
   2. Hide video controls (browser-native, can't be flattened).
   3. Targeted "thumb frame keeps, content hidden" — for reference thumbnails
      in imagen-media-bar: outer frame visible, inner image hidden.
   4. Hover overlays hidden (they're hover-only anyway).
   5. Leave textareas / buttons / labels / config panels alone — they paint as
      usual minus glass effect, exactly the "barely visible content outline"
      the user wants. */

body.hc-canvas-medium-lod .node,
body.hc-canvas-medium-lod .node *,
body.hc-canvas-medium-lod .canvas-node,
body.hc-canvas-medium-lod .canvas-node * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    transition: none !important;
    animation: none !important;
}

body.hc-canvas-medium-lod .node video::-webkit-media-controls,
body.hc-canvas-medium-lod .canvas-node video::-webkit-media-controls {
    display: none !important;
}

/* Reference thumbnails (image-gen .media-bar-item and video-workflow
   .video-workflow-ref-thumb): keep the frame visible as a flat box
   placeholder, hide the inner content. Active at mild/medium/tiny LOD
   (anything below 45%) because these tiny thumbnails are illegible at
   that zoom but each still paints an image + frame.
   color:transparent also hides the glyph text (视/参/图/文) inside
   .video-workflow-ref-thumb-glyph variants where the character is a
   direct text node (not a child element, so > * doesn't catch it). */
body.hc-canvas-mild-lod .node .media-bar-item,
body.hc-canvas-mild-lod .canvas-node .media-bar-item,
body.hc-canvas-medium-lod .node .media-bar-item,
body.hc-canvas-medium-lod .canvas-node .media-bar-item,
body.hc-canvas-tiny-lod .node .media-bar-item,
body.hc-canvas-tiny-lod .canvas-node .media-bar-item,
body.hc-canvas-mild-lod .node .video-workflow-ref-thumb,
body.hc-canvas-mild-lod .canvas-node .video-workflow-ref-thumb,
body.hc-canvas-medium-lod .node .video-workflow-ref-thumb,
body.hc-canvas-medium-lod .canvas-node .video-workflow-ref-thumb,
body.hc-canvas-tiny-lod .node .video-workflow-ref-thumb,
body.hc-canvas-tiny-lod .canvas-node .video-workflow-ref-thumb {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: transparent !important;
}
body.hc-canvas-mild-lod .node .media-bar-item > *,
body.hc-canvas-mild-lod .canvas-node .media-bar-item > *,
body.hc-canvas-medium-lod .node .media-bar-item > *,
body.hc-canvas-medium-lod .canvas-node .media-bar-item > *,
body.hc-canvas-tiny-lod .node .media-bar-item > *,
body.hc-canvas-tiny-lod .canvas-node .media-bar-item > *,
body.hc-canvas-mild-lod .node .video-workflow-ref-thumb > *,
body.hc-canvas-mild-lod .canvas-node .video-workflow-ref-thumb > *,
body.hc-canvas-medium-lod .node .video-workflow-ref-thumb > *,
body.hc-canvas-medium-lod .canvas-node .video-workflow-ref-thumb > *,
body.hc-canvas-tiny-lod .node .video-workflow-ref-thumb > *,
body.hc-canvas-tiny-lod .canvas-node .video-workflow-ref-thumb > * {
    visibility: hidden !important;
}

/* Hover overlays: fully invisible (only show on hover anyway, no value at
   medium zoom). */
body.hc-canvas-medium-lod .node .node-image-overlay,
body.hc-canvas-medium-lod .canvas-node .node-image-overlay,
body.hc-canvas-medium-lod .node .node-video-overlay,
body.hc-canvas-medium-lod .canvas-node .node-video-overlay {
    visibility: hidden !important;
    pointer-events: none !important;
}

/* =============================================================
 * 2026-05-14: 进一步打 medium/mild-LOD 的 paint 大头（用户反馈 25-40%
 * 缩放还是很卡的针对优化）。68 节点 4K 项目在这区间里，culling 已经几乎
 * 帮不上忙（viewport 太大几乎包住整张画布），剩下的 paint 都来自：
 *   1. <img> 双线性过采样（默认 image-rendering: auto = high quality bilinear）
 *   2. SVG connection path 每次 transform 都重 rasterize
 *   3. 节点内部 child layout 跟外层布局耦合（无 contain）
 * 按贡献排，分别打三刀。
 * ============================================================= */

/* 刀 1：medium/mild-LOD 下 canvas 节点的 <img> 切到 optimizeSpeed —— GPU 用 nearest
   或最便宜的双线性，跳过高质量过滤。在 25-40% 缩放下视觉差异肉眼几乎不可见，但 GPU
   per-frame 工作量明显下降。tiny-LOD 也带上覆盖整个 paint-省钱档。 */
body.hc-canvas-medium-lod .node img,
body.hc-canvas-medium-lod .canvas-node img,
body.hc-canvas-mild-lod .node img,
body.hc-canvas-mild-lod .canvas-node img,
body.hc-canvas-tiny-lod .node img,
body.hc-canvas-tiny-lod .canvas-node img {
    image-rendering: optimizeSpeed;
    image-rendering: -webkit-optimize-contrast;
}

/* 刀 2 已撤销（2026-05-14 用户反馈"体验感很差"）：原方案在 medium/mild-LOD +
   interacting 时隐藏非选中 connection-path，但 350ms 闪烁导致 UX 比卡顿本身更差。
   连接线 paint 暂时接受，未来改用 SVG → Canvas 2D / WebGL 重绘整层（一刀切）
   而不是 visibility 切换。 */

/* 刀 3 已撤销（2026-05-14 用户反馈"整个浏览器都很卡"）：原方案给 medium/mild-LOD
   下的所有节点加 `contain: layout style paint`，理论上能隔离 reflow/repaint，但
   实测在 60-80 节点项目里强制浏览器创建大量独立合成层 / paint 边界，反而拖累整体
   合成性能（GPU 合成阶段成本随层数 O(n) 增长）。撤回后改用 image-rendering 这种
   per-frame 廉价路径（刀 1/4）作为主要 perf 手段。 */

/* 刀 4（兜底）：interacting 全局下，所有 canvas 节点切到 optimizeSpeed —— 哪怕
   zoom 在 45% 以上，pan/drag 期间也省过滤。交互结束自动恢复。 */
body.hc-canvas-interacting .node img,
body.hc-canvas-interacting .canvas-node img {
    image-rendering: optimizeSpeed;
    image-rendering: -webkit-optimize-contrast;
}

/* content-visibility: auto was tried in round 4-5 to get browser-level paint
   culling for off-screen nodes. Removed because it caused severe visual bugs:
   - Paint containment clipped ports/delete-button positioned outside the node box
   - Combined with the node's backdrop-filter + the parent's will-change layer,
     content-visibility caused texture corruption (nodes appeared blurred, X-button
     ghost artifacts persisted after zoom). The interactions between content-visibility,
     CSS containment, GPU compositor layers, and stacking contexts on this canvas turned
     out to be too fragile to use as a perf primitive.
   Other optimizations from rounds 1-3 + 6 (backdrop-filter strip, will-change on
   canvasContent, video controls hide, interaction class hysteresis) remain in place
   and continue providing the bulk of the paint-phase wins. */

body.hc-canvas-viewport-budget .node.hc-node-offscreen,
body.hc-canvas-viewport-budget .canvas-node.hc-node-offscreen {
    visibility: hidden !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

body.hc-canvas-node-culling .node.hc-node-culled,
body.hc-canvas-node-culling .canvas-node.hc-node-culled {
    display: none !important;
    pointer-events: none !important;
}

body.hc-canvas-low-detail .node.hc-node-low-detail,
body.hc-canvas-low-detail .canvas-node.hc-node-low-detail {
    width: var(--hc-perf-node-width) !important;
    height: var(--hc-perf-node-height) !important;
    min-height: var(--hc-perf-node-height) !important;
    overflow: hidden !important;
    box-shadow: 0 8px 22px rgba(0,0,0,0.24) !important;
}

body.hc-canvas-low-detail .node.hc-node-low-detail > *:not(.node-port):not(.node-delete-btn),
body.hc-canvas-low-detail .canvas-node.hc-node-low-detail > *:not(.node-port):not(.node-delete-btn) {
    visibility: hidden !important;
    pointer-events: none !important;
}

body.hc-canvas-low-detail .node.hc-node-low-detail img,
body.hc-canvas-low-detail .node.hc-node-low-detail video,
body.hc-canvas-low-detail .canvas-node.hc-node-low-detail img,
body.hc-canvas-low-detail .canvas-node.hc-node-low-detail video {
    visibility: hidden !important;
}

/* ===== Stage 1: Hash Router 主面板切换 ===== */
.main-panel {
    display: none;
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.main-panel.active {
    display: flex;
    flex-direction: column;
}

/* Canvas 面板 active 时保留原有 canvas-container 行为（不破坏拖拽/滚动） */
.canvas-container.main-panel.active {
    display: block;
}

/* 占位面板内的居中提示 */
.main-panel-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-secondary, #848E9C);
    text-align: center;
}

.main-panel-placeholder h2 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text, #1E2026);
    margin: 0;
    letter-spacing: -0.5px;
}

.main-panel-placeholder p {
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    max-width: 480px;
}

/* nav 高亮态：路由激活时把 .top-center-nav-item 切到 .active */
.top-center-nav-item[data-route] {
    cursor: pointer;
}

/* "正在开发中" 占位样式（Film/Music 当前临时禁用时用） */
.main-panel-placeholder.coming-soon {
    gap: 16px;
    color: var(--text-secondary, #848E9C);
}
.main-panel-placeholder.coming-soon .coming-soon-icon {
    font-size: 64px;
    opacity: 0.55;
    filter: grayscale(0.2);
    margin-bottom: 4px;
    animation: comingSoonPulse 3s ease-in-out infinite;
}
.main-panel-placeholder.coming-soon h2 {
    font-size: 32px;
    font-weight: 600;
    color: var(--text, #f5f6fe);
    margin: 0;
    letter-spacing: -0.5px;
}
.main-panel-placeholder.coming-soon p {
    font-size: 16px;
    color: var(--accent, #ffa84f);
    margin: 0;
    font-weight: 500;
}
.main-panel-placeholder.coming-soon small {
    font-size: 13px;
    color: var(--text-tertiary, #6f747d);
    margin: 0;
    max-width: 380px;
    text-align: center;
}
@keyframes comingSoonPulse {
    0%, 100% { transform: translateY(0); opacity: 0.55; }
    50% { transform: translateY(-4px); opacity: 0.75; }
}

/* ===== Stage 1+ : 路由特定 body class 控制非画布 UI 的显隐 =====
   - body.route-canvas: 默认（左侧栏 / 剧本侧栏 / 画布工具都在）
   - body.route-film / body.route-project / body.route-music: 隐藏画布相关 UI
   原因：Film 和 Project 板块用 iframe 加载完整 v6 视觉，主项目左侧栏会跟 iframe 内布局重叠 */
body.route-film .left-sidebar,
body.route-project .left-sidebar,
body.route-music .left-sidebar,
body.route-film #scriptEditorSidebar,
body.route-project #scriptEditorSidebar,
body.route-music #scriptEditorSidebar,
body.route-film #leftToolbar,
body.route-project #leftToolbar,
body.route-music #leftToolbar,
body.route-film #toggleSidebarBtn,
body.route-project #toggleSidebarBtn,
body.route-music #toggleSidebarBtn,
body.route-film .canvas-minimap,
body.route-project .canvas-minimap,
body.route-music .canvas-minimap {
    display: none !important;
}

/* 默认 body.route-canvas 不需要规则 — 一切正常显示 */

/* Project cloud-update banner — surfaces when polled cloud updatedAt
   exceeds the local cache for the current project. Sits above the bottom
   minimap/toast lane so it doesn't clip the canvas chrome, and avoids the
   right-bottom region used by HC.showToast. The bottom-center strip below
   it is intentionally left clear for a future version-update banner. */
.hc-project-update-banner {
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translate(-50%, 20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50000;
    background: rgba(28, 32, 44, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 168, 79, 0.32);
    border-radius: 999px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
    color: #fff;
    user-select: none;
}

.hc-project-update-banner.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

.hc-project-update-banner-icon {
    display: inline-flex;
    align-items: center;
    color: rgba(255, 168, 79, 0.85);
}

.hc-project-update-banner-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.86);
    letter-spacing: 0.2px;
}

.hc-project-update-banner-action {
    border: 1px solid rgba(255, 168, 79, 0.55);
    background: rgba(255, 168, 79, 0.18);
    color: #ffa84f;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.hc-project-update-banner-action:hover {
    background: rgba(255, 168, 79, 0.32);
    color: #fff;
}

.hc-project-update-banner-close {
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.5);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.hc-project-update-banner-close:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* HolyCrab dialog — outline-style focus highlight, dark glass card.
   Used by HolyCrabDialog.prompt / .confirm in ui/dialog.js as the
   project-native replacement for window.prompt / window.confirm. */
.hc-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.hc-dialog-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.hc-dialog-card {
    background: #181c25;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.55),
        0 2px 8px rgba(0, 0, 0, 0.35);
    padding: 24px 26px 20px;
    width: min(440px, calc(100vw - 48px));
    color: rgba(255, 255, 255, 0.92);
    transform: translateY(16px) scale(0.98);
    transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
    font-family: inherit;
}

.hc-dialog-overlay.is-visible .hc-dialog-card {
    transform: translateY(0) scale(1);
}

.hc-dialog-title {
    font-size: 17px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    margin: 0 0 6px;
    letter-spacing: 0.2px;
}

.hc-dialog-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
    margin: 0 0 18px;
    line-height: 1.55;
}

.hc-dialog-message {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.6;
    margin: 8px 0 24px;
}

.hc-dialog-field {
    margin-bottom: 22px;
}

.hc-dialog-label {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.hc-dialog-input {
    width: 100%;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px 14px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.hc-dialog-input:focus {
    border-color: rgba(255, 168, 79, 0.85);
    background: rgba(255, 168, 79, 0.04);
    box-shadow: 0 0 0 3px rgba(255, 168, 79, 0.14);
}

.hc-dialog-input.is-invalid {
    border-color: rgba(255, 107, 107, 0.85);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.16);
    animation: hc-dialog-shake 0.32s ease;
}

@keyframes hc-dialog-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

.hc-dialog-input::placeholder {
    color: rgba(255, 255, 255, 0.32);
}

.hc-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.hc-dialog-btn {
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.12s ease;
    font-family: inherit;
    outline: none;
}

.hc-dialog-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(255, 168, 79, 0.32);
}

.hc-dialog-btn:active {
    transform: scale(0.97);
}

.hc-dialog-btn-ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.72);
}

.hc-dialog-btn-ghost:hover {
    border-color: rgba(255, 255, 255, 0.32);
    color: #fff;
}

.hc-dialog-btn-primary {
    background: #ffa84f;
    border: 1px solid #ffa84f;
    color: #1a1a1a;
}

.hc-dialog-btn-primary:hover {
    background: #ffb663;
    border-color: #ffb663;
}

.hc-dialog-btn-danger {
    background: transparent;
    border: 1px solid rgba(255, 107, 107, 0.62);
    color: #ff6b6b;
}

.hc-dialog-btn-danger:hover {
    background: rgba(255, 107, 107, 0.12);
    border-color: rgba(255, 107, 107, 0.88);
    color: #ff7a7a;
}

/* === Media upload status badge ===
   Tiny corner badge on an image/video node that signals cloud upload state.
   Originally a full overlay (half-transparent mask) but users felt it
   "locked" the node while uploading — even tiny 58KB images felt slow.
   Now it's a 24px badge in the top-right corner of the visual frame:
     uploading  → orange spinner (small circular badge)
     retrying   → yellow spinner (same shape)
     failed     → red pill with ! icon + "重传" button (slightly wider)
   The node itself stays fully interactive throughout — drag, edit, connect
   all work while upload happens silently in the background. Badge fades
   out on success (cleared by setNodeUploadState in nodes/media-upload.js). */
.media-upload-overlay {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: rgba(15, 17, 24, 0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 6;
    pointer-events: auto;
    border-radius: 999px;
    color: #fff;
    user-select: none;
    width: 24px;
    height: 24px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    transition: width 0.18s ease, padding 0.18s ease, background 0.18s ease;
}

.node[data-upload-state="uploading"] .media-upload-overlay,
.node[data-upload-state="retrying"] .media-upload-overlay,
.node[data-upload-state="failed"] .media-upload-overlay {
    display: inline-flex;
}

.node[data-upload-state="retrying"] .media-upload-overlay {
    background: rgba(60, 44, 12, 0.92);
}

.node[data-upload-state="failed"] .media-upload-overlay {
    background: rgba(220, 38, 38, 0.92);
    width: auto;
    padding: 0 10px;
    height: 22px;
}

.media-upload-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #ffba6a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.node[data-upload-state="retrying"] .media-upload-spinner {
    border-top-color: #f5c14b;
}

.node[data-upload-state="failed"] .media-upload-spinner {
    display: none;
}

.media-upload-failed-icon {
    display: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #b91c1c;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.node[data-upload-state="failed"] .media-upload-failed-icon {
    display: inline-flex;
}

.media-upload-status-text {
    /* hidden in badge mode — failure semantics carried by the retry button label */
    display: none;
}

.media-upload-retry-btn {
    display: none;
    appearance: none;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 0;
    cursor: pointer;
    letter-spacing: 0.4px;
    font-family: inherit;
    line-height: 1;
    white-space: nowrap;
    transition: opacity 0.15s ease;
}

.media-upload-retry-btn:hover:not(:disabled) {
    text-decoration: underline;
}

.media-upload-retry-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.node[data-upload-state="failed"] .media-upload-retry-btn {
    display: inline-flex;
}

/* === Version update banner ===
   Bottom-center toast that pops once per release when features/version-watcher.js
   detects a new cacheKey on the server. User can hit "立即更新" → location.reload()
   (picks up new code via ?v=cacheKey on every module URL) or "×" → dismiss.
   Dismissal is per-version via localStorage, so the banner won't nag for
   the same release twice — but the next bump shows again. */
.version-update-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(28px);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    max-width: min(560px, calc(100vw - 32px));
    background: linear-gradient(135deg, rgba(15, 17, 24, 0.97), rgba(35, 28, 18, 0.97));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 186, 106, 0.4);
    border-radius: 14px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 -1px 0 rgba(0, 0, 0, 0.4) inset;
    color: #fff7ec;
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.version-update-banner.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.version-update-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(255, 186, 106, 0.45));
}

.version-update-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.version-update-title {
    font-size: 13px;
    font-weight: 600;
    color: #ffba6a;
    letter-spacing: 0.5px;
}

.version-update-notes {
    font-size: 12px;
    color: rgba(255, 247, 236, 0.78);
    line-height: 1.45;
    word-break: break-word;
}

.version-update-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.version-update-btn {
    appearance: none;
    border: none;
    padding: 7px 16px;
    background: #ffba6a;
    color: #1f2937;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    letter-spacing: 0.4px;
    font-family: inherit;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.version-update-btn:hover {
    background: #ffc888;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 186, 106, 0.3);
}

.version-update-btn:active {
    transform: translateY(0);
}

.version-update-dismiss {
    appearance: none;
    background: transparent;
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: rgba(255, 247, 236, 0.6);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
    font-family: inherit;
}

.version-update-dismiss:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 640px) {
    .version-update-banner {
        bottom: 16px;
        padding: 12px 14px;
        gap: 10px;
        font-size: 12px;
    }
    .version-update-icon {
        font-size: 18px;
    }
    .version-update-title {
        font-size: 12px;
    }
    .version-update-notes {
        font-size: 11px;
    }
    .version-update-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
}

/* === Post-reload changelog modal ===
   Pops once after the user clicks "立即更新" in the banner. Driven by
   sessionStorage flag (set on reload, consumed on next page boot). Shows
   the full release notes list (window.HolyCrabRebuild.releaseNotesList).
   Dismissed by × / "知道了" / ESC / backdrop click. */
.version-changelog-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(8, 10, 16, 0.62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.version-changelog-modal-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.version-changelog-modal {
    width: min(520px, 100%);
    max-height: min(80vh, 720px);
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, #1a1d26 0%, #221f17 100%);
    border: 1px solid rgba(255, 186, 106, 0.25);
    border-radius: 16px;
    box-shadow:
        0 24px 70px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    color: #fff7ec;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
    opacity: 0;
    overflow: hidden;
}

.version-changelog-modal-backdrop.visible .version-changelog-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.version-changelog-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 22px 12px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.version-changelog-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.3px;
    color: #ffba6a;
    flex: 1;
    min-width: 0;
}

.version-changelog-modal-close {
    appearance: none;
    background: transparent;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: rgba(255, 247, 236, 0.55);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
    font-family: inherit;
}

.version-changelog-modal-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.version-changelog-modal-body {
    padding: 18px 22px 18px 22px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 186, 106, 0.35) transparent;
}

.version-changelog-modal-body::-webkit-scrollbar {
    width: 8px;
}

.version-changelog-modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 186, 106, 0.3);
    border-radius: 999px;
}

.version-changelog-modal-summary {
    margin: 0 0 14px 0;
    font-size: 13px;
    color: rgba(255, 247, 236, 0.82);
    line-height: 1.55;
    padding: 10px 14px;
    background: rgba(255, 186, 106, 0.08);
    border-left: 3px solid rgba(255, 186, 106, 0.6);
    border-radius: 8px;
}

.version-changelog-modal-section-title {
    margin: 0 0 10px 0;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 247, 236, 0.5);
}

.version-changelog-modal-list {
    margin: 0;
    padding: 0 0 0 24px;
    list-style: decimal;
    color: rgba(255, 247, 236, 0.92);
    font-size: 13.5px;
    line-height: 1.65;
}

.version-changelog-modal-list li {
    margin: 0 0 8px 0;
    padding-left: 2px;
}

.version-changelog-modal-list li::marker {
    color: rgba(255, 186, 106, 0.7);
    font-weight: 600;
}

.version-changelog-modal-empty {
    margin: 0;
    color: rgba(255, 247, 236, 0.55);
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

.version-changelog-modal-footer {
    padding: 14px 22px 20px 22px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.version-changelog-modal-confirm {
    appearance: none;
    border: none;
    padding: 9px 24px;
    background: #ffba6a;
    color: #1f2937;
    font-size: 13px;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    letter-spacing: 0.4px;
    font-family: inherit;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.version-changelog-modal-confirm:hover {
    background: #ffc888;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(255, 186, 106, 0.35);
}

.version-changelog-modal-confirm:active {
    transform: translateY(0);
}

@media (max-width: 640px) {
    .version-changelog-modal-backdrop {
        padding: 16px;
    }
    .version-changelog-modal {
        max-height: calc(100vh - 32px);
    }
    .version-changelog-modal-title {
        font-size: 16px;
    }
    .version-changelog-modal-header,
    .version-changelog-modal-body,
    .version-changelog-modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    .version-changelog-modal-list {
        font-size: 13px;
    }
}

/* =============================================================
 * 2026-05-13 E6: 导出模式选择 modal + 跨账号 ⚠️ 角标
 * - .export-mode-modal-* —— "保存项目"菜单点击后弹出的模式选择对话框
 * - [data-foreign-cloud-asset="1"]::after —— 跨账号轻量导入的节点左上角"⚠️ 仅预览"
 * ============================================================= */

.export-mode-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: hc-fade-in 160ms ease-out;
}

.export-mode-modal {
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 80px);
    overflow: hidden;
    background: linear-gradient(180deg, rgba(30, 33, 41, 0.98) 0%, rgba(22, 25, 32, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    color: var(--text-primary, #f5f5f5);
    display: flex;
    flex-direction: column;
    animation: hc-modal-pop 200ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes hc-modal-pop {
    from { opacity: 0; transform: translateY(6px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.export-mode-modal-header {
    padding: 18px 22px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.export-mode-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: rgba(255, 255, 255, 0.95);
}

.export-mode-modal-close {
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.55);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.export-mode-modal-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.95);
}

.export-mode-modal-body {
    padding: 14px 18px 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.export-mode-option {
    display: flex;
    gap: 10px;
    padding: 14px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    /* 关键：flexbox 默认 align-items: stretch 会把 radio 拉成竖条
       （因为 radio 没显式 height，被拉到选项卡满高 ~120px）。
       改 flex-start 让 radio 保留 intrinsic size 18×18。 */
    align-items: flex-start;
}

.export-mode-option:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 168, 79, 0.25);
}

.export-mode-option input[type="radio"] {
    /* 2026-05-14: 改 appearance:none 完全自定义。
       之前 appearance:auto + accent-color 让浏览器画原生 radio——Chrome 在 checked 态
       会渲染 "外层圆 + 内层小填充点" 的"靶心"样式，跟设计稿要的单一橙色实心圆不一致。
       现在用 ::before / box-shadow 自己画，跨浏览器一致。 */
    appearance: none;
    -webkit-appearance: none;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px;
    min-height: 18px;
    max-width: 18px;
    max-height: 18px;
    flex-shrink: 0;
    margin: 3px 0 0 0;
    padding: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.export-mode-option input[type="radio"]:hover {
    border-color: rgba(255, 168, 79, 0.55);
}

/* 2026-05-14 再修：用户要的是经典 radio 视觉 ——
     外圈橙色环 + 中间夹层透明 + 中心一个小橙圆点
   实现：:checked 边框变橙保持环外观，background 仍透明，用 ::before 在中心画
   一个 8×8 橙圆点。所有状态（默认 / hover / checked）几何一致，不会再有"双圈
   靶心"叠加（focus outline 已干掉）。 */
.export-mode-option input[type="radio"]:checked {
    border-color: #ffa84f;
    background: transparent;
}

.export-mode-option input[type="radio"]::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffa84f;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.12s ease;
    pointer-events: none;
}

.export-mode-option input[type="radio"]:checked::before {
    transform: translate(-50%, -50%) scale(1);
}

.export-mode-option input[type="radio"]:focus {
    outline: none;
}

.export-mode-option:has(input[type="radio"]:checked) {
    background: rgba(255, 168, 79, 0.08);
    border-color: rgba(255, 168, 79, 0.45);
}

.export-mode-option-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.export-mode-option-title {
    font-size: 14.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    gap: 8px;
}

.export-mode-option-badge {
    display: inline-block;
    padding: 1px 8px;
    background: rgba(255, 168, 79, 0.18);
    border: 1px solid rgba(255, 168, 79, 0.35);
    border-radius: 999px;
    font-size: 11px;
    color: rgba(255, 200, 130, 0.95);
    font-weight: 500;
    letter-spacing: 0.4px;
}

/* 2026-05-14: 「测试」状态 badge —— 灰色 / muted 色调，跟「推荐」（橙色）视觉区分。
   表示当前轻量导出功能还在测试中，跨账号 4K 自动迁移依赖 OSS 切换后才补。 */
.export-mode-option-badge.is-testing {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.62);
}

.export-mode-option-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.5;
}

.export-mode-option-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.export-mode-option-warn {
    font-size: 11.5px;
    font-style: italic;
    color: rgba(255, 174, 100, 0.85);
    margin-top: 2px;
}

.export-mode-modal-footer {
    padding: 14px 18px 18px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    margin-top: 4px;
}

.export-mode-modal-footer button {
    padding: 8px 18px;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.export-mode-cancel {
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    border-color: rgba(255, 255, 255, 0.15);
}

.export-mode-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.95);
}

.export-mode-confirm {
    background: linear-gradient(180deg, #ffa84f 0%, #ff8c2c 100%);
    color: #1a1a1a;
    border-color: rgba(255, 168, 79, 0.7);
    font-weight: 600;
}

.export-mode-confirm:hover {
    background: linear-gradient(180deg, #ffb866 0%, #ff9a45 100%);
}

@keyframes hc-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* 跨账号轻量导入节点角标 —— 左上角"⚠️ 仅预览" */
.node[data-foreign-cloud-asset="1"],
.canvas-node[data-foreign-cloud-asset="1"] {
    position: relative;
}

.node[data-foreign-cloud-asset="1"]::after,
.canvas-node[data-foreign-cloud-asset="1"]::after {
    content: "⚠️ 仅预览";
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 5;
    padding: 2px 8px;
    background: rgba(255, 152, 64, 0.92);
    color: #2a1a05;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 999px;
    border: 1px solid rgba(255, 200, 100, 0.6);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.3px;
}

