/* =====================================================
   📦 预览卡片结构
   ===================================================== */
.preview-item {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    text-align: center;
    padding: 10px;
}

.preview-item .thumb {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #f5f7fb;
}

.preview-item .thumb img,
.preview-item img {
    display: block;
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.preview-item img:hover {
    transform: scale(1.05);
}

.preview-item p {
    font-size: 12px;
    margin: 5px 0 0;
    word-break: break-all;
    color: #555;
}

/* =====================================================
   🖼 结果预览区 (grid 布局)
   ===================================================== */
#previewList.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
    padding: 10px;
}


/* =====================================================
   🛠️ 卡片顶部工具栏（小图按钮）
   ===================================================== */
.card-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    z-index: 5;
    pointer-events: none;
}

.card-toolbar .btn {
    pointer-events: auto;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 9999px;
    color: #fff;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .15s ease, filter .15s ease, opacity .15s ease;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
    opacity: .96;
}

.card-toolbar .btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.card-toolbar .btn:active {
    transform: translateY(0);
    filter: brightness(.95);
}

.card-toolbar .btn-download {
    background: #10b981;
}

.card-toolbar .btn-remove {
    background: #3D85C6;
}

/* 单独的下载按钮（左上角） */
.download-btn-top {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #10b981;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.download-btn-top:hover {
    background: #059669;
}

/* 单独的下载按钮（右下角） */
.download-btn {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.download-btn:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: scale(1.15);
}


/* =====================================================
   🌙 暗色模式覆盖
   ===================================================== */
html[data-user-color-scheme="dark"] .preview-item {
    background: #1e293b;
    border-color: #334155;
}

html[data-user-color-scheme="dark"] .preview-item .thumb {
    background: #0b1220;
}

html[data-user-color-scheme="dark"] .preview-item p {
    color: #cbd5e1;
}

html[data-user-color-scheme="dark"] .card-toolbar .btn-download {
    background: #059669;
}

html[data-user-color-scheme="dark"] .card-toolbar .btn-remove {
    background: #2563eb;
}

html[data-user-color-scheme="dark"] #icoSizeGroup label {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
}

html[data-user-color-scheme="dark"] #icoSizeGroup label:hover {
    background: linear-gradient(135deg, #2563eb, #9333ea);
    color: #fff;
}

html[data-user-color-scheme="dark"] #result h3,
html[data-user-color-scheme="dark"] #icoSizeGroup h3 {
    color: #e2e8f0;
}

html[data-user-color-scheme="dark"] .preview-item img {
    background: #0f172a;
}

html[data-user-color-scheme="dark"] #toolBox h2 {
    color: #eee;
}

html[data-user-color-scheme="dark"] #dropZone {
    border-color: #555;
    color: #aaa;
}

html[data-user-color-scheme="dark"] #dropZone:hover {
    background: rgba(61, 133, 198, 0.15);
}

html[data-user-color-scheme="dark"] .navbar {
    background-color: #1f3144 !important;
}

html[data-user-color-scheme="dark"] #editorCanvas {
    background: #1e293b;
}


/* =====================================================
   📤 上传/工具区
   ===================================================== */
#toolBox {
    padding: 20px;
    margin: 20px auto;
    max-width: 720px;
    text-align: center;
}

#toolBox h2 {
    font-size: 1.8em;
    margin-bottom: 20px;
    color: #333;
}

#dropZone {
    border: 2px dashed #bbb;
    border-radius: 10px;
    padding: 50px 20px;
    margin: 20px auto;
    max-width: 500px;
    cursor: pointer;
    background: transparent;
    transition: all .3s ease;
    position: relative;
    color: #666;
    font-size: 15px;
}

#dropZone input[type=file] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

#dropZone:hover {
    border-color: #3D85C6;
    background: rgba(61, 133, 198, 0.05);
    transform: scale(1.02);
}


/* =====================================================
   🔘 通用按钮（升级版，拟态风格）
   ===================================================== */
#editorToolbar button,
.toolbar-row button,
button,
#toolBox>button {
    margin: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(145deg, #4f9dff, #2563eb);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.25),
        inset 0 1px 2px rgba(255, 255, 255, 0.25);
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* 悬停 */
#editorToolbar button:hover,
.toolbar-row button:hover,
button:hover,
#toolBox>button:hover {
    background: linear-gradient(145deg, #60a5fa, #1e40af);
    transform: translateY(-2px);
    box-shadow:
        0 6px 14px rgba(0, 0, 0, 0.35),
        0 0 6px rgba(96, 165, 250, 0.7);
    text-shadow:
        0 1px 3px rgba(0, 0, 0, 0.6),
        0 0 6px rgba(255, 255, 255, 0.7);
}

/* 点击 */
#editorToolbar button:active,
.toolbar-row button:active,
button:active,
#toolBox>button:active {
    transform: scale(0.95);
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.35);
    background: linear-gradient(145deg, #1e40af, #3b82f6);
}

/* 特殊按钮 - 应用/确认 */
#applyEdit,
#applyFilter,
#applyWatermark {
    background: linear-gradient(145deg, #10b981, #059669);
}
#applyEdit:hover,
#applyFilter:hover,
#applyWatermark:hover {
    background: linear-gradient(145deg, #34d399, #047857);
    box-shadow:
        0 6px 14px rgba(0, 0, 0, 0.35),
        0 0 6px rgba(16, 185, 129, 0.8);
}

/* 特殊按钮 - 清空/危险 */
#clearBtn {
    background: linear-gradient(145deg, #f87171, #dc2626);
}
#clearBtn:hover {
    background: linear-gradient(145deg, #fca5a5, #b91c1c);
    box-shadow: 0 6px 14px rgba(0,0,0,0.35),
                0 0 6px rgba(239,68,68,0.8);
}

/* 特殊按钮 - 撤销 */
#undoBtn {
    background: linear-gradient(145deg, #fb923c, #ea580c);
}
#undoBtn:hover {
    background: linear-gradient(145deg, #fdba74, #c2410c);
    box-shadow: 0 6px 14px rgba(0,0,0,0.35),
                0 0 6px rgba(251,146,60,0.8);
}

/* 特殊按钮 - 取消 */
#closeEditor {
    background: linear-gradient(145deg, #94a3b8, #475569);
}
#closeEditor:hover {
    background: linear-gradient(145deg, #cbd5e1, #334155);
    box-shadow: 0 6px 14px rgba(0,0,0,0.35),
                0 0 6px rgba(148,163,184,0.7);
}

button i,
button svg {
    font-size: 1.1em;
    vertical-align: middle;
}

/* =====================================================
   📝 按钮文字优化（立体 + 发光 + 可读性）
   ===================================================== */
#editorToolbar button,
.toolbar-row button,
button,
#toolBox>button {
    font-weight: 600;
    /* 字更粗一点 */
    letter-spacing: 0.6px;
    /* 增加字间距 */
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.4),
        /* 立体阴影 */
        0 0 2px rgba(255, 255, 255, 0.2);
    /* 柔和高光 */
}

/* ✅ 鼠标悬停时文字更亮 */
#editorToolbar button:hover,
.toolbar-row button:hover,
button:hover,
#toolBox>button:hover {
    text-shadow:
        0 1px 3px rgba(0, 0, 0, 0.5),
        0 0 6px rgba(255, 255, 255, 0.6);
}

/* ✅ 绿色按钮（确认/应用）文字高光偏绿 */
#applyEdit:hover,
#applyFilter:hover,
#applyWatermark:hover {
    text-shadow:
        0 1px 3px rgba(0, 0, 0, 0.5),
        0 0 6px rgba(16, 185, 129, 0.8);
}

/* ✅ 红色按钮（清空）文字高光偏红 */
#clearBtn:hover {
    text-shadow:
        0 1px 3px rgba(0, 0, 0, 0.5),
        0 0 6px rgba(239, 68, 68, 0.8);
}


/* =====================================================
   📦 功能区卡片美化
   ===================================================== */
.toolbar-row {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(6px); /* 玻璃磨砂效果 */
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

/* 小标题 */
.toolbar-row h4 {
    flex: 0 0 100%;
    font-size: 14px;
    color: #9ca3af;
    margin: 0 0 10px 0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ========== 按钮美化 ========== */
#editorToolbar button,
.toolbar-row button {
    background: linear-gradient(145deg, #3b82f6, #2563eb);
    color: #fff;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    transition: all 0.25s ease;
}

#editorToolbar button:hover {
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}

#editorToolbar button:active {
    transform: scale(0.95);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

/* ========== 输入框 & 下拉框 ========== */
.toolbar-row input[type="text"],
.toolbar-row select {
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) inset;
}

/* ========== 滑块 ========== */
.toolbar-row input[type="range"] {
    flex: 0 1 140px;
    max-width: 160px;
    cursor: pointer;
    accent-color: #3b82f6;
}

.slider-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #e5e7eb;
    white-space: nowrap;
}

/* 颜色选择器 */
.toolbar-row input[type="color"] {
    width: 42px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) inset;
}




/* =====================================================
   ⬇️ 下拉框（格式选择）
   ===================================================== */
#format {
    margin: 10px;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    transition: border .25s ease, box-shadow .25s ease;
}

#format:focus {
    border-color: #3D85C6;
    box-shadow: 0 0 0 3px rgba(61, 133, 198, .2);
    outline: none;
}


/* =====================================================
   📉 压缩滑块
   ===================================================== */
#qualityBox {
    margin: 12px 0;
}

#quality {
    vertical-align: middle;
    margin-left: 8px;
}


/* =====================================================
   🔍 对比区（压缩前后预览）
   ===================================================== */
.compare-block {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    margin: 20px auto;
    flex-wrap: wrap;
}

.compare-block .img-wrapper {
    position: relative;
    max-width: 45%;
    text-align: center;
}

.compare-block img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    transition: transform 0.25s ease;
}

.compare-block img:hover {
    transform: scale(1.05);
}


/* =====================================================
   🧭 Navbar
   ===================================================== */
.navbar {
    background-color: #3D85C6 !important;
    transition: background-color .3s ease;
}


/* =====================================================
   🔠 ICON 尺寸选择
   ===================================================== */
#icoSizeGroup label {
    display: inline-block;
    padding: 4px 10px;
    margin: 0 6px 6px 0;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #334155;
    background: #fff;
}

#icoSizeGroup input {
    display: none;
}

#icoSizeGroup label:hover {
    background: linear-gradient(135deg, #6a5af9, #00c6ff);
    color: #fff;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, .15);
}

#icoSizeGroup label:has(input:checked) {
    background: linear-gradient(135deg, #3887e7, #ff758c);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}


/* =====================================================
   🎚 滑块文字标签
   ===================================================== */
.slider-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #fff;
    min-width: 120px;
}

.slider-label input[type="range"] {
    flex: 1;
    cursor: pointer;
    accent-color: #3D85C6;
}


/* =====================================================
   🎨 编辑器滚动条
   ===================================================== */
#editorToolbar::-webkit-scrollbar {
    width: 8px;
}

#editorToolbar::-webkit-scrollbar-thumb {
    background: #3d85c6;
    border-radius: 4px;
}

#editorToolbar::-webkit-scrollbar-track {
    background: transparent;
}


/* =====================================================
   🖼 编辑器覆盖层 (Overlay)
   ===================================================== */
#editorOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 10px;
    box-sizing: border-box;
}


/* =====================================================
   🛠 工具栏里的控件 (button / range / color)
   ===================================================== */
.toolbar-row button,
.toolbar-row input[type="range"],
.toolbar-row input[type="color"] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 6px 10px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
}

.toolbar-row input[type="color"] {
    height: 36px;
    padding: 2px;
}

.toolbar-row button:hover {
    background: linear-gradient(135deg, #2563eb, #3D85C6);
    transform: translateY(-2px);
}

.toolbar-row button:active {
    transform: scale(0.96);
}


/* =====================================================
   🏷 工具栏标签 (label)
   ===================================================== */
.toolbar-row label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
}


/* =====================================================
   🖼 编辑器 Overlay（再次定义，背景色稍浅）
   ===================================================== */
#editorOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

/* （这里保留了你注释掉的旧版 editorPanel & editorCanvas，不删） */


/* =====================================================
   🖼 编辑器 Canvas
   ===================================================== */
#editorCanvas {
    max-width: 100%;
    height: auto;
}


/* =====================================================
   🔲 编辑器 toolbar 行
   ===================================================== */
#editorToolbar .toolbar-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

#editorToolbar button:active {
    transform: translateY(1px);
}


/* =====================================================
   ✏️ 编辑器输入框 / 下拉框
   ===================================================== */
#editorToolbar input[type="text"],
#editorToolbar select {
    padding: 8px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    background: #fff;
    min-width: 160px;
}


/* =====================================================
   🎚 slider 标签（重复定义，保留）
   ===================================================== */
.slider-label {
    color: #e6eef7;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}


/* =====================================================
   🎚 滑块美化（重点部分）
   ===================================================== */
/* webkit 轨道 */
#editorToolbar input[type=range]::-webkit-slider-runnable-track {
    height: 10px;
    border-radius: 8px;
    background: transparent;
}

/* webkit 拇指 */
#editorToolbar input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    margin-top: -4px;
    box-shadow: 0 6px 16px rgba(11, 24, 40, 0.45);
    border: 3px solid rgba(255, 255, 255, 0.95);
    cursor: pointer;
    transition: transform 120ms cubic-bezier(.22, .9, .35, 1);
}

#editorToolbar input[type=range]:active::-webkit-slider-thumb {
    transform: scale(1.08);
}

/* Firefox 轨道 & 拇指 */
#editorToolbar input[type=range]::-moz-range-track {
    height: 10px;
    border-radius: 8px;
    background: transparent;
}

#editorToolbar input[type=range]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    border: 3px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 6px 16px rgba(11, 24, 40, 0.45);
    cursor: pointer;
    transition: transform 120ms cubic-bezier(.22, .9, .35, 1);
}

#editorToolbar input[type=range]:active::-moz-range-thumb {
    transform: scale(1.08);
}


/* =====================================================
   🔒 防止弹窗滚动 body
   ===================================================== */
body.editor-modal-open {
    overflow: hidden;
    touch-action: none;
}


/* =====================================================
   🪟 弹窗主体（Editor Panel）
   ===================================================== */
#editorPanel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border-radius: 12px;
    background: #1e293b;
    max-width: 90vw;
    min-width: 800px;
    max-height: 90vh;
    overflow: hidden;
}


/* =====================================================
   🛠 编辑器 Toolbar 总体
   ===================================================== */
#editorToolbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    margin-top: 12px;
    max-height: 28vh;
    overflow-y: auto;
    padding: 10px;
    box-sizing: border-box;
}

#editorToolbar button {
    background: linear-gradient(180deg, #3b82f6, #2b6fd3);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(19, 40, 80, 0.25);
    min-width: 80px;
    max-width: 150px;
    height: auto;
    padding: 6px 12px;
    font-size: 14px;
    white-space: nowrap;
}

#editorToolbar input,
#editorToolbar select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}


/* =====================================================
   🎚 限定 Toolbar 滑块容器
   ===================================================== */
#editorToolbar input[type=range] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 220px;
    height: 10px;
    padding: 0;
    margin: 0;
    background: transparent;
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
    transition: background 120ms linear;
}


/* =====================================================
   🧩 工具栏行容器
   ===================================================== */
.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    align-items: center;
}

.toolbar-row button {
    background: linear-gradient(135deg, #3D85C6, #2563eb);
    color: #fff;
    min-width: 90px;
    max-width: 120px;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.toolbar-row select,
.toolbar-row input[type="text"] {
    flex: 0 1 140px;
    max-width: 140px;
    min-width: 100px;
    background: #fff;
    border: 1px solid #ccc;
    font-size: 14px;
    padding: 6px 8px;
    border-radius: 6px;
    box-sizing: border-box;
}

.toolbar-row input[type="range"] {
    flex: 0 1 140px;
    max-width: 155px;
    cursor: pointer;
    accent-color: #3D85C6;
}

.toolbar-row input[type="color"] {
    flex: 0 0 50px;
    height: 32px;
    padding: 2px;
}


/* =====================================================
   📱 响应式适配 (max-width: 768px)
   ===================================================== */
@media (max-width: 768px) {
    #editorPanel {
        width: 95vw;
        min-width: auto;
        max-width: 98%;
        height: auto;
        padding: 8px;
    }

    #editorCanvas {
        max-height: 50vh;
    }

    #editorToolbar {
        display: grid;
        grid-template-columns: 1fr;
        max-height: 35vh;
        font-size: 14px;
        overflow-y: auto;
        padding-right: 6px;
    }

    .toolbar-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .toolbar-row button,
    .toolbar-row input,
    .toolbar-row select {
        font-size: 13px;
        padding: 6px 8px;
    }

    #toolBox>button {
        display: block;
        width: 100%;
        margin: 8px 0;
    }
}


/* =====================================================
   📱 窄屏特殊适配 (max-width: 700px)
   ===================================================== */
@media (max-width: 700px) {
    #editorToolbar input[type=range] {
        width: 150px;
    }
}