:root {
    /* Основные тона: пыльный синий и мягкий шалфейный */
    --primary-gradient: linear-gradient(135deg, #6491b3 0%, #82bda8 100%);
    --active-gradient: linear-gradient(135deg, #527996, #679c89);
    

    --title-gradient: linear-gradient(135deg, #6c849c 0%, #333660 100%);
    
    --bg-color: #f6f8f9; 
    --card-bg: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-radius: 20px;
}

body { 
    font-family: 'Nunito', sans-serif; 
    background: linear-gradient(135deg, #3a4b5c, #6a7c8a); 
    color: var(--text-main); 
    padding: 20px 20px 40px; 
    margin: 0;
    min-height: 100vh;
}

.container { 
    max-width: 800px; 
    margin: 0 auto; 
    background: rgba(255, 255, 255, 0.98); 
    padding: 40px; 
    border-radius: 24px; 
    box-shadow: 0 25px 50px rgba(0,0,0,0.15); 
    backdrop-filter: blur(10px);
}

h1 { 
    text-align: center; 
    font-weight: 800;
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: var(--title-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0px 2px 8px rgba(246, 65, 108, 0.25));
    letter-spacing: -0.5px;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 40px;
    font-size: 1.1rem;
}

.step { 
    margin-bottom: 25px; 
    padding: 20px; 
    background: #f8fafc; 
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.step:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border-color: #cbd5e1;
}

label { 
    font-weight: 700; 
    display: block; 
    margin-bottom: 12px; 
    font-size: 1.1rem; 
    color: #1e293b; 
}

.help-text { 
    font-size: 0.85rem; 
    color: #94a3b8; 
    font-weight: 400; 
    font-style: italic;
}

input[type="text"], input[type="number"], input[type="email"], input[type="password"] { 
    width: 100%; 
    padding: 14px 16px; 
    border: 2px solid #e2e8f0; 
    border-radius: 12px; 
    box-sizing: border-box; 
    font-size: 1rem; 
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: #6491b3;
    box-shadow: 0 0 0 3px rgba(100, 145, 179, 0.15);
}

.btn-group { 
    display: flex; 
    gap: 10px; 
    flex-wrap: wrap; 
}

.btn-group.scrollable { 
    padding: 10px; 
    background: #ffffff; 
    border: 1px solid #e2e8f0; 
    border-radius: 12px; 
    align-content: flex-start; 
}

.btn { 
    padding: 10px 18px; 
    border: 1px solid #e2e8f0; 
    border-radius: 30px; 
    cursor: pointer; 
    background-color: #ffffff; 
    transition: all 0.25s ease; 
    font-size: 0.95rem; 
    font-weight: 600;
    color: #475569; 
}

.btn:hover { 
    background-color: #f1f5f9; 
    transform: translateY(-1px);
}

.btn.active { 
    background: var(--active-gradient); 
    color: white; 
    box-shadow: 0 4px 12px rgba(107, 163, 143, 0.3); 
    transform: translateY(-1px);
}

.custom-input { display: none; margin-top: 15px; }

.submit-btn { 
    width: 100%; 
    padding: 18px; 
    background: var(--primary-gradient); 
    color: white; 
    border: none; 
    border-radius: 16px; 
    font-size: 1.2rem; 
    font-weight: 800; 
    cursor: pointer; 
    margin-top: 20px; 
    transition: all 0.3s ease; 
    box-shadow: 0 8px 20px rgba(100, 145, 179, 0.3);
}

.submit-btn:hover { 
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(100, 145, 179, 0.4);
}

.submit-btn:disabled { 
    background: #cbd5e1; 
    cursor: not-allowed; 
    box-shadow: none;
    transform: none;
}

#loading { 
    text-align: center; 
    display: none; 
    margin-top: 30px; 
    font-size: 1.1rem; 
    color: #6491b3;
    font-weight: 600;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

#result-container { 
    display: none; 
    margin-top: 40px; 
    padding: 35px; 
    background-color: #fdfbf7; 
    border: 1px solid #e2d9c3;
    border-radius: 12px; 
    white-space: pre-wrap; 
    line-height: 1.8; 
    font-size: 1.1rem;
    font-family: 'Merriweather', serif; 
    color: #2c2724;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.02), 0 10px 25px rgba(0,0,0,0.05);
}

.category-title { 
    margin: 20px 0 10px; 
    font-size: 0.85rem; 
    color: #64748b; 
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 1.5px; 
}

.authors-container { 
    background: #ffffff; 
    padding: 15px 20px; 
    border-radius: 12px; 
    border: 1px solid #e2e8f0; 
}

#rating-section {
    display: none; 
    margin-top: 30px;
    padding: 25px;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

.rating-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #2d3748;
    margin-bottom: 15px;
}

.stars {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.star-btn {
    font-size: 2.5rem;
    color: #cbd5e1; 
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
    padding: 0;
    line-height: 1;
}

.star-btn:hover {
    transform: scale(1.2);
}

.star-btn.active {
    color: #f59e0b; 
    text-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

#rating-message {
    margin-top: 15px;
    font-weight: 600;
    font-size: 1.1rem;
    color: #6491b3; 
    display: none;
}

.site-footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    color: rgba(255,255,255,0.7);
    font-size: 0.95rem;
}
.site-footer a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: color 0.2s;
}
.site-footer a:hover {
    color: #ffffff;
    text-decoration: underline;
}
.footer-links {
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}
.footer-separator {
    color: rgba(255,255,255,0.3);
}

.expand-toggle {
    display: none;
}

#tts-controls {
    margin-top: 30px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: #ffffff;
    padding: 25px;
    border-radius: 16px;
    border: 2px dashed #cbd5e1;
    box-shadow: 0 10px 25px rgba(0,0,0,0.03);
}

.voice-select-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #475569;
    flex-wrap: wrap;
    justify-content: center;
}

.voice-select {
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    background-color: #f8fafc;
    color: #1e293b;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s;
}

.voice-select:focus {
    border-color: #6491b3;
}

.tts-btn-primary {
    background: linear-gradient(135deg, #e58c8a 0%, #d76e79 100%); 
    color: white;
    border: none;
    padding: 15px 35px;
    border-radius: 30px;
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 15px rgba(215, 110, 121, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tts-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(215, 110, 121, 0.4);
}

.tts-btn-primary:disabled {
    background: #cbd5e1;
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

/* --- Верхняя панель (Личный кабинет) --- */
.top-bar {
    max-width: 900px;
    margin: 0 auto 30px;
    background: rgba(255, 255, 255, 0.85); /* Полупрозрачный белый */
    padding: 12px 25px;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    border: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    justify-content: space-between; /* Разносим элементы влево и вправо */
    align-items: center;
    
    /* Эффект матового стекла */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    
    /* ФИКСАЦИЯ ПРИ ПРОКРУТКЕ */
    position: sticky;
    top: 15px;
    z-index: 1000;
}

.tb-left, .tb-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Стили логина (почты) */
.user-email, .guest-logo {
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}
.user-email svg { color: #6491b3; }
.guest-logo { color: #6491b3; font-size: 1.1rem; }

/* Стили Баланса */
.user-limits {
    font-weight: 800;
    font-size: 0.95rem;
    color: #334155;
    background: #f1f5f9;
    padding: 6px 14px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Стили кнопок панели */
.tb-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.tb-btn-lib {
    background: rgba(100, 145, 179, 0.1);
    color: #6491b3;
}
.tb-btn-lib:hover {
    background: rgba(100, 145, 179, 0.2);
    transform: translateY(-1px);
}

.tb-btn-admin {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}
.tb-btn-admin:hover {
    background: rgba(245, 158, 11, 0.2);
    transform: translateY(-1px);
}

.tb-btn-logout {
    background: rgba(226, 232, 240, 0.5);
    color: #64748b;
    padding: 8px 12px;
}
.tb-btn-logout:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* --- Модальное окно --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    /* Делаем фон чуть темнее, чтобы компенсировать отсутствие размытия */
    background: rgba(15, 32, 39, 0.9); 
    
    /* УДАЛЯЕМ ИЛИ ЗАКОММЕНТИРУЕМ ЭТУ СТРОКУ: */
    /* backdrop-filter: blur(5px); */ 
    
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-modal {
    position: absolute;
    top: 20px; right: 25px;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.close-modal:hover { color: #d76e79; }

#auth-title {
    text-align: center;
    margin-top: 0;
    color: #6491b3;
    font-size: 1.8rem;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-weight: 600;
    font-size: 0.95rem;
}
.auth-switch a {
    color: #6491b3;
    text-decoration: none;
    margin-left: 5px;
}
.auth-switch a:hover { text-decoration: underline; }

.login-top-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.login-top-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(100, 145, 179, 0.3);
}

/* Мобильная адаптация */
@media (max-width: 700px) {
    .top-bar {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        justify-content: center;
    }
    .tb-left, .tb-right {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 600px) {
    .container { padding: 25px 15px; }
    h1 { font-size: 1.7rem; }
    .btn { width: 100%; text-align: center; }
    .btn-group { flex-direction: column; }

    /* --- Кнопки возраста в ряд (кружочки) --- */
        #age-buttons.btn-group {
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: center;
            gap: 10px;
        }
        
        #age-buttons .btn:not([data-value="custom"]) {
            width: 46px;      /* Фиксированная ширина для идеального круга */
            height: 46px;     /* Фиксированная высота */
            padding: 0;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.05rem;
            flex: none;       /* Запрещаем кнопке растягиваться */
        }
        
        #age-buttons .btn[data-value="custom"] {
            width: 100%;
            flex-basis: 100%; /* Принудительно отправляем на новую строку */
            margin-top: 8px;
        }
    
    .footer-separator { display: none; }
    .footer-links { flex-direction: column; gap: 8px; }
    
    .collapsible-container.mobile-collapsed {
        max-height: 290px;
        overflow: hidden;
        position: relative;
    }
    .collapsible-container.mobile-collapsed::after {
        content: '';
        position: absolute;
        bottom: 0; left: 0; right: 0;
        height: 60px;
        background: linear-gradient(to bottom, rgba(255,255,255,0), #ffffff);
        pointer-events: none;
        border-radius: 0 0 12px 12px;
    }
    
    .expand-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        color: #6491b3;
        font-weight: 800;
        font-size: 0.95rem;
        padding: 15px 10px 0;
        cursor: pointer;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        transition: opacity 0.3s;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    .expand-toggle:active {
        opacity: 0.6;
    }

    .modal-content { padding: 30px 20px; width: 90%; }
}

.user-info-group {
    display: flex;
    align-items: center;
    gap: 12px;
}
.tb-logout-inline {
    color: #94a3b8;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}
.tb-logout-inline:hover {
    color: #ef4444; /* Иконка станет красной при наведении */
}

/* --- Стили для красивых уведомлений --- */
.notification-card {
    background: #ffffff;
    padding: 25px 30px;
    border-radius: 24px;
    max-width: 800px;
    margin: 0 auto 25px auto;
    box-shadow: 0 15px 35px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    text-align: center;
    animation: modalFadeIn 0.4s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.notification-card p {
    margin: 10px 0 5px 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.notification-card span {
    font-size: 0.95rem;
    color: #64748b;
    font-weight: 600;
}

.notif-success p { color: #166534; }
.notif-warning p { color: #991b1b; }

.blue-yarn {
    display: inline-block;
    
    /* Отменяем прозрачность заголовка для эмодзи */
    -webkit-text-fill-color: initial; 
    text-fill-color: initial;
    
    /* Настройка цвета: делаем его серо-синим и благородным */
    filter: hue-rotate(185deg) saturate(70%) brightness(110%);
    
    /* Легкое увеличение и плавность */
    transform: scale(1.1);
    transition: transform 0.3s ease;
    cursor: default;
    
    /* Чтобы он не прыгал при загрузке */
    vertical-align: middle;
    margin-left: 8px;
}

/* Эффект при наведении (опционально) */
.blue-yarn:hover {
    transform: scale(1.2) rotate(10deg);
}