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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

.container {
    max-width: 100%;
    height: 100vh;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Error */
.error {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    position: relative;
}

.error h2 {
    color: #e74c3c;
    margin-bottom: 15px;
}

/* Main Content */
.header {
    text-align: center;
    margin-bottom: 15px;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.header h1 {
    font-size: 1.5rem;
    margin-bottom: 5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.3;
}

/* Photo Section */
.photo-section {
    background: white;
    border-radius: 15px;
    padding: 20px 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 15px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
}

.photo-instructions {
    margin-bottom: 20px;
}

.instruction-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.photo-instructions p {
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 1.4;
}

.photo-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1.15rem;
    /* Увеличено с 1rem */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    width: 100%;
    max-width: 280px;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #219a52;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Caption Section */
.caption-section {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 15px;
    flex-shrink: 0;
}

.caption-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #6c757d;
    font-size: 0.9rem;
}

.caption-section label::after {
    content: " (необязательно)";
    font-weight: normal;
    opacity: 0.7;
}

#captionInput {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#captionInput:focus {
    outline: none;
    border-color: #3498db;
}

.char-counter {
    text-align: right;
    margin-top: 5px;
    font-size: 0.8rem;
    color: #6c757d;
}

/* Preview Section - ОПТИМИЗИРОВАНО ДЛЯ МАКСИМАЛЬНОГО ПРОСМОТРА */
.preview-section {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Заголовок предпросмотра с крестиком */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.preview-header h3 {
    margin-bottom: 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.close-preview-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #6c757d;
    cursor: pointer;
    padding: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.close-preview-btn:hover {
    background: #f8f9fa;
    color: #e74c3c;
}

/* ОПТИМИЗИРОВАННЫЙ ПРЕДПРОСМОТР - МАКСИМАЛЬНАЯ ИНФОРМАТИВНОСТЬ */
.photo-preview {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    min-height: 200px;
    /* Минимальная высота для маленьких экранов */
    max-height: 50vh;
    /* Ограничение по высоте для больших экранов */
}

#previewImage {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    /* Сохраняем пропорции, обрезаем если нужно */
    display: block;
}

/* Actions */
.actions {
    text-align: center;
    margin-top: 15px;
    flex-shrink: 0;
}

/* Success */
.success {
    text-align: center;
    padding: 30px 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    position: relative;
}

.success-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.success h2 {
    color: #27ae60;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px;
    border-radius: 5px;
    font-size: 11px;
    z-index: 1000;
    max-width: 250px;
}

/* Main content area */
#main {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* КНОПКИ ЗАКРЫТИЯ ПРИЛОЖЕНИЯ */
.close-app-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 5px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.close-app-btn:hover {
    background: white;
    color: #e74c3c;
    transform: scale(1.1);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .photo-section {
        padding: 15px 10px;
    }

    .instruction-icon {
        font-size: 2.5rem;
    }

    .btn {
        width: 100%;
        max-width: 100%;
        font-size: 1.1rem;
        /* Увеличено для планшетов */
    }

    .debug-panel {
        display: none !important;
    }

    .close-app-btn {
        width: 30px;
        height: 30px;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }

    .header {
        margin-bottom: 10px;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .photo-section,
    .caption-section,
    .preview-section {
        padding: 12px;
        margin-bottom: 10px;
    }

    .instruction-icon {
        font-size: 2rem;
    }

    .preview-header h3 {
        font-size: 1rem;
    }

    .btn {
        padding: 10px 15px;
        min-height: 40px;
        font-size: 1.05rem;
        /* Увеличено для мобильных */
    }

    .close-app-btn {
        top: 5px;
        right: 5px;
        width: 25px;
        height: 25px;
        font-size: 1.2rem;
    }
}

/* Small height devices */
@media (max-height: 700px) {
    .instruction-icon {
        font-size: 2rem !important;
        margin-bottom: 5px;
    }

    .photo-instructions {
        margin-bottom: 10px;
    }

    .photo-instructions p {
        font-size: 0.8rem;
    }

    .btn {
        padding: 8px 12px;
        min-height: 36px;
        font-size: 0.85rem;
    }

    .header h1 {
        font-size: 1.1rem;
    }

    .photo-preview {
        min-height: 150px;
        max-height: 40vh;
    }
}

@media (max-height: 600px) {
    .container {
        padding: 5px;
    }

    .header {
        margin-bottom: 5px;
    }

    .photo-section,
    .caption-section,
    .preview-section {
        padding: 8px;
        margin-bottom: 8px;
    }

    .instruction-icon {
        display: none;
    }

    .photo-preview {
        min-height: 120px;
        max-height: 35vh;
    }

    .close-app-btn {
        top: 3px;
        right: 3px;
        width: 22px;
        height: 22px;
        font-size: 1.1rem;
    }
}

/* Для очень высоких экранов */
@media (min-height: 1000px) {
    .photo-preview {
        max-height: 60vh;
    }
}

.closing-message {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 10px 0;
    font-style: italic;
}

/* ... существующие стили без изменений ... */

/* Moderation Rejected */
.moderation-rejected {
    text-align: center;
    padding: 25px 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    position: relative;
}

.rejected-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #e74c3c;
}

.moderation-rejected h2 {
    color: #e74c3c;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.rejection-reason {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
    text-align: left;
    max-width: 100%;
}

.rejection-reason strong {
    color: #495057;
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.rejection-reason p {
    color: #6c757d;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Responsive для блока модерации */
@media (max-width: 480px) {
    .moderation-rejected {
        padding: 20px 15px;
    }

    .rejection-reason {
        padding: 12px;
        margin: 12px 0;
    }

    .rejected-icon {
        font-size: 2.5rem;
        margin-bottom: 12px;
    }

    .moderation-rejected h2 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
}

@media (max-height: 600px) {
    .moderation-rejected {
        padding: 15px 12px;
    }

    .rejected-icon {
        font-size: 2rem;
        margin-bottom: 10px;
    }

    .rejection-reason {
        padding: 10px;
        margin: 10px 0;
    }
}

/* Exceeded Limit Block */
.exceeded-limit {
    text-align: center;
    padding: 30px 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    position: relative;
    animation: fadeInScale 0.5s ease-out;
}

.exceeded-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #e74c3c;
}

.exceeded-limit h2 {
    color: #e74c3c;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 700;
}

.exceeded-limit p {
    color: #6c757d;
    margin-bottom: 10px;
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
}

.limit-timer {
    margin: 20px 0;
    padding: 15px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-radius: 10px;
    border: 1px solid #ffecb5;
}

.limit-timer p {
    color: #856404;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
}

#limitCountdown {
    font-size: 1.2rem;
    font-weight: 700;
    color: #d63031;
    transition: all 0.3s ease;
}

/* Кнопка "Закрыть сейчас" для лимита */
#closeLimitNowButton {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
}

#closeLimitNowButton:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Responsive для блока лимита */
@media (max-width: 480px) {
    .exceeded-limit {
        padding: 25px 15px;
    }

    .exceeded-icon {
        font-size: 3rem;
        margin-bottom: 15px;
    }

    .exceeded-limit h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    .limit-timer {
        margin: 15px 0;
        padding: 12px;
    }
}

@media (max-height: 600px) {
    .exceeded-limit {
        padding: 20px 15px;
    }

    .exceeded-icon {
        font-size: 2.5rem;
        margin-bottom: 12px;
    }

    .limit-timer {
        margin: 12px 0;
        padding: 10px;
    }
}

/* Moderation Wait Screen */
.moderation-wait {
    text-align: center;
    padding: 30px 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    position: relative;
    animation: fadeInScale 0.5s ease-out;
}

.moderation-spinner {
    margin-bottom: 25px;
}

.spinner.large {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(52, 152, 219, 0.3);
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.moderation-wait h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 600;
}

.moderation-wait p {
    color: #6c757d;
    margin-bottom: 15px;
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
    max-width: 300px;
}

.moderation-info {
    margin-top: 20px;
    padding: 12px 20px;
    background: #e8f4fd;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}

.moderation-info p {
    color: #2c3e50;
    font-size: 0.9rem;
    margin: 0;
    font-style: italic;
}

/* Анимация пульсации для текста */
@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    100% {
        opacity: 1;
    }
}

.moderation-wait p {
    animation: pulse 2s infinite;
}

/* Responsive для блока ожидания модерации */
@media (max-width: 480px) {
    .moderation-wait {
        padding: 25px 15px;
    }

    .moderation-spinner {
        margin-bottom: 20px;
    }

    .spinner.large {
        width: 50px;
        height: 50px;
    }

    .moderation-wait h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    .moderation-wait p {
        font-size: 0.9rem;
    }

    .moderation-info {
        margin-top: 15px;
        padding: 10px 15px;
    }
}

@media (max-height: 600px) {
    .moderation-wait {
        padding: 20px 15px;
    }

    .moderation-spinner {
        margin-bottom: 15px;
    }

    .spinner.large {
        width: 45px;
        height: 45px;
    }

    .moderation-wait h2 {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }

    .moderation-info {
        margin-top: 12px;
        padding: 8px 12px;
    }
}

/* Стили для информации о сжатии */
.compression-info {
    background: #e8f4fd;
    border: 1px solid #b3d4fc;
    border-radius: 8px;
    padding: 10px 15px;
    margin: 10px 0;
    font-size: 0.85rem;
    color: #2c3e50;
    text-align: center;
}

.compression-info p {
    margin: 5px 0;
    line-height: 1.4;
}

.compression-progress {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin: 10px 0;
    overflow: hidden;
}

.compression-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Индикатор этапов сжатия */
.compression-stages {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 0.75rem;
    color: #6c757d;
}

.compression-stage {
    text-align: center;
    flex: 1;
    padding: 5px;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.compression-stage.active {
    color: #3498db;
    font-weight: bold;
    opacity: 1;
}

.compression-stage.completed {
    color: #27ae60;
    opacity: 1;
}

/* Для больших файлов - предупреждение */
.large-file-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 10px 0;
    font-size: 0.8rem;
    color: #856404;
}

.large-file-warning strong {
    display: block;
    margin-bottom: 3px;
}

/* Анимация пульсации для прогресса */
@keyframes pulse-progress {
    0% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.7;
    }
}

.compressing .compression-progress-bar {
    animation: pulse-progress 1.5s infinite;
}