:root {
            /* 提供的设计色值 */
            --main-color: #8080ff;
            --main-hover: #5a64ff;
            --btcolor: linear-gradient(113deg, #4c73ff, #6a52ff);
            --text1: #ffffff;
            --text2: #c7d1e2;
            --text3: #969dbb;
            --line: #7878784d;
            --bg: #222228;
            --panel-bg: #2E2E33;
            
            /* 特效变量 */
            --vignette-op: 0;
            --grain-op: 0;
            --vignette-size: 50%;
        }

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

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text1);
    height: 100vh;
    display: flex;
    flex-direction: column;
    /* 【修改】将 overflow: hidden 改为 touch-action: none，或者保持 hidden 但需确保容器能捕获事件 */
    overflow: hidden; 
    padding: 0 0 0 60px;
    /* 【新增】针对触摸行为的优化 */
    -webkit-overflow-scrolling: touch; 
        }
        
        /* 彻底修复所有 SVG 图标变形问题 */
        svg { 
            flex-shrink: 0 !important; 
            flex-grow: 0 !important;
            display: inline-block;
        }
        .histogram-wrapper {
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
        }
        .hist-toggle { display: none; }
        .histogram-container {
            padding: 10px; 
            border-bottom: 10px solid var(--bg);
            flex-shrink: 0; /* 【新增】防止被挤压 */
        }

        /* 顶部导航 */
        .header {
            height: 60px;
            background: var(--panel-bg);
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
            border-bottom: 1px solid var(--line);
            flex-shrink: 0;
        }

        .header h1 { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
        .header-actions { display: flex; gap: 10px; align-items: center; }
        .tab-btn svg { flex-shrink: 0;
    width: 16px;
    height: 16px;
 }
 /* 专属颜色滑动条样式 */
input[type="range"].slider-temp {
    background: linear-gradient(to right, #4a90e2 0%, #ffffff4d 50%, #f5a623 100%);
}
input[type="range"].slider-tint {
    background: linear-gradient(to right, #50e3c2 0%, #ffffff4d 50%, #bd10e0 100%);
}
input[type="range"].slider-sat {
    background: linear-gradient(to right, #9ba3af 0%, #ff5a5a 100%);
}
input[type="range"].slider-exp {
    background: linear-gradient(to right, #6f757c 0%, #f2f5f8 100%);
}
input[type="range"].slider-light {
    background: linear-gradient(to right, #9ba3af 0%, #f2f5f8 100%);
}
input[type="range"].slider-shadow {
    background: linear-gradient(to right, #3d3f42 0%, #babcc3 100%);
}
input[type="range"].slider-contrast {
    background:repeating-linear-gradient(to right, transparent 0, transparent 2px, var(--bg) 2px, var(--bg) 4px), linear-gradient(to right, #464a4c 0%, #99a0a6 100%);
    background-size: 100% 100%;
}
input[type="range"].slider-contrast::-webkit-slider-runnable-track {
    background: transparent;
}
input[type="range"].slider-rotate {
    background: repeating-linear-gradient(to right, transparent 0, transparent 5px, var(--line) 5px, var(--line) 6px);
    background-size: 100% 100%;
}
        .btn {
            background: var(--main-color);
            color: white;
            border: none;
            padding: 8px 14px;
            border-radius: 36px;
            cursor: pointer;
            font-size: 13px;
            font-weight: 500;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            transition: all 0.2s;
            justify-content: center;
        }
        .btn:hover { opacity: 0.9; background: var(--main-hover); }
        .btn-outline {
            background: var(--line);
            color: var(--text2);
            border: 1px solid var(--line);
        }
        .btn-outline:hover { background: var(--bg); }
        
        .btn-danger {
            background: var(--line);
            color: var(--text2);
        }
        .btn-danger:hover { background: #ff6b81; color: white; }

        /* 主体布局 */
        .main-workspace {
            display: flex;
            flex: 1;
            overflow: hidden;
            flex-direction: column;
        }

        /* 视图区 */
        .view-area {
            flex: 1;
            background: var(--bg);
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
            overflow: hidden;
        }

        .canvas-container {
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        #transform-wrapper {
    position: absolute;
    left: 50%;
    top: 50%;
    cursor: grab;
    transform: translate(-50%, -50%);
    transform-origin: center center;
}
#transform-wrapper:active { cursor: grabbing; }

#image-wrapper {
    transform-origin: center center;
    pointer-events: none; /* 让鼠标事件穿透到外层，保证拖拽顺畅 */
}

#target-image {
    display: none;
    -webkit-user-drag: none;
    user-select: none;
    border: 1px solid var(--line);
}

        /* 特效叠加层 */
        .overlay {
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            pointer-events: none;
        }
        .vignette-layer {
            background: radial-gradient(circle, transparent var(--vignette-size), var(--vignette-color, rgba(0,0,0,0.9)) 150%);
            opacity: var(--vignette-op);
            mix-blend-mode: var(--vignette-blend, multiply);
        }
        .grain-layer {
            background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: var(--grain-op);
    mix-blend-mode: overlay;
        }

        .control-panel {
    display: flex;               /* 【新增】开启弹性盒布局 */
    flex-direction: column;      /* 【新增】纵向排列 */
    transition: height 0.3s ease;
    overflow: hidden;
    background: var(--panel-bg);
}

.control-panel.collapsed {
    height: 26px !important;
}


        /* 选项卡 */
        .tabs {
            display: flex;
            border-bottom: 1px solid var(--line);
            overflow-x: auto;
            background: var(--panel-bg);
            scrollbar-width: none;
            flex-shrink: 0; /* 【新增】防止被挤压 */
        }
        .tabs::-webkit-scrollbar {
            display: none;
        }
        .tab-btn {
            flex: 1;
            padding: 12px 4px;
            border: none;
            background: none;
            color: var(--text1);
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            white-space: nowrap;
            border-bottom: 2px solid transparent;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
        }
        .tab-btn.active {
            color: var(--main-color);
            border-bottom: 2px solid var(--main-color);
            background: var(--line);
        }

        /* 控制组滚动区 */
         .controls-scroll {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            /* 【新增】开启移动端流畅滚动并允许上下滑动手势 */
            -webkit-overflow-scrolling: touch; 
            touch-action: pan-y;
        }
        .controls-scroll::-webkit-scrollbar { width: 6px; }
        .controls-scroll::-webkit-scrollbar-track { background: transparent; }
        .controls-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }        
        .control-group {
            display: none;
            animation: fadeIn 0.3s ease;
        }
        .control-group.active { display: block; }

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

        .param-row { margin-bottom: 16px; }
        .param-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 6px;
            font-size: 13px;
            color: var(--text2);
            align-items: center;
        }
        .param-input-group {
            display: flex;
            align-items: center;
            gap: 12px;
        }
/* 旋转滑块专属样式：将圆形改为竖线 */
#slider-rotate {
    -webkit-appearance: none;
    height: 10px; /* 增加容器高度，方便布局 */
}

/* 针对 Webkit 内核 (Chrome, Safari, Edge) */
#slider-rotate::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 2px;           /* 竖线宽度 */
    height: 18px;          /* 竖线高度 */
    background: var(--text2); 
    cursor: ew-resize;
    border-radius: 0;      /* 去掉圆角变直角 */
    box-shadow: none;      /* 去掉阴影 */
    margin-top: -7px;      /* 调整位置，使其垂直居中跨过轨道 */
    transition: background 0.2s;
}

#slider-rotate::-webkit-slider-thumb:hover {
    background: var(--text1); /* 悬停时变白色 */
}

/* 重新定义轨道线，确保它在竖线中间穿过 */
#slider-rotate::-webkit-slider-runnable-track {
    width: 100%;
    height: 2px;
    background: var(--line);
    border-radius: 1px;
}

/* 针对 Firefox */
#slider-rotate::-moz-range-thumb {
    width: 2px;
    height: 18px;
    background: var(--main-color);
    border: none;
    border-radius: 0;
    cursor: ew-resize;
}
#slider-rotate::-moz-range-track {
    background: var(--line);
    height: 2px;
}
        /* 滑块 */
        input[type="range"] {
            flex: 1;
            -webkit-appearance: none;
            user-select: none;
            height: 4px;
            background: var(--line);
            border-radius: 2px;
            outline: none;
            touch-action: pan-y; 
        }
        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 16px; height: 16px;
            border-radius: 50%;
            background: var(--text1);
            cursor: pointer;
            box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2);
            transition: transform 0.1s;
        }
        input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

        input[type="number"] {
            width: 55px;
            padding: 4px 0;
            text-align: center;
            border: 1px solid var(--line);
            border-radius: 4px;
            color: var(--text1);
            font-size: 12px;
            background: var(--bg);
        }
        input[type="number"]:focus { outline: none; border-color: var(--main-color); }

        /* 预设 */
        .preset-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
            gap: 10px;
        }
        .preset-card2 {
            padding: 8px 0;
            text-align: center;
            background: var(--line);
            border: 1px solid var(--line);
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            color: var(--text2);
            transition: all 0.15s;
        }
        .preset-card2:hover { border-color: var(--main-color); color: var(--main-color); }
        .preset-card { 
            /* === 新增与修改的布局属性 === */
            display: flex;             /* 开启弹性盒布局 */
            align-items: flex-end;     /* 垂直方向：将内容靠底部对齐 */
            justify-content: center;   /* 水平方向：将内容居中对齐 */
            padding: 0 0 2px 0;       /* 移除原有的上下均匀内边距，改为只给底部留出 10px 的呼吸空间 */
            
            /* === 以下为原有的基础样式保留 === */
            border: 1px solid var(--line);
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 600;
            color: var(--text1);
            transition: all 0.15s;
            background-size: cover;
            height: 130px;
            
            /* (可选优化) 加强一点文字阴影，防止底部背景偏白时看不清文字 */
            text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 0, 0, 0.9);
         }
        .preset-card:hover { border-color: var(--main-color); }
        /* 变换面板 */
        .transform-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
        }

        /* 缩放控制器 */
        .zoom-controls {
            position: absolute;
            bottom: 20px;
            background: rgba(0, 0, 0, 0.2);
            padding: 8px 12px;
            border-radius: 20px;
            border: 1px solid var(--line);
            display: flex;
            gap: 12px;
            align-items: center;
            z-index: 10;
            backdrop-filter: blur(5px);
        }
        .zoom-btn {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 16px;
            color: var(--text1);
        }
        .zoom-btn:hover {
            color: var(--text2);
        }
        .upload-overlay {
            position: absolute;
            top: 0; 
            left: 0; 
            width: calc(100% - 20px); 
            height: calc(100% - 20px);
            background: var(--panel-bg);
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            z-index: 10;
            border: 2px dashed var(--line);
            border-radius: 8px;
            margin: 10px;
            transition: all ease 0.2s;
        }
        .upload-overlay:hover {
            border-color: var(--main-color);
            background: rgba(90, 100, 255, 0.05);
            cursor: pointer;
            transition: all ease 0.2s;
        }
        #file-input { display: none; }
        .panel-toggle-btn {display: none;}
        
        @media (min-width: 768px) {
            
    .control-panel { 
        transition: height 0.3s ease; 
        /* 避免动画过程内容挤压溢出 */
        overflow: hidden; 
    }
    .control-panel.collapsed { 
        height: 26px !important; /* 收起后仅保留箭头的区域 */
    }
            .main-workspace { flex-direction: row; }
            
            .control-panel {
                width: 380px; /* 加宽面板，保证所有标签一排显示 */
                height: 100%;
                border-top: none;
            }
            .tabs {
                overflow-x: visible; /* PC 端不需要滑动 */
                flex-wrap: nowrap;
            }
            .tab-btn {
                font-size: 12px;
            }
        }
        .svg-filters { width: 0; height: 0; position: absolute; }
        /* 可选颜色专属样式 */
.hsl-tabs {
    display: flex; gap: 8px; margin-bottom: 15px; 
    flex-wrap: wrap; justify-content: space-between;
}
.hsl-color-btn {
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid transparent; cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.hsl-color-btn.active {
    border-color: #ffffff;
    transform: scale(1.2);
    box-shadow: 0 0 6px rgba(255,255,255,0.4);
}
/* ==================== Cropper.js 移动端触摸完美优化 ==================== */

/* 1. 阻断移动端浏览器默认滑动行为干扰，保障极速跟手 */
.cropper-container, .cropper-wrap-box {
    touch-action: none !important;
    -webkit-touch-callout: none !important;
}

/* 2. 彻底隐藏原带的所有白块控制点，但保留 44px 的隐式触摸热区（手指粗也能轻松点中） */
.cropper-point {
    width: 44px !important;
    height: 44px !important;
    background-color: transparent !important;
    opacity: 0 !important;
    border: none !important;
}

/* 3. 加粗外层主边框，移动端高反差显示 */
.cropper-view-box {
    outline: 3px solid rgba(255, 255, 255, 0.9) !important;
}

/* 4. 加粗九宫格的虚线，不晃眼、无白块 */
.cropper-dashed {
    border: 0 dashed rgba(255, 255, 255, 0.8) !important;
}
.cropper-dashed.dashed-h {
    border-top-width: 2px !important;
    border-bottom-width: 2px !important;
}
.cropper-dashed.dashed-v {
    border-left-width: 2px !important;
    border-right-width: 2px !important;
}

/* 5. 隐藏 Cropper 默认自带的细实线边缘 */
.cropper-line {
    display: none !important; 
}
        @media (max-width: 768px) {
            .panel-toggle-btn {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 26px;
        background: var(--panel-bg);
        border-bottom: 1px solid var(--line);
        color: var(--text3);
        cursor: pointer;
        flex-shrink: 0;
        position: sticky;
        top: 0;
        z-index: 20;
        touch-action: manipulation;
    }

    .control-panel {
        height: 55vh;
    }

    .control-panel.collapsed {
        height: 26px !important;
    }
            .header h1 {display: none;}
            .btn {padding: 7px;}
            body { padding: 0 !important; }
            .header {     
                justify-content: center; 
                padding: 0 0 0 40px;
            }
            .histogram-wrapper {
                position: fixed;
                top: 60px;
                right: 0;
                width: 50%;
                z-index: 15;
                display: flex;
                flex-direction: column;
                align-items: flex-end;
            }
            .histogram-container {
                position: relative;
                top: auto;
                right: auto;
                width: 100%;
                border: none;
                background: #0000002b;
                backdrop-filter: blur(10px);
                border-bottom-left-radius: 8px;
                overflow: hidden;
                transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
                max-height: 150px; 
                opacity: 1;
            }
            .histogram-container.collapsed {
                max-height: 0;
                padding: 0 !important;
                border: none;
                opacity: 0;
            }
            .hist-toggle {
                display: flex;
                background: var(--panel-bg);
                color: var(--text2);
                padding: 6px 12px;
                border-bottom-left-radius: 8px;
                cursor: pointer;
                align-items: center;
                gap: 4px;
                font-size: 11px;
                user-select: none;
                -webkit-tap-highlight-color: transparent;
                box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
            }
        }