* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border: #334155;
    --success: #10b981;
    --error: #ef4444;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, #1a1f3a 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem 1rem;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: var(--surface-light);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: var(--surface-light);
    transform: scale(1.02);
}

.upload-content svg {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-content p {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-content span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.editor-section {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    margin-top: 2rem;
}

.image-preview-container,
.result-container {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
}

.image-preview-container h3,
.result-container h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.image-wrapper {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: var(--background);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.controls-panel {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 2rem;
}

.controls-panel h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

.form-group input[type="number"],
.form-group input[type="range"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
}

.form-group input[type="range"] {
    padding: 0;
    accent-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.quality-value {
    display: inline-block;
    margin-left: 0.5rem;
    color: var(--primary-color);
    font-weight: 600;
}

.btn {
    display: inline-block;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    width: 100%;
    margin-top: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.result-actions {
    margin-top: 1rem;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: 8px;
    padding: 1rem;
    color: var(--error);
    margin-top: 1rem;
}

@media (max-width: 1024px) {
    .editor-section {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        position: relative;
        top: 0;
    }

    .image-wrapper {
        aspect-ratio: 16/9;
    }
}

@media (max-width: 640px) {
    header h1 {
        font-size: 2rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }
}
