        :root {
            --canvas-bg: #edf3f8;
            --surface: #ffffff;
            --surface-strong: #ffffff;
            --surface-soft: #f8fafc;
            --surface-muted: #eef3fb;
            --line: #cbd5e1;
            --line-strong: #b6c2d1;
            --text: #0f172a;
            --text-soft: #334155;
            --text-muted: #64748b;
            --accent: #2440ED;
            --accent-hover: #1d35c9;
            --accent-soft: #eff6ff;
            --accent-line: #bfdbfe;
            --gdrive-panel-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(239, 246, 255, 0.64));
            --gdrive-panel-border: rgba(147, 197, 253, 0.36);
            --gdrive-panel-shadow: 0 12px 26px rgba(37, 66, 243, 0.08);
            --gdrive-avatar-bg: rgba(255, 255, 255, 0.92);
            --gdrive-avatar-shadow: rgba(37, 66, 243, 0.18);
            --gdrive-label-color: var(--text-muted);
            --gdrive-user-color: var(--accent);
            --gdrive-logout-color: var(--danger);
            --gdrive-logout-border: rgba(239, 68, 68, 0.22);
            --gdrive-logout-bg: rgba(255, 255, 255, 0.96);
            --gdrive-logout-hover-bg: rgba(255, 248, 248, 0.98);
            --danger: #ef4444;
            --success: #10b981;
            --dot-color: rgba(37, 99, 235, 0.11);
            --body-glow-a: rgba(191, 219, 254, 0.52);
            --body-glow-b: rgba(226, 232, 240, 0.72);
            --body-grad-a: #f8fbff;
            --body-grad-b: #e8eef6;
            --port-border: #ffffff;
            --radius-xs: 6px;
            --radius-sm: 8px;
            --radius-md: 12px;
            --radius-lg: 18px;
            --radius-xl: 24px;
            --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
            --shadow-card: 0 18px 45px rgba(15, 23, 42, 0.10), 0 2px 8px rgba(15, 23, 42, 0.04);
            --shadow-focus: 0 0 0 3px rgba(37, 66, 243, 0.16);
            --control-height: 36px;

            /* === 新拟态设计系统 === */
            /* 节点新拟态阴影 */
            --neu-shadow:
                6px 6px 14px rgba(163, 177, 198, 0.32),
                -6px -6px 14px rgba(255, 255, 255, 0.38);
            --neu-shadow-hover:
                8px 8px 18px rgba(163, 177, 198, 0.38),
                -8px -8px 18px rgba(255, 255, 255, 0.42);
            --neu-shadow-active:
                10px 10px 22px rgba(163, 177, 198, 0.42),
                -10px -10px 22px rgba(255, 255, 255, 0.48);
            --neu-inset:
                inset 3px 3px 6px rgba(163, 177, 198, 0.22),
                inset -3px -3px 6px rgba(255, 255, 255, 0.35);
            --neu-inset-deep:
                inset 4px 4px 10px rgba(163, 177, 198, 0.3),
                inset -4px -4px 10px rgba(255, 255, 255, 0.4);

            /* 节点背景 */
            --node-neu-bg: linear-gradient(145deg, #f0f4f8, #ffffff);
            --node-neu-surface: #f4f7fa;

            /* 节点类型色彩（浅色模式统一蓝色体系） */
            --type-ai: #2440ED;
            --type-chat: #2440ED;
            --type-preview: #2440ED;
            --type-image: #2440ED;
            --type-text: #2440ED;
            --type-compare: #2440ED;
            --type-parallel: #2440ED;
            --type-doubao: #2440ED;

            /* 间距系统 */
            --space-xs: 4px;
            --space-sm: 8px;
            --space-md: 12px;
            --space-lg: 16px;
            --space-xl: 24px;

            /* 动效 */
            --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
            --duration-fast: 0.12s;
            --duration-normal: 0.2s;
        }

        body,
        html {
            margin: 0;
            padding: 0;
            height: 100%;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            overflow: hidden;
            background:
                radial-gradient(circle, var(--dot-color) 1px, transparent 1.2px),
                radial-gradient(circle at 12% 16%, var(--body-glow-a), transparent 28%),
                radial-gradient(circle at 88% 10%, var(--body-glow-b), transparent 32%),
                linear-gradient(135deg, var(--body-grad-a) 0%, var(--canvas-bg) 48%, var(--body-grad-b) 100%);
            background-size: 28px 28px, auto, auto, auto;
            user-select: none;
        }

        .svg-icon {
            width: 1.1em;
            height: 1.1em;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
            fill: none;
            stroke: currentColor;
            display: inline-block;
            vertical-align: middle;
        }
        @keyframes spin {
            100% {
                transform: rotate(360deg);
            }
        }
        .spin {
            animation: spin 1s linear infinite;
        }

        #canvas-container {
            position: relative;
            width: 100vw;
            height: 100vh;
            overflow: hidden;
        }
        #canvas-viewport {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            transform-origin: 0 0;
        }
        #edges-layer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            overflow: visible;
            z-index: 5;
        }


        .edge-group {
            pointer-events: all;
            cursor: pointer;
        }
        .edge-group .edge-visual {
            transition: stroke 0.2s, stroke-width 0.2s;
        }
        .edge-group.edge-hovered .edge-visual {
            stroke: var(--edge-hover-stroke);
            stroke-width: var(--edge-hover-width);
        }
        body.edge-scissor-mode #canvas-container,
        body.edge-scissor-mode #canvas-container * {
            cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Ctext x='1' y='22' font-size='22'%3E%E2%9C%82%EF%B8%8F%3C/text%3E%3C/svg%3E") 4 20, crosshair !important;
        }
        body.edge-cutting-active #canvas-container,
        body.edge-cutting-active #canvas-container * {
            cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Ctext x='1' y='22' font-size='22'%3E%E2%9C%82%EF%B8%8F%3C/text%3E%3C/svg%3E") 4 20, crosshair !important;
        }

        #snap-guides { position: absolute; inset: 0; overflow: visible; pointer-events: none; z-index: 55; }
        .snap-guide {
            position: absolute;
            pointer-events: none;
            opacity: 0.92;
            transform: translateZ(0);
            animation: snapGuideIn 0.12s ease-out;
        }
        .snap-guide.vertical { width: 1px; }
        .snap-guide.horizontal { height: 1px; }
        .snap-guide-core,
        .snap-guide-glow {
            position: absolute;
            display: block;
            pointer-events: none;
        }
        .snap-guide.vertical .snap-guide-core {
            left: 0;
            top: 0;
            width: 1px;
            height: 100%;
            background: repeating-linear-gradient(
                to bottom,
                rgba(37, 66, 243, 0) 0,
                rgba(37, 66, 243, 0) 4px,
                rgba(96, 165, 250, 0.98) 4px,
                rgba(96, 165, 250, 0.98) 10px,
                rgba(37, 66, 243, 0) 10px,
                rgba(37, 66, 243, 0) 16px
            );
            box-shadow: 0 0 0 0.5px rgba(255,255,255,0.72);
        }
        .snap-guide.horizontal .snap-guide-core {
            left: 0;
            top: 0;
            width: 100%;
            height: 1px;
            background: repeating-linear-gradient(
                to right,
                rgba(37, 66, 243, 0) 0,
                rgba(37, 66, 243, 0) 4px,
                rgba(96, 165, 250, 0.98) 4px,
                rgba(96, 165, 250, 0.98) 10px,
                rgba(37, 66, 243, 0) 10px,
                rgba(37, 66, 243, 0) 16px
            );
            box-shadow: 0 0 0 0.5px rgba(255,255,255,0.72);
        }
        .snap-guide.vertical .snap-guide-glow {
            left: -2px;
            top: 0;
            width: 5px;
            height: 100%;
            background: repeating-linear-gradient(
                to bottom,
                rgba(59, 130, 246, 0) 0,
                rgba(59, 130, 246, 0) 4px,
                rgba(59, 130, 246, 0.28) 4px,
                rgba(59, 130, 246, 0.28) 10px,
                rgba(59, 130, 246, 0) 10px,
                rgba(59, 130, 246, 0) 16px
            );
            filter: blur(2px);
        }
        .snap-guide.horizontal .snap-guide-glow {
            left: 0;
            top: -2px;
            width: 100%;
            height: 5px;
            background: repeating-linear-gradient(
                to right,
                rgba(59, 130, 246, 0) 0,
                rgba(59, 130, 246, 0) 4px,
                rgba(59, 130, 246, 0.28) 4px,
                rgba(59, 130, 246, 0.28) 10px,
                rgba(59, 130, 246, 0) 10px,
                rgba(59, 130, 246, 0) 16px
            );
            filter: blur(2px);
        }
        @keyframes snapGuideIn {
            from { opacity: 0; }
            to { opacity: 0.92; }
        }

        #selection-box {
            position: absolute;
            border: var(--selection-border);
            background: var(--selection-bg);
            display: none;
            pointer-events: none;
            z-index: 50;
        }

        .canvas-scrollbar {
            position: absolute;
            z-index: 1100;
            opacity: 0.52;
            transition: opacity 0.15s, background 0.15s;
            pointer-events: auto;
        }
        .canvas-scrollbar:hover,
        .canvas-scrollbar.dragging {
            opacity: 1;
        }
        .canvas-scrollbar-x {
            left: 18px;
            right: 18px;
            bottom: 5px;
            height: 8px;
            border-radius: 999px;
            background: rgba(148, 163, 184, 0.10);
        }
        .canvas-scrollbar-y {
            top: 58px;
            right: 5px;
            bottom: 64px;
            width: 8px;
            border-radius: 999px;
            background: rgba(148, 163, 184, 0.10);
        }
        .canvas-scrollbar-thumb {
            position: absolute;
            border-radius: 999px;
            background: rgba(71, 85, 105, 0.42);
            box-shadow: 0 1px 3px rgba(15, 23, 42, 0.10);
            cursor: grab;
        }
        .canvas-scrollbar-thumb:hover,
        .canvas-scrollbar.dragging .canvas-scrollbar-thumb {
            background: rgba(37, 99, 235, 0.68);
        }
        .canvas-scrollbar.dragging .canvas-scrollbar-thumb {
            cursor: grabbing;
        }
        .canvas-scrollbar-x .canvas-scrollbar-thumb {
            top: 1.5px;
            height: 5px;
            min-width: 34px;
        }
        .canvas-scrollbar-y .canvas-scrollbar-thumb {
            left: 1.5px;
            width: 5px;
            min-height: 34px;
        }
        .canvas-scrollbar.hidden {
            display: none;
        }

        .matrix-layout-wrap {
            position: relative;
            display: flex;
            align-items: center;
        }
        .matrix-layout-popover {
            position: absolute;
            top: calc(100% + 8px);
            left: 50%;
            transform: translateX(-50%) translateY(-4px);
            display: flex;
            gap: 4px;
            padding: 5px;
            border-radius: 9px;
            background: rgba(255, 255, 255, 0.96);
            border: 1px solid var(--line);
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s ease;
            z-index: 360;
        }
        .matrix-layout-popover::before {
            content: '';
            position: absolute;
            left: 0;
            right: 0;
            top: -10px;
            height: 10px;
        }
        .matrix-layout-wrap:hover .matrix-layout-popover {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
            transform: translateX(-50%) translateY(0);
        }
        .matrix-layout-option {
            min-width: 28px;
            height: 26px;
            border: none;
            border-radius: 6px;
            background: transparent;
            color: var(--text-soft);
            font-size: 12px;
            font-weight: 700;
            cursor: pointer;
        }
        .matrix-layout-option:hover {
            background: var(--accent-soft);
            color: var(--accent);
        }

        #status-bar {
            position: absolute;
            top: 48px;
            right: 22px;
            background: transparent;
            padding: 8px 0;
            border-radius: 0;
            box-shadow: none;
            z-index: 1200;
            font-size: 12px;
            color: var(--text-muted);
            border: none;
            display: flex;
            align-items: center;
            gap: 12px;
            pointer-events: auto;
        }
        .status-val {
            font-weight: 600;
            color: var(--text);
        }
        .status-val.highlight {
            color: var(--accent);
        }
        .perf-monitor-inline {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 11px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        }
        .perf-monitor-inline .status-val {
            font-variant-numeric: tabular-nums;
            min-width: 42px;
            text-align: right;
        }

        .resource-status-panel {
            position: absolute;
            top: 88px;
            right: 20px;
            width: fit-content;
            min-width: 0;
            max-width: min(520px, calc(100vw - 40px));
            padding: 10px 14px;
            border-radius: var(--radius-lg);
            background: var(--resource-status-bg);
            border: var(--resource-status-border);
            box-shadow: var(--resource-status-shadow);
            backdrop-filter: var(--resource-status-filter);
            z-index: 1190;
            color: var(--resource-status-text);
            font-size: 12px;
            pointer-events: auto;
            box-sizing: border-box;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: width var(--duration-normal) var(--ease-out), padding var(--duration-normal) var(--ease-out), box-shadow var(--duration-normal) var(--ease-out), border-color var(--duration-normal) var(--ease-out), background var(--duration-normal) var(--ease-out), transform var(--duration-normal) var(--ease-out);
        }
        .resource-status-content {
            min-width: 0;
            overflow: visible;
            transition: max-width var(--duration-normal) var(--ease-out), opacity var(--duration-fast) ease;
        }
        .resource-status-main {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 7px;
            white-space: nowrap;
            width: 100%;
            max-width: 100%;
            text-align: right;
        }
        .resource-status-dot {
            width: 8px;
            height: 8px;
            border-radius: 999px;
            flex: 0 0 8px;
            background: var(--resource-status-dot-bg);
            box-shadow: var(--resource-status-dot-shadow);
            margin-left: 6px;
            position: relative;
            z-index: 1;
        }
        .resource-status-title,
        .resource-status-compact-label {
            font-weight: 800;
            color: var(--resource-status-title);
        }
        .resource-status-compact-label {
            display: none;
        }
        .resource-status-value {
            font-weight: 700;
            color: var(--resource-status-value);
        }
        .resource-status-sep {
            color: var(--resource-status-sep);
        }
        .resource-status-save {
            font-weight: 800;
            color: var(--resource-status-save);
        }
        .resource-status-hint {
            margin-top: 5px;
            color: var(--text-muted);
            line-height: 1.35;
            font-size: 11px;
            white-space: normal;
            text-align: right;
            max-width: 100%;
        }
        .resource-status-toggle {
            width: 26px;
            height: 26px;
            border: var(--resource-status-toggle-border);
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex: 0 0 auto;
            color: var(--resource-status-toggle-text);
            background: var(--resource-status-toggle-bg);
            box-shadow: var(--resource-status-toggle-shadow);
            cursor: pointer;
            transition: transform var(--duration-fast) ease, color var(--duration-fast) ease, box-shadow var(--duration-fast) ease, background var(--duration-fast) ease;
        }
        .resource-status-toggle svg {
            width: 13px;
            height: 13px;
            transition: transform var(--duration-normal) var(--ease-out);
        }
        .resource-status-toggle:hover {
            color: var(--resource-status-toggle-hover-text);
            background: var(--resource-status-toggle-hover-bg);
            transform: translateX(-1px);
            box-shadow: var(--neu-shadow-hover);
        }
        .resource-status-panel.resource-collapsed {
            padding: 9px 10px 9px 18px;
            border-radius: 999px;
            max-width: 170px;
            overflow: visible;
        }
        .resource-status-panel.resource-collapsed .resource-status-content {
            max-width: 72px;
            overflow: visible;
        }
        .resource-status-panel.resource-collapsed .resource-status-main {
            gap: 6px;
        }
        .resource-status-panel.resource-collapsed .resource-status-title,
        .resource-status-panel.resource-collapsed .resource-status-value,
        .resource-status-panel.resource-collapsed .resource-status-sep,
        .resource-status-panel.resource-collapsed .resource-status-save,
        .resource-status-panel.resource-collapsed .resource-status-hint {
            display: none;
        }
        .resource-status-panel.resource-collapsed .resource-status-compact-label {
            display: inline;
            font-size: 12px;
        }
        .resource-status-panel.resource-collapsed .resource-status-toggle svg {
            transform: rotate(180deg);
        }
        .resource-status-panel.resource-collapsed.resource-ok {
            border-color: var(--resource-status-collapsed-ok-border);
            box-shadow: var(--resource-status-collapsed-ok-shadow);
        }
        .resource-status-panel.resource-collapsed.resource-warn {
            box-shadow: 0 12px 30px rgba(245, 158, 11, 0.18), 0 0 0 1px rgba(245, 158, 11, 0.08) inset;
        }
        .resource-status-panel.resource-collapsed.resource-danger {
            box-shadow: 0 12px 32px rgba(239, 68, 68, 0.20), 0 0 0 1px rgba(239, 68, 68, 0.10) inset;
        }
        .resource-status-panel.resource-collapsed.resource-unsaved {
            outline: 2px solid var(--resource-status-collapsed-unsaved-outline);
            outline-offset: 2px;
        }
        .resource-status-panel.resource-warn {
            background: var(--resource-status-warn-bg);
            border-color: var(--resource-status-warn-border);
            box-shadow: var(--resource-status-warn-shadow);
        }
        .resource-status-panel.resource-warn .resource-status-dot {
            background: var(--resource-status-warn-dot-bg);
            box-shadow: var(--resource-status-warn-dot-shadow);
        }
        .resource-status-panel.resource-warn .resource-status-title {
            color: var(--resource-status-warn-title);
        }
        .resource-status-panel.resource-danger {
            background: var(--resource-status-danger-bg);
            border-color: var(--resource-status-danger-border);
            box-shadow: var(--resource-status-danger-shadow);
        }
        .resource-status-panel.resource-danger .resource-status-dot {
            background: var(--resource-status-danger-dot-bg);
            box-shadow: var(--resource-status-danger-dot-shadow);
        }
        .resource-status-panel.resource-danger .resource-status-title,
        .resource-status-panel.resource-danger .resource-status-save {
            color: var(--resource-status-danger-title);
        }
        .resource-status-panel.resource-unsaved .resource-status-save {
            color: #f97316;
        }

        #key-indicator {
            position: absolute;
            bottom: 20px;
            left: 330px;
            display: flex;
            gap: 8px;
            z-index: 100;
            pointer-events: none;
            transition: left 0.3s;
        }
        .key-badge {
            background: var(--node-neu-bg);
            color: var(--text);
            border: 1px solid rgba(203, 213, 225, 0.45);
            padding: 8px 16px;
            border-radius: var(--radius-sm);
            font-size: 14px;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
            font-weight: 600;
            box-shadow: var(--neu-shadow);
            animation: popIn 0.15s var(--ease-out);
        }
        @keyframes popIn {
            from {
                transform: scale(0.8) translateY(5px);
                opacity: 0;
            }
            to {
                transform: scale(1) translateY(0);
                opacity: 1;
            }
        }

        #toast {
            position: fixed;
            top: -60px;
            left: 50%;
            transform: translateX(-50%);
            background: var(--toast-bg);
            backdrop-filter: var(--toast-filter);
            color: var(--toast-text);
            padding: 12px 24px;
            border-radius: var(--toast-radius);
            border: var(--toast-border);
            font-size: 13px;
            font-weight: 550;
            z-index: 2000;
            transition: top 0.4s var(--ease-out);
            box-shadow: var(--neu-shadow);
            pointer-events: none;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        #toast.toast-with-actions {
            pointer-events: auto;
            padding: 10px 12px 10px 18px;
            gap: 12px;
        }
        #toast .toast-message {
            white-space: nowrap;
        }
        #toast .toast-actions {
            display: inline-flex;
            gap: 8px;
            align-items: center;
        }
        #toast .toast-action-btn {
            border: 1px solid color-mix(in srgb, var(--accent-line) 70%, rgba(255,255,255,0.35));
            border-radius: 999px;
            padding: 6px 12px;
            background: linear-gradient(180deg, var(--accent), var(--accent-hover));
            color: #fff;
            font: inherit;
            font-size: 12px;
            font-weight: 800;
            line-height: 1;
            cursor: pointer;
            box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent), inset 0 1px 0 rgba(255,255,255,0.18);
            transition: transform 0.16s var(--ease-out), background 0.16s var(--ease-out), border-color 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
            white-space: nowrap;
        }
        #toast .toast-action-btn::before {
            content: '↗';
            margin-right: 5px;
            font-size: 11px;
        }
        #toast .toast-action-btn:hover {
            transform: translateY(-1px);
            background: linear-gradient(180deg, var(--accent-hover), var(--accent));
            border-color: color-mix(in srgb, var(--accent) 70%, white);
            box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 34%, transparent), inset 0 1px 0 rgba(255,255,255,0.24);
        }
        #toast .toast-action-btn:active {
            transform: translateY(0) scale(0.98);
        }
        #toast.show {
            top: 88px;
        }

        #toast.import-progress-toast,
        #toast.import-progress-done,
        #toast.import-progress-error {
            width: max-content;
            max-width: min(86vw, 720px);
            min-width: 0;
            justify-content: center;
            text-align: center;
            white-space: nowrap;
        }
        #toast.import-progress-done {
            border-color: rgba(16, 185, 129, 0.45);
        }
        #toast.import-progress-error {
            border-color: rgba(239, 68, 68, 0.45);
        }

        #save-progress-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(15, 23, 42, 0.7);
            backdrop-filter: blur(4px);
            z-index: 3000;
            display: none;
            align-items: center;
            justify-content: center;
        }
        #save-progress-overlay.show {
            display: flex;
        }
        .progress-card {
            background: var(--progress-bg);
            border: var(--progress-border);
            border-radius: var(--progress-radius);
            padding: 32px 40px;
            box-shadow: var(--progress-shadow);
            text-align: center;
            min-width: 320px;
            max-width: 420px;
        }
        .progress-card .spin-icon {
            width: 36px;
            height: 36px;
            color: var(--accent);
            margin-bottom: 12px;
        }
        .progress-card .progress-title {
            font-size: 15px;
            font-weight: 600;
            color: var(--text);
            margin-bottom: 8px;
        }
        .progress-card .progress-detail {
            font-size: 12px;
            color: var(--text-muted);
            margin-bottom: 16px;
        }
        .progress-card .progress-bar-track {
            width: 100%;
            height: 6px;
            background: var(--canvas-bg);
            border-radius: 3px;
            overflow: hidden;
        }
        .progress-card .progress-bar-fill {
            height: 100%;
            background: var(--accent);
            border-radius: 3px;
            transition: width 0.3s;
            width: 0%;
        }

        #context-menu,
        #canvas-action-menu,
        #img-context-menu,
        #lightbox-context-menu {
            position: absolute;
            background: var(--node-neu-bg);
            backdrop-filter: blur(12px);
            border-radius: var(--radius-md);
            border: 1px solid rgba(203, 213, 225, 0.45);
            box-shadow: var(--neu-shadow-hover);
            padding: 6px;
            display: none;
            z-index: 200;
            min-width: 140px;
            width: max-content;
            white-space: nowrap;
        }
        #img-context-menu {
            z-index: 300;
        }
        #lightbox-context-menu {
            z-index: 2030;
            min-width: 168px;
        }
        .menu-item {
            padding: 9px 14px;
            font-size: 13px;
            color: var(--text-soft);
            cursor: pointer;
            border-radius: var(--radius-sm);
            transition: all var(--duration-fast) ease;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        #context-menu .menu-item {
            justify-content: flex-start;
            text-align: left;
        }
        .menu-item:hover {
            background: var(--accent-soft);
            color: var(--accent);
        }
        .menu-divider {
            height: 1px;
            background: rgba(203, 213, 225, 0.35);
            margin: 5px 8px;
        }
        .menu-section-title {
            padding: 5px 10px 3px;
            font-size: 11px;
            font-weight: 800;
            line-height: 1.2;
            letter-spacing: 0.08em;
            color: var(--text-muted);
            opacity: 0.78;
            pointer-events: none;
            user-select: none;
        }
        #context-menu .menu-section-title {
            text-align: left;
        }
        #context-menu {
            padding: 8px;
            border-radius: 14px;
        }
        #context-menu .menu-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(126px, 1fr));
            gap: 6px 8px;
            min-width: 292px;
        }
        #context-menu .menu-column {
            display: flex;
            flex-direction: column;
            min-width: 0;
            gap: 4px;
        }
        #context-menu .menu-column + .menu-column {
            border-left: 1px solid color-mix(in srgb, var(--text-muted) 18%, transparent);
            padding-left: 8px;
        }
        #context-menu .menu-section {
            min-width: 0;
            padding: 1px;
            border-radius: 10px;
        }
        #context-menu .menu-section-title {
            display: flex;
            align-items: center;
            gap: 5px;
            padding: 2px 6px 4px;
            color: var(--accent);
            opacity: 0.88;
        }
        #context-menu .menu-section-title::before {
            content: '';
            width: 3px;
            height: 10px;
            border-radius: 999px;
            background: color-mix(in srgb, var(--accent) 72%, white);
            box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 10%, transparent);
        }
        #context-menu .menu-item {
            min-height: 28px;
            padding: 5px 8px;
            border-radius: 8px;
        }
        #context-menu .menu-item .svg-icon {
            flex: 0 0 auto;
            width: 14px;
            height: 14px;
            color: var(--text-muted);
        }
        #context-menu .menu-item:hover .svg-icon {
            color: var(--accent);
        }
        #context-menu .menu-divider {
            margin: 1px 3px;
            background: color-mix(in srgb, var(--text-muted) 16%, transparent);
        }
        #context-menu .menu-section-wide {
            grid-column: 1 / -1;
            border-top: 1px solid color-mix(in srgb, var(--text-muted) 18%, transparent);
            padding-top: 5px;
        }
        #context-menu .menu-section-wide .menu-item {
            justify-content: flex-start;
            width: calc(50% - 4px);
        }
        #context-menu .menu-section-wide .menu-divider {
            display: none;
        }
        #prompt-ref-tooltip {
            position: fixed;
            top: 0; left: 0;
            width: 148px; padding: 8px;
            border-radius: var(--radius-md);
            background: var(--navigator-bg);
            border: var(--navigator-border);
            box-shadow: var(--navigator-shadow);
            backdrop-filter: blur(12px);
            pointer-events: none;
            opacity: 0; visibility: hidden;
            transform: translate3d(0, 6px, 0);
            transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
            z-index: 2600;
        }
        #prompt-ref-tooltip.show { opacity: 1; visibility: visible; transform: translate3d(0, 0, 0); }
        #prompt-ref-tooltip img { display: block; width: 100%; height: 108px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid rgba(203, 213, 225, 0.35); }

        #lightbox {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(15, 23, 42, 0.95);
            backdrop-filter: blur(8px);
            z-index: 2000;
            display: none;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            opacity: 0;
            transition: opacity 0.2s;
        }
        #lightbox.show {
            opacity: 1;
            display: flex;
        }
        .lb-img {
            max-width: 95vw;
            max-height: 90vh;
            object-fit: contain;
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
            border-radius: 8px;
            cursor: grab;
        }
        .lb-nav {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background: transparent;
            border: none;
            color: rgba(255, 255, 255, 0.6);
            padding: 20px;
            cursor: pointer;
            transition: all 0.2s;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 2010;
        }
        .lb-nav:hover {
            color: white;
            background: rgba(255, 255, 255, 0.1);
            transform: translateY(-50%) scale(1.1);
        }
        .lb-nav:active {
            transform: translateY(-50%) scale(0.95);
        }
        .lb-prev {
            left: 40px;
        }
        .lb-next {
            right: 40px;
        }
        .lb-close {
            position: absolute;
            top: 30px;
            right: 40px;
            background: none;
            border: none;
            color: rgba(255, 255, 255, 0.6);
            cursor: pointer;
            transition: color 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 10px;
            z-index: 2010;
        }
        .lb-close:hover {
            color: white;
        }
        .lb-footer {
            position: absolute;
            left: 50%;
            bottom: 44px;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            gap: 12px;
            z-index: 2010;
            max-width: min(72vw, 920px);
        }
        .lb-counter {
            color: rgba(255, 255, 255, 0.78);
            font-size: 13px;
            font-variant-numeric: tabular-nums;
            background: rgba(0, 0, 0, 0.42);
            padding: 6px 14px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, 0.12);
            backdrop-filter: blur(10px);
            white-space: nowrap;
        }
        .lb-meta {
            display: flex;
            align-items: center;
            gap: 8px;
            min-width: 0;
            background: rgba(0, 0, 0, 0.34);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 999px;
            padding: 6px 14px;
            backdrop-filter: blur(10px);
            color: rgba(255, 255, 255, 0.9);
        }
        .lb-meta-name {
            max-width: min(34vw, 420px);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 13px;
        }
        .lb-meta-res {
            color: rgba(255, 255, 255, 0.68);
            font-size: 12px;
            white-space: nowrap;
        }

        .lb-actions {
            display: contents;
        }
        .lb-btn {
            appearance: none;
            -webkit-appearance: none;
            cursor: pointer;
            transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
            font: inherit;
            font-size: 13px;
            gap: 6px;
        }
        .lb-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            border-color: rgba(255, 255, 255, 0.28);
            color: #fff;
        }
        .lb-btn:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }
        .lb-btn .svg-icon {
            width: 16px;
            height: 16px;
        }
        .lb-btn:active {
            transform: scale(0.95);
        }
        #align-panel {
            position: absolute;
            top: 48px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(255, 255, 255, 0.95);
            padding: 6px;
            border-radius: 10px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
            z-index: 300;
            display: none;
            gap: 4px;
            backdrop-filter: blur(8px);
            border: 1px solid var(--line);
        }
        .align-btn {
            background: transparent;
            border: none;
            border-radius: 6px;
            padding: 6px 10px;
            color: var(--text-soft);
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .align-btn:hover {
            background: var(--canvas-bg);
            color: var(--text);
        }

        .toggle-wrap {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .toggle-switch {
            position: relative;
            width: 40px;
            height: 22px;
            flex-shrink: 0;
        }
        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        .toggle-slider {
            position: absolute;
            inset: 0;
            background: var(--toggle-bg);
            border-radius: 22px;
            cursor: pointer;
            transition: background 0.2s;
        }
        .toggle-slider::before {
            content: '';
            position: absolute;
            width: 16px;
            height: 16px;
            left: 3px;
            top: 3px;
            background: var(--toggle-knob-bg);
            border-radius: 50%;
            transition: transform 0.2s;
            box-shadow: var(--toggle-knob-shadow);
        }
        .toggle-switch input:checked+.toggle-slider {
            background: var(--toggle-checked-bg);
        }
        .toggle-switch input:checked+.toggle-slider::before {
            transform: translateX(18px);
            background: var(--toggle-checked-knob-bg);
        }
        .toggle-switch input:focus+.toggle-slider {
            box-shadow: var(--toggle-focus-shadow);
        }

        .gd-status-dot {
            display: inline-block;
            width: 7px;
            height: 7px;
            border-radius: 50%;
            margin-right: 4px;
        }
        .gd-status-dot.connected {
            background: var(--success);
        }
        .gd-status-dot.disconnected {
            background: var(--line-strong);
        }
        .gd-btn {
            padding: 7px 14px;
            border-radius: 8px;
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            border: 1px solid var(--line);
            background: var(--surface-strong);
            color: var(--text-soft);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            white-space: nowrap;
            min-height: 32px;
            box-sizing: border-box;
        }
        .gd-btn:hover {
            background: var(--surface-soft);
            border-color: var(--accent-line);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
        }
        .gd-btn.google {
            background: var(--surface-strong);
            border-color: var(--line);
            color: var(--text-soft);
        }
        .gd-btn.google:hover {
            background: var(--surface-soft);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }
        .gd-btn.google svg {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
        }
        /* loading 态：禁止点击 + 转圈 */
        .gd-btn.is-loading {
            cursor: progress;
            pointer-events: none;
            opacity: .82;
        }
        .gd-btn[disabled],
        .gd-btn:disabled {
            cursor: not-allowed;
            pointer-events: none;
            opacity: .55;
        }
        .gd-btn .gd-btn-spinner {
            display: none;
            width: 14px;
            height: 14px;
            border: 2px solid currentColor;
            border-top-color: transparent;
            border-radius: 50%;
            animation: gd-btn-spin .7s linear infinite;
            flex-shrink: 0;
        }
        .gd-btn.is-loading .gd-btn-spinner { display: inline-block; }
        .gd-btn.is-loading > svg { display: none; }
        @keyframes gd-btn-spin {
            to { transform: rotate(360deg); }
        }
        .toggle-sm {
            width: 34px;
            height: 18px;
        }
        .toggle-sm .toggle-slider::before {
            width: 12px;
            height: 12px;
            left: 3px;
            top: 3px;
        }
        .toggle-sm input:checked+.toggle-slider::before {
            transform: translateX(16px);
        }

        .custom-model-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 12px;
            background: var(--canvas-bg);
            border-radius: 6px;
            margin-bottom: 8px;
            font-size: 13px;
        }
        .custom-model-item:last-child {
            margin-bottom: 0;
        }

        /* ================== 缩略导航图 ================== */
        #canvas-navigator {
            position: fixed;
            right: 20px;
            bottom: 20px;
            width: 220px;
            padding: 8px;
            border-radius: var(--navigator-radius);
            background: var(--navigator-bg);
            border: var(--navigator-border);
            box-shadow: var(--navigator-shadow);
            backdrop-filter: var(--navigator-filter);
            z-index: 1050;
            display: none;
            user-select: none;
        }
        #canvas-navigator.show { display: block; }
        .navigator-map {
            position: relative;
            height: 130px;
            border-radius: 10px;
            border: var(--navigator-map-border);
            overflow: hidden;
            cursor: crosshair;
            background: var(--navigator-map-bg);
            background-size: 18px 18px, 18px 18px, auto, auto;
        }
        #canvas-navigator.show { display: block; }
        #canvas-navigator.top { bottom: auto; top: 20px; }
        .navigator-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin-bottom: 8px;
            color: var(--text);
            font-size: 12px;
            font-weight: 700;
        }
        .navigator-hint {
            color: var(--navigator-hint-text);
            font-size: 10px;
            font-weight: 500;
            white-space: nowrap;
        }
        .navigator-map {
            position: relative;
            height: 154px;
            border-radius: 14px;
            border: 1px solid var(--line);
            overflow: hidden;
            cursor: crosshair;
            background: var(--navigator-map-bg);
            background-size: 18px 18px, 18px 18px, auto, auto;
        }
        .navigator-node {
            position: absolute;
            min-width: 3px;
            min-height: 3px;
            border-radius: 4px;
            background: var(--navigator-node-bg);
            border: 1px solid var(--navigator-node-border);
        }
        .navigator-node.nav-ai { background: var(--navigator-node-ai-bg); border-color: var(--navigator-node-ai-border); }
        .navigator-node.nav-preview { background: var(--navigator-node-preview-bg); border-color: var(--navigator-node-preview-border); }
        .navigator-node.nav-image { background: var(--navigator-node-image-bg); border-color: var(--navigator-node-image-border); }
        .navigator-node.nav-chat { background: var(--navigator-node-chat-bg); border-color: var(--navigator-node-chat-border); }
        .navigator-viewport {
            position: absolute;
            border: 2px solid var(--accent);
            border-radius: 8px;
            background: var(--navigator-viewport-bg);
            box-shadow: var(--navigator-viewport-shadow);
            pointer-events: none;
        }

        /* === 非 Dock / 非右上状态栏：取消底部阴影与发光 === */
        #toast,
        .key-badge,
        #canvas-navigator,
        #context-menu,
        #canvas-action-menu,
        #img-context-menu,
        #prompt-ref-tooltip,
        .progress-card,
        .matrix-layout-popover {
            box-shadow: none !important;
        }

        .menu-item:hover,
        .matrix-layout-option:hover {
            box-shadow: none !important;
        }

        /* ================== 全局开灯 / 关灯主题切换 ================== */
        .theme-transition-overlay {
            position: fixed;
            inset: 0;
            z-index: 999999;
            pointer-events: none;
            opacity: 0;
            transform: translateZ(0);
            will-change: opacity, backdrop-filter, background;
        }

        .theme-transition-overlay.to-light {
            background:
                linear-gradient(180deg, rgba(255,255,255,0.76), rgba(255,248,220,0.38) 42%, rgba(255,255,255,0.62)),
                rgba(255,255,255,0.24);
            animation: themeLightOn 520ms var(--ease-out) forwards;
        }

        .theme-transition-overlay.to-dark {
            background:
                linear-gradient(180deg, rgba(0,0,0,0.62), rgba(2,6,23,0.76) 46%, rgba(0,0,0,0.68)),
                rgba(0,0,0,0.34);
            animation: themeLightOff 560ms var(--ease-out) forwards;
        }

        .theme-transition-overlay.to-wechat {
            background:
                radial-gradient(circle at 50% 50%, rgba(21,172,112,0.20), rgba(250,250,250,0.72) 42%, rgba(238,238,240,0.88)),
                rgba(255,255,255,0.24);
            animation: themeWechatOn 540ms var(--ease-out) forwards;
        }

        @keyframes themeLightOn {
            0% {
                opacity: 0;
                backdrop-filter: brightness(1) blur(0px);
            }
            35% {
                opacity: 0.88;
                backdrop-filter: brightness(1.18) blur(1px);
            }
            68% {
                opacity: 0.46;
                backdrop-filter: brightness(1.08) blur(0.5px);
            }
            100% {
                opacity: 0;
                backdrop-filter: brightness(1) blur(0px);
            }
        }

        @keyframes themeLightOff {
            0% {
                opacity: 0;
                backdrop-filter: brightness(1) blur(0px);
            }
            42% {
                opacity: 0.74;
                backdrop-filter: brightness(0.72) blur(1px);
            }
            72% {
                opacity: 0.36;
                backdrop-filter: brightness(0.88) blur(0.5px);
            }
            100% {
                opacity: 0;
                backdrop-filter: brightness(1) blur(0px);
            }
        }

        @keyframes themeWechatOn {
            0% {
                opacity: 0;
                backdrop-filter: brightness(1) saturate(1) blur(0px);
            }
            38% {
                opacity: 0.82;
                backdrop-filter: brightness(1.08) saturate(1.04) blur(1px);
            }
            70% {
                opacity: 0.44;
                backdrop-filter: brightness(1.02) saturate(1.02) blur(0.5px);
            }
            100% {
                opacity: 0;
                backdrop-filter: brightness(1) saturate(1) blur(0px);
            }
        }

        @media (prefers-reduced-motion: reduce) {
            .theme-transition-overlay {
                animation: none !important;
                display: none !important;
            }
        }
