:root {
    --primary-color: #2196f3;
    --primary-dark: #1976d2;
    --background-color: #f5f5f5;
    --text-color: #333;
    --border-color: #ddd;
    --success-color: #4caf50;
    --error-color: #f44336;
    --container-width: 1000px;
    --spacing-unit: 1rem;
    --border-radius: 8px;
}

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
        Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: var(--spacing-unit);
}

/* 响应式容器 */
@media (max-width: 768px) {
    .container {
        padding: calc(var(--spacing-unit) / 2);
    }
}

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: calc(var(--spacing-unit) * 2);
    padding: calc(var(--spacing-unit) * 2) 0;
}

header h1 {
    color: var(--primary-color);
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
}

.subtitle {
    color: #666;
    margin-top: 0.5rem;
    font-size: 1.1rem;
}

/* 上传区域样式 */
.upload-section {
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.drop-zone {
    border: 2px dashed var(--primary-color);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing-unit) * 2);
    text-align: center;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone.drag-over {
    border-color: var(--primary-dark);
    background: #f0f8ff;
}

@media (max-width: 768px) {
    .drop-zone {
        min-height: 150px;
        padding: var(--spacing-unit);
    }
}

.file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    color: var(--primary-color);
    margin-left: auto;
    margin-right: auto;
}


@media (max-width: 768px) {
    .upload-icon {
        font-size: 2rem;
    }
}

.upload-hint {
    color: #666;
    font-size: 0.9rem;
    display: block;
    margin-top: 0.5rem;
}

/* 控制区域样式 */
.controls-section {
    background: white;
    padding: calc(var(--spacing-unit) * 1.5);
    border-radius: var(--border-radius);
    margin-bottom: calc(var(--spacing-unit) * 2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.control-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-unit);
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .control-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group label {
        margin-bottom: 0.5rem;
    }
}

.slider-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--spacing-unit);
    min-width: 200px;
}

/* 自定义范围滑块样式 */
input[type="range"] {
    flex: 1;
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* 预览区域样式 */
.preview-section {
    background: white;
    padding: calc(var(--spacing-unit) * 1.5);
    border-radius: var(--border-radius);
    margin-bottom: calc(var(--spacing-unit) * 2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.preview-section h2 {
    margin-bottom: var(--spacing-unit);
    color: var(--text-color);
    font-size: 1.5rem;
}

.preview-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.preview-container canvas {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: block;
    margin: 0 auto;
}

/* 按钮样式 */
.action-section {
    text-align: center;
    margin-top: calc(var(--spacing-unit) * 2);
}

.primary-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    min-width: 200px;
}

.primary-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.primary-button:active {
    transform: translateY(0);
}

.primary-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (max-width: 768px) {
    .primary-button {
        width: 100%;
        padding: 0.8rem 1.5rem;
    }
}

/* 加载遮罩层样式 */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.loading-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    width: 90%;
    max-width: 300px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    margin: 1rem auto;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.3s ease;
}

#progressText {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #1a1a1a;
        --text-color: #ffffff;
        --border-color: #333;
    }

    .controls-section,
    .preview-section,
    .drop-zone {
        background: #2d2d2d;
    }

    .upload-hint {
        color: #aaa;
    }

    .subtitle {
        color: #aaa;
    }
}

/* 触摸设备优化 */
@media (hover: none) {
    .primary-button:hover {
        transform: none;
        box-shadow: none;
    }
}

/* 安全区域适配 */
@supports (padding: env(safe-area-inset-bottom)) {
    .container {
        padding-left: max(var(--spacing-unit), env(safe-area-inset-left));
        padding-right: max(var(--spacing-unit), env(safe-area-inset-right));
        padding-bottom: max(var(--spacing-unit), env(safe-area-inset-bottom));
    }
}
.footer {
    text-align: center;
    margin-top: calc(var(--spacing-unit) * 2);
    padding: calc(var(--spacing-unit) * 2) 0;
    color: #666;
    font-size: 0.9rem;
}
