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

:root {
    --primary-color: #3b82f6;
    --secondary-color: #8b5cf6;
    --accent-color: #10b981;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --radius: 12px;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, #1a1f3a 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 40px 0;
    position: relative;
}

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

header p {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.language-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
}

.lang-btn {
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.lang-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

main {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 30px;
    margin-bottom: 60px;
}

.controls-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
    height: fit-content;
}

.control-group {
    margin-bottom: 30px;
}

.control-group label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#resolution {
    width: 100%;
    padding: 12px;
    background: var(--background);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#resolution:hover {
    border-color: var(--primary-color);
}

#resolution:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.style-buttons, .theme-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.style-btn, .theme-btn {
    padding: 12px;
    background: var(--background);
    border: 2px solid var(--border);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

.style-btn:hover, .theme-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.style-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: transparent;
}

.theme-btn.active {
    border-color: var(--accent-color);
    background: var(--surface-hover);
}

.style-btn .icon {
    font-size: 20px;
}

.color-preview {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: inline-block;
}

.color-preview.ocean {
    background: linear-gradient(135deg, #0077be, #74c0fc);
}

.color-preview.sunset {
    background: linear-gradient(135deg, #ff6b6b, #feca57);
}

.color-preview.forest {
    background: linear-gradient(135deg, #27ae60, #52c41a);
}

.color-preview.cosmic {
    background: linear-gradient(135deg, #6c5ce7, #fd79a8);
}

.color-preview.minimal {
    background: linear-gradient(135deg, #2c3e50, #95a5a6);
}

.color-preview.vibrant {
    background: linear-gradient(135deg, #ff006e, #3a86ff);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

#complexity {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: var(--background);
    border-radius: 3px;
    outline: none;
}

#complexity::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

#complexity::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

#complexityValue {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 18px;
    min-width: 30px;
    text-align: center;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 30px;
}

.primary-btn, .secondary-btn {
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

.secondary-btn {
    background: var(--surface-hover);
    color: var(--text-primary);
}

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

.preview-area {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.canvas-container {
    position: relative;
    background: var(--background);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
}

#wallpaperCanvas {
    max-width: 100%;
    max-height: 600px;
    display: block;
    border-radius: 8px;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 20px;
    color: var(--text-secondary);
}

.preview-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.download-btn {
    flex: 1;
    padding: 12px 24px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.download-btn:hover:not(:disabled) {
    background: #0ea674;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.3);
}

.download-btn:disabled {
    background: var(--surface-hover);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.icon-btn {
    padding: 12px;
    background: var(--surface-hover);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--background);
    transform: translateY(-2px);
}

.gallery-section {
    grid-column: 1 / -1;
    margin-top: 40px;
}

.gallery-section h2 {
    margin-bottom: 20px;
    font-size: 1.8rem;
    color: var(--text-primary);
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.gallery-item {
    position: relative;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 4/3;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 10px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
}

.gallery-overlay span {
    color: white;
    font-size: 12px;
    text-transform: capitalize;
}

footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }
    
    .controls-panel {
        max-width: 600px;
        margin: 0 auto;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .language-selector {
        position: static;
        justify-content: center;
        margin-top: 20px;
    }
}

@media (max-width: 640px) {
    .style-buttons, .theme-buttons {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    header p {
        font-size: 1rem;
    }
}