/* ==========================================================
   SpriteFX Studio Pro — UI 优化版
   深色专业编辑器风格 · 卡片化分层
   ========================================================== */

:root {
    --bg-0: #0b0e14;
    --bg-1: #131722;
    --bg-2: #1a2130;
    --bg-3: #232c40;
    --border-1: rgba(255, 255, 255, 0.06);
    --border-2: rgba(255, 255, 255, 0.12);
    --text-0: #e9edf5;
    --text-1: #aab3c5;
    --text-2: #6b7590;
    --accent: #4f8cff;
    --accent-2: #86b0ff;
    --accent-grad: linear-gradient(135deg, #4f8cff 0%, #7a5cff 100%);
    --success: #34d399;
    --warn: #fbbf24;
    --danger: #f87171;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg-0);
    color: var(--text-1);
    font-family: var(--font);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app { display: flex; height: 100vh; min-width: 0; }

/* ========== 全局滚动条 ========== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.09); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); border: 2px solid transparent; background-clip: padding-box; }

/* ========== 左侧面板 ========== */
#sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--bg-1);
    border-right: 1px solid var(--border-1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0 16px;
}

.sidebar-header {
    margin: 0 -16px 10px;
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--border-1);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--accent-grad);
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(95, 110, 255, 0.35);
}
.logo-icon svg { width: 18px; height: 18px; }
.logo-text h1 { margin: 0; font-size: 14px; font-weight: 700; color: var(--text-0); letter-spacing: 0.2px; }
.logo-text span { font-size: 9px; color: var(--text-2); letter-spacing: 0.16em; font-weight: 600; }

/* 导入区域 */
.import-zone {
    border: 1.5px dashed var(--border-2);
    border-radius: 12px;
    padding: 10px 12px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-2);
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    margin-bottom: 2px;
}
.import-zone:hover, .import-zone.dragover { border-color: var(--accent); background: rgba(79, 140, 255, 0.08); }
.import-zone.dragover { transform: scale(1.015); }
.import-zone input[type="file"] { display: none; }
.import-inner { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.import-inner svg { width: 22px; height: 22px; color: var(--accent-2); }
.import-title { font-size: 12.5px; font-weight: 600; color: var(--text-0); }
.import-hint { font-size: 10px; color: var(--text-2); }

/* 预览背景 */
#canvas-container.bg-light { background-color: #f2f2f2; background-image: none; }
#canvas-container.bg-light #previewCanvas { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); }
#canvas-container.bg-checker { background-color: #23262d; background-image: linear-gradient(45deg, #3a3f48 25%, transparent 25%, transparent 75%, #3a3f48 75%), linear-gradient(45deg, #3a3f48 25%, transparent 25%, transparent 75%, #3a3f48 75%); background-size: 18px 18px; background-position: 0 0, 9px 9px; }

/* 选项按钮 */
.option-btn {
    width: 28px; height: 28px; border-radius: 8px;
    border: 1px solid var(--border-2); background: var(--bg-3);
    cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    padding: 0;
}
.option-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.option-btn.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.3); }
.option-btn[data-bg="dark"] { background: var(--bg-0); }
.option-btn[data-bg="light"] { background: #f0f0f0; border-color: #aab3c5; }
.option-btn[data-bg="checker"] { background-color: #23262d; background-image: linear-gradient(45deg, #3a3f48 25%, transparent 25%, transparent 75%, #3a3f48 75%), linear-gradient(45deg, #3a3f48 25%, transparent 25%, transparent 75%, #3a3f48 75%); background-size: 8px 8px; background-position: 0 0, 4px 4px; }
.option-btn[data-bg="custom"] { background: #1a1a1a; }

/* 预设按钮 */
.preset-row { display: flex; gap: 6px; }
.preset-btn {
    flex: 1; padding: 5px 4px; border-radius: 7px;
    background: var(--bg-3); border: 1px solid var(--border-2);
    color: var(--text-1); font-size: 11px; cursor: pointer;
    font-family: inherit; transition: all 0.15s;
    white-space: nowrap;
}
.preset-btn:hover { border-color: var(--accent); color: var(--text-0); }
.preset-btn.active { background: rgba(79, 140, 255, 0.16); border-color: var(--accent); color: var(--accent-2); font-weight: 600; }

/* 拖拽条 */
.resizer {
    width: 5px; flex-shrink: 0;
    cursor: col-resize;
    background: transparent;
    position: relative; z-index: 6;
    transition: background 0.15s;
}
.resizer:hover, .resizer.dragging { background: rgba(79, 140, 255, 0.4); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }

/* 分区标题 */
.section-label {
    display: flex; align-items: center; gap: 10px;
    font-size: 10.5px; font-weight: 700;
    letter-spacing: 0.14em; color: var(--text-2);
    margin: 12px 2px 7px;
    user-select: none;
}
.section-label::before {
    content: ""; width: 4px; height: 14px; border-radius: 2px;
    flex-shrink: 0; background: var(--accent);
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border-1); }
/* 分区配色 */
.section-label.accent-blue::before { background: #4f8cff; }
.section-label.accent-blue { color: #86b0ff; }
.section-label.accent-purple::before { background: #a78bfa; }
.section-label.accent-purple { color: #c4b5fd; }
.section-label.accent-green::before { background: #34d399; }
.section-label.accent-green { color: #6ee7b7; }
.section-label.accent-amber::before { background: #fbbf24; }
.section-label.accent-amber { color: #fcd34d; }
.section-label.accent-blue::after, .section-label.accent-purple::after,
.section-label.accent-green::after, .section-label.accent-amber::after {
    background: linear-gradient(to right, var(--border-1), transparent);
}

/* 控制卡片 */
.control-card {
    background: var(--bg-2);
    border: 1px solid var(--border-1);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex; flex-direction: column; gap: 8px;
    transition: border-color 0.18s;
    margin-bottom: 8px;
}
.control-card:hover { border-color: var(--border-2); }

/* 分区卡片主题色（左侧色条，hover 加深） */
.section-label.accent-blue + .control-card { border-left: 3px solid rgba(79, 140, 255, 0.75); }
.section-label.accent-purple + .control-card, .section-label.accent-purple + .control-card + .control-card, .section-label.accent-purple + .control-card + .control-card + .control-card { border-left: 3px solid rgba(167, 139, 250, 0.75); }
.section-label.accent-green + .control-card, .section-label.accent-green + .control-card + .control-card, .section-label.accent-green + .control-card + .control-card + .control-card { border-left: 3px solid rgba(52, 211, 153, 0.75); }
.section-label.accent-amber + .control-card { border-left: 3px solid rgba(251, 191, 36, 0.75); }

.label-row {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    font-size: 12.5px; color: var(--text-1);
    user-select: none;
}
.row-actions { display: flex; align-items: center; gap: 7px; }

.val-badge {
    font-family: var(--mono); font-size: 11px; color: var(--accent-2);
    background: rgba(79, 140, 255, 0.13);
    padding: 2.5px 8px; border-radius: 6px;
    min-width: 40px; text-align: center;
}

.reset-btn {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; border-radius: 7px;
    color: var(--text-2); cursor: pointer;
    transition: color 0.18s, background 0.18s, transform 0.25s;
    padding: 0;
}
.reset-btn svg { width: 14px; height: 14px; }
.reset-btn:hover { color: var(--danger); background: rgba(248, 113, 113, 0.12); transform: rotate(-160deg); }

/* 颜色选择 */
.color-picker { position: relative; width: 34px; height: 26px; }
.color-swatch {
    position: absolute; inset: 0;
    border-radius: 8px; border: 1px solid var(--border-2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.color-picker input[type="color"] {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer; border: none; padding: 0; z-index: 2;
}
.color-picker-sm { width: 30px; height: 22px; }
.color-picker-sm .color-swatch { border-radius: 6px; }

/* 滑块 */
input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px; border-radius: 999px;
    background: linear-gradient(to right, var(--accent) var(--fill, 50%), rgba(255, 255, 255, 0.1) var(--fill, 50%));
    outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: #fff; border: 3px solid var(--accent);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
    transition: transform 0.15s, box-shadow 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.18); box-shadow: 0 0 0 7px rgba(79, 140, 255, 0.18); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: pointer; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); }

/* 展开按钮 */
.expand-btn {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; background: transparent; border: none;
    border-top: 1px dashed var(--border-1);
    padding: 8px 2px 0; margin-top: 2px;
    font-size: 11px; color: var(--text-2); cursor: pointer;
    font-family: inherit; transition: color 0.15s;
}
.expand-btn:hover { color: var(--text-1); }
.expand-btn .arrow { font-size: 9px; transition: transform 0.22s ease; }
.expand-btn.open .arrow { transform: rotate(180deg); }

/* 高级参数面板 */
.details-panel {
    display: none; flex-direction: column; gap: 11px;
    padding: 11px; background: rgba(8, 11, 17, 0.5);
    border: 1px solid var(--border-1); border-radius: 10px;
}
.details-panel.show { display: flex; animation: panel-in 0.22s ease; }
@keyframes panel-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.sub-control { display: flex; flex-direction: column; gap: 7px; }
.sub-control .label-row { font-size: 11.5px; color: var(--text-2); }
.dual-range { display: flex; gap: 8px; }
.dual-range input[type="range"] { flex: 1; }

/* 像素形状切换 + 行内开关 */
.shape-switch { display: flex; gap: 6px; width: 100%; }
.shape-switch .preset-btn { flex: 1; }
.check-inline { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-1); cursor: pointer; user-select: none; }

/* 多层发光 */
.glow-layer-list { display: flex; flex-direction: column; gap: 8px; }
.glow-layer {
    border: 1px solid var(--border-1); border-radius: 10px;
    background: rgba(8, 11, 17, 0.45);
    overflow: hidden;
}
.glow-layer-head {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    cursor: pointer; user-select: none;
}
.glow-layer-head:hover { background: rgba(255, 255, 255, 0.03); }
.glow-layer-name { font-size: 11.5px; font-weight: 600; color: var(--text-0); flex: 1; }
.glow-layer-on {
    font-size: 10px; padding: 2px 7px; border-radius: 999px;
    background: rgba(52, 211, 153, 0.15); color: var(--success);
    font-family: var(--mono);
}
.glow-layer-off {
    font-size: 10px; padding: 2px 7px; border-radius: 999px;
    background: var(--bg-3); color: var(--text-2);
    font-family: var(--mono);
}
.glow-layer-arrow { font-size: 9px; color: var(--text-2); transition: transform 0.2s; }
.glow-layer.open .glow-layer-arrow { transform: rotate(180deg); }
.glow-layer-del {
    width: 20px; height: 20px; border-radius: 6px; border: none;
    background: transparent; color: var(--text-2); cursor: pointer;
    font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s; padding: 0;
}
.glow-layer-del:hover { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.glow-layer-body {
    display: none; flex-direction: column; gap: 9px;
    padding: 10px 12px 12px; border-top: 1px solid var(--border-1);
}
.glow-layer.open .glow-layer-body { display: flex; }
.add-layer-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 7px; border-radius: 8px;
    background: transparent; border: 1px dashed var(--border-2);
    color: var(--text-2); font-size: 11.5px; cursor: pointer;
    font-family: inherit; transition: all 0.15s;
}
.add-layer-btn svg { width: 13px; height: 13px; }
.add-layer-btn:hover { border-color: var(--accent); color: var(--accent-2); background: rgba(79, 140, 255, 0.06); }

/* 预设管理 */
.preset-manager { gap: 8px; }
.btn-sm { padding: 8px 12px; font-size: 12px; border-radius: 8px; }
.btn-sm svg { width: 13px; height: 13px; }
.saved-preset-list { display: flex; flex-direction: column; gap: 5px; max-height: 160px; overflow-y: auto; }
.saved-preset-item {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    padding: 7px 10px; border-radius: 8px;
    background: var(--bg-3); border: 1px solid var(--border-2);
    font-size: 12px; color: var(--text-1); cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.saved-preset-item:hover { border-color: var(--accent); background: rgba(79, 140, 255, 0.1); }
.saved-preset-item .sp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-preset-item .sp-del {
    width: 18px; height: 18px; border-radius: 5px; border: none;
    background: transparent; color: var(--text-2); cursor: pointer; font-size: 12px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.saved-preset-item .sp-del:hover { background: var(--danger); color: #fff; }
.saved-preset-empty { font-size: 11px; color: var(--text-2); text-align: center; padding: 10px 0; }

/* 底部操作按钮（跟随滚动，不遮挡内容） */
.sidebar-actions {
    margin-top: 16px;
    padding: 4px 0 14px;
    display: flex; flex-direction: column; gap: 9px;
}
.btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 11px 14px; border-radius: 10px;
    border: none; font-size: 13px; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: all 0.18s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn.primary {
    background: var(--accent-grad); color: #fff;
    box-shadow: 0 4px 14px rgba(79, 140, 255, 0.32);
}
.btn.primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79, 140, 255, 0.4); }
.btn.primary:active { transform: translateY(0); }
.btn.secondary { background: var(--bg-3); color: var(--text-1); border: 1px solid var(--border-2); }
.btn.secondary:hover { background: #2a3450; color: var(--text-0); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none; filter: none; box-shadow: none; }

/* ========== 主视口 ========== */
#viewport {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    position: relative; background: var(--bg-0);
}
.viewport-topbar {
    height: 46px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 16px;
    background: var(--bg-1); border-bottom: 1px solid var(--border-1);
}
.file-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-name {
    font-size: 13px; font-weight: 600; color: var(--text-0);
    max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-dims {
    font-size: 11px; font-family: var(--mono); color: var(--text-2);
    background: var(--bg-2); border: 1px solid var(--border-1);
    padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.zoom-badge {
    font-size: 11.5px; font-family: var(--mono); color: var(--text-1);
    background: var(--bg-2); border: 1px solid var(--border-1);
    padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-btn {
    height: 28px; padding: 0 12px; border-radius: 8px;
    background: var(--bg-2); border: 1px solid var(--border-2);
    color: var(--text-1); font-size: 12px; cursor: pointer;
    font-family: inherit; transition: all 0.15s; white-space: nowrap;
}
.topbar-btn:hover { border-color: var(--accent); color: var(--text-0); }
#helpBtn { width: 28px; padding: 0; font-weight: 700; font-size: 14px; }
.bg-switcher {
    display: flex; align-items: center; gap: 4px;
    padding: 3px; border-radius: 10px;
    background: var(--bg-2); border: 1px solid var(--border-1);
}
.bg-switcher .option-btn { width: 22px; height: 22px; border-radius: 6px; }
.bg-switcher .option-btn[data-bg="checker"] { background-size: 6px 6px; background-position: 0 0, 3px 3px; }

#canvas-container {
    flex: 1; position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background-image: radial-gradient(rgba(255, 255, 255, 0.055) 1.2px, transparent 1.2px);
    background-size: 18px 18px;
    cursor: grab;
    user-select: none;
}
#canvas-container.grabbing { cursor: grabbing; }
#previewCanvas { display: block; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55); border-radius: 2px; }

/* 空状态 */
.empty-state {
    position: absolute; inset: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    text-align: center; color: var(--text-2); pointer-events: none;
}
.empty-state svg { width: 54px; height: 54px; opacity: 0.65; }
.empty-state h2 { margin: 8px 0 0; font-size: 16px; font-weight: 600; color: var(--text-1); }
.empty-state p { margin: 0; font-size: 12.5px; }

/* 缩放控制 */
.zoom-controls {
    position: absolute; right: 16px; bottom: 16px; z-index: 5;
    display: flex; align-items: center; gap: 2px;
    background: rgba(20, 26, 40, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-2);
    border-radius: 999px; padding: 4px;
    box-shadow: var(--shadow-lg);
    transition: opacity 0.2s;
}
.zoom-controls.off { opacity: 0.35; pointer-events: none; }
.zoom-controls button {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; color: var(--text-1);
    cursor: pointer; font-size: 16px; line-height: 1;
    transition: background 0.15s, color 0.15s; font-family: inherit;
}
.zoom-controls button:hover { background: rgba(255, 255, 255, 0.09); color: var(--text-0); }
.zoom-value { min-width: 50px; text-align: center; font-size: 11.5px; font-family: var(--mono); color: var(--text-1); }
.zoom-controls .zoom-fit { width: auto; padding: 0 12px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }

/* ========== 右侧缩略图 ========== */
#thumb-sidebar {
    width: 190px; flex-shrink: 0;
    background: var(--bg-1); border-left: 1px solid var(--border-1);
    display: flex; flex-direction: column; height: 100%;
}
.thumb-header {
    height: 46px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 13px; border-bottom: 1px solid var(--border-1);
}
.check-all { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-1); cursor: pointer; user-select: none; }
.thumb-count {
    font-size: 10.5px; font-family: var(--mono); color: var(--text-2);
    background: var(--bg-2); border: 1px solid var(--border-1);
    padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}

#thumb-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }

.thumb-wrapper {
    position: relative; flex-shrink: 0;
    padding: 6px; border-radius: 12px;
    background: var(--bg-2);
    border: 1.5px solid transparent;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.thumb-wrapper:hover { background: var(--bg-3); }
.thumb-wrapper.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.16); }
.thumb-item {
    width: 100%; aspect-ratio: 1; border-radius: 8px;
    background: #0b0e14;
    cursor: pointer; display: block;
    user-select: none;
}
.thumb-name {
    font-size: 11px; color: var(--text-2); text-align: center;
    padding: 5px 2px 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thumb-wrapper.active .thumb-name { color: var(--accent-2); }
.thumb-check { position: absolute; top: 10px; left: 10px; z-index: 2; }
.thumb-del {
    position: absolute; top: 10px; right: 10px; z-index: 2;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(10, 13, 20, 0.7); color: #fff;
    border: none; cursor: pointer; font-size: 13px; line-height: 1;
    opacity: 0; transition: opacity 0.15s, background 0.15s; padding: 0;
}
.thumb-dl {
    position: absolute; bottom: 10px; right: 10px; z-index: 2;
    width: 22px; height: 22px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(10, 13, 20, 0.75); color: var(--accent-2);
    border: 1px solid var(--border-2); cursor: pointer; font-size: 13px; line-height: 1;
    opacity: 0; transition: opacity 0.15s, background 0.15s, border-color 0.15s; padding: 0;
}
.thumb-wrapper:hover .thumb-del, .thumb-wrapper:hover .thumb-dl { opacity: 1; }
.thumb-del:hover { background: var(--danger); }
.thumb-dl:hover { background: rgba(79, 140, 255, 0.2); border-color: var(--accent); }
.thumb-empty { color: var(--text-2); font-size: 12px; text-align: center; padding: 28px 0; user-select: none; }

/* 复选框 */
input[type="checkbox"] {
    -webkit-appearance: none; appearance: none;
    width: 15px; height: 15px; border-radius: 4px;
    border: 1.5px solid var(--border-2);
    background: var(--bg-1); cursor: pointer; position: relative;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0; margin: 0;
}
input[type="checkbox"]:hover { border-color: var(--accent-2); }
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after {
    content: ""; position: absolute; left: 4.5px; top: 1px;
    width: 4px; height: 8px;
    border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ========== Toast 提示 ========== */
#toast {
    position: fixed; left: 50%; bottom: 30px; z-index: 999;
    transform: translate(-50%, 16px);
    display: flex; align-items: center; gap: 8px;
    background: #1d2436; color: var(--text-0);
    padding: 10px 18px; border-radius: 999px;
    font-size: 13px; font-weight: 500;
    border: 1px solid var(--border-2);
    box-shadow: var(--shadow-lg);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: 80vw; white-space: nowrap;
}
#toast::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
#toast.warn::before { background: var(--warn); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 焦点可访问性 */
.btn:focus-visible, .reset-btn:focus-visible, .expand-btn:focus-visible,
.zoom-controls button:focus-visible, .thumb-del:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ========== 帮助模态框 ========== */
.modal-mask {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(5, 8, 14, 0.65);
    backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center;
    padding: 24px;
}
.modal-mask.show { display: flex; animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
    width: 100%; max-width: 620px; max-height: 82vh;
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: modal-in 0.24s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-1);
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text-0); }
.modal-close {
    width: 28px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; color: var(--text-2);
    font-size: 18px; cursor: pointer; transition: all 0.15s; padding: 0;
}
.modal-close:hover { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.modal-body { padding: 18px 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.help-section { display: flex; flex-direction: column; gap: 5px; }
.help-section h3 {
    margin: 0; font-size: 13px; font-weight: 600; color: var(--accent-2);
    display: flex; align-items: center; gap: 8px;
}
.help-section h3::before { content: ""; width: 4px; height: 13px; border-radius: 2px; background: var(--accent); flex-shrink: 0; }
.help-section p { margin: 0; font-size: 12.5px; line-height: 1.7; color: var(--text-1); }
.help-intro { font-size: 12.5px; line-height: 1.7; color: var(--text-1); padding-bottom: 4px; border-bottom: 1px dashed var(--border-1); }
.help-kbd {
    display: inline-block; padding: 1px 6px; border-radius: 5px;
    background: var(--bg-3); border: 1px solid var(--border-2);
    font-family: var(--mono); font-size: 11px; color: var(--text-0);
    margin: 0 2px;
}

/* 响应式 */
@media (max-width: 1000px) {
    #sidebar { width: 285px; }
    #thumb-sidebar { width: 165px; }
}
