:root {
    --bg-gradient-light: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-gradient-dark: linear-gradient(135deg, #1a1c29 0%, #2d1b4e 100%);
    --card-bg-light: rgba(255, 255, 255, 0.95);
    --card-bg-dark: rgba(30, 30, 40, 0.95);
    --text-primary-light: #1a1a1a;
    --text-primary-dark: #ffffff;
    --text-secondary-light: #666666;
    --text-secondary-dark: #a0a0a0;
    --accent-color: #7c3aed;
    --accent-hover: #6d28d9;
    --input-bg-light: #f3f4f6;
    --input-bg-dark: #1f2937;
    --border-light: #e5e7eb;
    --border-dark: #374151;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient-light);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: background 0.3s ease;
}

body.dark-mode {
    background: var(--bg-gradient-dark);
}

.container {
    width: 100%;
    max-width: 900px;
}

.card {
    background: var(--card-bg-light);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

body.dark-mode .card {
    background: var(--card-bg-dark);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo i {
    background: var(--accent-color);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary-light);
}

body.dark-mode .logo h1 {
    color: var(--text-primary-dark);
}

.theme-toggle {
    background: var(--input-bg-light);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--text-primary-light);
}

body.dark-mode .theme-toggle {
    background: var(--input-bg-dark);
    color: var(--text-primary-dark);
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: var(--accent-color);
    color: white;
}

.input-section {
    margin-bottom: 30px;
}

.textarea-wrapper {
    position: relative;
    margin-bottom: 20px;
}

textarea {
    width: 100%;
    padding: 20px;
    padding-right: 60px;
    border: 2px solid var(--border-light);
    border-radius: 16px;
    background: var(--input-bg-light);
    color: var(--text-primary-light);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    min-height: 120px;
    transition: all 0.3s ease;
}

body.dark-mode textarea {
    background: var(--input-bg-dark);
    border-color: var(--border-dark);
    color: var(--text-primary-dark);
}

textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

textarea::placeholder {
    color: var(--text-secondary-light);
}

body.dark-mode textarea::placeholder {
    color: var(--text-secondary-dark);
}

.voice-btn {
    position: absolute;
    right: 15px;
    bottom: 15px;
    background: var(--accent-color);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.voice-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.control-select {
    padding: 14px 18px;
    border: 2px solid var(--border-light);
    border-radius: 12px;
    background: var(--input-bg-light);
    color: var(--text-primary-light);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

body.dark-mode .control-select {
    background: var(--input-bg-dark);
    border-color: var(--border-dark);
    color: var(--text-primary-dark);
}

body.dark-mode .control-select option {
    background-color: var(--input-bg-dark);
    color: var(--text-primary-dark);
}

.control-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.generate-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    grid-column: span 2;
}

.generate-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(124, 58, 237, 0.3);
}

.generate-btn:active {
    transform: translateY(0);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.results-section {
    margin-top: 30px;
}

.loader {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-light);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

body.dark-mode .spinner {
    border-color: var(--border-dark);
    border-top-color: var(--accent-color);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader p {
    color: var(--text-secondary-light);
    font-size: 1rem;
}

body.dark-mode .loader p {
    color: var(--text-secondary-dark);
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid #ef4444;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #dc2626;
}

.error-message i {
    font-size: 24px;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.image-item {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: var(--input-bg-light);
    aspect-ratio: 1;
    transition: all 0.3s ease;
}

body.dark-mode .image-item {
    background: var(--input-bg-dark);
}

.image-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 15px;
    display: flex;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-item:hover .image-actions {
    opacity: 1;
}

.action-btn {
    background: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--accent-color);
}

.action-btn:hover {
    background: var(--accent-color);
    color: white;
    transform: scale(1.1);
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 30px;
    color: white;
    text-decoration: none;
    font-size: 1rem;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.back-link:hover {
    opacity: 1;
}

@media (max-width: 768px) {
    .card {
        padding: 25px;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .generate-btn {
        grid-column: span 1;
    }

    .images-grid {
        grid-template-columns: 1fr;
    }
}