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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

.container {
    display: flex;
    min-height: 100vh;
}

.app-layout {
    display: flex;
    width: 100%;
}

.left-sidebar {
    width: 320px;
    background: #f8f9ff;
    padding: 30px 25px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 2px solid #e0e0e0;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.left-sidebar.collapsed {
    transform: translateX(-320px);
}

.sidebar-toggle {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 32px;
    height: 32px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.sidebar-toggle:hover {
    background: #667eea;
}

.sidebar-toggle:hover svg {
    stroke: white;
}

.sidebar-toggle svg {
    stroke: #667eea;
    transition: stroke 0.3s ease;
}

.sidebar-expand {
    position: fixed;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: #667eea;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 999;
}

.sidebar-expand:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.sidebar-expand svg {
    stroke: white;
}

.left-sidebar::-webkit-scrollbar {
    width: 8px;
}

.left-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.left-sidebar::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.left-sidebar::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

.sidebar-title {
    color: #333;
    font-size: 1.4em;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 700;
}

.sidebar-subtitle {
    color: #667eea;
    font-size: 1.05em;
    font-weight: 600;
    margin: 20px 0 15px 0;
}

.sidebar-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 25px 0;
}

.sidebar-actions {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-block {
    width: 100%;
}

.left-sidebar .control-group {
    margin-bottom: 20px;
}

.left-sidebar .control-group label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    font-size: 1em;
}

.left-sidebar .control-group select,
.left-sidebar .control-group input[type="range"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.left-sidebar .control-group select:focus {
    outline: none;
    border-color: #667eea;
}

.left-sidebar .control-group input[type="range"] {
    padding: 0;
    height: 8px;
    background: #ddd;
    cursor: pointer;
}

.left-sidebar .control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
}

.left-sidebar .control-group-small {
    margin-bottom: 15px;
}

.left-sidebar .control-group-small label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.left-sidebar .control-group-small input[type="range"] {
    width: 100%;
    padding: 0;
    height: 6px;
    background: #ddd;
    cursor: pointer;
    border: none;
    border-radius: 3px;
}

.left-sidebar .control-group-small input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
}

.left-sidebar .control-group-small input[type="text"],
.left-sidebar .control-group-small input[type="password"] {
    width: 100%;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    transition: border-color 0.3s;
    font-family: monospace;
}

.left-sidebar .control-group-small input[type="text"]:focus,
.left-sidebar .control-group-small input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
}

.main-content {
    flex: 1;
    margin-left: 320px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 0;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 40px;
    text-align: center;
}

header h1 {
    font-size: 2.2em;
    margin-bottom: 8px;
}

header p {
    font-size: 1.05em;
    opacity: 0.95;
}

.upload-section {
    margin: 40px;
    margin-bottom: 20px;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 60px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
}

.upload-area:hover {
    border-color: #764ba2;
    background: #f0f2ff;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #764ba2;
    background: #e8ebff;
    transform: scale(1.02);
}

.upload-area svg {
    color: #667eea;
    margin-bottom: 20px;
}

.upload-area p {
    font-size: 1.2em;
    color: #333;
    margin-bottom: 10px;
}

.upload-area .hint {
    font-size: 0.9em;
    color: #666;
}

#fileInput {
    display: none;
}

.button-group {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.btn {
    flex: 1;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f2ff;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.preview-section {
    margin: 0 40px 40px 40px;
}

.view-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.toggle-btn {
    padding: 10px 20px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: #f0f2ff;
}

.toggle-btn.active {
    background: #667eea;
    color: white;
}

.preview-container {
    position: relative;
}

/* 对比滑块视图 */
.comparison-slider {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 15px;
    overflow: hidden;
}

.comparison-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    user-select: none;
    cursor: ew-resize;
}

.comparison-canvas {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: top;
}

.comparison-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.comparison-overlay canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.comparison-divider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: white;
    cursor: ew-resize;
    transform: translateX(-50%);
    z-index: 10;
}

.divider-line {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: white;
    transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.divider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s ease;
}

.divider-handle:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.divider-handle svg {
    width: 24px;
    height: 24px;
}

.comparison-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding: 0 10px;
    font-size: 0.95em;
    color: #666;
    font-weight: 500;
}

.label-left {
    text-align: left;
}

.label-right {
    text-align: right;
}

/* 并排视图 */
.side-by-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.preview-box {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 15px;
}

.preview-box h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.preview-box canvas {
    width: 100%;
    height: auto;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.batch-section {
    background: #f8f9ff;
    padding: 30px;
    border-radius: 15px;
    margin: 0 40px 40px 40px;
}

.batch-section h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.3em;
}

#batchList {
    margin-bottom: 20px;
}

.batch-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.batch-item.processing {
    border-left: 4px solid #667eea;
}

.batch-item.completed {
    border-left: 4px solid #4caf50;
}

.label-red {
    color: #e74c3c;
}

.label-green {
    color: #27ae60;
}

.label-blue {
    color: #3498db;
}

.slider-red::-webkit-slider-thumb {
    background: #e74c3c !important;
}

.slider-green::-webkit-slider-thumb {
    background: #27ae60 !important;
}

.slider-blue::-webkit-slider-thumb {
    background: #3498db !important;
}

footer {
    background: #f8f9ff;
    padding: 20px;
    text-align: center;
    color: #666;
    border-top: 2px solid #e0e0e0;
    margin-top: auto;
}

.histogram-container {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

#histogramCanvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 5px;
}

.histogram-legend {
    display: flex;
    justify-content: space-around;
    margin-top: 10px;
    font-size: 0.85em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.legend-red {
    background: rgba(255, 99, 132, 0.8);
}

.legend-green {
    background: rgba(75, 192, 75, 0.8);
}

.legend-blue {
    background: rgba(54, 162, 235, 0.8);
}

.legend-luma {
    background: rgba(200, 200, 200, 0.8);
}

.curves-container {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.curve-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.curve-tab {
    flex: 1;
    padding: 8px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.curve-tab:hover {
    background: #f0f2ff;
}

.curve-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.curve-tab[data-channel="r"].active {
    background: #e74c3c;
    border-color: #e74c3c;
}

.curve-tab[data-channel="g"].active {
    background: #27ae60;
    border-color: #27ae60;
}

.curve-tab[data-channel="b"].active {
    background: #3498db;
    border-color: #3498db;
}

#curveCanvas {
    width: 100%;
    height: auto;
    display: block;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: crosshair;
    background: #f8f9fa;
}

.curve-controls {
    margin-top: 10px;
}

.hsl-container {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.hsl-color-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.hsl-color-btn {
    padding: 10px;
    border: 3px solid transparent;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.hsl-color-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.hsl-color-btn.active {
    border-color: white;
    box-shadow: 0 0 0 2px #667eea, 0 4px 12px rgba(0,0,0,0.3);
    transform: scale(1.08);
}

.hsl-controls {
    margin-bottom: 10px;
}

.color-grading-container {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.grading-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.grading-tab {
    flex: 1;
    padding: 8px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.grading-tab:hover {
    background: #f0f2ff;
}

.grading-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.grading-wheels {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

#colorWheelCanvas {
    width: 200px;
    height: 200px;
    cursor: crosshair;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.wheel-info {
    margin-top: 10px;
    font-size: 0.85em;
    color: #666;
    text-align: center;
}

.grading-controls {
    margin-bottom: 10px;
}

@media (max-width: 1024px) {
    .left-sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 2px solid #e0e0e0;
    }

    .main-content {
        margin-left: 0;
    }

    .app-layout {
        flex-direction: column;
    }

    .side-by-side {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    header h1 {
        font-size: 1.8em;
    }

    .view-toggle {
        flex-direction: column;
    }

    .toggle-btn {
        width: 100%;
    }
}
