/* ===== Mekpoo 无限画布 ===== */
:root {
    --bg-main: #050814;
    --bg-board: #060b18;
    --bg-surface: #141419;
    --bg-elevated: #1c1c24;
    --accent: #0ea5e9;
    --accent-hover: #38bdf8;
    --accent-glow: rgba(14, 165, 233, 0.3);
    --accent-dim: rgba(14, 165, 233, 0.15);
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #22c55e;
    --warning: #f59e0b;
    --text-main: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-dim: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --toolbar-height: 44px;
    --statusbar-height: 26px;
    --sidebar-width: 220px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    overflow: hidden;
    font-family: var(--font-main);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ===== 工具栏 ===== */
#toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--toolbar-height);
    padding: 0 10px;
    background: linear-gradient(180deg, rgba(18, 18, 26, 0.97) 0%, rgba(12, 12, 18, 0.98) 100%);
    backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid var(--border);
    z-index: 500;
    flex-shrink: 0;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px 0 4px;
}

.logo-icon {
    width: 20px;
    height: 20px;
    fill: var(--accent);
    filter: drop-shadow(0 0 4px var(--accent-glow));
}

.logo-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.logo-text small {
    font-size: 9px;
    color: var(--accent);
    font-weight: 600;
    vertical-align: super;
    margin-left: 2px;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-light);
    margin: 0 4px;
    flex-shrink: 0;
}

.btn-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* ===== 工具按钮 ===== */
.tool-btn {
    position: relative;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
    flex-shrink: 0;
}

.tool-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    transition: fill var(--transition-fast);
}

.tool-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-main);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.tool-btn:active {
    transform: translateY(0);
    background: var(--accent-dim);
}

.tool-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.tool-btn.active:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.tool-btn.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.tool-btn.small {
    width: 24px;
    height: 24px;
}

.tool-btn.small svg {
    width: 14px;
    height: 14px;
}

/* Tooltip */
.tool-btn[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    animation: tooltipFade 0.15s ease;
}

@keyframes tooltipFade {
    from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== 下拉选择 ===== */
select {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    font-size: 11px;
    height: 26px;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
}

select:hover { border-color: var(--accent); }
select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

/* ===== 颜色选择器 ===== */
.color-picker-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    background: none;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border-light);
    border-radius: 50%;
    transition: border-color var(--transition-fast);
}
input[type="color"]:hover::-webkit-color-swatch { border-color: var(--accent); }

/* ===== 缩放指示器 ===== */
.zoom-indicator {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    min-width: 52px;
    text-align: center;
    cursor: default;
}

.status-text {
    font-size: 11px;
    color: var(--text-dim);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== 主内容区 ===== */
#main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ===== 侧栏 ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-smooth), opacity var(--transition-smooth);
    z-index: 100;
    overflow: hidden;
}

.sidebar.hidden {
    width: 0;
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.layer-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.layer-list::-webkit-scrollbar { width: 4px; }
.layer-list::-webkit-scrollbar-track { background: transparent; }
.layer-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 12px;
    color: var(--text-secondary);
}

.layer-item:hover { background: var(--bg-elevated); }
.layer-item.active { background: var(--accent-dim); color: var(--accent); }
.layer-item.locked { opacity: 0.5; }

.layer-thumb {
    width: 32px;
    height: 24px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-main);
}

.layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-icons {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.layer-icon-btn {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 3px;
    padding: 0;
    transition: all var(--transition-fast);
}

.layer-icon-btn:hover { color: var(--text-main); background: var(--bg-elevated); }
.layer-icon-btn svg { width: 12px; height: 12px; fill: currentColor; }

/* ===== 画布区域 · 星空科技背景（主画布平铺满天星 + 科技网格） ===== */
#board-container {
    position: relative;
    flex: 1;
    overflow: hidden;
    background-color: #030510;
    background-image:
        radial-gradient(ellipse 120% 70% at 50% -10%, rgba(14, 165, 233, 0.18) 0%, transparent 55%),
        radial-gradient(ellipse 90% 60% at 100% 30%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
        radial-gradient(ellipse 70% 50% at 0% 80%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
        linear-gradient(165deg, #050a18 0%, #0a1028 35%, #060c1c 70%, #030510 100%);
}

#board {
    position: absolute;
    top: 0;
    left: 0;
    width: 8000px;
    height: 8000px;
    z-index: 5;
    transform-origin: 0 0;
    background-color: transparent;
    /* 星空 + 科技网格（平铺满天星，随画布平移） */
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Crect fill='none' width='256' height='256'/%3E%3Ccircle cx='12' cy='40' r='0.6' fill='%23ffffff' opacity='0.55'/%3E%3Ccircle cx='48' cy='18' r='0.5' fill='%23e0f2fe' opacity='0.45'/%3E%3Ccircle cx='90' cy='62' r='0.8' fill='%23fff' opacity='0.65'/%3E%3Ccircle cx='130' cy='28' r='0.5' fill='%23bae6fd' opacity='0.4'/%3E%3Ccircle cx='180' cy='55' r='0.7' fill='%23fff' opacity='0.55'/%3E%3Ccircle cx='220' cy='22' r='0.5' fill='%23e0e7ff' opacity='0.45'/%3E%3Ccircle cx='240' cy='88' r='0.6' fill='%23fff' opacity='0.5'/%3E%3Ccircle cx='30' cy='100' r='0.5' fill='%23cffafe' opacity='0.4'/%3E%3Ccircle cx='75' cy='120' r='0.9' fill='%23fff' opacity='0.7'/%3E%3Ccircle cx='115' cy='95' r='0.5' fill='%23dbeafe' opacity='0.35'/%3E%3Ccircle cx='160' cy='130' r='0.6' fill='%23fff' opacity='0.5'/%3E%3Ccircle cx='200' cy='108' r='0.5' fill='%23f0f9ff' opacity='0.45'/%3E%3Ccircle cx='245' cy='125' r='0.7' fill='%23fff' opacity='0.55'/%3E%3Ccircle cx='20' cy='155' r='0.5' fill='%23e0f2fe' opacity='0.4'/%3E%3Ccircle cx='55' cy='180' r='0.8' fill='%23fff' opacity='0.6'/%3E%3Ccircle cx='100' cy='165' r='0.5' fill='%23bae6fd' opacity='0.38'/%3E%3Ccircle cx='145' cy='195' r='0.6' fill='%23fff' opacity='0.52'/%3E%3Ccircle cx='188' cy='170' r='0.5' fill='%23cffafe' opacity='0.42'/%3E%3Ccircle cx='230' cy='200' r='0.7' fill='%23fff' opacity='0.58'/%3E%3Ccircle cx='15' cy='220' r='0.5' fill='%23e0e7ff' opacity='0.4'/%3E%3Ccircle cx='65' cy='235' r='0.6' fill='%23fff' opacity='0.48'/%3E%3Ccircle cx='125' cy='218' r='0.5' fill='%23dbeafe' opacity='0.36'/%3E%3Ccircle cx='175' cy='245' r='0.85' fill='%23fff' opacity='0.62'/%3E%3Ccircle cx='210' cy='230' r='0.5' fill='%23bae6fd' opacity='0.4'/%3E%3Ccircle cx='250' cy='250' r='0.6' fill='%23f0f9ff' opacity='0.5'/%3E%3Ccircle cx='38' cy='72' r='0.45' fill='%23fff' opacity='0.35'/%3E%3Ccircle cx='102' cy='48' r='0.45' fill='%23e0f2fe' opacity='0.32'/%3E%3Ccircle cx='168' cy='78' r='0.5' fill='%23fff' opacity='0.4'/%3E%3Ccircle cx='8' cy='190' r='0.45' fill='%23cffafe' opacity='0.33'/%3E%3Ccircle cx='140' cy='8' r='0.5' fill='%23fff' opacity='0.42'/%3E%3Ccircle cx='195' cy='35' r='0.45' fill='%23e0e7ff' opacity='0.3'/%3E%3C/svg%3E"),
        radial-gradient(1px 1px at 10% 10%, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(1px 1px at 25% 35%, rgba(224, 242, 254, 0.35), transparent),
        radial-gradient(1.2px 1.2px at 40% 8%, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(1px 1px at 55% 55%, rgba(186, 230, 253, 0.3), transparent),
        radial-gradient(1px 1px at 70% 20%, rgba(255, 255, 255, 0.45), transparent),
        radial-gradient(1px 1px at 85% 70%, rgba(224, 231, 255, 0.35), transparent),
        radial-gradient(1px 1px at 15% 80%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 92% 40%, rgba(207, 250, 254, 0.4), transparent),
        radial-gradient(circle, rgba(56, 189, 248, 0.12) 1px, transparent 1px),
        linear-gradient(rgba(14, 165, 233, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(14, 165, 233, 0.04) 1px, transparent 1px),
        linear-gradient(rgba(99, 102, 241, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.025) 1px, transparent 1px),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 199px,
            rgba(14, 165, 233, 0.02) 199px,
            rgba(14, 165, 233, 0.02) 200px
        );
    background-size:
        256px 256px,
        200px 200px,
        220px 220px,
        180px 180px,
        240px 240px,
        260px 260px,
        190px 190px,
        210px 210px,
        230px 230px,
        32px 32px,
        64px 64px,
        64px 64px,
        16px 16px,
        16px 16px,
        200px 100%;
    transition: background-color 0.3s;
}

#board.dragging-over {
    background-color: rgba(14, 165, 233, 0.06);
}

#drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    /* 不使用 100%，让 canvas 的 CSS 尺寸与其像素尺寸一致，避免缩放失真 */
    /* 实际尺寸由 JS 设置为 CANVAS_SIZE x CANVAS_SIZE */
    z-index: 10;
    pointer-events: none;
    transform-origin: 0 0;
}

#drawing-canvas.active {
    pointer-events: all;
    cursor: crosshair;
}

/* ===== 图片项 ===== */
.image-item {
    position: absolute;
    cursor: move;
    border: 2px solid transparent;
    box-shadow: var(--shadow-md);
    user-select: none;
    border-radius: var(--radius-sm);
    overflow: visible;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.image-item.selected {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow), var(--shadow-md);
}

.image-item.locked {
    cursor: default;
    border-style: dashed;
    border-color: var(--warning);
    opacity: 0.85;
}

.image-item.locked::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 16px;
    height: 16px;
    background: var(--warning);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z'/%3E%3C/svg%3E") no-repeat center;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z'/%3E%3C/svg%3E") no-repeat center;
    border-radius: 50%;
    z-index: 10;
}

.image-item img {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
    border-radius: 2px;
}

/* 图片悬停控件 */
.img-controls {
    position: absolute;
    top: -32px;
    right: 0;
    display: none;
    gap: 3px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    padding: 3px 4px;
    border-radius: var(--radius-sm);
}

.image-item:hover .img-controls { display: flex; }
.image-item.locked:hover .img-controls { display: none; }

.img-ctrl-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: rgba(255,255,255,0.7);
    border: none;
    cursor: pointer;
    border-radius: 3px;
    padding: 0;
    transition: all var(--transition-fast);
}

.img-ctrl-btn:hover { background: rgba(255,255,255,0.15); color: white; }
.img-ctrl-btn.del:hover { background: var(--danger); color: white; }
.img-ctrl-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* 缩放手柄 */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent);
    border: 1.5px solid white;
    border-radius: 50%;
    z-index: 50;
    display: none;
    transition: transform var(--transition-fast);
}

.image-item.selected .resize-handle { display: block; }
.resize-handle:hover { transform: scale(1.3); }

.resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }

/* 旋转手柄 */
.rotate-handle {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: var(--accent);
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    z-index: 50;
    display: none;
    transition: transform var(--transition-fast);
}

.image-item.selected .rotate-handle { display: block; }
.rotate-handle:hover { transform: translateX(-50%) scale(1.2); }
.rotate-handle::before {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 10px;
    background: var(--accent);
}

/* ===== 分组样式 ===== */
.group-container {
    position: absolute;
    border: 2px dashed var(--accent);
    border-radius: var(--radius-md);
    background: var(--accent-dim);
    cursor: move;
    user-select: none;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    z-index: 1;
}

.group-container.selected {
    border-color: var(--accent-hover);
    background: rgba(14, 165, 233, 0.1);
    box-shadow: var(--shadow-glow);
}

.group-label {
    position: absolute;
    top: -22px;
    left: 8px;
    font-size: 11px;
    color: var(--accent);
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent-dim);
    cursor: text;
    white-space: nowrap;
}

/* ===== 标注/便签 ===== */
.note-item {
    position: absolute;
    min-width: 120px;
    min-height: 40px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    cursor: move;
    user-select: none;
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.5;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    z-index: 20;
    overflow: visible;
}

.note-item.selected {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.note-item .note-content {
    outline: none;
    min-height: 20px;
    word-wrap: break-word;
}

.note-item .note-content:focus {
    cursor: text;
}

.note-item .note-delete {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: var(--danger);
    color: white;
    border: 2px solid var(--bg-main);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    z-index: 10;
}

.note-item:hover .note-delete { display: flex; }

/* ===== 选择框 ===== */
#selection-box {
    position: absolute;
    border: 1.5px solid var(--accent);
    background: var(--accent-dim);
    display: none;
    z-index: 100;
    pointer-events: none;
    border-radius: 2px;
}

/* ===== 迷你地图 ===== */
.minimap {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 180px;
    height: 120px;
    background: rgba(14, 14, 22, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    z-index: 50;
    box-shadow: var(--shadow-md);
    transition: opacity var(--transition-normal);
}

.minimap.hidden { display: none; }

.minimap canvas {
    width: 100%;
    height: 100%;
}

#minimap-viewport {
    position: absolute;
    border: 1.5px solid var(--accent);
    background: rgba(14, 165, 233, 0.1);
    pointer-events: none;
}

/* ===== 右键菜单 ===== */
.context-menu {
    position: fixed;
    background: rgba(16, 16, 24, 0.96);
    backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 4px;
    min-width: 200px;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
    animation: menuSlideIn 0.15s ease;
}

.context-menu.hidden { display: none; }

@keyframes menuSlideIn {
    from { opacity: 0; transform: scale(0.95) translateY(-4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.menu-item:hover {
    background: var(--accent-dim);
    color: var(--text-main);
}

.menu-item svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex-shrink: 0;
}

.menu-divider {
    height: 1px;
    background: var(--border);
    margin: 3px 8px;
}

/* ===== 取色器弹窗 ===== */
.color-popup {
    position: absolute;
    background: rgba(16, 16, 24, 0.96);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 12px;
    z-index: 200;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
}

.color-popup.hidden { display: none; }

.color-preview {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    border: 1px solid var(--border);
}

.color-values {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.color-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

.color-row span:first-child {
    color: var(--text-dim);
    font-weight: 600;
    min-width: 30px;
}

.color-row span:last-child {
    font-family: var(--font-mono);
    color: var(--text-main);
}

.copy-color-btn {
    width: 100%;
    padding: 6px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: background var(--transition-fast);
}

.copy-color-btn:hover { background: var(--accent-hover); }

/* ===== 裁剪覆盖层 ===== */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
}

.crop-overlay.hidden { display: none; }

.crop-rect {
    position: absolute;
    border: 2px dashed white;
    background: transparent;
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--accent);
    border-radius: 50%;
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }

.crop-actions {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
}

.crop-action-btn {
    padding: 6px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.crop-action-btn.apply {
    background: var(--accent);
    color: white;
}

.crop-action-btn.apply:hover { background: var(--accent-hover); }

.crop-action-btn.cancel {
    background: var(--bg-elevated);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.crop-action-btn.cancel:hover { background: var(--bg-surface); }

/* ===== 空状态 ===== */
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-dim);
    z-index: 8;
    pointer-events: none;
    animation: emptyPulse 3s ease-in-out infinite;
}

@keyframes emptyPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.9; }
}

.empty-icon {
    width: 64px;
    height: 64px;
    fill: var(--text-dim);
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 13px;
    margin-bottom: 4px;
}

.shortcut-hint {
    font-size: 11px !important;
    color: var(--text-dim) !important;
    margin-top: 8px !important;
}

/* ===== 底部状态栏 ===== */
#statusbar {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--statusbar-height);
    padding: 0 12px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-dim);
    z-index: 500;
    flex-shrink: 0;
}

.sb-right {
    margin-left: auto;
}

/* ===== Toast 通知 ===== */
#toast-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: rgba(16, 16, 24, 0.96);
    backdrop-filter: blur(20px);
    color: var(--text-main);
    padding: 8px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    font-size: 12px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    pointer-events: auto;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* ===== 灰度模式 ===== */
#board.grayscale .image-item img {
    filter: grayscale(100%);
}

/* ===== 滚动条全局 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ===== 拖放高亮 ===== */
#board-container.drag-active {
    background-color: rgba(14, 165, 233, 0.08) !important;
}

#board-container.drag-active #board {
    background-color: rgba(14, 165, 233, 0.05) !important;
}

#board-container.drag-active::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    pointer-events: none;
    z-index: 9999;
    animation: dragPulse 1.5s ease-in-out infinite;
}

@keyframes dragPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* ===== 图片信息覆盖层 ===== */
.img-info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: rgba(255,255,255,0.7);
    font-size: 10px;
    font-family: var(--font-mono);
    text-align: right;
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
    border-radius: 0 0 2px 2px;
}

.image-item:hover .img-info-overlay {
    opacity: 1;
}

/* ===== 标注颜色条 ===== */
.note-color-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* ===== 工具提示增强 ===== */
.tool-btn[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #e2e8f0;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 10000;
    pointer-events: none;
    animation: tooltipFade 0.15s ease;
    font-weight: 400;
    letter-spacing: 0;
}

/* ===== 图片入场动画 ===== */
.image-item {
    animation: imageIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes imageIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

/* ===== 标注入场动画 ===== */
.note-item {
    animation: noteIn 0.25s ease;
}

@keyframes noteIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 选中项高亮脉冲 ===== */
.image-item.selected {
    animation: selectPulse 0.3s ease;
}

@keyframes selectPulse {
    0% { box-shadow: var(--shadow-md); }
    50% { box-shadow: 0 0 30px var(--accent-glow), var(--shadow-md); }
    100% { box-shadow: var(--shadow-glow), var(--shadow-md); }
}

/* ===== 工具按钮小尺寸 ===== */
.tool-btn.small {
    width: 22px;
    height: 22px;
}

.tool-btn.small svg {
    width: 12px;
    height: 12px;
}

/* ===== 画布网格背景增强 - 已合并到上方主定义 ===== */

/* ===== 滤镜菜单项图标 ===== */
.menu-item[data-action^="filter_"]::before {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.menu-item[data-action="filter_none"]::before { background: linear-gradient(135deg, #ef4444, #3b82f6); }
.menu-item[data-action="filter_grayscale"]::before { background: linear-gradient(135deg, #333, #aaa); }
.menu-item[data-action="filter_invert"]::before { background: linear-gradient(135deg, #fff, #000); border: 1px solid var(--border); }
.menu-item[data-action="filter_sepia"]::before { background: linear-gradient(135deg, #d4a574, #8b6914); }
.menu-item[data-action="filter_blur"]::before { background: linear-gradient(135deg, #60a5fa, #a78bfa); filter: blur(2px); }

/* ===== 右键菜单子标题 ===== */
.menu-item:hover svg {
    fill: var(--accent);
}

/* ===== 响应式调整 ===== */
@media (max-width: 900px) {
    .btn-group[data-tooltip="对齐"] {
        display: none;
    }
    .logo-text small {
        display: none;
    }
}
