:root {
    --primary-color: #4f46e5; /* Indigo */
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --primary-glow: rgba(79, 70, 229, 0.4);
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-radius: 24px;
}

body {
    background-color: var(--bg-color);
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* Фоновые пятна (Ambient Light) */
.ambient-light {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: float 10s infinite alternate;
}

.ambient-light.one {
    background: radial-gradient(circle, rgba(99,102,241,0.3) 0%, rgba(255,255,255,0) 70%);
    top: -10%;
    left: -10%;
}

.ambient-light.two {
    background: radial-gradient(circle, rgba(168,85,247,0.3) 0%, rgba(255,255,255,0) 70%);
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0); }
    100% { transform: translate(30px, 30px); }
}

/* Карточка */
.main-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255,255,255,0.5);
    padding: 3.5rem 3rem;
    width: 100%;
    max-width: 580px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Заголовки */
.badge-ai {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.app-title {
    font-weight: 800;
    font-size: 2.5rem;
    letter-spacing: -1px;
    margin-bottom: 0.75rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 2.5rem;
}

/* Зона загрузки */
.upload-zone {
    background: #fff;
    border: 2px dashed #e2e8f0;
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    group: upload;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary-color);
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

.icon-container {
    width: 80px;
    height: 80px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    transition: all 0.3s ease;
}

.upload-zone:hover .icon-container {
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.1);
}

.upload-icon {
    font-size: 2.5rem;
    color: #94a3b8;
    transition: color 0.3s ease;
}

.upload-zone:hover .upload-icon {
    color: var(--primary-color);
}

.upload-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.upload-hint {
    color: #94a3b8;
    font-size: 0.9rem;
    margin: 0;
}

/* --- ПРЕВЬЮ (ИСПРАВЛЕНО) --- */
#previewContainer {
    margin-top: 0;
    border-radius: 20px;
    overflow: hidden;
    
    /* СКРЫТО ПО УМОЛЧАНИЮ */
    display: none; 
    
    /* Фиксы размеров */
    width: 100%;
    background: #f1f5f9; /* Серый фон, чтобы видеть блок если картинка битая */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    position: relative;
}

.preview-wrapper {
    width: 100%;
    /* Убрал display: flex, чтобы не схлопывалось */
    display: block;
    position: relative;
}

#preview {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    min-height: 250px; /* Минимальная высота, чтобы блок не был пустым */
    max-height: 500px;
}

.preview-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.preview-wrapper:hover .preview-overlay {
    opacity: 1;
}

.preview-overlay i {
    color: white;
    font-size: 2rem;
}

/* Кнопка удаления */
.btn-close-preview {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.btn-close-preview:hover {
    transform: scale(1.1);
    background: #fff;
    color: #dc2626;
}

/* Кнопка действия */
.btn-primary-custom {
    background: var(--primary-gradient);
    border: none;
    padding: 16px 32px;
    border-radius: 16px;
    font-weight: 600;
    font-size: 1.1rem;
    width: 100%;
    margin-top: 2rem;
    color: white;
    transition: all 0.3s;
    box-shadow: 0 10px 20px -5px var(--primary-glow);
    display: block;
    position: relative;
    overflow: hidden;
}

.btn-primary-custom:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px var(--primary-glow);
    color: white;
}

.btn-primary-custom:active {
    transform: translateY(0);
}

/* Прогресс бар */
.progress-container {
    margin-top: 2rem;
    display: none;
}

.topic-input-block {
    margin-top: 1.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 30px -15px rgba(0,0,0,0.1);
}

.topic-input-block textarea {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.progress {
    height: 8px;
    border-radius: 10px;
    background-color: #e2e8f0;
    overflow: hidden;
}

.progress-bar {
    background: var(--primary-gradient);
    border-radius: 10px;
    animation: shimmer 2s infinite linear;
    background-size: 200% 100%;
}

/* Ошибки */
.error-message {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 16px;
    padding: 1rem;
    margin-top: 1.5rem;
    display: none;
    font-size: 0.95rem;
    align-items: center;
    animation: shake 0.4s ease-in-out;
}

/* Лайтбокс */
.lightbox {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox.active { opacity: 1; pointer-events: all; cursor: zoom-out; }
.lightbox img {
    max-width: 95%; max-height: 95%;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lightbox.active img { transform: scale(1); }

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Адаптивность */
@media (max-width: 576px) {
    .main-card { padding: 2rem 1.5rem; border-radius: 20px; }
    .app-title { font-size: 2rem; }
    .upload-zone { padding: 2rem 1rem; }
}

input[type="file"] { display: none; }