/* --- 基礎設定 --- */
:root { --inv-scale: 1; }
body, html { 
    margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background-color: #1a1a1a; 
    color: #ddd; user-select: none; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}
body.dragging-over { background-color: #2a2a2a; box-shadow: inset 0 0 0 4px #888; }
#selection-box { position: fixed; border: 1px solid rgba(150, 150, 150, 0.5); background-color: rgba(150, 150, 150, 0.1); z-index: 9999; display: none; pointer-events: none; }

/* 🔒 禁止瀏覽器原生的圖片拖曳 */
.item img, .item video { -webkit-user-drag: none; user-drag: none; }

/* --- 路由節點 (Reroute) --- */
.reroute-item { width: 12px; height: 12px; background-color: #777; border: 1px solid #ccc; border-radius: 50%; box-shadow: 0 0 3px rgba(0,0,0,0.5); transition: background-color 0.2s, transform 0.1s, border-color 0.2s; z-index: 100; cursor: move; }
.reroute-item:hover { background-color: #999; border-color: #fff; transform: scale(1.2); }
.reroute-item.selected { background-color: #fff; border-color: #fff; transform: scale(1.3); box-shadow: 0 0 8px rgba(255,255,255,0.5); z-index: 110; }
.reroute-item .resize-handle { display: none !important; }
.reroute-item .node-port { display: none !important; }

/* --- 收合按鈕 --- */
.collapse-btn { position: absolute; top: -8px; right: -8px; width: 14px; height: 14px; background-color: #222; border: 1px solid #777; border-radius: 50%; color: #aaa; font-size: 12px; line-height: 10px; text-align: center; cursor: pointer; z-index: 1500; display: none; user-select: none; box-shadow: 0 1px 3px rgba(0,0,0,0.5); transition: all 0.2s; transform-origin: center center; transform: scale(var(--inv-scale)); }
.collapse-btn:hover { background-color: #444; border-color: #bbb; color: #fff; }
.item.collapsed .collapse-btn { background-color: #333; color: #ccc; border-color: #ccc; font-weight: normal; }
.item.collapsed .collapse-btn:hover { background-color: #444; border-color: #fff; color: #fff; }
.collapse-btn[data-count]::after { content: attr(data-count); position: absolute; top: -6px; right: -8px; background-color: #444; color: #ccc; border: 1px solid #666; font-size: 9px; font-weight: normal; padding: 0px 3px; border-radius: 6px; min-width: 6px; line-height: 10px; display: none; pointer-events: none; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.item.collapsed .collapse-btn[data-count]::after { display: block; }
.item.hidden { opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }

/* --- 連線系統 --- */
.connection-wrapper { cursor: context-menu; pointer-events: auto; }
.connection-hit { fill: none; stroke: transparent; stroke-width: 15px; pointer-events: stroke; }
.connection-line { fill: none; stroke: #888; stroke-width: 1.5px; filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.3)); pointer-events: none; transition: stroke-width 0.1s, stroke 0.1s, opacity 0.3s ease; marker-end: url(#arrow-normal); }
.connection-wrapper:hover .connection-line { stroke-width: 2.5px; stroke: #ccc; marker-end: url(#arrow-hover); }
.connection-wrapper.hidden-line { opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }

/* --- 輔助線 (Smart Guides) --- */
#guide-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5000; overflow: visible; }
.guide-line { stroke: #00aaff; stroke-width: 1px; stroke-dasharray: 4 2; opacity: 0.8; pointer-events: none; }
.guide-line.docking { stroke: #4caf50; stroke-width: 2px; stroke-dasharray: none; filter: drop-shadow(0 0 2px rgba(76, 175, 80, 0.8)); opacity: 1; z-index: 9999; }

/* --- 字型下拉選單 --- */
.font-select { background: transparent; color: #aaa; border: 1px solid transparent; border-radius: 4px; padding: 2px 4px; font-size: 12px; cursor: pointer; outline: none; margin: 0 4px; max-width: 90px; font-family: inherit; transition: all 0.2s; }
.font-select:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: #555; }
.font-select option { background: #222; color: #fff; }

/* --- 懸浮工具列 --- */
.item-toolbar { position: absolute; top: -38px; left: 0; width: 100%; height: 38px; display: flex; justify-content: center; align-items: flex-start; padding-top: 5px; padding-bottom: 10px; box-sizing: border-box; z-index: 1000; opacity: 0; visibility: hidden; transform-origin: bottom center; transform: scale(var(--inv-scale)); transition: opacity 0.2s ease, visibility 0s 0.2s; }
.item-toolbar::after { content: ''; position: absolute; bottom: -15px; left: 0; width: 100%; height: 20px; background: transparent; z-index: -1; pointer-events: none; }
.item.selected .item-toolbar { opacity: 1; visibility: visible; transition-delay: 0s; }
.tool-btn { width: 28px; height: 28px; margin: 0 2px; background: rgba(30, 30, 30, 0.9); border: 1px solid #444; border-radius: 4px; color: #aaa; display: flex; align-items: center; justify-content: center; cursor: pointer; pointer-events: auto; transition: all 0.1s ease; backdrop-filter: blur(4px); box-shadow: 0 2px 4px rgba(0,0,0,0.3); font-size: 12px; font-weight: bold; }
.tool-btn svg { width: 16px; height: 16px; stroke-width: 1.5px; stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; pointer-events: none; }
.tool-btn:hover { background: #444; color: #fff; transform: translateY(-1px); border-color: #888; }
.tool-btn.delete-btn { border-color: #533; background: rgba(50, 20, 20, 0.9); color: #c66; margin-left: 6px; }
.tool-btn.delete-btn:hover { background: #800; border-color: #d00; color: #fff; }
.tool-btn.active { color: #fff; background-color: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.3); box-shadow: 0 0 8px rgba(0, 0, 0, 0.2); }

/* --- Splash & Header --- */
#splash-screen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100vw; height: 100vh; background-color: #1a1a1a; z-index: 50000; display: flex; align-items: center; justify-content: center; opacity: 1; transition: opacity 1.5s ease-out; pointer-events: none; margin: 0; padding: 0; }
#splash-screen.active { pointer-events: auto; }
#splash-logo { max-width: 500px; width: 40%; height: auto; max-height: 50vh; object-fit: contain; filter: drop-shadow(0 0 30px rgba(0,0,0,0.8)); animation: breathe 3s ease-in-out infinite; margin: auto; display: block; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.03); opacity: 0.9; } }

#top-header { position: fixed; top: 0; left: 0; width: 100%; height: 50px; background: rgba(20, 20, 20, 0.95); backdrop-filter: blur(10px); border-bottom: 1px solid #333; z-index: 10001; display: flex; align-items: center; padding: 0 15px; box-sizing: border-box; gap: 15px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
#project-name-wrapper { display: flex; align-items: center; border-right: 1px solid #444; padding-right: 15px; height: 30px; }
#project-name { font-size: 16px; font-weight: 600; color: #eee; padding: 4px 8px; border-radius: 4px; border: 1px solid transparent; cursor: text; transition: all 0.2s; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
#project-name:hover { background: rgba(255,255,255,0.1); }
#project-name:focus { background: #000; border-color: #666; outline: none; cursor: text; }

#toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; overflow-x: auto; height: 100%; padding-right: 60px; }
#toolbar::-webkit-scrollbar { display: none; }
#toolbar button { background: transparent; color: #aaa; border: 1px solid transparent; padding: 6px; cursor: pointer; border-radius: 6px; transition: 0.15s; min-width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
#toolbar button:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: #555; }
#toolbar button svg { width: 18px; height: 18px; stroke-width: 2px; stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; }
#toolbar button.active { background: #444; color: #fff; border-color: #666; }
/* 🔥 唯讀模式下，被鎖定的按鈕樣式 */
#toolbar button.locked-feature { opacity: 0.4; cursor: pointer; position: relative; }
#toolbar button.locked-feature:hover { background: rgba(255, 100, 100, 0.1); border-color: rgba(255, 100, 100, 0.3); color: #ff8888; }
.separator { width: 1px; height: 24px; background: #444; margin: 0 4px; flex-shrink: 0; }

#btn-lang { position: absolute; right: 10px; top: 7px; background: transparent; color: #aaa; border: 1px solid transparent; padding: 6px; cursor: pointer; border-radius: 6px; transition: 0.15s; min-width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
#btn-lang:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: #555; }
#btn-lang svg { width: 18px; height: 18px; stroke-width: 2px; stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* 🔥 PRO Upgrade Button (Web Demo Only) */
#btn-upgrade {
    position: absolute; right: 56px; top: 9px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #1a1a1a; 
    border: 1px solid #DAA520;
    font-weight: 800; font-family: 'JetBrains Mono', monospace; font-size: 12px;
    padding: 0 12px; height: 32px; border-radius: 4px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    text-decoration: none; box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    transition: all 0.2s ease; z-index: 4000;
}
#btn-upgrade:hover { transform: scale(1.05); box-shadow: 0 0 15px rgba(255, 215, 0, 0.6); color: #000; }
#btn-upgrade:active { transform: scale(0.95); }

/* 🔥 Upgrade Modal (Popup) */
#upgrade-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(8px);
    z-index: 99999; display: none; opacity: 0; transition: opacity 0.3s ease;
    align-items: center; justify-content: center;
}
#upgrade-modal.active { display: flex; opacity: 1; }
.modal-content {
    background: #222; border: 1px solid #444; border-radius: 12px;
    width: 400px; max-width: 90%; padding: 30px;
    text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    transform: translateY(20px); transition: transform 0.3s ease;
}
#upgrade-modal.active .modal-content { transform: translateY(0); }
.modal-icon { font-size: 48px; margin-bottom: 20px; display: block; filter: drop-shadow(0 0 10px rgba(255,215,0,0.5)); }
.modal-title { font-size: 22px; color: #fff; margin: 0 0 10px 0; font-weight: bold; }
.modal-desc { font-size: 14px; color: #aaa; line-height: 1.6; margin-bottom: 25px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.btn-primary { 
    background: #FFD700; color: #000; border: none; padding: 10px 24px; 
    border-radius: 6px; font-weight: bold; cursor: pointer; text-decoration: none; 
    font-size: 14px; transition: 0.2s; 
}
.btn-primary:hover { background: #ffea70; transform: translateY(-2px); }
.btn-secondary {
    background: transparent; color: #aaa; border: 1px solid #555; padding: 10px 24px;
    border-radius: 6px; cursor: pointer; font-size: 14px; transition: 0.2s;
}
.btn-secondary:hover { border-color: #888; color: #fff; }


#file-input, #logo-input { display: none; }
#status { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); color: #00ffaa; background: rgba(0,0,0,0.9); padding: 8px 24px; border-radius: 8px; pointer-events: none; opacity: 0; transition: opacity 0.5s; z-index: 9999; border: 1px solid #444; font-family: monospace; box-shadow: 0 4px 12px rgba(0,0,0,0.5); font-size: 14px; }

/* --- Help Panel --- */
#help-container { position: fixed; bottom: 20px; right: 20px; z-index: 4000; display: flex; flex-direction: column; align-items: flex-end; }
#help-btn { width: 40px; height: 40px; border-radius: 50%; background: #333; color: #fff; border: 2px solid #666; font-size: 18px; font-weight: bold; box-shadow: 0 4px 10px rgba(0,0,0,0.5); cursor: help; transition: 0.2s; }
#help-btn:hover { background: #555; border-color: #fff; transform: scale(1.1); }
#help-panel { display: none; background: rgba(0, 0, 0, 0.95); border: 1px solid #666; border-radius: 8px; padding: 16px; margin-bottom: 12px; min-width: 320px; backdrop-filter: blur(10px); color: #ddd; font-size: 13px; line-height: 1.6; box-shadow: 0 5px 25px rgba(0,0,0,0.7); pointer-events: none; opacity: 0; transition: opacity 0.2s; transform: translateY(10px); }
#help-container:hover #help-panel { display: block; opacity: 1; pointer-events: auto; transform: translateY(0); }
#help-panel b { color: #fff; display: block; border-bottom: 1px solid #555; padding-bottom: 8px; margin-bottom: 10px; font-size: 14px; }
#help-panel div { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; border-bottom: 1px dashed #333; padding-bottom: 4px; }
#help-panel div:last-child { border-bottom: none; margin-bottom: 0; }
#help-panel div span:first-child { color: #fff; font-weight: bold; background: #444; padding: 2px 8px; border-radius: 4px; border: 1px solid #666; font-family: Consolas, monospace; font-size: 12px; min-width: 20px; text-align: center; box-shadow: 0 2px 0 #222; white-space: nowrap; }
#help-panel div span:last-child { color: #ccc; font-weight: normal; text-align: right; margin-left: 10px; }
.help-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; padding-top: 12px; border-top: 1px solid #444; }
.footer-logo { height: 100px; width: auto; opacity: 1.0; border-radius: 4px; margin-right: 15px; }
.footer-info { text-align: right; display: flex; flex-direction: column; gap: 4px; }
.footer-row-top { font-size: 14px; color: #eee; }
.version-tag { font-size: 10px; background: #333; border: 1px solid #555; padding: 1px 4px; border-radius: 3px; color: #aaa; margin-left: 4px; vertical-align: middle; }
.footer-row-bottom { font-size: 10px; color: #666; line-height: 1.3; }

/* Language Menu */
#lang-container { position: fixed; top: 60px; right: 10px; z-index: 4000; }
.popover-panel { display: none; background: rgba(0, 0, 0, 0.9); border: 1px solid #666; border-radius: 8px; padding: 15px; margin-bottom: 10px; min-width: 150px; backdrop-filter: blur(10px); color: #ddd; font-size: 13px; line-height: 1.6; box-shadow: 0 5px 20px rgba(0,0,0,0.6); pointer-events: auto; opacity: 0; transition: opacity 0.2s; }
.popover-panel.active { display: block; opacity: 1; }
#lang-menu div { padding: 8px 12px; cursor: pointer; border-radius: 4px; transition: 0.1s; display: flex; justify-content: space-between; }
#lang-menu div:hover { background: rgba(255,255,255,0.1); color: #fff; }
#lang-menu div.active { background: #444; color: #fff; }

/* --- Canvas --- */
#viewport { width: 100%; height: 100%; position: relative; background-image: radial-gradient(#333 1px, transparent 1px); background-size: 20px 20px; transform-origin: 0 0; margin-top: 50px; }
#canvas-content { position: absolute; top: 0; left: 0; transform-origin: 0 0; width: 0; height: 0; }
.item { position: absolute; border: 2px solid transparent; box-sizing: border-box; z-index: 10; transition: opacity 0.3s ease; }
.item.selected { border: 2px solid #ccc; z-index: 20; } 
#connection-layer { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; z-index: 0; }
#drag-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; overflow: visible; }

/* --- 連接點 --- */
.node-port { position: absolute; width: 9px; height: 9px; background: #444; border: 1px solid #777; border-radius: 50%; cursor: crosshair; opacity: 0; transition: opacity 0.2s, background 0.2s, transform 0.2s, border-color 0.2s; z-index: 100; user-select: none; }
.item:hover .node-port { opacity: 1; }
.node-port:hover { background: #999; border-color: #fff; transform: scale(1.2); box-shadow: 0 0 5px rgba(255,255,255,0.3); }
.node-port:active { background: #fff; border-color: #fff; }
.node-input-left { left: -6px; top: 50%; transform: translateY(-50%); }
.node-output-right { right: -6px; top: 50%; transform: translateY(-50%); }
.node-input-top { top: -6px; left: 50%; transform: translateX(-50%); }
.node-output-bottom { bottom: -6px; left: 50%; transform: translateX(-50%); }
.node-input-left:hover { transform: translateY(-50%) scale(1.2); }
.node-output-right:hover { transform: translateY(-50%) scale(1.2); }
.node-input-top:hover { transform: translateX(-50%) scale(1.2); }
.node-output-bottom:hover { transform: translateX(-50%) scale(1.2); }

.media-item { width: 300px; }
.media-item img, .media-item video { display: block; width: 100%; height: auto; pointer-events: none; background: #000; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.video-icon { position: absolute; top: 5px; left: 5px; width: 24px; height: 24px; background: rgba(0, 0, 0, 0.6); border-radius: 50%; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.video-icon::after { content: ''; display: block; width: 0; height: 0; border-style: solid; border-width: 5px 0 5px 8px; border-color: transparent transparent transparent #fff; transform: translateX(1px); }
.media-item:hover .video-icon, .media-item.playing .video-icon { opacity: 0; }
.file-name-label { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.5); color: #ccc; padding: 1px 5px; border-radius: 3px; font-size: 10px; white-space: nowrap; pointer-events: none; display: none; z-index: 20; max-width: 200px; overflow: hidden; text-overflow: ellipsis; border: 1px solid #444; }
body.show-names .file-name-label { display: block; }

/* 影片控制 Bar */
.video-scrubber { position: absolute; bottom: 0; left: 0; width: 100%; height: 12px; background: transparent; z-index: 20; cursor: pointer; display: flex; align-items: flex-end; }
.video-progress-bg { width: 100%; height: 2px; background: rgba(255, 255, 255, 0.2); transition: height 0.15s ease-out; position: relative; }
.video-progress-fill { height: 100%; width: 0%; background: #00aaff; pointer-events: none; position: relative; }
.video-thumb { width: 10px; height: 10px; background: #fff; border-radius: 50%; position: absolute; top: 50%; left: 100%; transform: translate(-50%, -50%) scale(0); transition: transform 0.15s ease-out; pointer-events: none; box-shadow: 0 0 5px rgba(0,0,0,0.5); }
.video-scrubber:hover .video-progress-bg { height: 4px; }
.video-scrubber:hover .video-thumb { transform: translate(-50%, -50%) scale(1); }
.video-timecode { position: absolute; bottom: 16px; left: 8px; background: rgba(10, 10, 10, 0.75); backdrop-filter: blur(4px); color: #eee; font-family: 'JetBrains Mono', monospace; font-size: 11px; padding: 3px 6px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.15); pointer-events: none; z-index: 15; opacity: 0; transition: opacity 0.2s ease-in-out; }
.media-item:hover .video-timecode, .item.selected .video-timecode { opacity: 1; }

/* 筆記元件 */
.note-item { min-width: 150px; background-color: transparent; border: 1px dashed rgba(150,150,150,0.3); color: #eee; padding: 0px; font-size: 16px; cursor: grab; outline: none; white-space: pre-wrap; transition: background-color 0.2s, border 0.2s; user-select: none; line-height: 1.5; }
.note-item:hover { border: 1px solid rgba(150,150,150,0.6); background-color: rgba(0,0,0,0.3); }
.note-item.has-color:hover { background-color: var(--bg-color); }
.note-item.editing { cursor: text; user-select: text; border: 1px solid #ccc !important; background-color: rgba(0,0,0,0.6); box-shadow: 0 4px 15px rgba(0,0,0,0.5); z-index: 2000; }
.note-item.empty::before { display: none; }
.note-content { position: relative; padding: 10px; box-sizing: border-box; width: 100%; min-height: 24px; outline: none; white-space: pre-wrap; }
.note-content.empty::before { content: attr(data-placeholder); color: rgba(255, 255, 255, 0.4); pointer-events: none; position: absolute; top: 10px; left: 10px; }
.note-picker { position: absolute; top: -20px; left: 2px; width: 18px; height: 18px; border: 1px solid #aaa; border-radius: 3px; padding: 0; background: none; cursor: pointer; z-index: 2001; opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0s 0.2s; }
.note-item.selected .note-picker, .note-item.editing .note-picker { opacity: 1; visibility: visible; transition-delay: 0s; }

/* 群組與對比 */
.group-item { background-color: rgba(255, 255, 255, 0.05); border: 1px dashed #555; border-radius: 8px; padding-top: 35px; min-width: 50px; min-height: 50px; transition: width 0.2s, height 0.2s, left 0.2s, top 0.2s, background-color 0.2s; }
.group-item.selected { border: 1px solid #ccc; }
.group-item.drag-hover { background-color: rgba(200, 200, 200, 0.1) !important; border-color: #ccc; }
.group-header { position: absolute; top: 0; left: 0; right: 0; height: 24px; background: rgba(50,50,50,0.5); border-radius: 6px 6px 0 0; display: flex; align-items: center; padding: 0 8px; cursor: move; }
.group-title { flex-grow: 1; color: #ccc; font-size: 11px; border: none; background: transparent; outline: none; cursor: text; }
.group-color-picker { width: 14px; height: 14px; border: none; padding: 0; background: none; cursor: pointer; opacity: 0.5; }
.group-color-picker:hover { opacity: 1; }
.resize-handle { position: absolute; bottom: -5px; right: -5px; width: 10px; height: 10px; background: #888; border: 1px solid #333; cursor: nwse-resize; border-radius: 50%; z-index: 1002; display: none; user-select: none; }
.item:hover .resize-handle, .item.selected .resize-handle { display: block; }
.compare-item { background: #000; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.6); }
.compare-item img, .compare-item video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.img-front-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
.compare-handle { position: absolute; top: 0; bottom: 0; width: 30px; background: transparent; cursor: col-resize; z-index: 100; transform: translateX(-50%); pointer-events: auto; display: flex; justify-content: center; }
.compare-handle::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; background: rgba(255,255,255,0.5); transform: translateX(-50%); transition: all 0.1s; }
.compare-handle:hover::after { background: rgba(255,255,255,0.9); box-shadow: 0 0 5px rgba(255,255,255,0.5); }
.compare-handle.dragging::after { width: 1px; background: #fff; opacity: 0.8; }
.handle-circle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.8); font-size: 16px; font-weight: bold; pointer-events: none; white-space: nowrap; transition: opacity 0.1s; }
.compare-handle.dragging .handle-circle { opacity: 0; }

/* 暫時隱藏 Logo 更換按鈕 */
#btn-logo { display: none !important; }

/* 簡報模式與特殊效果 */
body.mode-presentation { background-color: #000 !important; overflow: hidden; cursor: none !important; }
body.mode-presentation * { cursor: none !important; }
body.mode-presentation .item-toolbar, body.mode-presentation .resize-handle, body.mode-presentation .node-port, body.mode-presentation #selection-box, body.mode-presentation .group-header, body.mode-presentation .file-name-label, body.mode-presentation #connection-layer, body.mode-presentation #status, body.mode-presentation #top-header, body.mode-presentation #help-container, body.mode-presentation .collapse-btn, body.mode-presentation .video-icon, body.mode-presentation #minimap-container, body.mode-presentation #minimap-toggle-btn { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; transition: opacity 0.3s ease, visibility 0.3s ease !important; }
body.mode-presentation #canvas-content { transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1); }
body.mode-presentation .item.selected { border-color: transparent !important; outline: none !important; box-shadow: none !important; }
body.mode-presentation .youtube-title-bar { display: none !important; }
body.mode-presentation #laser-pointer { display: block; }
#laser-pointer { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 99999; display: none; }
.laser-core { position: absolute; width: 12px; height: 12px; background-color: #fff; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 5px #ff0055, 0 0 10px #ff0055, 0 0 20px #ff0055, 0 0 40px #ff0000; will-change: transform; z-index: 100001; transition: width 0.15s ease-out, height 0.15s ease-out, box-shadow 0.15s ease-out; }
.laser-core.clicking { width: 30px; height: 30px; background-color: #fff; box-shadow: 0 0 20px #ff0055, 0 0 50px #ff0055, 0 0 100px #ff3377; }
.trail-dot { position: fixed; width: 10px; height: 10px; background-color: #ffffff; border-radius: 50%; pointer-events: none; z-index: 100000; box-shadow: 0 0 4px #ff0055, 0 0 10px #ff0055, 0 0 20px #ff0055, 0 0 30px #ff0055; mix-blend-mode: screen; animation: fadeOut 0.2s linear forwards; will-change: transform, opacity; }
@keyframes fadeOut { 0% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; } }
.highlight-new { animation: flashHighlight 0.8s ease-out forwards; z-index: 9999 !important; }
@keyframes flashHighlight { 0% { box-shadow: 0 0 0 4px #00aaff, 0 0 30px #00aaff; border-color: #00aaff; transform: scale(1.05); } 50% { box-shadow: 0 0 0 2px rgba(0, 170, 255, 0.5), 0 0 15px rgba(0, 170, 255, 0.5); transform: scale(1); } 100% { box-shadow: none; } }

/* 富文本 Popup */
#rich-text-popup { position: fixed; display: none; justify-content: center; align-items: center; padding: 4px; background: rgba(20, 20, 20, 0.95); border: 1px solid #555; border-radius: 8px; box-shadow: 0 8px 20px rgba(0,0,0,0.6); z-index: 999999; transform: translateX(-50%); backdrop-filter: blur(8px); opacity: 0; transition: opacity 0.15s ease-out; pointer-events: auto; }
#rich-text-popup.active { display: flex; opacity: 1; }
#rich-text-popup .tool-btn { margin: 0 2px; width: 28px; height: 28px; background: transparent; border: none; box-shadow: none; }
#rich-text-popup .tool-btn:hover { background: #444; }
.color-split-group { display: flex; align-items: center; margin: 0 4px; border: 1px solid #555; border-radius: 4px; overflow: hidden; height: 24px; background: transparent; transition: 0.2s; }
.color-split-group:hover { border-color: #fff; }
.color-apply-btn { width: 24px; height: 100%; display: flex; justify-content: center; align-items: center; cursor: pointer; background: transparent; }
.color-apply-btn:hover { background: rgba(255,255,255,0.15); }
.color-indicator { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.4); pointer-events: none; }
.color-picker-trigger { width: 12px; height: 100%; padding: 0; border: none; border-left: 1px solid #555; background: transparent; cursor: pointer; }
.color-picker-trigger::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-trigger::-webkit-color-swatch { border: none; border-radius: 0; }

/* FPS 選單 */
#project-fps-select { background: transparent; color: #aaa; border: 1px solid transparent; border-radius: 6px; padding: 2px 8px; font-size: 13px; font-weight: bold; font-family: 'JetBrains Mono', monospace, sans-serif; cursor: pointer; outline: none; height: 36px; margin-left: 4px; transition: all 0.15s; }
#project-fps-select:hover { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: #555; }
#project-fps-select option { background: #222; color: #fff; }

/* 音效元件 */
.audio-item { background: rgba(20, 20, 20, 0.85); border: 1px solid rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px); border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; width: 300px; height: 80px; }
.audio-waveform-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: pointer; z-index: 5; }
.audio-drag-zone { position: absolute; top: 0; left: 0; width: 100%; height: 35%; z-index: 10; cursor: grab; }
.audio-drag-zone:active { cursor: grabbing; }
.audio-item .file-name-label { position: absolute; top: 6px; left: 12px; bottom: auto; background: transparent; font-size: 11px; color: #aaa; font-weight: bold; pointer-events: none; z-index: 15; }

/* 批註模式 */
body.markup-mode #toolbar { transform: translateY(-100%); opacity: 0; }
body.markup-mode #canvas-container { background-color: #050505; }
body.markup-mode #connection-layer { opacity: 0.05; filter: blur(2px); transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); pointer-events: none; }
body.markup-mode #canvas-content .item:not(.markup-active) { opacity: 0.15; filter: blur(4px) grayscale(50%); pointer-events: none; transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
body.markup-mode #canvas-content .item.markup-active { z-index: 100; box-shadow: 0 0 40px rgba(0, 170, 255, 0.2); transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
#markup-topbar { position: fixed; top: -60px; left: 0; width: 100%; height: 50px; background: rgba(15, 15, 15, 0.95); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255, 70, 70, 0.4); display: flex; justify-content: center; align-items: center; gap: 16px; color: #ff4444; font-family: 'JetBrains Mono', sans-serif; font-size: 13px; letter-spacing: 1px; z-index: 20000; transition: top 0.4s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 0 4px 20px rgba(0,0,0,0.5); pointer-events: auto; }
body.markup-mode #markup-topbar { top: 0; }
body.markup-mode #top-header { transform: translateY(-100%) !important; opacity: 0 !important; pointer-events: none !important; }

.markup-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 50; cursor: crosshair; touch-action: none; display: none; }
.item.has-markup .markup-canvas { display: block; pointer-events: none; }
.item.markup-active .markup-canvas { display: block; pointer-events: auto !important; }
.item.markup-active .video-scrubber { display: block !important; z-index: 60; }
.item.has-markup::after { content: ''; position: absolute; top: -6px; right: -6px; width: 14px; height: 14px; background-color: #ff4444; border: 2px solid #1a1a1a; border-radius: 50%; box-shadow: 0 0 10px #ff4444, 0 0 20px #ff0000; z-index: 200; animation: pulse-red 2s infinite; pointer-events: none; transform-origin: top right; transform: scale(var(--inv-scale)); }
@keyframes pulse-red { 0% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(255, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); } }
.item.markup-active.has-markup::after { display: none; }
.markup-controls { display: flex; align-items: center; gap: 12px; margin-left: 16px; padding-left: 16px; border-left: 1px solid rgba(255,255,255,0.2); }
.markup-controls input[type="color"] { width: 24px; height: 24px; border: none; border-radius: 4px; cursor: pointer; background: transparent; padding: 0; }
.markup-controls input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.markup-controls input[type="color"]::-webkit-color-swatch { border: 1px solid #777; border-radius: 4px; }
.markup-controls input[type="range"] { width: 80px; cursor: pointer; accent-color: #ff4444; }
.markup-size-label { color: #fff; width: 24px; font-weight: bold; }
.markup-clear-btn { background: rgba(255, 50, 50, 0.2); border: 1px solid rgba(255, 50, 50, 0.5); color: #ffaaaa; padding: 2px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; transition: 0.2s; }
.markup-clear-btn:hover { background: #ff4444; color: #fff; }
.markup-mic-btn { background: transparent; border: 1px solid #555; color: #ccc; padding: 2px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: bold; transition: 0.2s; display: flex; align-items: center; gap: 4px; user-select: none; }
.markup-mic-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.markup-mic-btn:active { transform: scale(0.95); background: #ff4444; color: #fff; border-color: #ff4444; }
.markup-mic-btn.recording { background: rgba(255, 50, 50, 0.2); border-color: #ff4444; color: #ff4444; animation: pulse-recording 1s infinite; }
@keyframes pulse-recording { 0% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.5); } 70% { box-shadow: 0 0 0 6px rgba(255, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); } }

/* 小地圖 */
#minimap-toggle-btn { position: fixed; bottom: 24px; left: 24px; width: 36px; height: 36px; border-radius: 8px; background: rgba(20, 20, 20, 0.85); border: 1px solid rgba(255, 255, 255, 0.15); color: #ccc; display: flex; justify-content: center; align-items: center; cursor: pointer; z-index: 4001; backdrop-filter: blur(12px); transition: all 0.2s; }
#minimap-toggle-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; transform: scale(1.05); }
#minimap-toggle-btn svg { width: 18px; height: 18px; }
.icon-eye-closed { display: none; }
#minimap-toggle-btn.is-hidden .icon-eye-open { display: none; }
#minimap-toggle-btn.is-hidden .icon-eye-closed { display: block; color: #888; }
#minimap-container { position: fixed; bottom: 24px; left: 72px; width: 240px; height: 160px; background: rgba(20, 20, 20, 0.85); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 8px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6); z-index: 4000; overflow: hidden; backdrop-filter: blur(12px); cursor: crosshair; transform-origin: bottom left; transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s; }
#minimap-container:hover { border-color: rgba(255, 255, 255, 0.3); }
#minimap-container.is-hidden { opacity: 0; transform: scale(0.9) translateX(-10px); pointer-events: none; }
#minimap-content { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.minimap-node { position: absolute; background: rgba(255, 255, 255, 0.25); border-radius: 2px; }
.minimap-node.is-selected { background: rgba(255, 255, 255, 0.9) !important; box-shadow: 0 0 6px #fff; }
#minimap-viewport { position: absolute; border: 1.5px solid #ff4444; background: rgba(255, 68, 68, 0.05); box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); pointer-events: none; box-sizing: border-box; }

/* 語音小節點 */
.image-voice-panel { position: absolute; bottom: 8px; left: 8px; display: flex; flex-direction: row; gap: 6px; z-index: 150; pointer-events: auto; }
.image-voice-wrapper { position: relative; display: flex; justify-content: center; align-items: center; }
.image-voice-btn { width: 16px; height: 16px; border-radius: 50%; background: rgba(0, 170, 255, 0.8); border: 1px solid #1a1a1a; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.5); transition: all 0.2s; padding: 0; display: flex; justify-content: center; align-items: center; color: #fff; font-size: 10px; font-weight: bold; font-family: 'JetBrains Mono', monospace; z-index: 20 !important; position: relative !important; }
.image-voice-btn:hover { background: #00aaff; transform: scale(1.15); }
.image-voice-btn.playing { background: #ff4444; border-color: #fff; animation: pulse-red 1s infinite; }
.voice-delete-btn { position: absolute !important; top: -18px; left: 50%; transform: translateX(-50%) scale(0.5); width: 14px; height: 14px; background: #ff4444; color: #fff; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 10px; font-weight: bold; cursor: pointer; opacity: 0; visibility: hidden; pointer-events: none; transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); border: 1px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.5); z-index: 20 !important; }
.item.markup-active .image-voice-wrapper:hover .voice-delete-btn { opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(-50%) scale(1); }
.item.markup-active .image-voice-panel { opacity: 0.5; transition: 0.2s; }
.item.markup-active .image-voice-panel:hover { opacity: 1; }
.image-voice-wrapper::before { content: ''; position: absolute; top: -30px; bottom: -10px; left: -10px; right: -10px; z-index: 1 !important; }

/* 時間軸標記 */
.voice-marker, .markup-marker { position: absolute !important; top: 50% !important; width: 20px !important; height: 20px !important; margin: 0 !important; padding: 0 !important; transform: translate(-50%, -50%) !important; display: block !important; cursor: pointer; z-index: 15 !important; }
.voice-marker::after, .markup-marker::after { content: '' !important; position: absolute !important; left: 50% !important; width: 6px !important; height: 6px !important; border-radius: 50% !important; transform: translate(-50%, -50%) !important; transition: transform 0.15s, background-color 0.1s !important; display: block !important; margin: 0 !important; }
.voice-marker::after { top: -2px !important; background: #00aaff !important; box-shadow: 0 0 6px #00aaff !important; }
.markup-marker::after { top: 22px !important; background: #ff4444 !important; box-shadow: 0 0 6px #ff0000 !important; }
.voice-marker:hover::after, .markup-marker:hover::after { transform: translate(-50%, -50%) scale(1.5) !important; background: #fff !important; }
.timeline-voice-delete-btn, .timeline-markup-delete-btn { position: absolute !important; left: 50% !important; margin: 0 !important; width: 16px !important; height: 16px !important; border-radius: 50% !important; background: #ff4444 !important; color: #fff !important; display: flex !important; justify-content: center !important; align-items: center; font-size: 11px !important; font-weight: bold !important; cursor: pointer; opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; transition: 0.2s !important; border: 1px solid #fff !important; box-shadow: 0 2px 5px rgba(0,0,0,0.5) !important; z-index: 20 !important; transform-origin: center center !important; }
.timeline-voice-delete-btn { top: -22px !important; transform: translate(-50%, -50%) scale(0.5) !important; }
.timeline-markup-delete-btn { top: 42px !important; transform: translate(-50%, -50%) scale(0.5) !important; }
.item.markup-active .voice-marker:hover .timeline-voice-delete-btn, .item.markup-active .markup-marker:hover .timeline-markup-delete-btn { opacity: 1 !important; visibility: visible !important; pointer-events: auto !important; transform: translate(-50%, -50%) scale(1) !important; }
.timeline-voice-delete-btn:hover, .timeline-markup-delete-btn:hover { background: #cc0000 !important; transform: translate(-50%, -50%) scale(1.2) !important; }
.voice-marker::before, .markup-marker::before { content: '' !important; position: absolute !important; left: -10px !important; right: -10px !important; z-index: 1 !important; display: block !important; background: transparent !important; }
.voice-marker::before { top: -36px !important; bottom: 10px !important; }
.markup-marker::before { top: 10px !important; bottom: -36px !important; }

/* 禪模式 (Zen Mode) */
:root { --zen-anim: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
body.zen-mode #top-header { transform: translateY(-100%); opacity: 0; pointer-events: none; transition: var(--zen-anim); }
body.zen-mode #help-container, body.zen-mode #minimap-toggle-btn, body.zen-mode #minimap-container, body.zen-mode #status { transform: translateY(150%); opacity: 0; pointer-events: none; transition: var(--zen-anim); }
#top-header, #help-container, #minimap-toggle-btn, #minimap-container, #status { transition: var(--zen-anim); }
body.zen-mode #canvas-container { background-image: radial-gradient(circle, #444 1px, transparent 1px) !important; background-color: #2a2a2a !important; opacity: 1 !important; visibility: visible !important; }
body.zen-mode #viewport { margin-top: 0 !important; height: 100vh !important; transition: margin-top 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
body.zen-mode #help-container.zen-peek-bottom-active, body.zen-mode #minimap-toggle-btn.zen-peek-bottom-active, body.zen-mode #status.zen-peek-bottom-active { transform: translateY(0); opacity: 1; pointer-events: auto; }
body.zen-mode #minimap-container.zen-peek-bottom-active:not(.is-hidden) { transform: translateY(0); opacity: 1; pointer-events: auto; }
body.zen-mode #minimap-container.is-hidden { opacity: 0 !important; pointer-events: none !important; transform: translateY(20px) scale(0.9) !important; }
#top-header { z-index: 10001 !important; }
body.zen-mode #top-header.zen-peek-active { transform: translateY(0) !important; opacity: 1 !important; pointer-events: auto !important; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
#markup-topbar { z-index: 20000 !important; }