/* ============================================================
   图片排版工具 - 样式表
   ============================================================ */

/* ===== CSS 变量 ===== */
:root {
    --bg: #f3f4f7;
    --card: #ffffff;
    --text: #1a1f2e;
    --text-secondary: #4a5060;
    --muted: #868e9c;
    --line: #e6e8ed;
    --line-light: #f0f1f5;
    --brand: #4f6ef7;
    --brand-hover: #3b56e0;
    --brand-light: #eef1ff;
    --brand-alpha: rgba(79, 110, 247, 0.06);
    --danger: #e5484d;
    --danger-light: #fef2f2;
    --success: #10b981;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --info-light: #f0f9ff;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-xs: 4px;
    --header-h: 48px;
    --panel-w: 265px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.03);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.10);
    --transition: 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 全局重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    font-size: 13px;
    line-height: 1.5;
}

/* ===== 顶栏 ===== */
.app-header {
    height: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    flex-shrink: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; }
.header-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}
.header-center { display: flex; gap: 6px; }
.header-right { display: flex; }

.header-btn {
    height: 31px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.header-btn:hover { background: #f8f9fb; border-color: #d1d5db; color: var(--text); }
.header-btn:active { background: #f0f1f5; }
.header-btn.primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.header-btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.header-btn.primary:active { background: #3451d1; }

/* ===== 工作区三栏布局 ===== */
.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
}
.panel {
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
}
.panel-left {
    width: var(--panel-w);
    background: var(--card);
    border-right: 1px solid var(--line);
}
.panel-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #eaecf1;
}
.panel-right {
    width: var(--panel-w);
    background: var(--card);
    border-left: 1px solid var(--line);
}

/* ===== 滚动条 ===== */
.panel::-webkit-scrollbar { width: 5px; }
.canvas-wrapper::-webkit-scrollbar { width: 6px; height: 6px; }
.panel::-webkit-scrollbar-track,
.canvas-wrapper::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: #e0e3ea; border-radius: 8px; }
.canvas-wrapper::-webkit-scrollbar-thumb { background: #ccd0d8; border-radius: 8px; }
.panel::-webkit-scrollbar-thumb:hover { background: #cdd1d8; }

/* ===== 左侧面板 ===== */
.panel-section { padding: 14px; }

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.count {
    font-size: 10px;
    color: var(--muted);
    background: #f3f4f6;
    padding: 0 6px;
    border-radius: 7px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
    line-height: 16px;
    height: 16px;
}

/* 上传区域 */
.upload-zone {
    border: 1.5px dashed #cfd3dc;
    border-radius: var(--radius);
    padding: 16px 12px 14px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 10px;
    background: #fafbfd;
}
.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--brand);
    background: var(--brand-light);
}
.upload-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #eef0f5;
    color: #b4bac8;
    font-size: 20px;
    font-weight: 300;
    margin-bottom: 4px;
}
.upload-zone:hover .upload-icon,
.upload-zone.dragover .upload-icon {
    background: var(--brand-light);
    color: var(--brand);
}
.upload-text { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.upload-hint { font-size: 10px; color: #b4bac8; margin-top: 2px; }

/* 图片列表 */
.image-list { display: flex; flex-direction: column; gap: 6px; }

.image-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--line-light);
    background: #ffffff;
    position: relative;
    overflow: hidden;
}
.image-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.2s;
}
.image-item:hover {
    background: #f8f9fb;
    border-color: #dfe1e8;
}
.image-item.active {
    background: var(--brand-light);
    border-color: var(--brand);
}
.image-item.active::before {
    background: var(--brand);
}
.image-item.dragging { opacity: 0.4; }

.item-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.item-thumb-wrap {
    position: relative;
    flex-shrink: 0;
}

.image-order {
    position: absolute;
    top: -4px;
    left: -4px;
    font-size: 9px;
    color: #fff;
    font-weight: 700;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    border-radius: 50%;
    z-index: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    line-height: 1;
}

.image-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: #edf0f5;
    border: 1px solid #e4e7ed;
}

.image-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.image-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.image-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    flex-wrap: wrap;
}
.image-label-tag {
    color: var(--brand);
    font-weight: 700;
    font-size: 10px;
}
.image-fit-badge {
    font-size: 9px;
    padding: 0 5px;
    border-radius: 3px;
    font-weight: 600;
    line-height: 14px;
    height: 14px;
}
.image-fit-badge.contain { background: #e0f2fe; color: #0369a1; }
.image-fit-badge.cover  { background: #fef3c7; color: #92400e; }
.image-size-tag {
    font-size: 9px;
    color: var(--muted);
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-weight: 500;
}

.image-caption-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    font-size: 11px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: var(--transition);
}
.image-caption-input::placeholder { color: #c0c6d2; font-size: 10px; }
.image-caption-input:hover { border-color: #d1d5db; }
.image-caption-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(79, 110, 247, 0.12);
}

.image-empty {
    text-align: center;
    padding: 36px 12px;
    font-size: 12px;
    color: #bec4d2;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: #fafbfd;
    margin-top: 4px;
}
.image-empty::before {
    content: '⬆';
    display: block;
    font-size: 22px;
    color: #d4d9e3;
    margin-bottom: 8px;
    font-weight: 300;
}

/* 图片操作按钮（hover 显示） */
.image-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(4px);
    transition: opacity 0.15s, transform 0.15s;
}
.image-item:hover .image-actions,
.image-item.active .image-actions {
    opacity: 1;
    transform: translateX(0);
}
.img-btn {
    width: 22px;
    height: 22px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    white-space: nowrap;
    font-weight: 500;
}
.img-btn:hover { background: #eef0f5; color: var(--text-secondary); }
.img-fit-btn:hover  { background: var(--brand-light); color: var(--brand); }
.img-replace-btn:hover { background: #ecfdf5; color: var(--success); }
.img-hide-btn:hover { background: var(--warning-light); color: var(--warning); }
.img-hide-btn.off { color: #cfd3dc; }
.img-del-btn:hover { background: var(--danger-light); color: var(--danger); }

/* ===== 中间面板 ===== */
.canvas-tools {
    height: 36px;
    padding: 0 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.canvas-info {
    font-size: 11px;
    color: var(--muted);
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-weight: 500;
}
.zoom-controls { display: flex; gap: 2px; align-items: center; }
.zoom-btn {
    width: 26px;
    height: 26px;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    background: transparent;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: var(--transition);
    font-family: inherit;
    flex-shrink: 0;
}
.zoom-btn:hover { background: #f3f4f6; color: var(--text-secondary); }
.zoom-btn:active { background: #eef0f5; }
#zoomFit { width: auto; padding: 0 7px; font-size: 10px; font-weight: 500; }
.zoom-label {
    font-size: 10px;
    color: var(--muted);
    min-width: 36px;
    text-align: center;
    font-weight: 600;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}

.canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #eaecf1;
    background-image:
        linear-gradient(45deg, #dfe2e9 25%, transparent 25%),
        linear-gradient(-45deg, #dfe2e9 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dfe2e9 75%),
        linear-gradient(-45deg, transparent 75%, #dfe2e9 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0px;
    min-height: 0;
}
#previewCanvas {
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
    border-radius: 1px;
    background: #fff;
}

/* ===== 右侧设置面板 ===== */
.panel-right { padding-top: 4px; }

.settings-group {
    margin: 0 10px 6px;
    background: #fafbfd;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    overflow: hidden;
}
.settings-group:last-child { margin-bottom: 10px; }

.settings-header {
    padding: 9px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
    transition: background 0.15s;
}
.settings-header:hover { background: #f3f5f8; }
.settings-header span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.settings-header span:first-child::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--brand);
    flex-shrink: 0;
    opacity: 0.6;
}
.settings-arrow {
    font-size: 14px;
    color: #bcc2ce;
    transition: transform 0.2s;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    font-weight: 700;
    line-height: 1;
}
.settings-header:hover .settings-arrow { background: #e6e9f0; color: var(--muted); }
.settings-header.collapsed .settings-arrow { transform: rotate(-90deg); }
.settings-header.collapsed { border-radius: var(--radius); }

.settings-body {
    padding: 2px 12px 11px;
    border-top: 1px solid var(--line-light);
}
.settings-header.collapsed + .settings-body { display: none; }

.setting-row { margin-bottom: 9px; }
.setting-row:last-child { margin-bottom: 0; }
.setting-row label {
    display: block;
    font-size: 10px;
    color: var(--muted);
    margin-bottom: 4px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.setting-row select,
.setting-row input[type="number"] {
    width: 100%;
    height: 31px;
    padding: 0 28px 0 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}
.setting-row select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2399a0b0'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}
.setting-row input[type="color"] {
    width: 100%;
    height: 31px;
    padding: 2px 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #fff;
    transition: var(--transition);
}
.setting-row select:hover,
.setting-row input[type="number"]:hover { border-color: #d0d4dd; }
.setting-row select:focus,
.setting-row input[type="number"]:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}
.setting-row input[type="color"]:hover { border-color: #d0d4dd; }
.setting-row input[type="color"]:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

/* 颜色输入行 — 并排显示色块+数值 */
.checkbox-row {
    display: flex;
    align-items: center;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--brand);
}

.color-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.color-input-row input[type="color"] {
    flex-shrink: 0;
    width: 31px;
    height: 31px;
}
.color-input-row input[type="text"] {
    flex: 1;
    height: 31px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: "SF Mono","Fira Code","Consolas",monospace;
    color: var(--text);
    background: #fff;
    transition: var(--transition);
}
.color-input-row input[type="text"]:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

/* 滑块 */
.slider-row { margin-bottom: 9px; }
.slider-row:last-child { margin-bottom: 0; }
.slider-row label {
    display: block;
    font-size: 10px;
    color: var(--muted);
    margin-bottom: 4px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.slider-wrap { display: flex; align-items: center; gap: 8px; }
.slider-wrap input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: linear-gradient(to right, var(--brand) var(--pct, 50%), #e5e8ee var(--pct, 50%));
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}
.slider-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: 2px solid var(--brand);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: box-shadow 0.15s, transform 0.15s;
}
.slider-wrap input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.08);
    box-shadow: 0 1px 6px rgba(79,110,247,0.25);
}
.slider-val {
    font-size: 10px;
    color: var(--brand);
    min-width: 30px;
    text-align: right;
    font-weight: 700;
    font-family: "SF Mono","Fira Code","Consolas",monospace;
    background: var(--brand-light);
    padding: 2px 5px;
    border-radius: 3px;
}

/* 预设按钮 */
.preset-grid { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 9px; }
.preset-btn {
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    background: #fff;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-secondary);
    transition: var(--transition);
    font-weight: 500;
}
.preset-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.preset-btn.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    font-weight: 600;
}
.preset-btn.active:hover { background: var(--brand-hover); }

/* 布局行列输入 */
.layout-row {
    display: flex;
    gap: 8px;
}
.layout-row .setting-row {
    flex: 1;
    margin-bottom: 4px;
}
.setting-hint {
    font-size: 9px;
    color: #b0b8c4;
    margin-top: 2px;
}

/* 位置按钮 */
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.pos-btn {
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    background: #fff;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-secondary);
    text-align: center;
    transition: var(--transition);
    font-weight: 500;
}
.pos-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.pos-btn.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    font-weight: 600;
}
.pos-btn.active:hover { background: var(--brand-hover); }

/* ===== 拖拽排序指示器 ===== */
.image-item.drag-over-before {
    border-top: 2px solid var(--brand);
    border-radius: 0;
}
.image-item.drag-over-after {
    border-bottom: 2px solid var(--brand);
    border-radius: 0;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e2235;
    color: #fff;
    padding: 9px 22px;
    border-radius: 18px;
    font-size: 12px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s, transform 0.22s;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    font-weight: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-3px); }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(18, 20, 32, 0.4);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}
.modal {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 460px;
    max-height: 82vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    animation: modalIn 0.18s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 14px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #b0b8c4;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-body { padding: 18px 20px; }
.modal-footer {
    padding: 10px 20px;
    border-top: 1px solid var(--line-light);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.modal-btn {
    height: 31px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
}
.modal-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.modal-btn.secondary { background: #fff; color: var(--text-secondary); }
.modal-btn.primary:hover { background: var(--brand-hover); }
.modal-btn.secondary:hover { background: #f5f6f9; }

/* 自定义标注弹窗行 */
.custom-label-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-light);
}
.custom-label-row:last-child { border-bottom: none; }
.custom-label-row .cl-thumb {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-xs);
    object-fit: cover;
    border: 1px solid #edf0f5;
}
.custom-label-row .cl-name {
    flex: 1;
    font-size: 12px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-secondary);
}
.custom-label-row input {
    width: 80px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-family: inherit;
    transition: var(--transition);
}
.custom-label-row input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(79, 110, 247, 0.12);
}

/* 导出预览 */
.export-preview-wrap {
    text-align: center;
    max-height: 55vh;
    overflow: auto;
    background: #f5f6fa;
    border-radius: var(--radius);
    padding: 12px;
}
.export-preview-wrap canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ===== 预览覆盖层 ===== */
.preview-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preview-overlay-mask {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 17, 23, 0.55);
    backdrop-filter: blur(4px);
}
.preview-overlay-content {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    max-width: 94vw;
    max-height: 92vh;
    min-width: 420px;
    overflow: hidden;
}
.preview-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line-light);
    flex-shrink: 0;
}
.preview-overlay-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.preview-overlay-info {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    background: #eef0f5;
    padding: 3px 10px;
    border-radius: 10px;
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}
.preview-overlay-actions {
    display: flex;
    gap: 8px;
}
.preview-overlay-btn {
    padding: 6px 16px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}
.preview-overlay-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-light);
}
.preview-overlay-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #f3f4f7;
}
#previewCanvasFull {
    display: block;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
}

/* ===== Footer ===== */
.app-footer {
    height: 24px;
    background: var(--card);
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-secondary);
    gap: 8px;
}

@media (max-width: 1024px) {
    :root { --panel-w: 230px; }
}
@media (max-width: 768px) {
    .workspace { flex-direction: column; }
    .panel-left,
    .panel-right {
        width: 100%;
        max-height: 190px;
        border: none;
        border-bottom: 1px solid var(--line);
    }
    .panel-center { flex: 1; }
    .panel-right { border-bottom: none; border-top: 1px solid var(--line); }
    .header-center { gap: 3px; }
    .header-btn { height: 28px; padding: 0 10px; font-size: 11px; }
    .preview-overlay-content { max-width: 98vw; max-height: 96vh; min-width: auto; border-radius: 8px; }
    .preview-overlay-body { padding: 12px; }
    .canvas-wrapper {
        background-size: 14px 14px;
        background-position: 0 0, 0 7px, 7px -7px, -7px 0px;
    }
}

/* ===== 全页面拖拽遮罩 ===== */
body.global-drag::after {
    content: '拖放图片到任意位置即可上传';
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--brand);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    z-index: 99999;
    box-shadow: 0 4px 16px rgba(79,110,247,0.4);
    pointer-events: none;
    animation: dragPulse 1s ease-in-out infinite alternate;
}
body.global-drag::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(79,110,247,0.06);
    border: 3px dashed var(--brand);
    z-index: 99998;
    pointer-events: none;
}
@keyframes dragPulse {
    from { transform: translateX(-50%) translateY(0); }
    to   { transform: translateX(-50%) translateY(2px); }
}

/* 画布空状态 */
#previewCanvas:only-child {
    cursor: default;
}
