:root {
    --bg: #03050a;
    --surface: #131924;
    --surface-hover: #202a38;
    --border: rgba(148, 175, 219, 0.26);
    --text-main: #edf3ff;
    --text-sub: #91a4c7;
    --accent: #5e9cff;
    --success: #3fd47a;
    --danger: #ff5e59;
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --bg-grid-dot: rgba(183, 210, 255, 0.14);
    --chrome-bg: rgba(12, 18, 29, 0.8);
    --chrome-bg-strong: rgba(10, 16, 27, 0.94);
    --chrome-border: rgba(168, 194, 234, 0.16);
    --topbar-gradient-start: rgba(8, 13, 22, 0.88);
    --topbar-gradient-end: rgba(8, 13, 22, 0.02);
    --btn-text: #fff;
    --input-muted-bg: rgba(6, 10, 18, 0.42);
    --color-scheme: dark;
    --hero-ring: rgba(94, 156, 255, 0.22);
    --panel-shadow: 0 22px 44px rgba(6, 10, 18, 0.48);
    --route-fx-bg: rgba(6, 10, 18, 0.88);
    --route-fx-ring: rgba(147, 197, 255, 0.42);
    --route-fx-ring-soft: rgba(147, 197, 255, 0.22);
    --route-fx-ring-faint: rgba(147, 197, 255, 0.12);
    --route-fx-text: #c7d9f5;
}

:root[data-theme='light'] {
    --bg: #f1f3f7;
    --surface: #f7f9fc;
    --surface-hover: #eef2f7;
    --border: rgba(28, 41, 66, 0.14);
    --text-main: #171d2c;
    --text-sub: #5f6c83;
    --accent: #2b63d8;
    --success: #2c8f52;
    --danger: #c93d34;
    --bg-grid-dot: rgba(27, 45, 82, 0.055);
    --chrome-bg: rgba(247, 250, 255, 0.78);
    --chrome-bg-strong: rgba(247, 250, 255, 0.92);
    --chrome-border: rgba(28, 41, 66, 0.12);
    --topbar-gradient-start: rgba(239, 244, 252, 0.9);
    --topbar-gradient-end: rgba(239, 244, 252, 0.12);
    --btn-text: #142033;
    --input-muted-bg: rgba(34, 58, 99, 0.045);
    --color-scheme: light;
    --hero-ring: rgba(43, 99, 216, 0.12);
    --panel-shadow: 0 14px 32px rgba(24, 38, 64, 0.1);
    --route-fx-bg: rgba(233, 239, 249, 0.84);
    --route-fx-ring: rgba(43, 99, 216, 0.26);
    --route-fx-ring-soft: rgba(43, 99, 216, 0.14);
    --route-fx-ring-faint: rgba(43, 99, 216, 0.08);
    --route-fx-text: #42597f;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Google Sans', -apple-system, sans-serif; user-select: none; }

body { 
    background-color: var(--bg); color: var(--text-main); height: 100vh; overflow: hidden; color-scheme: var(--color-scheme);
    background-image: radial-gradient(var(--bg-grid-dot) 1px, transparent 1px);
    background-size: 30px 30px; background-position: 0 0;
}

:root[data-theme='light'] .top-btn { background: rgba(24, 40, 68, 0.04); border-color: rgba(24, 40, 68, 0.14); }
:root[data-theme='light'] .top-btn:hover { background: rgba(24, 40, 68, 0.08); }
:root[data-theme='light'] .draggable-tool,
:root[data-theme='light'] .gen-item,
:root[data-theme='light'] .img-gen-select,
:root[data-theme='light'] .img-gen-prompt,
:root[data-theme='light'] .cropper-workspace,
:root[data-theme='light'] .help-close,
:root[data-theme='light'] .material-item,
:root[data-theme='light'] .action-pill,
:root[data-theme='light'] .mode-tabs,
:root[data-theme='light'] .prompt-container {
    border-color: rgba(15, 23, 42, 0.14);
}
:root[data-theme='light'] .draggable-tool,
:root[data-theme='light'] .gen-item,
:root[data-theme='light'] .action-pill,
:root[data-theme='light'] .mode-tabs,
:root[data-theme='light'] .img-slot,
:root[data-theme='light'] .img-gen-slot { background: rgba(24, 40, 68, 0.03); }
:root[data-theme='light'] .draggable-tool:hover,
:root[data-theme='light'] .mode-tab.active,
:root[data-theme='light'] .action-pill:hover { background: rgba(24, 40, 68, 0.08); }
:root[data-theme='light'] .canvas-selection-toolbar {
    background: rgba(255,255,255,0.92);
    border-color: rgba(43,99,216,0.16);
    box-shadow: 0 18px 38px rgba(61,83,123,0.16), inset 0 0 0 1px rgba(255,255,255,0.72);
}
:root[data-theme='light'] .canvas-selection-toolbar button {
    background: rgba(43,99,216,0.055);
}
:root[data-theme='light'] .selection-marquee.is-window {
    background: rgba(43,99,216,0.12);
}
:root[data-theme='light'] .selection-marquee.is-crossing {
    background: rgba(41,188,103,0.11);
}
:root[data-theme='light'] .card-header,
:root[data-theme='light'] .local-image-card .card-header,
:root[data-theme='light'] .gen-actions { border-bottom-color: rgba(15, 23, 42, 0.08); border-top-color: rgba(15, 23, 42, 0.08); }
:root[data-theme='light'] .card-prompt img,
:root[data-theme='light'] .card-media,
:root[data-theme='light'] .img-slot.has-img img,
:root[data-theme='light'] .global-tooltip,
:root[data-theme='light'] .help-content,
:root[data-theme='light'] .veo-toast { border-color: rgba(15, 23, 42, 0.14); }
:root[data-theme='light'] .video-card,
:root[data-theme='light'] .floating-console,
:root[data-theme='light'] .tool-drawer,
:root[data-theme='light'] .tool-generator,
:root[data-theme='light'] .tool-image-gen,
:root[data-theme='light'] .tool-cropper,
:root[data-theme='light'] .material-drawer,
:root[data-theme='light'] .ref-popover,
:root[data-theme='light'] .help-content,
:root[data-theme='light'] .sys-modal-content,
:root[data-theme='light'] .minimap-container {
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
}
:root[data-theme='light'] .video-card,
:root[data-theme='light'] .floating-console,
:root[data-theme='light'] .tool-drawer,
:root[data-theme='light'] .tool-generator,
:root[data-theme='light'] .tool-image-gen,
:root[data-theme='light'] .tool-cropper,
:root[data-theme='light'] .material-drawer,
:root[data-theme='light'] .ref-popover,
:root[data-theme='light'] .help-content,
:root[data-theme='light'] .sys-modal-content,
:root[data-theme='light'] .minimap-container {
    background: var(--chrome-bg-strong) !important;
    border-color: var(--border) !important;
}
:root[data-theme='light'] .prompt-container,
:root[data-theme='light'] .mode-tabs,
:root[data-theme='light'] .action-pill,
:root[data-theme='light'] .img-slot,
:root[data-theme='light'] .img-gen-slot,
:root[data-theme='light'] .gen-item,
:root[data-theme='light'] .draggable-tool,
:root[data-theme='light'] .frame-box,
:root[data-theme='light'] .material-item {
    background: rgba(246, 249, 255, 0.72) !important;
    border-color: rgba(25, 39, 64, 0.12) !important;
}
:root[data-theme='light'] .card-header,
:root[data-theme='light'] .local-image-card .card-header,
:root[data-theme='light'] .help-content h2,
:root[data-theme='light'] .drawer-title,
:root[data-theme='light'] .palette-group-title,
:root[data-theme='light'] .node-input-label,
:root[data-theme='light'] .card-tag,
:root[data-theme='light'] .status-badge,
:root[data-theme='light'] .prompt-input,
:root[data-theme='light'] .card-prompt p,
:root[data-theme='light'] .help-section li,
:root[data-theme='light'] .frame-title-input,
:root[data-theme='light'] .frame-btn,
:root[data-theme='light'] .top-bar,
:root[data-theme='light'] .logo,
:root[data-theme='light'] .global-tooltip,
:root[data-theme='light'] .veo-toast {
    color: var(--text-main) !important;
}
:root[data-theme='light'] .card-prompt img,
:root[data-theme='light'] .img-slot.has-img img,
:root[data-theme='light'] .img-gen-slot img,
:root[data-theme='light'] .popover-img-item,
:root[data-theme='light'] .cropper-workspace,
:root[data-theme='light'] .material-item,
:root[data-theme='light'] .minimap-container {
    box-shadow: none;
}
:root[data-theme='light'] .help-close:hover { color: var(--text-main); background: rgba(15, 23, 42, 0.08); }
:root[data-theme='light'] .logo { text-shadow: none; }
:root[data-theme='light'] .global-tooltip::after { border-color: rgba(15, 23, 42, 0.14) transparent transparent transparent; }
:root[data-theme='light'] .global-tooltip.tooltip-bottom::after { border-color: transparent transparent rgba(15, 23, 42, 0.14) transparent; }
:root[data-theme='light'] .card-tag,
:root[data-theme='light'] .status-badge {
    background: rgba(24, 40, 68, 0.06) !important;
}
:root[data-theme='light'] .status-badge.success {
    background: rgba(31, 157, 70, 0.12) !important;
}
:root[data-theme='light'] .status-badge.failed {
    background: rgba(217, 48, 37, 0.12) !important;
}
:root[data-theme='light'] .status-badge.processing {
    background: rgba(10, 132, 255, 0.12) !important;
}
:root[data-theme='light'] .card-tag {
    color: var(--text-sub) !important;
}
:root[data-theme='light'] .palette-item {
    background: rgba(255, 255, 255, 0.88) !important;
    border-color: rgba(15, 23, 42, 0.12) !important;
    color: var(--text-main) !important;
}
:root[data-theme='light'] .palette-item:hover {
    background: rgba(15, 23, 42, 0.1) !important;
}
:root[data-theme='light'] .top-bar { background: linear-gradient(180deg, rgba(241, 246, 253, 0.9) 0%, rgba(241, 246, 253, 0) 100%); }
:root[data-theme='light'] .video-card,
:root[data-theme='light'] .card-prompt img,
:root[data-theme='light'] .card-tags,
:root[data-theme='light'] .card-tag,
:root[data-theme='light'] .status-badge,
:root[data-theme='light'] .ref-popover,
:root[data-theme='light'] .help-content,
:root[data-theme='light'] .sys-modal-content,
:root[data-theme='light'] .floating-console,
:root[data-theme='light'] .tool-drawer,
:root[data-theme='light'] .tool-generator,
:root[data-theme='light'] .tool-image-gen,
:root[data-theme='light'] .tool-cropper,
:root[data-theme='light'] .material-drawer,
:root[data-theme='light'] .minimap-container {
    backdrop-filter: blur(14px) saturate(106%);
}
:root[data-theme='light'] #bill-video-count,
:root[data-theme='light'] #bill-image-count,
:root[data-theme='light'] #top-bill-text {
    color: var(--text-main) !important;
}
:root[data-theme='light'] #error-modal-content {
    background: var(--chrome-bg-strong) !important;
    border-color: rgba(255, 69, 58, 0.2) !important;
}
:root[data-theme='light'] #error-modal-content .error-text,
:root[data-theme='light'] #error-modal-content h2,
:root[data-theme='light'] #error-modal-content p {
    color: var(--text-main) !important;
}

/* 首页 / 登录层保持默认深色，不跟随日间主题泛白 */
:root[data-theme='light'] .login-gate {
    background:
        radial-gradient(circle at 22% 4%, rgba(94, 156, 255, 0.18) 0%, transparent 42%),
        radial-gradient(circle at 78% 24%, rgba(94, 156, 255, 0.14) 0%, transparent 40%),
        linear-gradient(180deg, #04070e 0%, #060a12 50%, #020307 100%) !important;
}
:root[data-theme='light'] .login-gate::before {
    background:
        radial-gradient(560px circle at center, rgba(255,255,255,0.06) 0%, rgba(5, 8, 16, 0.78) 70%, rgba(3, 5, 10, 0.9) 100%) !important;
}

.top-bar { position: fixed; top: 0; left: 0; width: 100%; padding: 20px 32px; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(180deg, var(--topbar-gradient-start) 0%, var(--topbar-gradient-end) 100%); z-index: 1000; pointer-events: none; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; text-shadow: 0 2px 10px rgba(0,0,0,0.5); pointer-events: auto; }
.top-actions { display: flex; gap: 12px; pointer-events: auto; }
.top-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: var(--btn-text); padding: 8px 14px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 6px; backdrop-filter: blur(10px); transition: all 0.2s; font-size: 13px; }
.top-btn:hover { background: rgba(255,255,255,0.2); transform: translateY(-1px); }
/* 🌟 新增：次要操作转为极简纯图标圆形按钮 */
.top-btn.icon-only { padding: 8px; border-radius: 50%; width: 34px; height: 34px; justify-content: center; }
.top-btn.icon-only span { font-size: 18px; margin: 0; }

.tool-drawer { position: fixed; left: -320px; top: 0; width: 300px; height: 100vh; background: var(--chrome-bg); backdrop-filter: blur(25px); border-right: 1px solid var(--border); z-index: 900; transition: left 0.4s cubic-bezier(0.16, 1, 0.3, 1); padding: 80px 20px 20px 20px; display: flex; flex-direction: column; gap: 16px; box-shadow: 10px 0 30px rgba(0,0,0,0.5); }
.tool-drawer.open { left: 0; }
.drawer-title { font-size: 14px; font-weight: 600; color: var(--text-sub); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.draggable-tool { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); padding: 12px; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 12px; cursor: grab; transition: all 0.2s; }
.draggable-tool:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); transform: translateY(-2px); }
.draggable-tool:active { cursor: grabbing; }

.canvas-viewport {
    position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1; cursor: grab;
    touch-action: none; overscroll-behavior: none;
}
.canvas-viewport:active,
.canvas-viewport.is-panning { cursor: grabbing; }
.canvas-board {
    position: absolute; top: 0; left: 0; width: 1px; height: 1px; transform-origin: 0 0;
    will-change: transform; backface-visibility: hidden; contain: layout style;
}

.video-card { 
    position: absolute; left: 0; top: 0; 
    width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); cursor: default; 
    content-visibility: auto; contain-intrinsic-size: 340px 400px;
}
.canvas-board.is-moving .video-card,
.canvas-board.is-moving .frame-box { will-change: transform; }
.canvas-board.is-moving .video-card:not(.selected),
.canvas-board.is-moving .frame-box:not(.selected) {
    box-shadow: 0 8px 22px rgba(0,0,0,0.34);
}
.canvas-board.is-moving .video-card > *,
.canvas-board.is-moving .frame-box > * {
    pointer-events: none;
}
.canvas-board > .video-card.is-viewport-culled,
.canvas-board > .frame-box.is-viewport-culled {
    visibility: hidden;
    content-visibility: hidden;
    pointer-events: none !important;
    contain-intrinsic-size: var(--culled-width, 340px) var(--culled-height, 400px);
}

.card-header { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-sub); cursor: grab; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.card-header:active { cursor: grabbing; }
.card-header .time-model { display: flex; align-items: center; gap: 6px; pointer-events: none; }

.status-badge { padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; background: #2c2c2e; color: var(--text-main); }
.status-badge.success { background: rgba(50, 215, 75, 0.15); color: var(--success); }
.status-badge.failed { background: rgba(255, 69, 58, 0.15); color: var(--danger); }
.status-badge.processing { background: rgba(10, 132, 255, 0.15); color: var(--accent); }

.video-card[data-sync-status="processing"]::after,
.video-card.is-flow-running::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    pointer-events: none;
    padding: 1px;
    background: conic-gradient(from 0deg, transparent, rgba(10,132,255,0.1), var(--accent), rgba(10,132,255,0.1), transparent 38%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: runningBorderSpin 2.6s linear infinite;
}
.video-card.is-auto-retrying::after {
    background: conic-gradient(from 0deg, transparent, rgba(245,158,11,0.12), #f59e0b, rgba(245,158,11,0.12), transparent 42%);
    animation-duration: 1.4s;
}
@keyframes runningBorderSpin { to { transform: rotate(360deg); } }

.card-prompt { display: flex; gap: 8px; align-items: flex-start; }
.card-prompt img { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; background: #2c2c2e; flex-shrink: 0; cursor: pointer; border: 1px solid rgba(255,255,255,0.1); }
.card-prompt p { font-size: 13px; line-height: 1.4; color: var(--text-main); user-select: text; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.card-tags { display: flex; gap: 6px; flex-wrap: wrap;}
.card-tag { background: #2c2c2e; padding: 2px 6px; border-radius: 4px; font-size: 11px; color: var(--text-sub); }

.card-media { width: 100%; background: var(--surface-hover); border-radius: var(--radius-sm); overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,0.05); min-height: 120px; }
.card-media img, .card-media video { width: 100%; height: auto; display: block; max-height: 500px; object-fit: contain; }

.sticky-note { resize: both; overflow: hidden; min-width: 200px; min-height: 140px; background: rgba(255, 213, 79, 0.1); border: 1px solid rgba(255, 213, 79, 0.3); padding: 0; box-shadow: 0 10px 30px rgba(255, 213, 79, 0.05); }
.sticky-note .card-header { background: rgba(255, 213, 79, 0.15); padding: 10px 12px; border-bottom: none; border-radius: var(--radius-md) var(--radius-md) 0 0; }
.sticky-note textarea { width: 100%; height: calc(100% - 42px); background: transparent; border: none; color: var(--text-main); font-size: 14px; line-height: 1.6; resize: none; outline: none; padding: 0 12px 12px 12px; user-select: text; }

.tool-generator { width: 380px; background: var(--chrome-bg-strong); border: 1px solid var(--border); box-shadow: 0 20px 40px rgba(0,0,0,0.8); }
.tool-generator .gen-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 12px; }
.gen-item { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.gen-item label { font-size: 11px; color: var(--text-sub); display: flex; align-items: center; gap: 4px; }
.gen-item select { width: 100%; background: transparent; border: none; color: var(--text-main); font-size: 14px; font-weight: 500; outline: none; cursor: pointer; appearance: none; }
.gen-item select option { background: var(--surface); color: var(--text-main); }
.gen-actions { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgba(255,255,255,0.05); margin-top: 8px; }
.gen-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; }
.gen-btn.shuffle { background: linear-gradient(135deg, #4f46e5, #9333ea); color: white; }
.gen-btn.shuffle:hover { filter: brightness(1.1); }
.gen-btn.copy { background: rgba(255,255,255,0.1); color: var(--text-main); }
.gen-btn.copy:hover { background: rgba(255,255,255,0.15); }

.local-image-card { width: 220px !important; padding: 8px !important; background: var(--chrome-bg-strong) !important; box-shadow: 0 4px 20px rgba(0,0,0,0.8) !important; }
.local-image-card .card-header { padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,0.05); }

.generating-text { font-size: 13px; font-weight: 500; letter-spacing: 1px; margin-top: 12px; animation: pulseText 1.5s infinite; color: var(--accent); }
@keyframes pulseText { 0% {opacity:0.5;} 50% {opacity:1;} 100% {opacity:0.5;} }

.card-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; border-top: 1px solid var(--border); }
.card-actions button { background: transparent; border: none; color: var(--text-sub); cursor: pointer; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 4px; transition: all 0.2s; }
.card-actions button:hover { background: var(--surface-hover); color: var(--text-main); }
.card-actions button.reuse-btn:hover { color: var(--accent); background: rgba(10, 132, 255, 0.1); }
.card-actions button.retry-btn:hover { color: var(--success); background: rgba(50, 215, 75, 0.1); }
.card-actions button:disabled { opacity: 0.5; cursor: not-allowed; }

.floating-console { position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 940px; background: rgba(28, 28, 30, 0.85); backdrop-filter: blur(25px); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-lg); padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.8); z-index: 100; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); transform-origin: bottom center; }
.floating-console.minimized { transform: translateX(-50%) scale(0.6) translateY(20px); opacity: 0.5; cursor: pointer; }
.floating-console.minimized:hover { opacity: 0.95; transform: translateX(-50%) scale(0.65) translateY(10px); }
.floating-console.minimized .prompt-container { display: none; }
.floating-console.minimized * { pointer-events: none; }

.console-headline { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 2px; }
.console-headline > div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.console-eyebrow { font-family: monospace; font-size: 10px; letter-spacing: 1.4px; color: var(--text-sub); opacity: 0.72; }
.console-headline strong { font-size: 13px; color: var(--text-main); font-weight: 700; white-space: nowrap; }
.console-advanced-toggle {
    border: 1px solid var(--border); background: rgba(255,255,255,0.04); color: var(--text-sub);
    border-radius: 999px; padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; cursor: pointer; transition: 0.22s ease;
}
.console-advanced-toggle:hover,
.console-advanced-toggle.is-open { color: var(--text-main); border-color: rgba(10,132,255,0.45); background: rgba(10,132,255,0.12); }
.console-advanced-toggle .material-symbols-outlined { font-size: 15px; transition: transform 0.24s ease; }
.console-advanced-toggle.is-open .material-symbols-outlined { transform: rotate(90deg); }

.prompt-container { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.mode-tabs { display: flex; background: rgba(255, 255, 255, 0.05); border-radius: 100px; padding: 4px; width: fit-content; }
.mode-tab { padding: 6px 14px; border-radius: 100px; font-size: 13px; color: var(--text-sub); cursor: pointer; display: flex; align-items: center; gap: 6px; transition: all 0.2s; }
.mode-tab.active { background: rgba(255, 255, 255, 0.1); color: var(--text-main); }
.input-wrapper { display: flex; gap: 16px; align-items: flex-start; }
.slot-group { display: none; gap: 8px; align-items: center; flex-shrink: 0; position: relative; }
.slot-group.active { display: flex; }
.img-slot { width: 56px; height: 72px; border: 1px dashed #666; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; position: relative; background: rgba(255,255,255,0.02); transition: all 0.2s; overflow: hidden; }
.img-slot:hover, .img-slot.drag-over { border-color: var(--accent); background: rgba(10, 132, 255, 0.1); }
.img-slot.slot-just-filled { animation: slotPulseIn 0.62s cubic-bezier(0.16, 1, 0.3, 1); }
.img-slot span { font-size: 11px; color: var(--text-sub); margin-top: 4px; pointer-events: none; }
.img-slot.has-img { border: none; background: transparent; }
.img-slot img { width: 100%; height: 100%; object-fit: cover; position: absolute; top:0; left:0; z-index: 1; display: none; border-radius: 8px;}
.img-slot.has-img img { display: block; border: 1px solid var(--border); }
.count-badge { position: absolute; bottom: -6px; right: -6px; background: white; color: black; border-radius: 50%; width: 20px; height: 20px; display: none; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; z-index: 10; }
.remove-badge { position: absolute; top: -6px; right: -6px; background: rgba(0,0,0,0.8); border: 1px solid #444; border-radius: 50%; width: 20px; height: 20px; display: none; align-items: center; justify-content: center; font-size: 12px; z-index: 10; cursor: pointer; color: white; }
.img-slot.has-img .remove-badge { display: flex; }
.hidden-input { display: none; }

.ref-popover { position: absolute; bottom: calc(100% + 12px); left: 0; background: rgba(30, 30, 32, 0.95); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; display: flex; gap: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.8); z-index: 200; backdrop-filter: blur(20px); transform-origin: bottom left; }
.ref-list { display: flex; gap: 8px; }
.popover-img-item { width: 72px; height: 96px; border-radius: 8px; position: relative; overflow: hidden; border: 1px solid var(--border); }
.popover-img-item img { width: 100%; height: 100%; object-fit: cover; }
.popover-rm-btn { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.7); color: white; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10; }
.ref-add-btn { width: 72px; height: 96px; border-radius: 8px; border: 1px dashed var(--text-sub); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-sub); }

.prompt-input { flex: 1; background: transparent; border: none; color: var(--text-main); font-size: 14px; resize: none; height: 72px; line-height: 1.5; outline: none; user-select: text; }

.frame-timeline-widget {
    display: grid; grid-template-columns: 68px minmax(94px, 136px) 68px; align-items: center; gap: 8px;
    padding: 7px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(135deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
}
.frame-slot { width: 68px; height: 82px; border-radius: 12px; }
.frame-slot-kicker {
    position: absolute; top: 5px; left: 6px; z-index: 3;
    font-family: monospace; font-size: 8px !important; letter-spacing: 0.8px;
    color: rgba(255,255,255,0.72) !important; margin: 0 !important;
}
.frame-timeline-rail { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 0; }
.frame-timeline-rail .material-symbols-outlined { font-size: 17px; color: var(--accent); filter: drop-shadow(0 0 10px rgba(10,132,255,0.35)); }
.frame-rail-line { width: 100%; height: 2px; border-radius: 999px; background: rgba(255,255,255,0.12); overflow: hidden; position: relative; }
.frame-rail-line i {
    position: absolute; inset: 0; display: block;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: timelineFlow 2.2s linear infinite;
}
.frame-timeline-rail small {
    max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 9px; color: var(--text-sub); font-family: monospace; letter-spacing: 0.4px;
}
@keyframes timelineFlow { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.console-actions-row { display: flex; justify-content: space-between; align-items: center; padding-top: 0; gap: 12px;}
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.console-primary-pills { flex: 1; }
.action-pill { position: relative; background: rgba(255,255,255,0.08); border: 1px solid transparent; padding: 6px 12px; border-radius: 100px; font-size: 12px; color: var(--text-main); display: flex; align-items: center; gap: 4px; cursor: pointer; transition: all 0.2s; }
.action-pill:hover { background: rgba(255,255,255,0.15); }
.action-pill select { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.console-advanced-panel {
    border-top: 1px solid rgba(255,255,255,0.08); padding-top: 10px;
    max-height: 92px; opacity: 1; overflow: visible;
    transition: max-height 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease, padding 0.22s ease;
}
.console-advanced-panel.is-collapsed { max-height: 0; opacity: 0; padding-top: 0; overflow: hidden; border-top-color: transparent; pointer-events: none; }
.console-advanced-panel .pill-group { justify-content: flex-start; }

.submit-btn { background: var(--text-main); color: var(--bg); border: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.submit-btn:hover:not(:disabled) { transform: scale(1.05); }
.submit-btn:disabled { background: var(--border); cursor: not-allowed; }
.spinner { width: 20px; height: 20px; animation: rotate 2s linear infinite; }
.spinner circle { stroke: currentColor; stroke-width: 3; stroke-dasharray: 1, 200; stroke-dashoffset: 0; animation: dash 1.5s ease-in-out infinite; stroke-linecap: round; fill: none; }
@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash { 0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; } 50% { stroke-dasharray: 90, 200; stroke-dashoffset: -35px; } 100% { stroke-dasharray: 90, 200; stroke-dashoffset: -124px; } }
@keyframes slotPulseIn {
    0% { transform: scale(0.94); box-shadow: 0 0 0 rgba(10,132,255,0); }
    45% { transform: scale(1.04); box-shadow: 0 0 28px rgba(10,132,255,0.38); }
    100% { transform: scale(1); box-shadow: 0 0 0 rgba(10,132,255,0); }
}

body.space-pan-ready,
body.space-pan-ready .canvas-viewport,
body.space-pan-ready .video-card { cursor: grab !important; }
body.canvas-camera-active.space-pan-ready,
body.canvas-camera-active.space-pan-ready .canvas-viewport { cursor: grabbing !important; }

.canvas-card-context-menu {
    position: fixed; z-index: 2000; width: 218px;
    padding: 7px; border-radius: 14px; border: 1px solid var(--border);
    background: rgba(24,24,28,0.94); backdrop-filter: blur(22px);
    box-shadow: 0 18px 48px rgba(0,0,0,0.55);
    animation: contextPop 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.canvas-card-context-menu button {
    width: 100%; border: 0; background: transparent; color: var(--text-main);
    display: flex; align-items: center; gap: 9px; padding: 9px 10px;
    border-radius: 10px; cursor: pointer; text-align: left; font-size: 12px;
    transition: background 0.18s ease, transform 0.18s ease;
}
.canvas-card-context-menu button:hover { background: rgba(255,255,255,0.08); transform: translateX(2px); }
.canvas-card-context-menu button.danger { color: var(--danger); }
.canvas-card-context-menu .material-symbols-outlined { font-size: 16px; }
.context-menu-divider { height: 1px; background: var(--border); margin: 6px 4px; opacity: 0.8; }
@keyframes contextPop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }

/* 🎨 AI 生图工具专属样式 */
.tool-image-gen { width: 340px; background: var(--chrome-bg-strong); border: 1px solid var(--border); box-shadow: 0 20px 40px rgba(0,0,0,0.8); display: flex; flex-direction: column; gap: 12px; }
.img-gen-slots { display: flex; gap: 6px; padding: 0 12px; flex-wrap: wrap; }
.img-gen-slot { width: 52px; height: 52px; border: 1px dashed rgba(255,255,255,0.2); border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; transition: all 0.2s; overflow: hidden; background: rgba(255,255,255,0.02); }
.img-gen-slot:hover, .img-gen-slot.drag-over { border-color: var(--accent); background: rgba(10, 132, 255, 0.1); }
.img-gen-slot img { width: 100%; height: 100%; object-fit: cover; }
.img-gen-slot .remove-badge { position: absolute; top: -4px; right: -4px; width: 16px; height: 16px; font-size: 10px; }

.img-gen-controls { display: flex; gap: 8px; padding: 0 12px; flex-wrap: wrap; }
.img-gen-select { flex: 1; min-width: 80px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); color: var(--text-main); font-size: 11px; padding: 6px; border-radius: 6px; outline: none; }
.img-gen-select option { background: var(--surface); }

/* 🌟 增强版提示词框：支持垂直拖拽缩放、设定了极限高度、顺手加了聚焦高亮 */
.img-gen-prompt { 
    margin: 0 12px; background: var(--input-muted-bg); border: 1px solid rgba(255,255,255,0.1); 
    border-radius: 8px; padding: 8px; min-height: 60px; max-height: 400px; color: var(--text-main); 
    font-size: 13px; resize: vertical; outline: none; transition: border-color 0.2s ease;
}
.img-gen-prompt:focus { border-color: var(--accent); background: var(--input-muted-bg); }
.img-gen-btn { margin: 0 12px 12px 12px; background: var(--accent); color: #fff; border: none; padding: 10px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; justify-content: center; align-items: center; gap: 6px; }
.img-gen-btn:hover:not(:disabled) { filter: brightness(1.1); }
.img-gen-btn:disabled { background: var(--border); color: var(--text-sub); cursor: not-allowed; }

.img-gen-result { width: 100%; min-height: 120px; background: var(--surface-hover); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.img-gen-result img { width: 100%; height: auto; display: block; object-fit: contain; max-height: 400px; cursor: grab; }

/* ✂️ 图片裁切器专属样式 */
.tool-cropper { width: 340px; background: var(--chrome-bg-strong); border: 1px solid var(--border); box-shadow: 0 20px 40px rgba(0,0,0,0.8); display: flex; flex-direction: column; gap: 12px; }
.cropper-workspace { position: relative; width: 100%; border-radius: 8px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1); user-select: none; touch-action: none; background: var(--surface-hover); display: flex; align-items: center; justify-content: center; }
.cropper-workspace img { width: 100%; height: auto; display: block; pointer-events: none; }
.crop-box { position: absolute; border: 1px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,0.6); cursor: move; z-index: 10; touch-action: none; display: flex; align-items: center; justify-content: center; }
.crop-grid { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; pointer-events: none; }
.crop-grid div { border-right: 1px solid rgba(255,255,255,0.3); border-bottom: 1px solid rgba(255,255,255,0.3); }
.crop-grid div:nth-child(3n) { border-right: none; }
.crop-grid div:nth-child(n+7) { border-bottom: none; }
.crop-handle { position: absolute; background: #fff; border: 1px solid #333; border-radius: 50%; width: 12px; height: 12px; z-index: 11; touch-action: none; }
.ch-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.ch-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.ch-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.ch-se { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* ============================== */
/* 🔍 全局图片放大查看器 (Lightbox) */
/* ============================== */
.image-lightbox {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(15px);
    z-index: 9999; display: none; align-items: center; justify-content: center;
    cursor: zoom-out; opacity: 0; transition: opacity 0.2s ease;
}
.image-lightbox.show { display: flex; opacity: 1; }
.image-lightbox img {
    max-width: 90vw; max-height: 90vh; object-fit: contain;
    border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    transform: scale(0.95); transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.image-lightbox.show img { transform: scale(1); }

/* ============================== */
/* 🍞 全局 Toast 消息提示系统 */
/* ============================== */
#toast-container {
    position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 10px; z-index: 10000;
    pointer-events: none;
}
.veo-toast {
    background: var(--chrome-bg-strong); backdrop-filter: blur(16px);
    border: 1px solid var(--border); border-radius: 100px;
    padding: 10px 20px; font-size: 13px; font-weight: 500;
    color: var(--text-main); display: flex; align-items: center; gap: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: toastSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
}
.veo-toast.toast-error { border-color: rgba(255, 69, 58, 0.3); }
.veo-toast.toast-error span.icon { color: var(--danger); }
.veo-toast.toast-success { border-color: rgba(50, 215, 75, 0.3); }
.veo-toast.toast-success span.icon { color: var(--success); }
.veo-toast.toast-info span.icon { color: var(--accent); }
.veo-toast.fade-out { animation: toastFadeOut 0.3s ease forwards; }

@keyframes toastSlideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastFadeOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-10px); opacity: 0; } }

/* ============================== */
/* 💡 全局智能悬浮提示引擎 (Smart Tooltip) */
/* ============================== */
.global-tooltip {
    position: fixed; background: var(--chrome-bg-strong); color: var(--text-main); padding: 8px 14px;
    border-radius: 8px; font-size: 12px; font-weight: 500; pointer-events: none; z-index: 10000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8); border: 1px solid rgba(255,255,255,0.1);
    opacity: 0; transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); 
    white-space: nowrap; backdrop-filter: blur(10px);
    transform: translate(-50%, calc(-100% - 10px)); 
}
.global-tooltip.show { opacity: 1; }
.global-tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border-width: 6px; border-style: solid; border-color: rgba(255,255,255,0.1) transparent transparent transparent; }
.global-tooltip.tooltip-bottom { transform: translate(-50%, 10px);  }
.global-tooltip.tooltip-bottom::after { top: -12px; border-color: transparent transparent rgba(255,255,255,0.1) transparent; }

/* ============================== */
/* 📖 使用教程沉浸弹窗 (Help Modal) */
/* ============================== */
.help-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px); z-index: 9999; display: none; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s ease;
}
.help-modal.show { display: flex; opacity: 1; }
.help-content {
    background: var(--chrome-bg); border: 1px solid rgba(255,255,255,0.1); width: 640px; max-width: 90vw;
    border-radius: 20px; padding: 32px; box-shadow: 0 30px 80px rgba(0,0,0,0.8); position: relative;
    transform: translateY(20px) scale(0.98); transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.help-modal.show .help-content { transform: translateY(0) scale(1); }
.help-close { position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.05); border: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-sub); font-size: 20px; cursor: pointer; transition: all 0.2s; }
.help-close:hover { background: rgba(255,255,255,0.1); color: #fff; transform: scale(1.1); }
.help-content h2 { margin-bottom: 28px; font-size: 22px; display: flex; align-items: center; gap: 8px; color: var(--text-main); font-weight: 600; }
.help-section { margin-bottom: 24px; }
.help-section:last-child { margin-bottom: 0; }
.help-section h3 { font-size: 14px; color: var(--accent); margin-bottom: 12px; font-weight: 600; display: inline-block; padding-bottom: 4px; border-bottom: 2px solid rgba(10, 132, 255, 0.3); }
.help-section ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.help-section li { font-size: 13px; color: var(--text-main); line-height: 1.6; position: relative; padding-left: 16px; }
.help-section li::before { content: '✦'; position: absolute; left: 0; top: -1px; color: rgba(255,255,255,0.3); font-size: 14px;}
/* ============================== */
/* 🖱️ 多选与框选引擎样式 */
/* ============================== */

/* 被选中的卡片高亮描边 */
.video-card.selected,
.frame-box.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent), 0 20px 50px rgba(0,0,0,0.8);
    scale: 1.01;
    /* 🌟 核心修复：彻底删除了 transform 0.2s 的动画过渡，释放 JS 拖拽的绝对控制权 */
    transition: box-shadow 0.2s, border-color 0.2s, scale 0.18s ease;
}
/* 拖拽时的半透明蓝色选择框 */
.selection-marquee {
    position: absolute;
    background: rgba(10, 132, 255, 0.15);
    border: 1px solid var(--accent);
    pointer-events: none; /* 绝对穿透，不阻挡事件 */
    z-index: 9999;
    display: none;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(10,132,255,0.18), 0 12px 30px rgba(10,132,255,0.12);
    backdrop-filter: blur(2px);
}
.selection-marquee.is-window {
    background: rgba(10,132,255,0.16);
    border-color: var(--accent);
}
.selection-marquee.is-crossing {
    background: rgba(50,215,75,0.12);
    border-color: rgba(50,215,75,0.9);
    border-style: dashed;
    box-shadow: 0 0 0 1px rgba(50,215,75,0.18), 0 12px 30px rgba(50,215,75,0.1);
}
.canvas-selection-toolbar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1200;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border: 1px solid rgba(94,156,255,0.24);
    border-radius: 999px;
    background: linear-gradient(145deg, rgba(16,22,34,0.94), rgba(9,13,22,0.86));
    box-shadow: 0 18px 42px rgba(0,0,0,0.42), inset 0 0 0 1px rgba(255,255,255,0.035);
    backdrop-filter: blur(16px) saturate(1.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.canvas-selection-toolbar.show {
    opacity: 1;
    pointer-events: auto;
}
.canvas-selection-toolbar button {
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: rgba(255,255,255,0.035);
    color: var(--text-sub);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}
.canvas-selection-toolbar button:hover {
    color: var(--accent);
    background: rgba(94,156,255,0.1);
    border-color: rgba(94,156,255,0.28);
    transform: translateY(-1px);
}
.canvas-selection-toolbar .material-symbols-outlined {
    font-size: 17px;
}
/* ============================== */
/* 🎬 沉浸式 3D 登录舱与运镜动画 */
/* ============================== */

.login-gate {
    position: fixed; inset: 0; z-index: 99999;
    /* 🌟 修复1：增加 #0f0f11 纯黑打底色。这样即使 2K 图没加载完，也是高级的纯黑，绝不漏底！ */
    background-color: #0f0f11;
    background-image: url('../变清晰_突出光影感_2K_202605120056.webp');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    
    display: flex; justify-content: center; align-items: center;
    /* 🌟 修复2：删除了 perspective: 1000px; 它是导致毛玻璃闪烁的元凶 */
    transition: opacity 0.8s cubic-bezier(0.8, 0, 0.2, 1), backdrop-filter 0.8s;
}

/* 🌟 新增：环境暗场遮罩，压暗四周，突出中心光影，保证表单清晰度 */
.login-gate::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at center, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.7) 100%);
    z-index: 1; pointer-events: none;
}

/* 🌟 新增：粒子画布层，垫在背景上、遮罩下 */
.login-canvas {
    position: absolute; inset: 0; width: 100%; height: 100%;
    z-index: 2; pointer-events: none; 
}

.login-noise {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 0.5px, transparent 0.5px);
    background-size: 3px 3px;
    opacity: 0.08;
    mix-blend-mode: soft-light;
}

.login-halo {
    position: absolute;
    width: 460px;
    height: 460px;
    border-radius: 50%;
    z-index: 3;
    pointer-events: none;
    filter: blur(42px);
    opacity: 0.28;
    animation: loginHaloDrift 12s ease-in-out infinite alternate;
}

.login-halo-a {
    top: -120px;
    right: -120px;
    background: radial-gradient(circle, rgba(94,156,255,0.55) 0%, rgba(94,156,255,0) 70%);
}

.login-halo-b {
    left: -160px;
    bottom: -180px;
    background: radial-gradient(circle, rgba(129,140,248,0.42) 0%, rgba(129,140,248,0) 72%);
    animation-delay: 1.6s;
}

@keyframes loginHaloDrift {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(12px, -14px, 0) scale(1.08); }
}

.login-panel-direct {
    width: min(460px, calc(100vw - 32px));
    max-width: 460px;
}

.login-scene {
    --login-tilt-x: 0deg;
    --login-tilt-y: 0deg;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    perspective: 1200px;
}

.login-intro {
    display: none !important;
    position: relative;
    z-index: 11;
    border: 1px solid rgba(168, 194, 234, 0.18);
    border-radius: 24px;
    background: linear-gradient(160deg, rgba(12, 18, 28, 0.78), rgba(8, 13, 20, 0.56));
    backdrop-filter: blur(10px);
    padding: 26px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transform: translateZ(0) rotateX(calc(var(--login-tilt-x) * 0.35)) rotateY(calc(var(--login-tilt-y) * 0.35));
    transition: transform 0.22s ease, border-color 0.22s ease;
}

.login-kicker {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.18em;
    color: #9abaf5;
}

.login-intro h1 {
    margin: 0;
    font-size: 36px;
    font-weight: 600;
    line-height: 1.05;
    color: #f4f7ff;
}

.login-subtitle {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-sub);
}

.login-chip-grid {
    margin-top: 2px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.login-chip {
    min-height: 40px;
    border: 1px solid rgba(168, 194, 234, 0.16);
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    padding: 8px 10px;
    font-size: 11px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.login-chip .material-symbols-outlined {
    font-size: 16px;
    color: #9ec1ff;
}

.login-metrics {
    margin-top: auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.login-metric {
    border: 1px solid rgba(168, 194, 234, 0.14);
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    min-height: 64px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.login-metric strong {
    font-family: monospace;
    font-size: 16px;
    color: #d9e7ff;
}

.login-metric span {
    font-size: 11px;
    color: var(--text-sub);
}

.login-form-box {
    width: 100%;
    max-width: 430px;
    transform: translateZ(0) rotateX(var(--login-tilt-x)) rotateY(var(--login-tilt-y));
    transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.login-gate.unlocked {
    opacity: 0; pointer-events: none; backdrop-filter: blur(0px);
}

.gate-step {
    position: absolute; z-index: 10; 
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none;
    transform: translateY(40px) scale(0.85); 
    /* 🌟 补丁 1：千万不能用 transition: all，必须精确指定，防止浏览器盲目计算所有属性 */
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    /* 🌟 补丁 2：强行开启 GPU 预渲染与背面隐藏，解决初帧掉帧闪烁 */
    will-change: opacity, transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.gate-step.step-active {
    opacity: 1; pointer-events: auto;
    transform: translateY(0) scale(1); 
}

.gate-step.step-passed {
    opacity: 0; pointer-events: none;
    transform: translateY(-60px) scale(1.15); 
}
/* 启动按钮样式 */
.launch-btn {
    display: flex; flex-direction: column; align-items: center;
    color: var(--text-sub); cursor: pointer; padding: 40px;
    border-radius: 50%; transition: all 0.3s ease;
}
.launch-btn:hover { color: var(--text-main); transform: scale(1.1); text-shadow: 0 0 20px var(--accent); }
.launch-btn span { animation: pulse 2s infinite; }

/* --- 移植自你模板的 Glassmorphism 表单 --- */
.form-box {
    position: relative; width: min(430px, calc(100vw - 56px)); min-height: 420px; height: auto;
    /* 🌟 补丁 3：把底色白漆稍微加厚一点点（从 0.02 提升至 0.06），保证质感不透明 */
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px); 
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 30px 80px rgba(0,0,0,0.8);
    padding: 32px 34px;
    /* 🌟 补丁 4：创建一个独立的 3D 渲染复合层，死死锁住毛玻璃状态 */
    transform: translateZ(0); 
}
.form-value { width: 100%; }
.form-value form { width: 100%; }
.form-box h2 { font-size: 32px; color: #fff; text-align: center; margin-bottom: 20px; font-family: monospace; letter-spacing: 2px; }

.inputbox { position: relative; margin: 26px 0; width: 100%; border-bottom: 2px solid rgba(255,255,255,0.3); transition: border-color 0.3s; }
.inputbox:focus-within { border-color: var(--accent); }
.inputbox label {
    position: absolute; top: 50%; left: 5px; transform: translateY(-50%);
    color: var(--text-sub); font-size: 14px; pointer-events: none; transition: 0.3s ease;
}
.inputbox input:focus ~ label, .inputbox input:valid ~ label { top: -5px; color: var(--accent); font-size: 12px; }
.inputbox input {
    width: 100%; height: 50px; background: transparent; border: none; outline: none;
    font-size: 16px; padding: 0 35px 0 5px; color: #fff; font-family: monospace;
}
.inputbox ion-icon { position: absolute; right: 8px; color: var(--text-sub); font-size: 18px; top: 20px; }

.forget { margin: -8px 0 15px; font-size: 13px; color: var(--text-sub); display: flex; justify-content: center; align-items: center; gap: 4px; }
.form-box button {
    width: 100%; height: 45px; border-radius: 40px; background: #fff; border: none; outline: none;
    cursor: pointer; font-size: 14px; font-weight: 600; letter-spacing: 1px; color: #000;
    transition: all 0.3s;
}
.form-box button:hover { background: var(--accent); color: #fff; box-shadow: 0 0 20px var(--accent); }

/* ============================== */
/* 🚫 错误弹窗震动特效 */
/* ============================== */
@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
    20%, 40%, 60%, 80% { transform: translateX(6px); }
}

.error-shake {
    animation: errorShake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}
/* ============================== */
/* 🗂️ 右侧全局素材库抽屉 */
/* ============================== */
.material-drawer {
    position: fixed; right: -340px; top: 0; width: 320px; height: 100vh;
    background: var(--chrome-bg); backdrop-filter: blur(25px);
    border-left: 1px solid var(--border); z-index: 900;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 80px 20px 20px 20px; display: flex; flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}
.material-drawer.open { right: 0; }
.material-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    overflow-y: auto; padding-bottom: 20px; align-content: start;
}
/* 自定义优雅滚动条 */
.material-grid::-webkit-scrollbar { width: 4px; }
.material-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.material-item {
    position: relative; border-radius: 8px; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1); aspect-ratio: 1; cursor: grab; background: var(--surface-hover);
}
.material-item:active { cursor: grabbing; }
.material-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.material-item:hover img { transform: scale(1.05); }
.material-item .delete-btn {
    position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.7); color: white;
    border: none; width: 24px; height: 24px; border-radius: 50%;
    display: none; align-items: center; justify-content: center; cursor: pointer; z-index: 10; font-size: 14px;
    transition: all 0.2s;
}
.material-item:hover .delete-btn { display: flex; }
.material-item .delete-btn:hover { background: var(--danger); }
/* ============================== */
/* 🗺️ 全局鹰眼小地图 (Minimap) */
/* ============================== */
.minimap-container {
    position: fixed; bottom: 160px; right: 24px; /* 🌟 修复：上移避开底部控制台 */
    width: 200px; height: 140px;
    /* ... 后面保持不变 */
    background: var(--chrome-bg); backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px; z-index: 800; /* 高于画布，低于弹窗和抽屉 */
    overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    cursor: crosshair; transition: transform 0.22s ease, opacity 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}
.minimap-container:hover,
.minimap-container.is-awake {
    background: var(--chrome-bg-strong);
    border-color: rgba(255, 255, 255, 0.2);
}
#minimap-canvas {
    width: 100%; height: 100%; pointer-events: none;
}
.minimap-viewport-box {
    position: absolute; box-sizing: border-box;
    border: 1.5px solid var(--accent); /* 视口高亮框 */
    background: rgba(10, 132, 255, 0.1);
    border-radius: 4px; pointer-events: none;
    box-shadow: 0 0 10px rgba(10, 132, 255, 0.3);
}
/* ============================== */
/* 🗂️ 框架 (Frame) 折叠收纳系统 */
/* ============================== */
.frame-box {
    position: absolute; border: 2px dashed rgba(167, 139, 250, 0.4);
    background: rgba(167, 139, 250, 0.03); border-radius: 16px;
    pointer-events: none; z-index: 1; /* 垫在所有卡片底层 */
    transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1), border 0.3s;
}
.frame-header {
    position: absolute; top: -40px; left: -2px;
    background: rgba(167, 139, 250, 0.9); color: #fff;
    padding: 6px 14px; border-radius: 12px 12px 0 0;
    font-size: 14px; font-weight: bold; display: flex; align-items: center; gap: 10px;
    pointer-events: auto; cursor: grab; box-shadow: 0 4px 15px rgba(167, 139, 250, 0.3);
    backdrop-filter: blur(10px);
}
.frame-header:active { cursor: grabbing; }
.frame-title-input {
    background: transparent; border: none; color: #fff;
    font-weight: 600; font-size: 14px; outline: none; width: 140px;
}
.frame-title-input::placeholder { color: rgba(255,255,255,0.6); }
.frame-btn { background: transparent; border: none; color: #fff; cursor: pointer; display: flex; align-items: center; padding: 0; opacity: 0.8; transition: 0.2s; }
.frame-btn:hover { opacity: 1; transform: scale(1.1); }
/* 核心：被折叠时的隐藏动画 */
.hidden-in-frame { opacity: 0 !important; pointer-events: none !important; transform: scale(0.9) !important; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important; z-index: -1 !important; }
/* 🌟 新增：框架右下角自由拉伸把手 */
.frame-resize-handle {
    position: absolute; bottom: 0; right: 0;
    width: 28px; height: 28px;
    cursor: nwse-resize;
    z-index: 20;
    background: linear-gradient(135deg, transparent 50%, rgba(167, 139, 250, 0.4) 50%);
    border-bottom-right-radius: 14px;
    pointer-events: auto;
    transition: 0.2s;
}
.frame-resize-handle:hover {
    background: linear-gradient(135deg, transparent 50%, rgba(167, 139, 250, 0.8) 50%);
}

/* ============================== */
/* 🌌 Launch-C Unified Skin */
/* ============================== */
body.app-shell-init .top-bar,
body.app-shell-init .tool-drawer,
body.app-shell-init .material-drawer,
body.app-shell-init .minimap-container {
    opacity: 0;
    transform: translateY(14px) scale(0.986);
}

body.app-shell-init .floating-console {
    opacity: 0;
    transform: translateX(-50%) translateY(14px) scale(0.986);
}

body.app-shell-ready .top-bar,
body.app-shell-ready .tool-drawer,
body.app-shell-ready .material-drawer,
body.app-shell-ready .minimap-container {
    opacity: 1;
    transform: none;
    transition: opacity 0.44s cubic-bezier(0.16, 1, 0.3, 1), transform 0.44s cubic-bezier(0.16, 1, 0.3, 1);
}
body.app-shell-ready .minimap-container:not(.is-awake):not(:hover):not(.is-minimized) {
    opacity: 0.2;
    transform: translateY(6px) scale(0.92);
}

body.app-shell-ready .floating-console:not(.minimized) {
    opacity: 1;
    transform: translateX(-50%);
    transition: opacity 0.44s cubic-bezier(0.16, 1, 0.3, 1), transform 0.44s cubic-bezier(0.16, 1, 0.3, 1);
}

.route-transition {
    position: fixed;
    inset: 0;
    z-index: 2147483646;
    display: grid;
    place-items: center;
    background: var(--route-fx-bg);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.46s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.46s cubic-bezier(0.16, 1, 0.3, 1);
}

.route-transition.is-active {
    opacity: 1;
    visibility: visible;
}

.route-transition-ring {
    width: min(46vw, 420px);
    height: min(46vw, 420px);
    border-radius: 50%;
    border: 1px solid var(--route-fx-ring);
    box-shadow:
        0 0 0 24px var(--route-fx-ring-soft),
        0 0 0 64px var(--route-fx-ring-faint);
    animation: routePulse 1.2s ease-in-out infinite;
}

.route-transition-label {
    position: absolute;
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--route-fx-text);
}

@keyframes routePulse {
    0% { transform: scale(0.96); opacity: 0.78; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.04); opacity: 0.84; }
}

.top-bar {
    backdrop-filter: blur(16px);
}

.top-btn {
    border-radius: 999px;
    border-color: var(--chrome-border);
    background: var(--chrome-bg);
}

.top-btn:hover {
    box-shadow: 0 10px 24px rgba(6, 10, 18, 0.25);
}

.top-btn-pro {
    background: rgba(94, 156, 255, 0.18);
    border-color: rgba(147, 197, 255, 0.56);
    color: #bfd9ff;
}

.top-btn-pro:hover {
    background: rgba(94, 156, 255, 0.28);
}

.video-card,
.floating-console,
.tool-drawer,
.material-drawer,
.help-content,
.sys-modal-content,
.minimap-container {
    border-color: var(--chrome-border);
    box-shadow: var(--panel-shadow);
}

.floating-console,
.tool-drawer,
.material-drawer,
.minimap-container,
.prompt-container,
.mode-tabs,
.action-pill,
.draggable-tool,
.img-slot,
.img-gen-slot,
.material-item,
.frame-box {
    transition: all 0.25s ease;
}

.floating-console {
    border-radius: var(--radius-lg);
}

.login-gate {
    background-image: none;
    background:
        radial-gradient(circle at 22% 4%, var(--hero-ring) 0%, transparent 42%),
        radial-gradient(circle at 78% 24%, var(--hero-ring) 0%, transparent 40%),
        linear-gradient(180deg, #04070e 0%, #060a12 50%, #020307 100%);
}

.login-gate::before {
    background:
        radial-gradient(560px circle at center, rgba(255,255,255,0.06) 0%, rgba(5, 8, 16, 0.78) 70%, rgba(3, 5, 10, 0.9) 100%);
}

.form-box {
    border-radius: 24px;
    border-color: rgba(168, 194, 234, 0.2);
    background: linear-gradient(155deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
}

.form-box h2 {
    letter-spacing: 0.14em;
    font-family: 'Google Sans', sans-serif;
}

.launch-btn {
    border: 1px solid rgba(168, 194, 234, 0.24);
    background: rgba(255,255,255,0.03);
    box-shadow: 0 0 0 1px rgba(168, 194, 234, 0.12), 0 18px 44px rgba(4, 8, 14, 0.52);
}

.launch-btn:hover {
    border-color: rgba(147, 197, 255, 0.62);
    box-shadow: 0 0 0 1px rgba(147, 197, 255, 0.24), 0 20px 46px rgba(4, 8, 14, 0.65);
}

:root[data-theme='light'] .login-gate {
    background:
        radial-gradient(circle at 22% 4%, rgba(94, 156, 255, 0.18) 0%, transparent 42%),
        radial-gradient(circle at 78% 24%, rgba(94, 156, 255, 0.14) 0%, transparent 40%),
        linear-gradient(180deg, #04070e 0%, #060a12 50%, #020307 100%);
}

:root[data-theme='light'] .login-gate::before {
    background:
        radial-gradient(560px circle at center, rgba(255,255,255,0.06) 0%, rgba(5, 8, 16, 0.78) 70%, rgba(3, 5, 10, 0.9) 100%);
}

:root[data-theme='light'] .form-box {
    background: linear-gradient(155deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
    border-color: rgba(168, 194, 234, 0.2);
}

:root[data-theme='light'] .login-intro {
    background: linear-gradient(160deg, rgba(248, 251, 255, 0.96), rgba(240, 246, 255, 0.9));
    border-color: rgba(156, 183, 231, 0.45);
}

:root[data-theme='light'] .login-kicker {
    color: #2a5dbe;
}

:root[data-theme='light'] .login-intro h1 {
    color: #16315f;
}

:root[data-theme='light'] .login-subtitle {
    color: #3d4f72;
}

:root[data-theme='light'] .login-chip {
    border-color: rgba(156, 183, 231, 0.34);
    background: rgba(255,255,255,0.65);
    color: #1f3254;
}

:root[data-theme='light'] .login-chip .material-symbols-outlined {
    color: #2e64c8;
}

:root[data-theme='light'] .login-metric {
    border-color: rgba(156, 183, 231, 0.32);
    background: rgba(255,255,255,0.56);
}

:root[data-theme='light'] .login-metric strong {
    color: #16315f;
}

:root[data-theme='light'] .login-metric span {
    color: #3d4f72;
}

:root[data-theme='light'] .form-box h2,
:root[data-theme='light'] .inputbox input {
    color: #fff;
}

@media (max-width: 960px) {
    .login-panel-direct {
        width: min(460px, calc(100vw - 28px));
    }

    .login-scene {
        gap: 0;
    }

    .login-intro {
        display: none !important;
    }

    .login-form-box {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .login-panel-direct {
        width: calc(100vw - 20px);
    }

    .form-box {
        width: min(430px, calc(100vw - 30px));
        padding: 24px 20px;
        min-height: 392px;
    }

    .form-box h2 {
        font-size: 28px;
        margin-bottom: 14px;
    }

    .inputbox {
        margin: 22px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .route-transition,
    .route-transition-ring {
        animation: none !important;
        transition: none !important;
    }

    .login-halo {
        animation: none !important;
    }

    .login-intro,
    .login-form-box {
        transition: none !important;
        transform: none !important;
    }

    body.app-shell-init .top-bar,
    body.app-shell-init .floating-console,
    body.app-shell-init .tool-drawer,
    body.app-shell-init .material-drawer,
    body.app-shell-init .minimap-container {
        opacity: 1;
        transform: none;
    }
}

/* ===== Image Gen UI v3 ===== */
.tool-image-gen { width: 360px; box-shadow: 0 22px 44px rgba(0,0,0,0.72); gap: 0; overflow: hidden; }
.img-gen-shell { display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; position: relative; }
.img-gen-shell.is-running::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 10% -20%, rgba(94,156,255,0.14), transparent 45%);
}
.img-gen-statusbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 0 12px; }
.img-gen-status-badge {
    display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 10px;
    font-size: 10px; letter-spacing: 0.9px; font-weight: 700;
    border: 1px solid var(--border); background: rgba(255,255,255,0.04); color: var(--text-sub);
}
.img-gen-status-badge.is-pro { color: var(--accent); border-color: rgba(94,156,255,0.42); background: rgba(94,156,255,0.12); }
.img-gen-status-badge.is-trial { color: var(--text-sub); border-color: rgba(255,255,255,0.14); background: rgba(255,255,255,0.03); }
.img-gen-status-badge.is-variant {
    color: var(--warning);
    border-color: rgba(255, 202, 40, 0.35);
    background: rgba(255, 202, 40, 0.1);
}
.img-gen-size-chip {
    display: inline-flex; align-items: center; justify-content: center; min-height: 24px;
    border-radius: 999px; padding: 2px 10px; font-size: 10px;
    border: 1px solid var(--border); background: rgba(255,255,255,0.03); color: var(--text-sub);
}
.img-gen-upload-note { padding: 0 12px; font-size: 10px; color: var(--text-sub); opacity: 0.78; letter-spacing: 0.3px; }

.img-gen-slots { display: flex; gap: 7px; padding: 0 12px; flex-wrap: wrap; }
.img-gen-slot {
    width: 54px; height: 54px;
    border: 1px dashed rgba(255,255,255,0.2); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative; transition: all 0.22s ease;
    overflow: hidden; background: rgba(255,255,255,0.02);
}
.img-gen-slot:hover,
.img-gen-slot.drag-over {
    border-color: var(--accent);
    background: rgba(10, 132, 255, 0.12);
    transform: translateY(-1px);
}
.img-gen-slot img { width: 100%; height: 100%; object-fit: cover; }
.img-gen-slot .remove-badge { position: absolute; top: -4px; right: -4px; width: 16px; height: 16px; font-size: 10px; }
.img-gen-slot-add span { color: var(--text-sub); font-size: 20px; transition: transform 0.2s ease; }
.img-gen-slot-add:hover span { transform: scale(1.08); color: var(--accent); }

.img-gen-card-title {
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
}
.img-gen-card-title .material-symbols-outlined { font-size: 14px; }
.img-gen-variant-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 18px;
    border-radius: 999px;
    padding: 0 7px;
    border: 1px solid rgba(255, 202, 40, 0.32);
    background: rgba(255, 202, 40, 0.1);
    color: var(--warning);
    font-size: 10px;
    letter-spacing: 0.5px;
    font-weight: 800;
}
.img-gen-card-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.img-gen-card-close,
.img-gen-help-trigger {
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--text-sub);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.72;
    transition: opacity 0.18s ease, color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.img-gen-card-close:hover,
.img-gen-help-trigger:hover {
    opacity: 1;
    color: var(--accent);
    border-color: rgba(94,156,255,0.28);
    background: rgba(94,156,255,0.08);
    transform: translateY(-1px);
}
.img-gen-card-close .material-symbols-outlined,
.img-gen-help-trigger .material-symbols-outlined { font-size: 16px; }
.img-gen-help-trigger {
    color: rgba(148,163,184,0.72);
}
.img-gen-help-drawer {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
}
.img-gen-help-drawer.show {
    pointer-events: auto;
}
.img-gen-help-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2,6,14,0.42);
    opacity: 0;
    backdrop-filter: blur(4px);
    transition: opacity 0.22s ease;
}
.img-gen-help-drawer.show .img-gen-help-backdrop {
    opacity: 1;
}
.img-gen-help-panel {
    position: absolute;
    top: 72px;
    right: 18px;
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100vh - 96px);
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(16,22,34,0.96), rgba(9,13,22,0.94));
    box-shadow: 0 28px 80px rgba(0,0,0,0.48), inset 0 0 0 1px rgba(255,255,255,0.025);
    backdrop-filter: blur(18px) saturate(1.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateX(18px) scale(0.98);
    opacity: 0;
    outline: none;
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}
.img-gen-help-drawer.show .img-gen-help-panel {
    transform: translateX(0) scale(1);
    opacity: 1;
}
.img-gen-help-head {
    min-height: 62px;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(255,255,255,0.025);
}
.img-gen-help-eyebrow {
    color: var(--accent);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.7px;
}
.img-gen-help-head h2 {
    margin: 3px 0 0 0;
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.2;
}
.img-gen-help-close {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,0.035);
    color: var(--text-sub);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.18s ease;
}
.img-gen-help-close:hover {
    color: var(--accent);
    border-color: rgba(94,156,255,0.38);
    background: rgba(94,156,255,0.08);
}
.img-gen-help-close .material-symbols-outlined {
    font-size: 16px;
}
.img-gen-help-body {
    padding: 14px;
    overflow-y: auto;
    color: var(--text-sub);
    font-size: 12px;
    line-height: 1.72;
}
.img-gen-help-section {
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.075);
    border-radius: 12px;
    background: rgba(255,255,255,0.024);
}
.img-gen-help-section + .img-gen-help-section {
    margin-top: 10px;
}
.img-gen-help-kicker {
    margin: 0 0 8px 0;
    color: var(--accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
}
.img-gen-help-section h3 {
    margin: 0 0 8px 0;
    color: var(--text-main);
    font-size: 14px;
}
.img-gen-help-section p {
    margin: 0 0 8px 0;
}
.img-gen-help-section p:last-child {
    margin-bottom: 0;
}
.img-gen-help-section ul,
.img-gen-help-section ol {
    margin: 8px 0 0 0;
    padding-left: 18px;
}
.img-gen-help-section li {
    margin: 5px 0;
}
.img-gen-help-section strong {
    color: var(--text-main);
}
.img-gen-help-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0;
}
.img-gen-help-card {
    padding: 10px;
    border: 1px solid rgba(94,156,255,0.14);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(94,156,255,0.07), rgba(255,255,255,0.018));
}
.img-gen-help-card p {
    margin: 5px 0 0 0;
}
.img-gen-help-note {
    padding: 9px 10px;
    border: 1px solid rgba(255,184,77,0.2);
    border-radius: 11px;
    background: rgba(255,184,77,0.075);
    color: var(--text-main);
}
.img-gen-help-tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.img-gen-help-tag {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 9px;
    border: 1px solid rgba(94,156,255,0.18);
    border-radius: 999px;
    background: rgba(94,156,255,0.075);
    color: var(--accent);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.4px;
}
.img-gen-help-table {
    display: grid;
    gap: 8px;
}
.img-gen-help-table > div {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 8px 9px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 11px;
    background: rgba(255,255,255,0.018);
}
.img-gen-help-table span {
    color: var(--text-sub);
}
@media (max-width: 520px) {
    .img-gen-help-grid,
    .img-gen-help-table > div {
        grid-template-columns: 1fr;
    }
}
.img-gen-file-input { display: none; }
.img-gen-slots.img-gen-slots-fixed {
    position: relative;
    display: grid;
    grid-template-columns: minmax(116px, 1.35fr) repeat(2, minmax(66px, 1fr));
    grid-template-rows: repeat(2, 76px);
    gap: 8px;
    padding: 0;
    min-height: 160px;
    transform-origin: center;
    transition: transform 0.18s ease, filter 0.18s ease;
}
.img-gen-slots-fixed.drag-over {
    transform: scale(1.012);
    filter: drop-shadow(0 12px 26px rgba(94,156,255,0.12));
}
.img-gen-slots-fixed .img-gen-slot {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    border-radius: 10px;
    background: linear-gradient(145deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015));
}
.img-gen-slot-base {
    grid-row: span 2;
    border-style: solid;
    border-color: rgba(94,156,255,0.22);
}
.img-gen-slot-ref {
    border-color: rgba(255,255,255,0.16);
}
.img-gen-slot.has-image {
    border-style: solid;
}
.img-gen-slot.has-mask {
    border-color: rgba(50,215,75,0.42);
    box-shadow: 0 0 0 1px rgba(50,215,75,0.12), 0 0 22px rgba(50,215,75,0.08);
}
.img-gen-slot-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-sub);
    text-align: center;
    padding: 8px;
}
.img-gen-slot-placeholder .material-symbols-outlined {
    font-size: 20px;
    color: var(--accent);
    opacity: 0.72;
}
.img-gen-slot-placeholder strong {
    color: var(--text-main);
    font-size: 10px;
    letter-spacing: 0.8px;
}
.img-gen-slot-placeholder small {
    font-size: 9px;
    opacity: 0.72;
}
.img-gen-slot-label,
.img-gen-slot-mask-dot {
    position: absolute;
    left: 6px;
    z-index: 2;
    border-radius: 999px;
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.6px;
    backdrop-filter: blur(10px);
}
.img-gen-slot-label {
    bottom: 6px;
    color: #fff;
    background: rgba(0,0,0,0.52);
}
.img-gen-slot-mask-dot {
    top: 6px;
    color: var(--success);
    border: 1px solid rgba(50,215,75,0.32);
    background: rgba(8,20,12,0.62);
}
.img-gen-ref-control {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 25px;
    z-index: 4;
    display: grid;
    grid-template-columns: minmax(40px, 0.8fr) minmax(38px, 1fr);
    gap: 4px;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.img-gen-slot:hover .img-gen-ref-control,
.img-gen-slot:focus-within .img-gen-ref-control {
    opacity: 1;
    transform: translateY(0);
}
.img-gen-ref-intent,
.img-gen-ref-weight {
    min-width: 0;
    height: 20px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(8,10,16,0.7);
    color: #fff;
    backdrop-filter: blur(12px);
}
.img-gen-ref-intent {
    padding: 0 5px;
    font-size: 9px;
    outline: none;
}
.img-gen-ref-weight {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0 5px;
}
.img-gen-ref-weight span {
    width: 16px;
    font-size: 8px;
    color: rgba(255,255,255,0.78);
    font-family: monospace;
}
.img-gen-ref-weight input {
    min-width: 0;
    width: 100%;
    accent-color: var(--accent);
}
.img-gen-drop-overlay {
    position: absolute;
    inset: -2px;
    border-radius: 12px;
    border: 1px solid rgba(94,156,255,0.42);
    background: rgba(94,156,255,0.12);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transform: scale(0.98);
    pointer-events: none;
    backdrop-filter: blur(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 5;
}
.img-gen-drop-overlay .material-symbols-outlined { font-size: 22px; }
.img-gen-drop-overlay strong { font-size: 12px; }
.img-gen-slots-fixed.drag-over .img-gen-drop-overlay {
    opacity: 1;
    transform: scale(1);
}

.img-gen-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 12px; }
.img-gen-controls.img-gen-controls-pro { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.img-gen-select {
    width: 100%;
    min-width: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.07), rgba(255,255,255,0.028));
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-main);
    font-size: 11px;
    padding: 7px 8px;
    border-radius: 8px;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
    transition: transform 0.18s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.img-gen-select:hover {
    transform: translateY(-1px);
    border-color: rgba(94,156,255,0.45);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 8px 18px rgba(0,0,0,0.12);
}
.img-gen-select:focus {
    border-color: var(--accent);
    background: var(--input-muted-bg);
    box-shadow: 0 0 0 2px rgba(94,156,255,0.14);
}

.img-gen-custom-ratio { display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.img-gen-custom-label { font-size: 11px; color: var(--text-sub); }
.img-gen-ratio-input { width: 46px; text-align: center; padding: 6px 4px; }
.img-gen-size-hint { margin-left: auto; font-size: 10px; color: var(--text-sub); opacity: 0.8; }
.img-gen-ratio-colon { color: var(--text-sub); }

.img-gen-primary-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 6px;
    align-items: end;
    padding: 0;
}
.img-gen-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.img-gen-field > span {
    color: var(--text-sub);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
}
.img-gen-advanced-chip {
    height: 31px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: linear-gradient(135deg, rgba(255,255,255,0.055), rgba(255,255,255,0.018));
    color: var(--text-sub);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 9px;
    font-size: 10px;
    cursor: pointer;
    transition: transform 0.18s ease, color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.img-gen-advanced-chip .material-symbols-outlined {
    font-size: 15px;
    transition: transform 0.24s ease;
}
.img-gen-advanced-chip:hover,
.img-gen-advanced-chip.is-open {
    color: var(--accent);
    border-color: rgba(94,156,255,0.42);
    background: rgba(94,156,255,0.08);
    transform: translateY(-1px);
}
.img-gen-advanced-chip.is-open .material-symbols-outlined {
    transform: rotate(45deg);
}
.img-gen-seed-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 5px;
}
.img-gen-seed-lock {
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.18s ease;
}
.img-gen-seed-lock .material-symbols-outlined { font-size: 15px; }
.img-gen-seed-lock:hover,
.img-gen-seed-lock.is-locked {
    color: var(--accent);
    border-color: rgba(94,156,255,0.42);
    background: rgba(94,156,255,0.1);
}
.img-gen-seed-input {
    padding-left: 7px;
    padding-right: 7px;
}

.img-gen-prompt-assist {
    margin: 0 12px -2px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(255,255,255,0.045), rgba(255,255,255,0.014));
    padding: 8px;
}
.img-gen-prompt-assist-head {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    letter-spacing: 0.7px;
    color: var(--text-sub);
    font-weight: 800;
    margin-bottom: 6px;
}
.img-gen-prompt-assist-head .material-symbols-outlined {
    font-size: 14px;
    color: var(--accent);
}
.img-gen-prompt-chip-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 1px 0 5px;
    scrollbar-width: thin;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}
.img-gen-prompt-chip {
    flex: 0 0 auto;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.045);
    color: var(--text-main);
    border-radius: 999px;
    padding: 5px 8px;
    font-size: 10px;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.img-gen-prompt-chip span {
    color: var(--accent);
    margin-right: 5px;
    font-family: monospace;
}
.img-gen-prompt-chip:hover {
    transform: translateY(-1px);
    border-color: rgba(94,156,255,0.4);
    background: rgba(94,156,255,0.1);
}
.img-gen-prompt {
    margin: 0 12px;
    background: var(--input-muted-bg);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 10px;
    min-height: 72px;
    max-height: 420px;
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.46;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.img-gen-prompt:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(94,156,255,0.15); }

.img-gen-btn {
    margin: 0 12px;
    background: linear-gradient(135deg, var(--accent), #3f7fe2);
    color: #fff;
    border: none;
    padding: 11px 10px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    position: relative;
    overflow: hidden;
}
.img-gen-btn:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 10px 18px rgba(35, 82, 172, 0.35); }
.img-gen-btn:disabled { background: var(--border); color: var(--text-sub); cursor: not-allowed; box-shadow: none; }
.img-gen-btn.is-failed {
    background: linear-gradient(135deg, var(--danger), #b83b35);
}
.img-gen-btn .img-gen-btn-price { font-family: monospace; opacity: 0.92; margin-left: 4px; }
.img-gen-runtime { font-family: monospace; opacity: 0.85; margin-left: auto; }
.img-gen-btn.is-running::before {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);
    animation: imgBtnScan 1.8s linear infinite;
}

.img-gen-processing-wrap { display: flex; flex-direction: column; width: 100%; gap: 7px; }
.img-gen-processing-head { display: flex; justify-content: space-between; align-items: center; width: 100%; font-size: 12px; }
.img-gen-processing-left { display: flex; align-items: center; gap: 6px; }
.img-gen-timer { font-family: monospace; color: #fff; opacity: 0.95; font-weight: 700; letter-spacing: 0.7px; }
.img-gen-progress { width: 100%; height: 3px; background: rgba(255,255,255,0.2); border-radius: 999px; overflow: hidden; }
.img-gen-progress-bar {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(255,255,255,0.65), #fff);
    animation: fakeImgProgress 60s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

.img-gen-running-fx {
    margin: 0 12px;
    margin-top: -4px;
    height: 10px;
    border-radius: 999px;
    background: rgba(94,156,255,0.08);
    border: 1px solid rgba(94,156,255,0.2);
    overflow: hidden;
    position: relative;
}
.img-gen-running-beam {
    position: absolute;
    top: -4px;
    left: -18%;
    width: 16%;
    height: 18px;
    background: linear-gradient(90deg, transparent, rgba(94,156,255,0.65), transparent);
    animation: runningBeam 1.6s ease-in-out infinite;
}
.img-gen-running-beam.beam-2 { animation-delay: 0.8s; opacity: 0.75; }

.img-gen-result-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:8px; padding: 0 12px 0 12px; }
.img-gen-result {
    width: 100%;
    min-height: 120px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
}
.img-gen-result img { width: 100%; height: auto; display: block; object-fit: contain; max-height: 400px; cursor: grab; }

@keyframes fakeImgProgress {
    0% { width: 4%; }
    25% { width: 33%; }
    60% { width: 68%; }
    82% { width: 83%; }
    100% { width: 94%; }
}
@keyframes runningBeam {
    0% { left: -18%; }
    100% { left: 108%; }
}
@keyframes imgBtnScan {
    0% { left: -40%; }
    100% { left: 120%; }
}

@media (max-width: 720px) {
    .tool-image-gen { width: 320px; }
    .img-gen-controls,
    .img-gen-controls.img-gen-controls-pro { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

:root[data-theme='light'] .img-gen-status-badge.is-pro {
    border-color: rgba(43, 99, 216, 0.35);
    background: rgba(43, 99, 216, 0.1);
}
:root[data-theme='light'] .img-gen-running-fx {
    background: rgba(43, 99, 216, 0.08);
    border-color: rgba(43, 99, 216, 0.2);
}

/* ===== Image Gen Right Preview Dock (Aligned Layout) ===== */
.tool-image-gen {
    --img-gen-left-width: 360px;
    --img-gen-preview-width: 320px;
    --img-gen-total-width: calc(var(--img-gen-left-width) + var(--img-gen-preview-width));
    --img-gen-card-height: 520px;
    --img-gen-header-height: 44px;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    width: var(--img-gen-left-width);
    height: var(--img-gen-card-height);
    min-width: 320px;
    min-height: 420px;
    max-height: none;
    max-width: none;
    padding: 0;
    gap: 0;
    overflow: hidden;
    resize: both;
    z-index: 40;
    content-visibility: visible;
    contain: none;
    contain-intrinsic-size: auto;
    border-radius: 14px;
    box-sizing: border-box;
    transition: max-width 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.canvas-board > .video-card.tool-image-gen {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
}
.tool-image-gen *,
.tool-image-gen *::before,
.tool-image-gen *::after {
    box-sizing: border-box;
}
.tool-image-gen.is-preview-open {
    max-width: none;
}
.tool-image-gen .card-header {
    margin: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    height: var(--img-gen-header-height);
    min-height: var(--img-gen-header-height);
    max-height: var(--img-gen-header-height);
    box-sizing: border-box;
}

.img-gen-shell {
    gap: 0;
    padding: 0;
    overflow: hidden;
    height: calc(100% - var(--img-gen-header-height));
    min-height: 0;
    max-height: none;
}
.img-gen-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--img-gen-preview-width);
    width: 100%;
    height: 100%;
    min-height: 100%;
    align-items: stretch;
    transition: grid-template-columns 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}
.img-gen-split.preview-collapsed {
    grid-template-columns: minmax(0, 1fr) 0;
}

.img-gen-left {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: var(--surface);
    overflow: hidden;
}
.img-gen-split:not(.preview-collapsed) .img-gen-left {
    border-right: 1px solid var(--border);
}
.img-gen-split.preview-collapsed .img-gen-left {
    border-right: 0;
}
.img-gen-panel-head {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
}
.img-gen-panel-title {
    font-size: 11px;
    letter-spacing: 1.4px;
    font-weight: 700;
    color: var(--text-sub);
}
.img-gen-dock-toggle {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    color: var(--text-sub);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.img-gen-dock-toggle:hover {
    color: var(--accent);
    border-color: rgba(94,156,255,0.45);
    background: rgba(94,156,255,0.1);
}
.img-gen-input-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
}
.img-gen-input-body::-webkit-scrollbar,
.img-gen-preview-body::-webkit-scrollbar,
.img-gen-prompt-chip-row::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.img-gen-input-body::-webkit-scrollbar-thumb,
.img-gen-preview-body::-webkit-scrollbar-thumb,
.img-gen-prompt-chip-row::-webkit-scrollbar-thumb {
    background: rgba(94,156,255,0.28);
    border-radius: 999px;
    border: 2px solid rgba(11,16,26,0.72);
}
.img-gen-input-body::-webkit-scrollbar-track,
.img-gen-preview-body::-webkit-scrollbar-track,
.img-gen-prompt-chip-row::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.035);
    border-radius: 999px;
}

.img-gen-statusbar,
.img-gen-slots,
.img-gen-upload-note,
.img-gen-controls,
.img-gen-custom-ratio,
.img-gen-prompt,
.img-gen-btn {
    margin: 0;
    padding-left: 0;
    padding-right: 0;
}
.img-gen-statusbar { justify-content: flex-start; gap: 6px; }
.img-gen-statusbar .img-gen-size-chip { margin-left: auto; }
.img-gen-upload-note { padding: 0; }
.img-gen-controls { padding: 0; }
.img-gen-custom-ratio { padding: 0; }
.img-gen-prompt {
    flex: 0 0 auto;
    min-height: 92px;
    max-height: none;
    resize: vertical;
    overflow: auto;
    user-select: text;
}
.img-gen-param-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,0.018);
    overflow: hidden;
    flex: 0 0 auto;
}
.img-gen-param-head {
    width: 100%;
    min-height: 34px;
    border: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.018));
    color: var(--text-main);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    cursor: pointer;
    text-align: left;
    transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}
.img-gen-param-head:hover {
    background: linear-gradient(135deg, rgba(94,156,255,0.1), rgba(255,255,255,0.025));
    box-shadow: inset 0 0 0 1px rgba(94,156,255,0.08);
}
.img-gen-param-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.2px;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.img-gen-param-title .material-symbols-outlined {
    font-size: 14px;
}
.img-gen-param-summary {
    min-width: 0;
    color: var(--text-sub);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.img-gen-param-body {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 7px;
    border-top: 1px solid var(--border);
}
.img-gen-param-body .img-gen-controls,
.img-gen-param-body .img-gen-controls.img-gen-controls-pro {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    justify-content: start;
    align-items: end;
}
.img-gen-param-body .img-gen-select,
.img-gen-param-body .img-gen-size-chip {
    width: 100%;
    min-width: 0;
}
.img-gen-param-panel.is-collapsed .img-gen-param-head {
    background: rgba(94,156,255,0.055);
}
.tool-image-gen.is-img-variant-node {
    --img-gen-left-width: 330px;
    --img-gen-preview-width: 300px;
    --img-gen-card-height: 440px;
    border-color: rgba(255, 202, 40, 0.26);
    box-shadow: 0 18px 34px rgba(0,0,0,0.54), 0 0 0 1px rgba(255,202,40,0.06);
}
.tool-image-gen.is-img-variant-node .img-gen-upload-note,
.tool-image-gen.is-img-variant-node .img-gen-prompt-assist {
    display: none;
}
.tool-image-gen.is-img-variant-node .img-gen-input-body {
    gap: 8px;
}
.tool-image-gen.is-img-variant-node .img-gen-prompt {
    min-height: 76px;
}
.tool-image-gen.is-img-variant-node .img-gen-statusbar {
    gap: 5px;
}
.img-gen-mask-block {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}
.img-gen-mask-block.is-active {
    border-color: rgba(94,156,255,0.38);
    box-shadow: 0 0 0 1px rgba(94,156,255,0.14) inset;
}
.img-gen-mask-block.is-readonly {
    padding: 8px;
    background: linear-gradient(135deg, rgba(94,156,255,0.045), rgba(255,255,255,0.016));
}
.img-gen-mask-block.has-mask {
    border-color: rgba(50,215,75,0.28);
    box-shadow: inset 0 0 0 1px rgba(50,215,75,0.08);
}
.img-gen-mask-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.img-gen-mask-btn {
    min-height: 28px;
    padding: 0 9px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(255,255,255,0.065), rgba(255,255,255,0.025));
    color: var(--text-sub);
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: transform 0.18s ease, color 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.img-gen-mask-btn .material-symbols-outlined {
    font-size: 14px;
    line-height: 1;
}
.img-gen-mask-btn:hover:not(:disabled) {
    color: var(--accent);
    border-color: rgba(94,156,255,0.42);
    background: linear-gradient(135deg, rgba(94,156,255,0.15), rgba(94,156,255,0.045));
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.18);
}
.img-gen-mask-btn.is-hot {
    color: var(--accent);
    border-color: rgba(94,156,255,0.36);
    background: rgba(94,156,255,0.1);
}
.img-gen-mask-btn.is-primary {
    color: #fff;
    border-color: rgba(94,156,255,0.5);
    background: linear-gradient(135deg, rgba(94,156,255,0.95), rgba(58,110,220,0.76));
    box-shadow: 0 8px 18px rgba(35,82,172,0.22);
}
.img-gen-mask-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.img-gen-mask-control,
.img-gen-mask-brush {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-sub);
    min-height: 28px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.026);
}
.img-gen-mask-control .material-symbols-outlined {
    font-size: 14px;
    color: var(--accent);
}
.img-gen-mask-control input[type='range'],
.img-gen-mask-brush input[type='range'] {
    width: 94px;
    accent-color: var(--accent);
}
.img-gen-mask-control strong,
.img-gen-mask-brush span {
    min-width: 42px;
    text-align: right;
    font-family: monospace;
    color: var(--text-main);
    font-weight: 700;
}
.img-gen-mask-pill {
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
    color: var(--text-sub);
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    letter-spacing: 0.2px;
}
.img-gen-mask-pill.is-ready {
    color: var(--success);
    border-color: rgba(50,215,75,0.28);
    background: rgba(50,215,75,0.09);
}
.img-gen-mask-editor-shell {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.img-gen-mask-stage {
    position: relative;
    width: 100%;
    height: 220px;
    min-height: 140px;
    max-height: none;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 0%, rgba(94,156,255,0.08), transparent 34%),
        rgba(0,0,0,0.25);
    user-select: none;
    outline: none;
    touch-action: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
    transition: height 0.22s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.img-gen-mask-stage.is-panning .img-gen-mask-canvas {
    cursor: grabbing;
}
.img-gen-mask-stage.is-pan-mode .img-gen-mask-canvas {
    cursor: grab;
}
.img-gen-mask-base {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    pointer-events: none;
    transform-origin: 0 0;
    will-change: transform;
}
.img-gen-mask-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: crosshair;
    touch-action: none;
    background: transparent;
    transform-origin: 0 0;
    will-change: transform;
}
.img-gen-mask-tip {
    font-size: 10px;
    color: var(--text-sub);
    opacity: 0.88;
}
.img-gen-mask-mode-pill {
    height: 28px;
    padding: 0 9px;
    border-radius: 999px;
    border: 1px solid rgba(94,156,255,0.24);
    background: rgba(94,156,255,0.08);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.img-gen-mask-mode-pill.is-pan {
    color: var(--success);
    border-color: rgba(50,215,75,0.28);
    background: rgba(50,215,75,0.09);
}
.img-gen-mask-empty {
    min-height: 110px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    text-align: center;
    padding: 10px;
}
.img-gen-mask-preview {
    position: relative;
    width: 100%;
    height: 96px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    padding: 0;
    background: rgba(0,0,0,0.22);
    cursor: pointer;
    display: block;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.img-gen-mask-preview:hover {
    transform: translateY(-1px);
    border-color: rgba(94,156,255,0.42);
    box-shadow: 0 12px 24px rgba(0,0,0,0.18);
}
.img-gen-mask-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: saturate(0.95) contrast(1.02);
}
.img-gen-mask-preview::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0,0,0,0.05), rgba(0,0,0,0.42));
}
.img-gen-mask-preview.has-mask::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        repeating-linear-gradient(135deg, rgba(255,59,48,0.16) 0 8px, transparent 8px 16px),
        radial-gradient(circle at 68% 38%, rgba(255,59,48,0.22), transparent 30%);
    mix-blend-mode: screen;
}
.img-gen-mask-preview-label,
.img-gen-mask-preview-glow {
    position: absolute;
    z-index: 2;
    left: 9px;
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.6px;
    backdrop-filter: blur(10px);
}
.img-gen-mask-preview-label {
    top: 8px;
    color: #fff;
    background: rgba(0,0,0,0.5);
}
.img-gen-mask-preview-glow {
    bottom: 8px;
    color: var(--success);
    border: 1px solid rgba(50,215,75,0.3);
    background: rgba(4,18,10,0.62);
}
.img-gen-mask-preview-glow.is-muted {
    color: var(--text-sub);
    border-color: rgba(255,255,255,0.14);
    background: rgba(0,0,0,0.48);
}

.img-gen-mask-studio {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 28px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
.img-gen-mask-studio.show {
    opacity: 1;
    pointer-events: auto;
}
.img-gen-mask-studio-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 12%, rgba(94,156,255,0.18), transparent 32%),
        radial-gradient(circle at 78% 18%, rgba(50,215,75,0.08), transparent 28%),
        rgba(3,6,12,0.78);
    backdrop-filter: blur(18px) saturate(1.2);
}
.img-gen-mask-studio-panel {
    position: relative;
    width: min(1180px, 94vw);
    height: min(820px, 88vh);
    border: 1px solid rgba(94,156,255,0.24);
    border-radius: 18px;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(13,19,31,0.96), rgba(9,13,22,0.94));
    box-shadow: 0 34px 90px rgba(0,0,0,0.58), inset 0 0 0 1px rgba(255,255,255,0.035);
    display: flex;
    flex-direction: column;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
.img-gen-mask-studio.show .img-gen-mask-studio-panel {
    transform: translateY(0) scale(1);
}
.img-gen-mask-studio-head {
    min-height: 64px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.015));
}
.img-gen-mask-studio-kicker {
    font-size: 10px;
    letter-spacing: 1.8px;
    color: var(--accent);
    font-weight: 800;
}
.img-gen-mask-studio-title {
    margin-top: 3px;
    color: var(--text-main);
    font-size: 15px;
    font-weight: 800;
}
.img-gen-mask-studio-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.img-gen-mask-studio-body {
    flex: 1;
    min-height: 0;
    padding: 14px;
    background:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
        rgba(2,5,10,0.44);
    background-size: 22px 22px;
}
.img-gen-mask-stage-large {
    height: 100%;
    min-height: 420px;
    border-radius: 14px;
    border-color: rgba(94,156,255,0.28);
    background: rgba(0,0,0,0.32);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.025), 0 18px 44px rgba(0,0,0,0.3);
}
.img-gen-mask-studio-foot {
    min-height: 42px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 9px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-sub);
    font-size: 11px;
    background: rgba(255,255,255,0.018);
}

.img-gen-preview-panel {
    position: relative;
    left: auto;
    top: auto;
    bottom: auto;
    width: var(--img-gen-preview-width);
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    background: var(--surface);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    transform-origin: left center;
    transition: opacity 0.24s ease, transform 0.24s ease, border-color 0.2s ease, background 0.24s ease;
}
.img-gen-preview-panel .img-gen-preview-head,
.img-gen-preview-panel .img-gen-preview-body {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.16s ease;
}
.img-gen-preview-head {
    height: 44px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 10px;
    background: rgba(255,255,255,0.02);
}
.img-gen-preview-head-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.img-gen-preview-title {
    font-size: 11px;
    letter-spacing: 1.4px;
    font-weight: 700;
    color: var(--text-sub);
}
.img-gen-preview-tabs {
    display: flex;
    gap: 4px;
}
.img-gen-preview-tab {
    height: 24px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    color: var(--text-sub);
    font-size: 11px;
    border-radius: 6px;
    padding: 0 10px;
    cursor: pointer;
}
.img-gen-preview-tab.is-active {
    background: rgba(94,156,255,0.12);
    color: var(--accent);
    border-color: rgba(94,156,255,0.32);
}
.img-gen-preview-tab:disabled {
    opacity: 0.52;
    cursor: not-allowed;
}
.img-gen-preview-toggle {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    color: var(--text-sub);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.img-gen-preview-toggle:hover {
    color: var(--accent);
    border-color: rgba(94,156,255,0.45);
    background: rgba(94,156,255,0.1);
}
.img-gen-preview-body {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.img-gen-preview-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.img-gen-preview-feed {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: row dense;
    grid-auto-rows: 92px;
    gap: 8px;
    padding-right: 2px;
    align-content: start;
    overscroll-behavior: contain;
}
.img-gen-preview-item {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-hover);
    overflow: hidden;
    min-height: 92px;
    grid-row: span 2;
}
.img-gen-preview-item.is-landscape {
    grid-column: span 2;
}
.img-gen-preview-item.is-square {
    grid-column: span 1;
}
.img-gen-preview-item.is-portrait {
    grid-column: span 1;
    grid-row: span 3;
}
.img-gen-preview-item img {
    width: 100%;
    height: 100%;
    min-height: 92px;
    max-height: none;
    object-fit: contain;
    display: block;
    cursor: grab;
    background: rgba(0,0,0,0.16);
}
.img-gen-preview-actions {
    position: absolute;
    left: 6px;
    right: 28px;
    bottom: 6px;
    z-index: 4;
    display: flex;
    gap: 4px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.img-gen-preview-item:hover .img-gen-preview-actions,
.img-gen-preview-item:focus-within .img-gen-preview-actions {
    opacity: 1;
    transform: translateY(0);
}
.img-gen-preview-actions button {
    min-width: 0;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 999px;
    background: rgba(8,10,16,0.72);
    color: #fff;
    backdrop-filter: blur(12px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 6px;
    font-size: 9px;
    cursor: pointer;
    transition: background 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}
.img-gen-preview-actions button:hover {
    transform: translateY(-1px);
    border-color: rgba(94,156,255,0.46);
    background: rgba(94,156,255,0.18);
}
.img-gen-preview-actions .material-symbols-outlined {
    font-size: 13px;
}
.img-gen-preview-pending,
.img-gen-preview-failed {
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: span 1;
    grid-row: span 2;
}
.img-gen-preview-pending {
    border-style: dashed;
    border-color: rgba(94,156,255,0.35);
    background: rgba(94,156,255,0.06);
    overflow: hidden;
}
.img-gen-preview-failed {
    border-style: dashed;
    border-color: rgba(255,94,89,0.28);
    background: rgba(255,94,89,0.06);
}
.img-gen-preview-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 3;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(255,94,89,0.22);
    border-radius: 999px;
    background: rgba(255,255,255,0.78);
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.76;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.img-gen-preview-delete .material-symbols-outlined {
    font-size: 14px;
}
.img-gen-preview-delete:hover {
    opacity: 1;
    transform: translateY(-1px);
    border-color: rgba(255,94,89,0.5);
    background: rgba(255,94,89,0.12);
}
.img-gen-preview-pending-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    color: var(--text-sub);
    padding: 12px;
}
.img-gen-preview-pending .spinner,
.img-gen-processing-left .spinner {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}
.img-gen-preview-timer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 64px;
    height: 22px;
    padding: 0 8px;
    border: 1px solid rgba(94,156,255,0.26);
    border-radius: 999px;
    background: rgba(94,156,255,0.1);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}
.img-gen-preview-timer .material-symbols-outlined {
    font-size: 13px;
}
.img-gen-preview-skeleton {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 30% 20%, rgba(94,156,255,0.2), transparent 30%),
        linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
}
.img-gen-skeleton-sheen {
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
    animation: imgSkeletonScan 1.55s ease-in-out infinite;
}
.img-gen-skeleton-orb {
    position: absolute;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    right: 16px;
    top: 14px;
    background: radial-gradient(circle, rgba(94,156,255,0.26), transparent 68%);
    animation: imgSkeletonFloat 2.4s ease-in-out infinite;
}
.img-gen-preview-stage-lines {
    position: relative;
    width: 100%;
    min-height: 15px;
    font-size: 10px;
    color: var(--text-sub);
}
.img-gen-preview-stage-lines span {
    position: absolute;
    inset: 0;
    opacity: 0;
    animation: imgStageCycle 8s linear infinite;
}
.img-gen-preview-stage-lines span:nth-child(2) { animation-delay: 2s; }
.img-gen-preview-stage-lines span:nth-child(3) { animation-delay: 4s; }
.img-gen-preview-stage-lines span:nth-child(4) { animation-delay: 6s; }
.img-gen-retry-route-btn {
    height: 26px;
    border: 1px solid rgba(255,94,89,0.28);
    border-radius: 999px;
    background: rgba(255,94,89,0.08);
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 9px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.img-gen-retry-route-btn .material-symbols-outlined { font-size: 14px; }
.img-gen-retry-route-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(255,94,89,0.52);
    background: rgba(255,94,89,0.13);
}
.img-gen-preview-placeholder {
    flex: 1;
    min-height: 220px;
    border-radius: 8px;
    border: 1px dashed var(--border);
    background: rgba(255,255,255,0.015);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    gap: 8px;
    text-align: center;
    padding: 12px;
}
.img-gen-preview-placeholder-title {
    font-size: 13px;
    color: var(--text-main);
}
.img-gen-preview-placeholder-sub {
    font-size: 11px;
    opacity: 0.82;
}
.img-gen-preview-placeholder.is-processing {
    color: var(--accent);
    border-color: rgba(94,156,255,0.26);
    background: rgba(94,156,255,0.045);
}
.img-gen-preview-placeholder.is-failed {
    color: var(--danger);
    border-color: rgba(255,94,89,0.24);
    background: rgba(255,94,89,0.04);
}

.img-gen-preview-panel.is-running::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    border: 1px solid rgba(94,156,255,0.38);
    box-shadow: 0 0 0 1px rgba(94,156,255,0.1), 0 0 16px rgba(94,156,255,0.16);
    animation: previewPulse 1.6s ease-in-out infinite;
}
.img-gen-preview-panel.is-running::after {
    display: none;
}

.img-gen-preview-panel.is-collapsed {
    width: 0;
    min-width: 0;
    border-left: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateX(6px);
    box-shadow: none;
}
.img-gen-preview-panel.is-collapsed .img-gen-preview-head,
.img-gen-preview-panel.is-collapsed .img-gen-preview-body {
    opacity: 0;
    visibility: hidden;
}

@keyframes previewPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
@keyframes imgSkeletonScan {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(110%); }
}
@keyframes imgSkeletonFloat {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.55; }
    50% { transform: translateY(10px) scale(1.08); opacity: 0.9; }
}
@keyframes imgStageCycle {
    0%, 20% { opacity: 1; transform: translateY(0); }
    25%, 100% { opacity: 0; transform: translateY(-4px); }
}

@media (max-width: 1120px) {
    .tool-image-gen {
        --img-gen-preview-width: 300px;
    }
}

@media (max-width: 860px) {
    .tool-image-gen {
        width: 94vw;
        max-width: 94vw;
    }
    .tool-image-gen.is-preview-open {
        width: 94vw;
        max-width: 94vw;
    }
    .img-gen-split,
    .img-gen-split.preview-collapsed {
        grid-template-columns: minmax(0, 1fr);
    }
    .img-gen-primary-panel {
        grid-template-columns: minmax(0, 1fr);
    }
    .img-gen-slots.img-gen-slots-fixed {
        grid-template-columns: minmax(130px, 1fr) minmax(80px, 0.7fr);
        grid-template-rows: repeat(4, 72px);
    }
    .img-gen-slot-base {
        grid-row: span 2;
    }
    .img-gen-left {
        border-right: 0 !important;
    }
    .img-gen-preview-panel {
        width: 100%;
        border-left: 0;
        border-top: 1px solid var(--border);
        transform: none;
    }
    .img-gen-preview-panel.is-collapsed {
        display: none;
        width: 100%;
        opacity: 0;
        transform: none;
    }
    .img-gen-mask-studio {
        padding: 12px;
    }
    .img-gen-mask-studio-panel {
        width: 96vw;
        height: 88vh;
        border-radius: 14px;
    }
    .img-gen-mask-studio-head,
    .img-gen-mask-studio-foot {
        align-items: flex-start;
        flex-direction: column;
    }
    .img-gen-mask-studio-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .img-gen-mask-stage-large {
        min-height: 300px;
    }
}

:root[data-theme='light'] .img-gen-preview-panel {
    background: #ffffff;
}
:root[data-theme='light'] .img-gen-left {
    background: #ffffff;
}
:root[data-theme='light'] .img-gen-panel-head,
:root[data-theme='light'] .img-gen-preview-head {
    background: #f9fbff;
}
:root[data-theme='light'] .img-gen-preview-placeholder {
    background: #fbfcff;
}
:root[data-theme='light'] .img-gen-preview-panel.is-running::before {
    border-color: rgba(43,99,216,0.26);
    box-shadow: 0 0 0 1px rgba(43,99,216,0.08), 0 0 12px rgba(43,99,216,0.12);
}
:root[data-theme='light'] .img-gen-mask-block {
    background: #f6f9ff;
    border-color: rgba(43,99,216,0.16);
}
:root[data-theme='light'] .img-gen-slots-fixed .img-gen-slot {
    background: linear-gradient(145deg, #ffffff, #f5f8ff);
    border-color: rgba(43,99,216,0.16);
}
:root[data-theme='light'] .img-gen-slot-placeholder strong {
    color: #172033;
}
:root[data-theme='light'] .img-gen-drop-overlay {
    color: #17305f;
    background: rgba(43,99,216,0.14);
}
:root[data-theme='light'] .img-gen-primary-panel .img-gen-field > span,
:root[data-theme='light'] .img-gen-field > span {
    color: #66758f;
}
:root[data-theme='light'] .img-gen-advanced-chip {
    background: linear-gradient(135deg, #ffffff, #f3f7ff);
}
:root[data-theme='light'] .img-gen-mask-preview {
    background: #eef4ff;
}
:root[data-theme='light'] .img-gen-param-panel {
    background: #f8fbff;
    border-color: rgba(43,99,216,0.16);
}
:root[data-theme='light'] .img-gen-param-head {
    background: #ffffff;
}
:root[data-theme='light'] .img-gen-mask-stage {
    background: #eaf2ff;
}
:root[data-theme='light'] .img-gen-mask-btn {
    background: linear-gradient(135deg, #ffffff, #f4f7ff);
    color: #4c5870;
}
:root[data-theme='light'] .img-gen-mask-btn.is-primary {
    color: #ffffff;
    background: linear-gradient(135deg, #2f75ff, #1f56cf);
}
:root[data-theme='light'] .img-gen-mask-control {
    background: #ffffff;
    border-color: rgba(43,99,216,0.14);
}
:root[data-theme='light'] .img-gen-ref-intent,
:root[data-theme='light'] .img-gen-ref-weight,
:root[data-theme='light'] .img-gen-preview-actions button {
    background: rgba(255,255,255,0.82);
    color: #172033;
    border-color: rgba(43,99,216,0.16);
}
:root[data-theme='light'] .img-gen-ref-weight span {
    color: #66758f;
}
:root[data-theme='light'] .img-gen-prompt-assist {
    background: rgba(255,255,255,0.7);
    border-color: rgba(43,99,216,0.12);
}
:root[data-theme='light'] .img-gen-prompt-chip,
:root[data-theme='light'] .img-gen-seed-lock {
    background: rgba(43,99,216,0.045);
    border-color: rgba(43,99,216,0.12);
}
:root[data-theme='light'] .img-gen-mask-empty {
    background: #f8fbff;
}
:root[data-theme='light'] .img-gen-help-backdrop {
    background: rgba(223,231,246,0.46);
}
:root[data-theme='light'] .img-gen-help-panel {
    background: linear-gradient(145deg, rgba(255,255,255,0.97), rgba(246,249,255,0.95));
    box-shadow: 0 28px 80px rgba(61,83,123,0.22), inset 0 0 0 1px rgba(255,255,255,0.72);
}
:root[data-theme='light'] .img-gen-help-head {
    background: rgba(255,255,255,0.74);
}
:root[data-theme='light'] .img-gen-help-section {
    background: rgba(43,99,216,0.035);
    border-color: rgba(43,99,216,0.12);
}
:root[data-theme='light'] .img-gen-help-card,
:root[data-theme='light'] .img-gen-help-table > div {
    background: rgba(255,255,255,0.72);
    border-color: rgba(43,99,216,0.12);
}
:root[data-theme='light'] .img-gen-help-note {
    background: rgba(255,184,77,0.12);
    border-color: rgba(204,139,35,0.22);
    color: #243044;
}
:root[data-theme='light'] .img-gen-help-tag {
    background: rgba(43,99,216,0.08);
    border-color: rgba(43,99,216,0.15);
}
:root[data-theme='light'] .img-gen-help-close {
    background: #ffffff;
}
:root[data-theme='light'] .img-gen-mask-studio-backdrop {
    background:
        radial-gradient(circle at 18% 12%, rgba(43,99,216,0.18), transparent 32%),
        radial-gradient(circle at 78% 18%, rgba(41,188,103,0.08), transparent 28%),
        rgba(235,241,252,0.72);
}
:root[data-theme='light'] .img-gen-mask-studio-panel {
    background: linear-gradient(145deg, rgba(255,255,255,0.96), rgba(246,249,255,0.94));
    border-color: rgba(43,99,216,0.2);
    box-shadow: 0 34px 90px rgba(61,83,123,0.22), inset 0 0 0 1px rgba(255,255,255,0.8);
}
:root[data-theme='light'] .img-gen-mask-studio-head,
:root[data-theme='light'] .img-gen-mask-studio-foot {
    background: rgba(255,255,255,0.72);
    border-color: rgba(43,99,216,0.12);
}
:root[data-theme='light'] .img-gen-mask-studio-body {
    background:
        linear-gradient(rgba(43,99,216,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(43,99,216,0.05) 1px, transparent 1px),
        rgba(248,251,255,0.86);
    background-size: 22px 22px;
}
:root[data-theme='light'] .img-gen-mask-stage-large {
    background: #eef4ff;
}

/* Registration-style split login skin. Keeps the original login logic intact. */
.login-gate {
    position: fixed;
    inset: 0;
    z-index: 99999;
    padding: 0 !important;
    overflow: hidden;
    background: #ffffff !important;
    background-image: none !important;
    color: #111111;
}

.login-gate::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(90deg, #050505 0%, #050505 45vw, #ffffff 45vw, #ffffff 100%) !important;
}

.login-gate::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 45vw;
    z-index: 4;
    pointer-events: none;
    background:
        radial-gradient(circle at 26% 18%, rgba(255,255,255,0.12), transparent 28%),
        radial-gradient(circle at 82% 72%, rgba(255,255,255,0.06), transparent 34%),
        linear-gradient(rgba(255,255,255,0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: auto, auto, 72px 72px, 72px 72px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,1), rgba(0,0,0,0.86));
}

.login-canvas {
    z-index: 2;
    opacity: 0.3;
    mix-blend-mode: screen;
    clip-path: inset(0 55vw 0 0);
}

.login-noise {
    z-index: 3;
    opacity: 0.08;
    mix-blend-mode: normal;
    clip-path: inset(0 55vw 0 0);
    background-image: radial-gradient(rgba(255,255,255,0.16) 0.5px, transparent 0.5px);
    background-size: 3px 3px;
}

.login-halo {
    display: none !important;
}

.gate-step.login-panel-direct {
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
}

.gate-step.step-active.login-panel-direct {
    transform: none !important;
}

.login-scene {
    --login-tilt-x: 0deg;
    --login-tilt-y: 0deg;
    position: relative;
    z-index: 10;
    width: 100vw !important;
    height: 100vh !important;
    display: grid !important;
    grid-template-columns: minmax(420px, 45vw) minmax(0, 1fr);
    gap: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    perspective: 1200px;
    overflow: hidden;
}

.login-intro.login-split-copy {
    display: flex !important;
    position: relative;
    z-index: 11;
    grid-column: 1;
    width: 100%;
    max-width: none !important;
    min-height: 100vh !important;
    height: 100vh;
    padding: clamp(34px, 5vw, 68px) !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    color: #ffffff;
    transform-origin: center;
}

.login-intro.login-split-copy::before {
    content: "VS";
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin-bottom: auto;
    border: 1px solid rgba(255,255,255,0.32);
    border-radius: 999px;
    color: rgba(255,255,255,0.84);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
}

.login-intro.login-split-copy .login-kicker {
    margin: auto 0 0;
    color: rgba(255,255,255,0.52);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2em;
}

.login-intro.login-split-copy h1 {
    max-width: 620px;
    margin: 0;
    color: #ffffff !important;
    font-family: "Google Sans", "PingFang SC", "Noto Sans SC", sans-serif;
    font-size: clamp(46px, 6.4vw, 88px);
    font-weight: 300;
    line-height: 0.92;
    letter-spacing: -0.065em;
}

.login-intro.login-split-copy .login-subtitle {
    max-width: 460px;
    margin: 24px 0 14px;
    color: rgba(255,255,255,0.66) !important;
    font-size: 15px;
    line-height: 1.9;
}

.login-intro.login-split-copy .login-chip-grid {
    width: min(440px, 100%);
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.login-intro.login-split-copy .login-chip {
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0;
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.76);
    letter-spacing: 0.03em;
}

.login-intro.login-split-copy .login-chip .material-symbols-outlined {
    color: rgba(255,255,255,0.82);
}

.login-intro.login-split-copy .login-metrics {
    width: min(540px, 100%);
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    padding: 1px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.08);
}

.login-intro.login-split-copy .login-metric {
    min-height: 76px;
    padding: 14px;
    border: 0;
    border-radius: 0;
    background: rgba(0,0,0,0.22);
}

.login-intro.login-split-copy .login-metric strong {
    color: #ffffff;
    font-family: "Google Sans", monospace;
    font-size: 18px;
    font-weight: 500;
}

.login-intro.login-split-copy .login-metric span {
    color: rgba(255,255,255,0.54);
}

.login-form-box {
    grid-column: 2;
    align-self: center;
    justify-self: start;
    width: min(430px, 74%) !important;
    min-height: auto !important;
    height: auto !important;
    margin-left: clamp(56px, 9vw, 132px);
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transform-origin: center;
}

.login-form-box .form-value,
.login-form-box .form-value form {
    width: 100%;
}

.login-form-box h2 {
    margin: 0 0 42px;
    color: #111111 !important;
    text-align: left;
    font-family: "Google Sans", "PingFang SC", "Noto Sans SC", sans-serif;
    font-size: clamp(42px, 4.3vw, 60px);
    font-weight: 300;
    line-height: 1;
    letter-spacing: -0.055em;
}

.login-form-box .inputbox {
    margin: 31px 0;
    border-bottom: 1px solid #d4d4d8 !important;
}

.login-form-box .inputbox:focus-within {
    border-color: #111111 !important;
}

.login-form-box .inputbox input {
    height: 54px;
    color: #111111 !important;
    font-family: "Google Sans", "PingFang SC", "Noto Sans SC", sans-serif;
    font-size: 15px;
    letter-spacing: 0.01em;
}

.login-form-box .inputbox input[readonly] {
    color: #71717a !important;
}

.login-form-box .inputbox label {
    color: #71717a !important;
    font-size: 13px;
}

.login-form-box .inputbox input:focus ~ label,
.login-form-box .inputbox input:valid ~ label {
    color: #111111 !important;
}

.login-form-box .inputbox ion-icon {
    color: #71717a !important;
}

.login-form-box .forget {
    justify-content: flex-start;
    margin: -6px 0 28px;
    color: #71717a !important;
}

.login-form-box .forget input {
    accent-color: #111111;
}

.login-form-box button {
    position: relative;
    height: 58px;
    border-radius: 999px;
    background: #0a0a0a !important;
    color: #ffffff !important;
    overflow: hidden;
    box-shadow: none !important;
    transform: translateZ(0);
}

.login-form-box button::before {
    content: "";
    position: absolute;
    inset: -120%;
    background: linear-gradient(115deg, transparent 44%, rgba(255,255,255,0.28) 50%, transparent 56%);
    opacity: 0;
    transform: translateX(-38%);
    transition: opacity 0.24s ease;
}

.login-form-box button:hover {
    background: #0a0a0a !important;
    color: #ffffff !important;
    box-shadow: none !important;
    transform: scale(0.985);
}

.login-form-box button:hover::before {
    opacity: 1;
    animation: loginButtonSheen 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes loginButtonSheen {
    from { transform: translateX(-42%); }
    to { transform: translateX(42%); }
}

@media (max-width: 980px) {
    .login-gate {
        overflow-y: auto;
    }

    .login-gate::before {
        background: linear-gradient(180deg, #050505 0%, #050505 46vh, #ffffff 46vh, #ffffff 100%) !important;
    }

    .login-gate::after {
        width: 100vw;
        height: 46vh;
        bottom: auto;
    }

    .login-canvas,
    .login-noise {
        clip-path: inset(0 0 54vh 0);
    }

    .gate-step.login-panel-direct {
        min-height: 100vh;
        height: auto !important;
    }

    .login-scene {
        min-height: 100vh;
        height: auto !important;
        grid-template-columns: 1fr;
        grid-template-rows: minmax(46vh, auto) auto;
        overflow: visible;
    }

    .login-intro.login-split-copy {
        min-height: 46vh !important;
        height: auto;
        padding: 28px 24px 42px !important;
    }

    .login-intro.login-split-copy h1 {
        font-size: clamp(42px, 10vw, 72px);
    }

    .login-form-box {
        grid-column: 1;
        width: min(430px, calc(100vw - 44px)) !important;
        margin: 56px auto 64px;
    }
}

@media (max-width: 620px) {
    .login-intro.login-split-copy {
        gap: 18px;
    }

    .login-intro.login-split-copy::before,
    .login-intro.login-split-copy .login-chip-grid,
    .login-intro.login-split-copy .login-metrics {
        display: none;
    }

    .login-intro.login-split-copy h1 {
        font-size: 42px;
    }

    .login-form-box h2 {
        font-size: 40px;
        margin-bottom: 30px;
    }
}

/* Override legacy light-theme login masks so the right operation side stays white. */
:root[data-theme='light'] .login-gate {
    background: #ffffff !important;
    background-image: none !important;
}

:root[data-theme='light'] .login-gate::before {
    background: linear-gradient(90deg, #050505 0%, #050505 45vw, #ffffff 45vw, #ffffff 100%) !important;
}

:root[data-theme='light'] .login-gate::after {
    width: 45vw;
}

:root[data-theme='light'] .login-form-box {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

:root[data-theme='light'] .login-form-box h2,
:root[data-theme='light'] .login-form-box .inputbox input {
    color: #111111 !important;
}

:root[data-theme='light'] .login-form-box .inputbox label,
:root[data-theme='light'] .login-form-box .inputbox ion-icon,
:root[data-theme='light'] .login-form-box .forget {
    color: #71717a !important;
}

@media (max-width: 980px) {
    :root[data-theme='light'] .login-gate::before {
        background: linear-gradient(180deg, #050505 0%, #050505 46vh, #ffffff 46vh, #ffffff 100%) !important;
    }

    :root[data-theme='light'] .login-gate::after {
        width: 100vw;
    }
}
