/* Generate Page Styles */

.generate-section {
    padding: 40px 0 80px 0;
    background: #ffffff;
    min-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

/* На странице генерации footer должен быть ниже экрана */
body:has(.generate-section) {
    min-height: 100vh;
}

.generate-title {
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 32px;
    color: #000000;
    flex-shrink: 0;
}

.generate-form {
    max-width: 640px;
    margin: 0 auto;
    transition: opacity 0.3s ease;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    padding: 0 20px;
}

.generate-form.generating .generate-box-wrapper {
    pointer-events: none;
}

.generate-form.generating .btn-generate {
    pointer-events: none;
    opacity: 0.7;
}

/* Одна рамка: поле ввода + настройки внутри */
.generate-box-wrapper {
    position: relative;
    margin-bottom: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.generate-box {
    background: #fff;
    border: 2px solid #e5e5e5;
    border-radius: 16px;
    padding: 20px;
    min-height: clamp(400px, calc(65vh - 120px), 800px);
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.generate-box:focus-within {
    border-color: #3390ec;
    box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.12);
}

.generate-box.dragover {
    border-color: #3390ec;
    background: #f5f9ff;
}

.generate-box-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.generate-select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #1a1a1a;
}

.generate-select-model {
    min-width: 180px;
}

.quality-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.generate-label-inline {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.generate-prompt-wrap {
    position: relative;
    flex: 1;
    display: flex;
    min-height: 0;
}

.generate-textarea {
    display: block;
    width: 100%;
    min-height: clamp(200px, calc(50vh - 180px), 600px);
    height: clamp(200px, calc(50vh - 180px), 600px);
    padding: 12px 40px 12px 0;
    border: none;
    resize: vertical;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.5;
    color: #1a1a1a;
    background: transparent;
}

.generate-prompt-clear {
    position: absolute;
    right: 24px; /* слева от маркера изменения размера textarea */
    bottom: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.generate-prompt-clear:hover {
    color: #333;
    background: #eee;
}

.generate-textarea::placeholder {
    color: #999;
}

.generate-textarea:focus {
    outline: none;
}

.generate-box-bottom {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    margin-top: auto;
}

/* Кнопки «Фото» и «Промт» — одинаковый размер и шрифт */
.generate-btn-gallery,
.generate-btn-prompt-picker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    white-space: nowrap;
}
.generate-btn-gallery:hover,
.generate-btn-prompt-picker:hover {
    border-color: #3390ec;
    background: #f5f9ff;
}
.generate-btn-gallery svg,
.generate-btn-prompt-picker svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.generate-btn-gallery-count {
    background: #3390ec;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.aspect-ratio-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.generate-select-aspect {
    width: auto;
    min-width: 80px;
}

/* Квадратики соотношения сторон */
.aspect-ratio-visual {
    display: flex;
    align-items: center;
    gap: 6px;
}

.aspect-icon {
    width: 24px;
    height: 24px;
    border: 2px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.aspect-icon:hover {
    border-color: #3390ec;
}

.aspect-icon.active {
    border-color: #3390ec;
    background: rgba(51, 144, 236, 0.15);
}

.aspect-1-1   { aspect-ratio: 1/1; }
.aspect-16-9  { width: 32px; height: 18px; }
.aspect-9-16  { width: 18px; height: 32px; }
.aspect-4-3   { width: 28px; height: 21px; }
.aspect-3-4   { width: 21px; height: 28px; }

.files-preview-inline {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    min-height: 0;
    flex-shrink: 0;
    max-height: 80px;
    overflow-y: auto;
}

.files-preview-inline .file-preview-item {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
}

.files-preview-inline .file-preview-item .preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Заглушка для HEIC/DNG — браузер не показывает превью */
.file-preview-placeholder {
    width: 100%;
    height: 100%;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #666;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.file-preview-placeholder-icon {
    font-size: 20px;
    margin-bottom: 2px;
}

.file-preview-placeholder-label {
    font-size: 9px;
    letter-spacing: 0.02em;
}

.files-preview-inline .file-preview-item .file-remove {
    width: 20px;
    height: 20px;
    top: 2px;
    right: 2px;
    font-size: 14px;
}

/* Оверлей загрузки поверх рамки */
.generate-loading-overlay {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.generate-loading-overlay .loading-spinner {
    margin-bottom: 16px;
}

.generate-loading-overlay .loading-text {
    margin-bottom: 4px;
}

.file-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 8px;
}

.form-hint {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: #666666;
    margin-top: 4px;
}

.required {
    color: #ff0000;
}

/* File Upload */
.file-upload-area {
    position: relative;
    border: 2px dashed #cccccc;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    background: #ffffff;
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: #3390ec;
    background: #f8f9fa;
}

.file-upload-area.dragover {
    border-color: #3390ec;
    background: #e8f4fd;
}

.file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload-content {
    pointer-events: none;
}

.file-upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.file-upload-text {
    font-size: 16px;
    color: #333333;
    margin-bottom: 8px;
}

.file-upload-link {
    color: #3390ec;
    text-decoration: underline;
}

.file-upload-hint {
    font-size: 14px;
    color: #666666;
}

.file-preview {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
}

.file-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    object-fit: contain;
}

/* Превью множественных файлов */
.files-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.file-preview-item {
    position: relative;
    border: 2px solid #cccccc;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    aspect-ratio: 1;
}

.file-preview-item .preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.file-preview-item .file-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ff0000;
    color: white;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
    z-index: 10;
}

.file-preview-item .file-remove:hover {
    background: #cc0000;
    transform: scale(1.1);
}

.file-preview-item .file-remove:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.file-preview-number {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.file-count {
    margin-top: 8px;
    font-size: 14px;
    color: #666666;
    font-weight: 500;
}

.file-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ff0000;
    color: white;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.file-remove:hover {
    background: #cc0000;
    transform: scale(1.1);
}

.file-error {
    color: #ff0000;
    font-size: 14px;
    margin-top: 8px;
    display: none;
}

.file-error.show {
    display: block;
}

/* Form Inputs */
.form-textarea,
.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #cccccc;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: #ffffff;
    color: #000000;
    transition: border-color 0.3s, opacity 0.3s, cursor 0.3s;
}

.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: #3390ec;
    box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.1);
}

.form-textarea:disabled,
.form-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f5f5f5;
}

.file-input:disabled {
    cursor: not-allowed;
    pointer-events: none;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.btn-generate {
    width: 100%;
    margin-top: 0;
    flex-shrink: 0;
}

.generate-history-link-wrap {
    margin-top: 16px;
    text-align: center;
}

.generate-history-link {
    font-size: 15px;
    color: #ffa500;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.generate-history-link:hover {
    color: #ff8c00;
    text-decoration: underline;
}

/* Result Container */
.result-container {
    max-width: 800px;
    margin: 40px auto 0;
    padding: 40px;
    padding-bottom: 60px;
    margin-bottom: 40px;
    background: #f8f9fa;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    scroll-margin-top: 20px;
    scroll-margin-bottom: 20px;
}

.result-title {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 24px;
    color: #000000;
}

.result-image-wrapper {
    text-align: center;
}

.result-image {
    max-width: 100%;
    max-height: 600px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
    display: block;
}

.result-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-secondary {
    background: #666666;
    color: white;
}

.btn-secondary:hover {
    background: #555555;
}

/* Loading Container */
.loading-container {
    max-width: 600px;
    margin: 40px auto 0;
    text-align: center;
    padding: 40px;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3390ec;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.loading-text {
    font-size: 18px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 8px;
}

.loading-hint {
    font-size: 14px;
    color: #666666;
}

/* Error Container - скрываем на всех устройствах, используем модальное окно */
.error-container {
    display: none !important;
}

.error-message {
    font-size: 16px;
    color: #856404;
    margin-bottom: 16px;
    text-align: center;
}

/* Error Modal - по аналогии с auth-modal */
.error-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px); /* Для Safari */
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Для iOS */
}

.error-modal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.error-modal-content {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
    text-align: center;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #000000;
    margin: 0 0 16px 0;
    text-align: center;
}

.error-modal-message {
    font-size: 16px;
    color: #666666;
    margin: 0 0 24px 0;
    text-align: center;
    line-height: 1.5;
}

.error-modal-content .btn {
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    display: block;
}

.error-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 28px;
    font-weight: 300;
    color: #999999;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s;
}

.error-modal-close:hover {
    color: #000000;
}

/* Модальное окно «Недостаточно токенов» с тарифами — компактное */
.tokens-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.tokens-modal.show {
    display: flex !important;
}

.tokens-modal-content {
    background-color: #ffffff;
    padding: 16px 20px 20px;
    border-radius: 12px;
    max-width: 520px;
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
    text-align: center;
    margin: auto;
}

.tokens-modal-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.tokens-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #000000;
    margin: 0 0 4px 0;
    text-align: center;
}

.tokens-modal-message {
    font-size: 14px;
    color: #666666;
    margin: 0 0 12px 0;
    text-align: center;
    line-height: 1.4;
}

.tokens-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 22px;
    font-weight: 300;
    color: #999999;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s;
}

.tokens-modal-close:hover {
    color: #000000;
}

.tokens-modal-tariffs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    text-align: center;
}

/* Компактные карточки: только токены, цена, кнопка */
.tokens-modal-tariffs-grid .tariff-card-compact {
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 0;
}

.tokens-modal-tariffs-grid .tariff-card-compact .tariff-tokens {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

.tokens-modal-tariffs-grid .tariff-card-compact .tariff-tokens-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    margin: 0;
}

.tokens-modal-tariffs-grid .tariff-card-compact .tariff-price {
    font-size: 16px;
    font-weight: 700;
    color: #3390ec;
    margin: 0;
}

.tokens-modal-tariffs-grid .tariff-card-compact .tariff-button {
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 13px;
    width: 100%;
}

/* Модальное окно «Библиотека промтов» на странице генерации */
.prompt-library-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}
.prompt-library-modal.is-open {
    opacity: 1;
    visibility: visible;
}
.prompt-library-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}
.prompt-library-box {
    position: relative;
    width: 100%;
    max-width: 560px;
    min-width: 320px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}
.prompt-library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.prompt-library-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
}
.prompt-library-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #f0f0f0;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.prompt-library-close:hover {
    background: #e0e0e0;
}
.prompt-library-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.prompt-library-categories .pl-cat-btn {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #e5e5e5;
    background: #fff;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.prompt-library-categories .pl-cat-btn:hover {
    border-color: #3390ec;
    color: #3390ec;
}
.prompt-library-categories .pl-cat-btn.active {
    background: #FFE135;
    border-color: #FFE135;
    color: #000;
}
.prompt-library-grid {
    flex: 1;
    min-height: 200px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 16px 20px 24px;
    display: grid;
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    grid-auto-rows: minmax(340px, auto);
    row-gap: 28px;
    column-gap: 12px;
    align-content: start;
    align-items: start;
    min-width: 0;
}
.prompt-library-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
    min-height: 340px;
}
.prompt-library-card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    min-height: 140px;
    background: #f8f9fa;
    overflow: hidden;
    flex-shrink: 0;
}
.prompt-library-card-thumb img {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.prompt-library-card-thumb-placeholder {
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #999;
    background: #f8f9fa;
}
.prompt-library-card-thumb-placeholder.show {
    display: flex !important;
}
.prompt-library-card-body {
    padding: 10px 12px;
    flex: 1;
    min-height: 72px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.prompt-library-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.3;
}
.prompt-library-card-cat {
    font-size: 11px;
    color: #3390ec;
    margin: 0;
}
.prompt-library-card-select {
    margin-top: auto;
    padding: 8px 12px;
    width: 100%;
    border: none;
    border-radius: 8px;
    background: #3390ec;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.prompt-library-card-select:hover {
    background: #2a7fd4;
}
.prompt-library-empty {
    padding: 24px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* На узком экране одна колонка — карточки во всю ширину, миниатюры одного размера */
@media (max-width: 380px) {
    .prompt-library-box {
        max-width: calc(100vw - 24px);
    }
    .prompt-library-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .tokens-modal-content {
        padding: 12px 16px 16px;
        max-height: calc(100vh - 24px);
    }
    .tokens-modal-title {
        font-size: 16px;
    }
    .tokens-modal-message {
        font-size: 13px;
    }
    .tokens-modal-tariffs-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .tokens-modal-tariffs-grid .tariff-card-compact .tariff-tokens {
        font-size: 20px;
    }
    .tokens-modal-tariffs-grid .tariff-card-compact .tariff-price {
        font-size: 14px;
    }
}

/* Mobile styles для модального окна ошибок */
@media (max-width: 768px) {
    .error-modal-content {
        padding: 32px 24px;
        margin: 20px;
        max-width: calc(100% - 40px);
        width: calc(100% - 40px);
    }

    .error-modal-title {
        font-size: 20px;
    }

    .error-modal-message {
        font-size: 14px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .error-icon {
        font-size: 40px;
    }
}

/* Дополнительные стили для Safari на iOS - по аналогии с auth-modal */
@supports (-webkit-touch-callout: none) {
    .error-modal {
        -webkit-overflow-scrolling: touch;
        position: fixed;
    }
    
    .error-modal-content {
        -webkit-transform: translateZ(0); /* Ускоряет рендеринг на iOS */
    }
}

/* Убеждаемся, что модальное окно ошибок всегда работает как модальное окно авторизации */
.error-modal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Responsive */
@media (max-width: 768px) {
    /* Страница генерации на мобильных: документ прокручивается, секция не ограничена по высоте */
    body:has(.generate-section) {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 100%;
    }

    html:has(.generate-section) {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .generate-section {
        padding: 8px 0 12px 0;
        min-height: calc(100vh - 58px);
        display: flex;
        flex-direction: column;
        overflow: visible;
        flex: none;
    }

    .generate-section .container {
        flex: none;
        overflow: visible;
    }

    .generate-title {
        font-size: 22px;
        margin-bottom: 12px;
        padding: 0 10px;
    }

    .generate-form {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        padding: 0 10px;
    }

    .generate-box-wrapper {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        margin-bottom: 12px;
    }

    .generate-box {
        padding: 10px;
        min-height: clamp(300px, calc(75vh - 180px), 600px);
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .generate-box-top {
        margin-bottom: 6px;
        gap: 8px;
    }

    .generate-select {
        padding: 6px 10px;
        font-size: 13px;
    }

    .generate-select-model {
        min-width: 100%;
        flex: 1;
    }

    .quality-wrap {
        gap: 6px;
    }

    .generate-label-inline {
        font-size: 12px;
    }

    .generate-textarea {
        flex: 1;
        min-height: clamp(150px, calc(45vh - 120px), 400px);
        padding: 8px 0;
        font-size: 15px;
        line-height: 1.4;
        resize: vertical;
    }

    .generate-box-bottom {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding-top: 8px;
        margin-top: auto;
        flex-shrink: 0;
    }

    .generate-btn-gallery,
    .generate-btn-prompt-picker {
        padding: 6px 10px;
        font-size: 12px;
        gap: 6px;
    }

    .generate-btn-gallery svg,
    .generate-btn-prompt-picker svg {
        width: 18px;
        height: 18px;
    }

    .aspect-ratio-picker {
        gap: 6px;
    }

    .generate-label-inline {
        font-size: 12px;
    }

    .generate-select-aspect {
        min-width: 70px;
        padding: 6px 8px;
        font-size: 12px;
    }

    .aspect-icon {
        width: 20px;
        height: 20px;
    }

    .aspect-16-9 {
        width: 28px;
        height: 16px;
    }

    .aspect-9-16 {
        width: 16px;
        height: 28px;
    }

    .aspect-4-3 {
        width: 24px;
        height: 18px;
    }

    .aspect-3-4 {
        width: 18px;
        height: 24px;
    }

    .files-preview-inline {
        margin-top: 6px;
        gap: 4px;
        max-height: 60px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .files-preview-inline .file-preview-item {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        flex-shrink: 0;
    }

    .btn-generate {
        width: 100%;
        padding: 14px;
        font-size: 16px;
        margin-top: 0;
        flex-shrink: 0;
    }

    .result-container {
        padding: 20px;
        padding-bottom: 40px;
        margin-bottom: 20px;
        margin-top: 24px;
    }
    
    .result-image {
        max-height: min(70vh, 400px);
        width: 100%;
        object-fit: contain;
    }
    
    .result-image-wrapper {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .generate-section {
        padding-bottom: 60px;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }
}
