/* ============================================
   СТРАНИЦА AI STUDIO - CSS
   ============================================ */

/* CSS-ПЕРЕМЕННЫЕ */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --dark-bg: #0a0a0f;
    --card-bg: rgba(255, 255, 255, 0.03); /* Прозрачный фон для Glassmorphism */
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --blur-bg: backdrop-filter: blur(24px) saturate(180%);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    /* Фон с градиентными пятнами (Glassmorphism style) */
    background: 
        radial-gradient(ellipse at top left, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(118, 75, 162, 0.1) 0%, transparent 50%),
        var(--dark-bg);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* HEADER - Шапка студии */
.studio-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1.5rem;
    width: 100%;
}

.studio-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 1rem;
}

.studio-header-top h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    flex-shrink: 0;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-balance-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Блок баланса */
.user-balance {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.75rem 1.25rem;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.balance-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-weight: 500;
}

.balance-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.balance-text {
    font-size: 0.9rem;
}

.free-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

#userBalanceAmount {
    color: #4ade80; /* Зеленый цвет для баланса */
    font-weight: 600;
}

/* Кнопка пополнения */
.balance-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.balance-btn:hover {
    transform: translateY(-1px);
}

/* Группа кнопок баланса (Пополнить / Личный кабинет / Войти) */
.balance-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* увеличенный отступ между кнопками, чтобы они не соприкасались */
    flex-wrap: nowrap;
}

/* Кнопка входа */
.login-btn {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: #4caf50;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Переключатель режимов */
.mode-switcher {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.375rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 0.5rem;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    width: fit-content;
    min-height: 48px;
}

.mode-btn {
    padding: 0.5rem 0.9rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.mode-btn.active {
    background: var(--primary-gradient);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.mode-btn {
    position: relative;
}

/* Пояснение к режимам (PRO и обычный) */

.mode-badge-dev {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    z-index: 10;
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mode-btn[data-mode="audio"]:not(.test-allowed),
.mode-btn[data-mode="video"]:not(.test-allowed) {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.mode-btn[data-mode="audio"]:not(.test-allowed)::after,
.mode-btn[data-mode="video"]:not(.test-allowed)::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    pointer-events: none;
}

/* WORKSPACE - Рабочая область */
.studio-workspace {
    display: grid;
    /* Левая колонка (панель управления) 400px, Правая (результат) - остальное */
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 2rem;
    /* Высоту не фиксируем — даём странице самой решать, нужна ли прокрутка */
    width: 100%;
    align-items: stretch;
}

/* Панель управления (Controls Panel) */
.controls-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    backdrop-filter: blur(24px) saturate(180%);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
	/* Делаем высоту панели сопоставимой с правой панелью результата,
	   чтобы левая колонка не «вытягивалась» выше */
	max-height: calc(100vh - 220px);
    overflow-y: auto;
    overflow-x: hidden;
    align-items: stretch;
    /* Скроллбар для WebKit */
    scrollbar-width: thin;
    scrollbar-color: #667eea rgba(255, 255, 255, 0.05);
}

/* Панель генерации (Result Panel) */
.generation-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    backdrop-filter: blur(24px) saturate(180%);
    height: 100%;
    /* Даём панели расти по содержимому, без собственного скролла — скролл только у страницы */
    max-height: none;
    overflow-y: visible;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.result-area {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.2);
    /* Даём блоку расти по содержимому, без внутреннего скролла — скролл только у страницы */
    min-height: 400px;
    max-height: none;
    margin-bottom: 2rem;
    position: relative;
    overflow: visible;
    width: 100%;
    box-sizing: border-box;
    padding: 1rem;
}

.result-placeholder {
    text-align: center;
    color: var(--text-muted);
    width: 100%;
    padding: 2rem;
}

/* Контейнер для изображения и кнопок в блоке результата после генерации */
.result-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

/* Картинки в большом блоке результата после генерации */
.result-image {
    max-width: 100%;
    /* Вписываем результат в окно по высоте: не больше высоты экрана с учётом шапки/отступов */
    max-height: calc(100vh - 260px);
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
}

/* Элементы формы */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


.form-control {
    width: 100%;
    padding: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
    backdrop-filter: blur(10px);
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

/* Стиль для SELECT */
select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 3rem;
    color: #ffffff !important;
    background-color: rgba(15, 15, 35, 0.8) !important;
}

/* Загрузка файлов */
.file-upload-wrapper {
    position: relative;
    width: 100%;
}

.file-input-hidden {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

.file-upload-btn {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    backdrop-filter: blur(10px);
}

.file-upload-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.file-upload-btn:active {
    transform: translateY(0);
}

.file-upload-btn svg {
    flex-shrink: 0;
    color: #667eea;
}

.file-upload-btn #fileUploadLabel {
    color: var(--text-primary);
    pointer-events: none;
}

.file-info {
    margin-top: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.file-info small {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.file-info #uploadedFiles {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Элементы списка загруженных файлов + заметное превью */
.uploaded-file-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.4rem 0.55rem 0.5rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.45rem;
}

.uploaded-file-icon {
    font-size: 0.85rem;
}

.uploaded-file-name {
    font-size: 0.8rem;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uploaded-file-preview {
	/* Делаем превью в левой панели компактнее, чтобы не раздувать высоту панели */
	width: auto;
	max-width: 150px;
	max-height: 120px;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Хедер элемента загруженного файла: имя + кнопка удаления */
.uploaded-file-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
}

.uploaded-file-remove {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.uploaded-file-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Кнопка генерации */
.generate-btn {
    width: 100%;
    padding: 1.5rem;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Секция подсказок */
.tips-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.tips-title {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tips-list {
    list-style: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.tips-list li {
    margin-bottom: 0.5rem;
    padding-left: 1rem;
    position: relative;
}

.tips-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: bold;
}

/* ДОПОЛНИТЕЛЬНЫЙ CSS для модальных окон, уведомлений, результатов */

/* Стили для Telegram Login Widget */
#telegram-login-container {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

#telegram-login-container iframe {
    border-radius: 12px !important;
    box-shadow: 0 8px 25px rgba(0, 136, 204, 0.3) !important;
    transition: all 0.3s ease !important;
}

#telegram-login-container iframe:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 15px 40px rgba(0, 136, 204, 0.4) !important;
}

/* Nav Back Button */
.nav-back {
    position: fixed;
    top: 2rem;
    left: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.75rem 1.25rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(24px) saturate(180%);
    z-index: 100;
    font-weight: 500;
}

.nav-back:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(-3px);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Уведомления (Notifications) */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 400px;
    z-index: 10000;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notification.success { border-left: 4px solid #43e97b; }
.notification.error { border-left: 4px solid #fa709a; }
.notification.info { border-left: 4px solid #4facfe; }

.notification-header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.notification-body {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.notification-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
}

/* Validation Messages */
.validation-message {
    display: none;
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(250, 112, 154, 0.1);
    border: 1px solid rgba(250, 112, 154, 0.3);
    border-radius: 12px;
    color: #fa709a;
    font-size: 0.875rem;
    line-height: 1.4;
    animation: fadeIn 0.3s ease;
}

.validation-message.show { display: block; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Loading Area */
.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    width: 100%;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 1.125rem;
    text-align: center;
}

/* Результаты пользователя (Results Section) */
.results-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    backdrop-filter: blur(10px);
}

/* Справка по моделям (audio/video) */
.models-help {
    margin-top: 2rem;
    background: rgba(15, 15, 35, 0.9);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    padding: 2rem;
    backdrop-filter: blur(16px);
}

.models-help-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.models-help-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.models-help-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.models-tab-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.models-tab-btn.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.models-help-content {
    margin-top: 0.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}

.models-tab-panel {
    display: none;
}

.models-tab-panel.active {
    display: block;
}

.model-card {
    background: rgba(9, 9, 15, 0.9);
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    padding: 0.75rem 1rem;
}

.model-card summary {
    list-style: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-card summary::-webkit-details-marker {
    display: none;
}

.model-card[open] summary {
    color: #e5e7eb;
}

.model-card .model-body {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.model-card .model-body ul {
    margin: 0.75rem 0 0;
    padding-left: 1.1rem;
}

.model-card .model-body li {
    margin-bottom: 0.2rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.results-filters {
    display: flex;
    gap: 1rem;
}

.results-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 1.5rem !important;
    align-items: stretch !important;
}

.result-item {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}

.result-item:hover {
    transform: translateY(-4px);
    border-color: #667eea;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.result-preview {
    height: 200px !important;
    min-height: 200px !important;
    max-height: 200px !important;
    background: rgba(255, 255, 255, 0.02) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    flex-shrink: 0 !important;
    width: 100% !important;
}

.result-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-preview .result-icon {
    color: var(--text-secondary);
    opacity: 0.5;
}

.result-info {
    padding: 1.5rem !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
}

.result-type {
    font-size: 0.85rem;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
}

.result-prompt {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.result-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.result-actions {
    display: flex !important;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: auto !important;
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.download-btn:hover {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Image Modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    /* Разрешаем внутренний вертикальный скролл, чтобы всегда был виден блок с промптом */
    overflow-y: auto;
    overflow-x: hidden;
    /* Убеждаемся, что кнопка закрытия видна */
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
	padding: 0.75rem 1rem 1rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    /* Ограничиваем по высоте экрана, внутреннее содержимое можно прокручивать */
    max-height: 90vh;
    max-width: 95vw;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    /* Убеждаемся, что кнопка закрытия видна - добавляем padding-top для места под кнопку */
    padding-top: 3.5rem; /* Добавляем место для кнопки закрытия сверху */
}

.modal-media-container {
    display: flex;
    justify-content: center;
	align-items: center;
	flex: 1 1 auto;
    width: 100%;
	min-height: 0;
}

.modal-media-container img,
.modal-media-container video {
    max-width: 100%;
    /* Вписываем медиа в окно: даём не больше ~70% высоты экрана под картинку,
       чтобы она целиком помещалась и оставалось место под промпт/отступы. */
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
}

.modal-media-container audio {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.modal-prompt {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    flex-shrink: 0;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.modal-prompt-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.modal-prompt-text {
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Скроллбар для промпта */
.modal-prompt-text::-webkit-scrollbar {
    width: 6px;
}

.modal-prompt-text::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.modal-prompt-text::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.modal-prompt-text::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .modal-content {
        padding: 1rem;
        max-width: 95vw;
    }
    
    .modal-media-container img,
    .modal-media-container video {
        max-height: 60vh;
    }
    
    .modal-prompt-text {
        max-height: 200px;
    }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.8rem;
    font-weight: 300;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10001; /* Убеждаемся, что кнопка поверх всего */
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s ease;
    /* Улучшаем видимость кнопки */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.modal-close:active {
    transform: scale(0.95);
}

/* Edit Modal */
.edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.edit-modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    max-width: 600px;
    width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

/* Модальное окно пополнения баланса */
.topup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: fadeIn 0.3s ease;
    margin: 0;
    padding: 0;
}

.topup-modal.show {
    display: flex !important;
}

.topup-modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.topup-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.topup-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.topup-modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    padding: 0;
}

.topup-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.topup-balance-info {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.topup-balance-info p {
    margin: 0.5rem 0;
    color: var(--text-primary);
}

.topup-min-amount {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.topup-form-group {
    margin-bottom: 1.5rem;
}

.topup-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.topup-input {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 1.125rem;
    transition: all 0.3s ease;
    font-family: inherit;
    /* Убираем стрелки для input type="number" */
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Убираем стрелки для Chrome, Safari, Edge */
.topup-input::-webkit-outer-spin-button,
.topup-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.topup-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: rgba(255, 255, 255, 0.1);
}

.topup-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    min-height: 1.5rem;
}

.topup-submit-btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
    font-family: inherit;
}

.topup-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.topup-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.topup-info {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.topup-info p {
    margin: 0.5rem 0;
}

/* Price Info */
.price-info {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.price-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.price-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.price-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.price-value.free {
    color: #4ade80;
}

.price-value.paid {
    color: #667eea;
}

.price-note {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Result Buttons */
.result-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.result-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #667eea;
}

.result-btn.download-btn:hover {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}

.result-btn.delete-btn {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.result-btn.delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: white;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-method {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.logout-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Results Empty */
.results-empty {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.results-empty h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.results-empty p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.loading-item {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.error-item {
    text-align: center;
    padding: 2rem;
    color: #fa709a;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .studio-workspace {
        grid-template-columns: 1fr; /* Одна колонка на узких экранах */
        gap: 1.5rem;
        height: auto;
        min-height: auto;
    }
    
    .controls-panel {
        max-height: none;
        order: -1; /* Панель управления над результатом */
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .studio-header h1 {
        font-size: 2rem;
    }
    
    .studio-header-top {
        flex-direction: column;
        align-items: center;
    }
    
    .header-balance-group {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .user-balance {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1rem;
    }
    
    .mode-switcher {
        flex-wrap: wrap;
        width: 100%;
        padding: 0.5rem;
    }
    
    .mode-btn {
        flex: 1 1 auto;
        min-width: 120px;
        margin: 0.25rem;
    }
    
    .results-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .results-filters {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .results-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .result-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-btn {
        width: 100%;
        min-width: 100%;
        padding: 0.5rem;
    }
    
    .notification {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        min-width: auto;
    }
    
    .nav-back {
        top: 1rem;
        left: 1rem;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .models-help-tabs {
        gap: 0.375rem;
        padding: 0.2rem;
    }
    
    .models-tab-btn {
        padding: 0.35rem 0.7rem;
        font-size: 0.85rem;
    }
}

/* ============================================
   ФУТЕР СТРАНИЦЫ STUDIO
   ============================================ */
.studio-footer {
    margin-top: 4rem;
    padding: 2rem 1rem;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.studio-footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

.studio-footer-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.studio-footer-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.studio-footer-text {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
    margin: 0;
}

.studio-footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9375rem;
    transition: all 0.3s ease;
    width: fit-content;
}

.studio-footer-link:hover {
    color: #764ba2;
    gap: 0.75rem;
}

.studio-footer-link svg {
    width: 14px;
    height: 14px;
}

.studio-footer-contacts {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.studio-footer-contact {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9375rem;
    padding: 0.625rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.3s ease;
}

.studio-footer-contact:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

.studio-footer-contact svg {
    width: 16px;
    height: 16px;
    color: #667eea;
    flex-shrink: 0;
}

.studio-footer-time {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-left: auto;
}

/* Мобильные стили для футера */
@media (max-width: 768px) {
    .studio-footer {
        margin-top: 3rem;
        padding: 1.5rem 1rem;
    }
    
    .studio-footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .studio-footer-title {
        font-size: 1rem;
    }
    
    .studio-footer-contact {
        flex-wrap: wrap;
    }
    
    .studio-footer-time {
        margin-left: 0;
        width: 100%;
    }
}

