:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6366f1;
    --secondary-hover: #4f46e5;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --background-color: #ffffff;
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 24px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --radius: 14px;
    --success: #10b981;
    --error: #ef4444;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    background: var(--background-color);
    min-height: 100vh;
}

.gradient-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: -1;
}

.gradient-1, .gradient-2, .gradient-3 {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    animation: gradientMove 20s infinite;
}

.gradient-1 {
    background: var(--primary-color);
    width: 600px;
    height: 600px;
    top: -200px;
    left: -200px;
    animation-delay: 0s;
}

.gradient-2 {
    background: var(--secondary-color);
    width: 800px;
    height: 800px;
    top: 50%;
    right: -300px;
    animation-delay: -5s;
}

.gradient-3 {
    background: var(--primary-hover);
    width: 700px;
    height: 700px;
    bottom: -200px;
    left: 30%;
    animation-delay: -10s;
}

@keyframes gradientMove {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(100px, 50px);
    }
    50% {
        transform: translate(50px, 100px);
    }
    75% {
        transform: translate(-50px, 50px);
    }
}

#app {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: #6b7280;
    font-size: 1.1rem;
}

.upload-area {
    background: rgba(255, 255, 255, 0.8);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(8px);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.02);
}

.upload-content {
    color: #6b7280;
}

.upload-content svg {
    margin-bottom: 16px;
}

.hint {
    font-size: 0.9rem;
    margin-top: 8px;
    color: #6b7280;
}

.settings-panel {
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius);
    padding: 32px;
    margin-top: 24px;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-md);
}

.settings-group {
    margin-bottom: 24px;
}

.settings-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
    background: white;
}

select:focus {
    border-color: var(--primary-color);
}

.quality-control, .scale-control {
    display: flex;
    align-items: center;
    gap: 16px;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.preview-container {
    margin: 24px 0;
    text-align: center;
}

.preview-container img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.action-buttons {
    display: flex;
    gap: 16px;
    margin-top: 32px;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

button.primary {
    background: var(--primary-color);
    color: white;
    flex: 1;
}

button.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

button.primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

button.secondary {
    background: var(--secondary-color);
    color: white;
}

button.secondary:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
}

button.secondary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

#clearBtn {
    background: #f3f4f6;
    color: #4b5563;
}

#clearBtn:hover {
    background: #e5e7eb;
}

.pages-preview {
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.pages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.pages-actions {
    display: flex;
    gap: 0.5rem;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.page-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
    background: white;
}

.page-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.page-item.selected {
    outline: 3px solid var(--primary-color);
}

.page-preview {
    width: 100%;
    aspect-ratio: 1/1.414;
    object-fit: cover;
    cursor: pointer;
}

.page-number {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.875rem;
    text-align: center;
}

.progress-bar {
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    overflow: hidden;
    height: 4px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    width: 0;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 500;
}

footer {
    margin-top: 60px;
    text-align: center;
    color: #6b7280;
}

.license {
    font-size: 0.9rem;
}

.license a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.license a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    #app {
        padding: 20px;
    }

    .upload-area {
        padding: 24px;
    }

    .settings-panel {
        padding: 20px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .pages-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .pages-header {
        flex-direction: column;
        gap: 1rem;
    }

    .pages-actions {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .pages-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}