* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
	background: #ffffff;
}

body.register-page .site-header .header-container > :not(.logo):not(.main-nav) {
    display: none !important;
}

body.login-page .site-header .header-container > :not(.logo):not(.main-nav) {
    display: none !important;
}



body.chat-page .header-new-chat,
body.chat-page .header-chats-btn,
body.chat-page .header-book-btn,
.header-subject-btn {
    display: flex;
}

body:not(.chat-page) .header-new-chat,
body:not(.chat-page) .header-chats-btn,
body:not(.chat-page) .header-book-btn {
    display: none;
}

.site-header {
	padding: 1rem 2rem;
	background: #573f5f;
    height: 80px;
}

.header-container {
	margin: 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
    height: 100%;
    position: relative;
}

/* Стили для центрирования навигации в ПК версии */
.main-nav.desktop-subjects {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    max-width: calc(100vw - 600px); /* Увеличиваем отступ для защиты от пересечений */
    max-width: min(calc(100vw - 600px), 650px); /* Уменьшаем максимальную ширину с большим отступом */
    z-index: 1000; /* Ниже кнопки "Чаты" */
}

.main-nav.desktop-subjects ul {
    display: flex;
    list-style: none;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    align-items: center;
    width: 100%;
}

.logo h1 {
	font-size: 1.8rem;
	font-weight: 700;
	display: flex;
	align-items: center;
	font-style: italic;
}

.logo-link {
	color: rgba(255, 255, 255, 0.95);
	text-decoration: none;
	letter-spacing: 0.5px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 24px;
    height: 24px;
    vertical-align: middle;
}

.globe-icon {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 6px;
}

.main-nav ul,
.login-nav ul {
	list-style: none;
	display: flex;
	gap: 0.2rem;
	align-items: center;
}

.nav-btn {
	color: rgba(255, 255, 255, 0.9);
	text-decoration: none;
	padding: 8px 20px;
	border-radius: 6px;
	transition: all 0.3s ease;
	font-weight: 500;
	background: rgba(255, 255, 255, 0.15);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	box-shadow: none;
}

/* Стили для кнопок предметов в десктопной версии */
.main-nav.desktop-subjects .nav-btn.subject-link {
	padding: 4px 10px;
	font-size: 13px;
	height: auto;
	min-height: 28px;
}

/* Адаптивные стили для кнопок предметов */
@media screen and (min-width: 1400px) {
    .main-nav.desktop-subjects {
        max-width: min(calc(100vw - 550px), 750px); /* На больших экранах с увеличенным защитным отступом */
    }
}

@media screen and (max-width: 1399px) and (min-width: 1201px) {
    .main-nav.desktop-subjects {
        max-width: calc(100vw - 600px); /* Промежуточный размер с увеличенной защитой */
    }
}

@media screen and (max-width: 1200px) and (min-width: 951px) {
    .main-nav.desktop-subjects {
        max-width: calc(100vw - 650px); /* На средних экранах максимальный защитный отступ */
    }
}

.nav-btn:hover {
	background: rgba(255, 255, 255, 0.25);
}

a.nav-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 1);
    font-weight: 600;
}

a.nav-btn.disabled {
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
    cursor: not-allowed;
}

.register {
	background: rgba(255, 255, 255, 0.15);
}

.register:hover {
	background: rgba(255, 255, 255, 0.35);
}

.user-menu {
	position: relative;
	z-index: 1050; /* Поверх всех других элементов */
}

.user-menu-trigger {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    padding: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Добавь vertical-align: middle; */
    vertical-align: middle;
}

.user-menu-trigger:hover {
	background: rgba(255, 255, 255, 0.25);
	transform: scale(1.05);
}

.user-menu-trigger svg {
    width: 32px;
    height: 32px;
    /* Добавь vertical-align: middle; */
    vertical-align: middle;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: -20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 8px 0;
    min-width: 150px;
    z-index: 1050;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
}

.dropdown-menu a:hover {
    background-color: #f5f5f5;
}

.user-menu:hover .dropdown-menu {
    display: block;
}

.variant-label {
	background: #fff;
	padding: 1rem;
	color: #333;
	font-weight: 500;
}

.main-nav ul,
.login-nav ul {
	flex-wrap: wrap;
	justify-content: center;
}

.login-nav ul {
    list-style: none;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    margin-left: auto;
}

.main-container {
    display: flex;
    height: calc(100vh - 80px);
    width: 100%;
    position: relative;
    gap: 0;
    padding: 0;
    margin: 0;
}

.chat-and-saved-container {
    flex: 1;
    display: flex;
    overflow-y: auto;
    height: calc(100vh - 80px);
    position: relative;
    margin: 0;
    padding: 0;
    width: 100%;
}

.contents-container {
    width: 330px;
    background: white;
    overflow-y: auto;
    padding: 30px 20px 20px 20px;
    height: calc(100vh - 80px);
    position: sticky;
    top: 0;
    left: 0;
    flex-shrink: 0;
    margin: 0;
}

.main-container::-webkit-scrollbar {
    width: 8px;
    position: fixed;
    right: 0;
}

.main-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.main-container::-webkit-scrollbar-thumb {
    background: #c4adc5;
    border-radius: 4px;
}

.main-container::-webkit-scrollbar-thumb:hover {
    background: #647697;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px); /* Учитываем высоту заголовка */
    width: 100%;
    position: relative;
    margin: 0;
    overflow: hidden;
}

.saved-chats-container {
    display: none; /* Hide the side panel */
}

.saved-chats-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1100;
    backdrop-filter: blur(5px);
}

.saved-chats-modal-content {
    background: #faf9ff;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    padding: 0;
    position: relative;
    overflow: hidden;
    box-shadow: none; /* Полностью убираем тень */
}

.saved-chats-modal-header {
    position: sticky;
    top: 0;
    background: #faf9ff;
    padding: 20px 30px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    z-index: 2;
}

.saved-chats-list-container {
    padding: 0 30px 30px 30px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

.saved-chats-list-container::-webkit-scrollbar {
    width: 8px;
}

.saved-chats-list-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
    margin: 4px;
}

.saved-chats-list-container::-webkit-scrollbar-thumb {
    background: #adb6c5;
    border-radius: 4px;
}

.saved-chats-list-container::-webkit-scrollbar-thumb:hover {
    background: #647697;
}

.saved-chats-modal-inner {
    height: 100%;
    max-height: calc(90vh - 90px); /* Adjust based on header height and padding */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px; /* Add some padding for the scrollbar */
    margin-right: -5px; /* Offset the padding */
}

.saved-chats-modal-content::-webkit-scrollbar {
    width: 8px;
}

.saved-chats-modal-content::-webkit-scrollbar-track {
    margin: 16px 0;
    background: #f1f1f1;
    border-radius: 4px;
}

.saved-chats-modal-content::-webkit-scrollbar-thumb {
    background: #adb6c5;
    border-radius: 4px;
}

.saved-chats-modal-content::-webkit-scrollbar-thumb:hover {
    background: #647697;
}

.saved-chats-list-container {
    padding: 25px;
}

#saved-chats-list {
    list-style: none;
    padding: 0;
}

#saved-chats-list li {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

#saved-chats-list li:hover {
    background-color: #f5eef5;
}

.saved-chats-container h3 {
    font-size: 16px;
    font-weight: 600;
    color: #573f5f;
    margin-bottom: 15px;
}

.saved-chats-container ul {
    list-style: none;
    padding: 0;
}

.saved-chats-container li {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.saved-chats-container li:hover {
    background-color: #f5eef5;
}

.saved-chats-container .new-chat-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    background: #33583d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.saved-chats-container .new-chat-btn:hover {
    background: #2a4832;
    transform: translateY(-1px);
}

.chat-options button {
    padding: 5px 10px;
    margin-left: 5px;
    background: #573f5f;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.chat-options button:hover {
    background: #4a344c;
}

.select-textbook-btn {
    border-radius: 6px;
    background: #33583d;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    width: fit-content;
    margin: -12px auto 10px auto;
    display: block;
    font-weight: 500;
    padding: 10px 20px;
    font-size: 15px;
    box-shadow: none;
}

.select-textbook-btn:hover {
    background: #2a4832;
    transform: translateY(-1px);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.15);
}

.send-btn {
    margin: 0;
    display: inline-flex;
}

.textbook-dropdown {
    position: relative;
    padding: 0;
    margin-top: 10px;
    width: 100%;
    display: flex;
    align-items: center;
}

.collapse-btn {
    display: none;
}

.collapse-btn:hover {
    display: none;
}

.collapse-btn svg {
    display: none;
}

.selected-textbook {
    padding: 10px;
    background-color: #f5eef5;
    border-radius: 8px;
    margin-top: 20px;
    display: inline-flex;
    align-items: center;
    gap: 15px;
    width: calc(100% + 3px);
    max-width: calc(100% + 3px);
    cursor: pointer;
    transition: all 0.3s ease;
}

.selected-book-cover {
    flex: 0 0 50px;
    width: 50px;
    height: 70px;
    min-width: 50px;
}

.selected-book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin-bottom: 0;
}

.selected-book-info {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    flex: 0 1 auto;
    text-align: left;
    padding: 0;
    white-space: normal;
    overflow: hidden;
    line-height: 1.3;
    max-height: 70px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.textbook-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#contents-list {
    list-style: none;
}

.chapter-title {
    font-size: 15px;
    font-weight: 600;
    color: #573f5f;
    padding: 12px 8px;
    margin: 10px 0 5px 0;
    background: #f5eef5;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chapter-title:hover {
    background: #ebe0eb;
}

.paragraph-item {
    font-size: 14px;
    padding: 8px 8px 8px 20px;
    margin: 2px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    color: #573f5f;
}

.paragraph-item:hover {
    background: #f5eef5;
    color: #573f5f;
}

#contents-list ul {
    list-style: none;
}

.chat-box {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Занимает оставшееся пространство */
    background: #d0cbd1;;
    width: 100%;
    position: relative;
    max-width: none;
    box-sizing: border-box;
    overflow-y: auto; /* Добавляем прокрутку */
}

.messages-area {
    height: auto;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1;
    background-color: #d0cbd1;
}

.message {
    max-width: 800px;
    padding: 15px 20px;
    border-radius: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    width: fit-content;
    min-width: 50px;
    word-wrap: break-word; /* Ensure long tokens do not overflow */
    overflow-wrap: anywhere; /* Prefer wrapping anywhere to avoid overflow */
    word-break: break-word;
}

.chatgpt-message {
    margin-right: auto;
    margin-left: 0;
    background: white;
    max-width: 720px;
    width: fit-content;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chatgpt-message ul {
    margin-left: 40px;
    margin-bottom: 20px;
}

.chatgpt-message h1, .chatgpt-message h2, .chatgpt-message h3, .chatgpt-message h4, .chatgpt-message h5, .chatgpt-message h6 {
    margin-bottom: 15px;
    font-size: 18px;
}

.user-message {
    position: relative;
    left: min(800px, 100%);
    transform: translateX(-100%);
    background: #f4f7fc;
    color: #333;
    max-width: 720px;
    width: fit-content;
    align-self: flex-start;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.system-message {
    max-width: 90%;
    background: #d9e4d9;
    
}

.message p {
    margin-bottom: 10px;
    white-space: pre-wrap; /* Preserve newlines and wrap long text */
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message p:last-child {
    margin-bottom: 0;
}

.message ol {
    padding-left: 20px;
    margin: 10px 0;
}

.message li {
    margin-bottom: 8px;
}

.message li:last-child {
    margin-bottom: 0;
}

.message .image-message {
    margin: 5px;
    max-width: 100%;
    display: inline-block;
}

.message .image-message img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    object-fit: cover;
}

/* Добавляем новые стили для контейнера изображений */
.message .images-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
    max-width: 100%;
}

/* Текст сообщения должен быть ниже изображений */
.message .message-text {
    margin-top: 8px;
    display: block;
    width: 100%;
    clear: both;
}

.input-area {
    position: relative;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 5px 70px 5px 70px;
    background: #d0cbd1;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-start;
    padding-left: 17%;
    min-height: 60px; /* Минимальная высота */
    flex-shrink: 0; /* Не позволяет уменьшаться */
}

.message-input-container {
    display: flex;
    gap: 8px;
    width: 800px;
    background: transparent;
    padding: 2px;
    border-radius: 20px;
    position: relative;
}

.input-section {
    flex: 1;
    background: #ffffff;
    border-radius: 20px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
    min-height: 48px;
    position: relative;
    height: auto;
    max-height: 230px; /* Увеличиваем максимальную высоту контейнера, чтобы вместить textarea */
    overflow: visible;
}

#message-input {
    width: 100%;
    overflow-y: auto;
    padding: 0;
    border: none;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
    background: transparent;
    min-height: 24px;
    max-height: 180px; /* Меняем максимальную высоту до 180px */
    height: auto;
    box-sizing: border-box;
    white-space: pre-wrap; /* Keep newline characters and wrap long words */
    overflow-wrap: anywhere;
    word-break: break-word;
}

#message-input::-webkit-scrollbar {
    width: 6px;
}

#message-input::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#message-input::-webkit-scrollbar-thumb {
    background: #c7c7c7;
    border-radius: 3px;
}

#message-input::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

#message-input:focus {
    outline: none;
}

.send-btn {
    width: 40px;
    height: 40px;
    background: #ffffff;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: none;
}

.send-btn:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.15);
}

.send-btn svg {
    width: 36px;
    height: 36px;
}

.send-btn svg path {
    stroke: #33583d;
    stroke-width: 3;
}

.switch-button {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
}

.message-actions {
    display: flex;
    flex-wrap: wrap; /* Позволяет создавать ряды */
    align-items: flex-start; /* Выравниваем по левому краю */
    gap: 8px;
    margin-top: 0px; /* Добавляем отступ сверху */
    position: relative;
    padding-left: 0;
    margin-bottom: 15px; /* Отступ снизу */
}

/* Кнопка "Продолжай объяснение" занимает всю ширину в своем ряду */
.start-explanation-btn {
    width: fit-content; /* Ширина по содержимому */
    margin-top: 8px; /* Отступ от верхнего ряда кнопок */
    flex-basis: 100%; /* Заставляет элемент начинаться с новой строки */
}

.example-btn, .explain-btn, .start-explanation-btn {
    padding: 6px 16px;
    background: #c7a95f;
    border-radius: 8px;
    box-shadow: none;
    cursor: pointer;
    font-size: 13px;
    color: #fff;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: none;
}

.action-btn:hover {
    background: #b69344;
    transform: translateY(-1px);
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.15);
}

.btn-icon {
    font-size: 14px;
}

.chat-options {
    position: relative;
}

.options-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.options-menu {
    position: absolute;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    display: none;
}

.chat-options:hover .options-menu {
    display: block;
}

.options-menu button {
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
}

.options-menu button:hover {
    background: #f0f0f0;
}

.switch-button input {
    display: none;
}

.slider {
    position: relative;
    width: 40px;
    height: 20px;
    background: #ccc;
    border-radius: 20px;
    cursor: pointer;
}

.slider:before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: 0.3s;
}

.switch-button input:checked + .slider {
    background: #01d80c;
}

.switch-button input:checked + .slider:before {
    transform: translateX(20px);
}

.contents-container h3 {
    font-size: 16px;
    font-weight: 600;
    color: #556686;
    padding: 15px;
    margin: 0;
    border-bottom: 1px solid #eee;
}

.chat-and-saved-container::-webkit-scrollbar {
    width: 8px;
    position: absolute;
    right: 0;
}

.chat-and-saved-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.chat-and-saved-container::-webkit-scrollbar-thumb {
    background: #adb6c5;
    border-radius: 4px;
}

.chat-and-saved-container::-webkit-scrollbar-thumb:hover {
    background: #647697;
}

.welcome-container {
    background: #f8f5ff;
    min-height: calc(100vh - 80px);
}

.welcome-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 20px;
}

.main-title {
    font-size: 3.5rem;
    color: #573f5f;
    text-align: center;
    margin-bottom: 100px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 2rem;
    color: #573f5f;
    text-align: center;
    margin-bottom: 50px;
    font-weight: 600;
    line-height: 1.4;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.section {
    margin-bottom: 100px;
    background: #ffffff;
    padding: 50px;
    border-radius: 30px;
    box-shadow: 0 20px 40px rgba(87, 63, 95, 0.05);
    transform: translateY(0);
    transition: transform 0.5s ease, box-shadow 0.5s ease;
    position: relative;
    overflow: hidden;
}

.section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: #573f5f;
    border-radius: 5px 5px 0 0;
}

.section:hover {
    transform: translateY(-10px);
    box-shadow: 0 30px 60px rgba(87, 63, 95, 0.12);
}

.section h2 {
    font-size: 2.5rem;
    color: #573f5f;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.section h3 {
    font-size: 1.8rem;
    color: #573f5f;
    margin-bottom: 20px;
    font-weight: 600;
    line-height: 1.4;
}

.lead-text {
    font-size: 1.3rem;
    color: #444;
    line-height: 1.8;
    margin-bottom: 30px;
    max-width: 900px;

}

.section.fade-in ul li {
    font-size: 1.6rem;
    color: #573f5f;
    margin-bottom: 20px;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 20px;
}

.section.fade-in p {
    font-size: 1.6rem;
    color: #573f5f;
    margin-bottom: 20px;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 20px;
}

.benefits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.benefit-card {
    background: #f2f2f2;
    padding: 35px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(87, 63, 95, 0.03);
    transition: all 0.5s ease;
    position: relative;
    overflow: hidden;
}

.benefit-card:hover {
    background: #ebebeb;
    transform: translateY(-15px) scale(1.02);
    box-shadow: 0 20px 40px rgba(87, 63, 95, 0.08);
}

.benefit-card h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #573f5f;
}

.benefit-card p {
    font-size: 1.35rem;
    line-height: 1.7;
    color: #444;
    margin-bottom: 20px;
}

.benefit-card ul {
    list-style: none;
    padding: 0;
}

.benefit-card li {
    margin-bottom: 15px;
    padding-left: 30px;
    position: relative;
    font-size: 1.35rem;
    line-height: 1.6;
    color: #444;
}

.benefit-card li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #33583d;
    font-weight: bold;
}

.audience-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.audience-item {
    background: #f2f2f2;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid rgba(87, 63, 95, 0.05);
    box-shadow: 0 10px 20px rgba(87, 63, 95, 0.03);
    font-size: 1.35rem;
    line-height: 1.5;
    color: #444;
}

.audience-item:hover {
    background: #ebebeb;
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(87, 63, 95, 0.1);
}

.steps-container {
    margin-top: 40px;
    display: grid;
    gap: 20px;
}

.step.fade-in{
    background: #f2f2f2;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(87, 63, 95, 0.03);
    transition: all 0.5s ease;
    position: relative;
    overflow: hidden;
    display: flex; 
    gap: 20px;
    align-items: center;
}

.step p {
    text-align: left;
    margin: 0;
}

.step:hover {
    background: #f5f5f5;
    transform: translateX(20px);
    box-shadow: 0 20px 40px rgba(87, 63, 95, 0.08);
}

.step-number {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: #573f5f;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
    margin-right: 20px;
}

.step:nth-child(6) .step-number {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
}

.final-cta {
    text-align: center;
    background: #ffffff;
    padding: 50px;
    margin: -40px;
    border-radius: 25px;
}

.start-steps {
    margin: 40px 0;
}

.start-title {
    font-size: 1.6rem;
    color: #573f5f;
    font-weight: 600;
    margin-bottom: 25px;
}

.start-steps ul {
    list-style: none;
    padding: 0;
    max-width: 600px;
    margin: 0 auto;
}

.start-steps li {
    background: #f2f2f2;
    padding: 15px 30px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(87, 63, 95, 0.03);
    transition: all 0.3s ease;
    font-size: 1.35rem;
    line-height: 1.7;
    color: #444;
}

.start-steps li:hover {
    background: #ebebeb;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(87, 63, 95, 0.1);
}

.motto {
    font-size: 1.6rem;
    color: #333;
    font-style: italic;
    margin: 40px 0;
    font-weight: 600;
}

.welcome-cta {
    margin-top: 60px;
    margin-bottom: 60px;
    text-align: center;
}

/* Добавляем стиль для отступа верхней кнопки */
.welcome-cta.top-cta {
    margin-top: 20px; /* Уменьшаем верхний отступ */
    margin-bottom: 60px; /* Уменьшаем нижний отступ */
}
/* Конец добавленного стиля */

.cta-button.primary {
    display: inline-block;
    padding: 18px 50px;
    font-size: 1.3rem;
    font-weight: 600;
    color: #ffffff;
    background: #33583d;
    border-radius: 16px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(87, 63, 95, 0.2);
}

.cta-button.primary:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(87, 63, 95, 0.3);
}

.site-footer {
    background: #573f5f;
    color: #fff;
    padding: 40px 0 20px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    margin-bottom: 30px;
}

.footer-section h3 {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.footer-section p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 10px;
}

.footer-section ul li a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section ul li a:hover {
    color: #fff;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
    text-align: center;
}

.footer-bottom p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.new-chat-btn {
    display: none;
}

.profile-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease;
    margin-left: 10px;
}

.profile-icon:hover {
    background: rgba(255, 255, 255, 0.35);
}

.profile-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.login-nav ul {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.header-textbook-btn {
    display: none;
}

.textbook-icon {
    width: 32px;
    height: 32px;
    transition: transform 0.2s ease;
}

.header-textbook-btn:hover .textbook-icon {
    transform: scale(1.1);
}

.header-textbook-btn,
.header-new-chat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    width: auto;
    height: 44px;
}

.button-text {
    color: white;
    font-size: 14px;
    font-weight: 500;
}

.contents-toggle {
    display: none;
}

.header-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    height: 44px;
    gap: 8px;
    position: relative;
    z-index: 1001; /* Поверх кнопок предметов */
}

.header-new-chat:hover {
    background: rgba(255, 255, 255, 0.25);
}

.new-chat-icon {
    width: 28px;
    height: 28px;
}

.header-chats-btn {
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    height: 44px;
    gap: 8px;
    position: relative;
    z-index: 1001; /* Поверх кнопок предметов */
}

/* Создаём защитную "стену" слева от кнопки "Чаты" */
.header-chats-btn::before {
    content: '';
    position: absolute;
    left: -30px; /* Защитная зона слева */
    top: -10px;
    bottom: -10px;
    width: 30px;
    background: transparent;
    z-index: 1001;
    pointer-events: none; /* Не блокируем клики */
}

.header-new-chat:hover .new-chat-icon {
    transform: scale(1.1);
}

.header-book-btn {
    display: none;
}

.mobile-only {
    display: none;
}

.welcome-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1100;
    backdrop-filter: blur(5px);
}

.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.textbook-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1100;
    backdrop-filter: blur(5px);
}

.paragraph-messages {
    padding: 40px 70px 0px 70px;
    padding-left: 17%;
    padding-right: 15%;
    padding-bottom: 75px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-height: 0;
    max-height: none;
    background-color: #d0cbd1;
    overflow-y: auto;
    overflow-x: hidden;
}

.paragraph-info {
    display: flex;
    width: 800px;
    margin: 4px;
    padding: 16px 20px 0px 0px;
    font-size: 18px;
    font-weight: 600;
    color: #000000;
    text-align: center;
    z-index: 1;
    background: #d0cbd1;
    border: none;
    box-shadow: none;
}

.textbook-modal-content {
    background: #faf9ff;
    border-radius: 16px;
    width: 90%;
    min-height: 400px;
    max-width: 1200px;
    max-height: 90vh;
    padding: 0 30px 30px 30px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: none;
}

.textbook-modal-header {
    position: sticky;
    top: 0;
    background: #faf9ff;
    padding: 20px 30px;
    margin: 0 -30px 20px -30px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    z-index: 1;
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 32px;
    color: #573f5f;
    cursor: pointer;
    padding: 5px;
    transition: all 0.3s ease;
    z-index: 2;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.textbook-modal-content::-webkit-scrollbar {
    width: 8px;
}

.textbook-modal-content::-webkit-scrollbar-track {
    margin: 16px 0;
    background: #f1f1f1;
    border-radius: 4px;
}

.textbook-modal-content::-webkit-scrollbar-thumb {
    background: #adb6c5;
    border-radius: 4px;
}

.textbook-modal-content::-webkit-scrollbar-thumb:hover {
    background: #647697;
}

.textbook-modal h2 {
    color: #573f5f;
    font-size: 24px;
    margin-bottom: 25px;
    text-align: center;
}

.grade-selector {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 20px 0;
}

.grade-select {
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid #d8d0e7;
    font-size: 16px;
    background: #f5f2ff;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #4b3f72;
    width: 200px;
    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='%234b3f72' 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 12px center;
    background-size: 20px;
    padding-right: 44px;
}

.grade-select:hover {
    border-color: #6a5acd;
    background-color: #f3f0ff;
}

.textbooks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    padding: 20px 0;
}

.textbook-card {
    background: #e8e6f1;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(87, 63, 95, 0.1);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid #d8d2e8;
    position: relative; /* Добавлено для корректного позиционирования возможных дочерних элементов */
}

/* Применяем hover-эффекты только если у карточки НЕТ класса .disabled */
.textbook-card:not(.disabled):hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(87, 63, 95, 0.15);
    background: #e0ddee;
}

/* Стили для карточки с классом disabled (по желанию можно добавить доп. стили) */
.textbook-card.disabled {
     opacity: 0.7; /* Например, делаем ее полупрозрачной */
     cursor: not-allowed; /* Показываем курсор "не разрешено" */
}

.textbook-cover-container {
    width: 150px;
    height: 200px;
    margin-bottom: 20px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(87, 63, 95, 0.1);
    background: #e8e6f1;
}

.textbook-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.textbook-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #e8e6f1;
    padding: 15px;
    border-radius: 16px;
    width: 100%;
    margin-top: 15px;
}

.textbook-name {
    font-size: 18px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 10px;
}

.textbook-details {
    font-size: 14px;
    color: #000000;
    margin-bottom: 20px;
}

.select-btn {
    padding: 10px 20px;
    background: #573f5f;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    width: 100%;
}

.select-btn:hover {
    background: #4a344c;
    transform: translateY(-2px);
}

/* Добавляем стили для неактивной кнопки */
.select-btn:disabled {
    background-color: #cccccc; /* Серый фон */
    color: #666666; /* Темно-серый текст */
    cursor: not-allowed; /* Курсор "не разрешено" */
    transform: none; /* Убираем эффект поднятия */
    box-shadow: none; /* Убираем тень */
}

.close-modal-btn:hover {
    color: #33583d;
    transform: scale(1.1);
}

.grade-title {
    display: none;
}

.auth-container {
    min-height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: white;
}

.auth-container form {
    background: #e8e4eb;
    padding: 50px;
    border-radius: 24px;
    width: 100%;
    max-width: 700px;
    box-shadow: 0 10px 40px rgba(87, 63, 95, 0.15);
}

.auth-container h1 {
    color: #573f5f;
    font-size: 28px;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 700;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #573f5f;
    font-weight: 500;
    font-size: 15px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(87, 63, 95, 0.1);
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    color: #333;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: #573f5f;
    background: white;
    box-shadow: 0 0 0 4px rgba(87, 63, 95, 0.1);
}

.auth-container .btn {
    width: 100%;
    padding: 14px;
    background: #33583d;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.auth-container .btn:hover {
    background: #2a4832;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(51, 88, 61, 0.2);
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 0px;
    background: white;
    border: 2px solid rgba(87, 63, 95, 0.1);
    border-radius: 12px;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.google-btn:hover {
    background: white;
    border-color: #573f5f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.google-btn img {
    width: 60px;
   
}

.divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: calc(50% - 30px);
    height: 1px;
    background: rgba(87, 63, 95, 0.2);
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.divider span {
    background: #e8e4eb;
    padding: 0 15px;
    color: #573f5f;
    font-size: 14px;
}

.links {
    text-align: center;
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.links a {
    color: #573f5f;
    text-decoration: none;
    font-size: 14px;
    position: relative;
}

.links a:first-child:after {
    position: absolute;
    right: -12px;
    color: rgba(87, 63, 95, 0.4);
}

.links a:hover {
    color: #33583d;
    text-decoration: underline;
}

.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 17px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Добавляем стили для alert-danger */
.alert-danger {
    color: #721c24; /* Темно-красный цвет текста */
    background-color: #f8d7da; /* Светло-розовый фон */
    border-color: #f5c6cb; /* Розовая рамка */
    border: 1px solid transparent; /* Убедимся, что рамка есть */
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.form-error {
    color: red;
    font-size: 17px;
    margin-top: 10px;
}

.welcome-modal-content {
    background: #faf9ff;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    padding: 40px;
    position: relative;
    text-align: center;
    box-shadow: 0 10px 40px rgba(87, 63, 95, 0.15);
}

.welcome-message {
    margin-bottom: 30px;
}

.welcome-message p {
    color: #573f5f;
    font-size: 18px;
    line-height: 1.6;
    margin-bottom: 15px;
}

.welcome-message p:first-child {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
}

.welcome-btn {
    padding: 12px 40px;
    background: #33583d;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.welcome-btn:hover {
    background: #2a4832;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(51, 88, 61, 0.2);
}

.upload-btn {
    width: 28px;
    height: 28px;
    background: #f4e7f7;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    display: none; /* Скрываем кнопку по умолчанию */
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: none;
    padding: 6px;
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1;
}

/* Tooltip for upload button: white background, rounded, appears above without shifting layout */
.upload-btn[data-tooltip] {
    position: absolute; /* keep absolute to not shift layout */
}
.upload-btn[data-tooltip-line1][data-tooltip-line2]:hover::after,
.upload-btn[data-tooltip-line1][data-tooltip-line2]:focus::after {
    content: attr(data-tooltip-line1) "\A" attr(data-tooltip-line2); /* enforce line break */
    position: absolute;
    bottom: calc(100% + 8px); /* show above the button */
    right: 0; /* anchor to the right edge so it grows leftwards */
    left: auto;
    transform: none;
    white-space: pre; /* keep explicit line break, no extra wrapping */
    background: #ffffff;
    color: #333333;
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    font-size: 12px;
    line-height: 1.3;
    width: max-content; /* exactly as wide as the longest line */
    max-width: 90vw; /* prevent overflow near edges */
    word-break: normal; /* avoid breaking every character */
    overflow-wrap: normal;
    text-align: left;
    z-index: 10;
}
.upload-btn[data-tooltip-line1][data-tooltip-line2]:hover::before,
.upload-btn[data-tooltip-line1][data-tooltip-line2]:focus::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 2px); /* small gap to tooltip box */
    right: 10px; /* arrow near the button on the right */
    left: auto;
    transform: none;
    border-width: 6px;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent; /* little arrow pointing down */
    z-index: 11;
}

/* On very small screens allow wrapping to avoid overflow */
@media (max-width: 480px) {
    .upload-btn[data-tooltip-line1][data-tooltip-line2]:hover::after,
    .upload-btn[data-tooltip-line1][data-tooltip-line2]:focus::after {
        width: 260px; /* constrain on small screens */
        max-width: 90vw;
        white-space: pre-wrap; /* allow wrapping inside the two lines if needed */
        word-break: break-word;
        overflow-wrap: anywhere;
    }
}

/* removed custom mobile upload menu — now using native iOS chooser */

/* iOS Safari quirk: file input must be in DOM and visible-ish to allow programmatic click */
.visually-hidden-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.term {
    border-bottom: 1px dotted #573f5f; /* Пунктирное подчеркивание */
    cursor: pointer; /* Курсор-указатель для наглядности */
    position: relative; /* Для правильного позиционирования tooltip (хотя сам tooltip теперь в body) */
    display: inline-block; /* Чтобы подчеркивание было только под текстом */
    color: #573f5f; /* Цвет в стиле сайта */
    font-weight: 500; /* Выделение текста */
}

.definition {
    display: none; /* Скрываем сам элемент определения */
}

.tooltip {
    position: absolute; /* Абсолютное позиционирование относительно body */
    background-color: #f5eef5;
    color: #333;
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(87, 63, 95, 0.2);
    width: max-content;
    max-width: 300px;
    z-index: 100; /* Поверх других элементов */
    font-size: 14px;
    line-height: 1.4;

}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%; /* Стрелка внизу подсказки */
    left: 50%;
    transform: translateX(-50%); /* Центрируем стрелку */
    margin-left: 0; /* Сбрасываем старый margin */
    border-width: 8px;
    border-style: solid;
    border-color: #f5eef5 transparent transparent transparent; /* Треугольник, указывающий вниз */
}

.quote-icon {
    margin-right: 5px;
    color: #573f5f;
    font-size: 16px;
}

/* Стили для страницы обратной связи */
.feedback-form textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(87, 63, 95, 0.1);
    border-radius: 12px; /* Убедимся, что скругление соответствует другим полям */
    font-size: 15px;
    transition: all 0.3s ease;
    color: #333;
    background: white;
    height: 200px; /* Устанавливаем фиксированную высоту, например 200px */
    resize: none; /* Запрещаем изменение размера */
    font-family: inherit; /* Наследуем шрифт */
    min-height: 100px; /* Добавим минимальную высоту на всякий случай */
}

.feedback-form textarea:focus {
    outline: none;
    border-color: #573f5f;
    background: white;
    box-shadow: 0 0 0 4px rgba(87, 63, 95, 0.1);
}

.contents-header {
    position: relative; /* Добавляем для абсолютного позиционирования крестика */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 10px;
}

.close-contents-btn {
    position: absolute;
    top: -5px;
    right: 0;
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-contents-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.close-contents-btn svg {
    width: 20px;
    height: 20px;
}

/* Добавим стили для кнопки "Продолжай объяснение" с большим закруглением */
.continue-explanation-btn {
    background-color: #005c1f; /* Яркий темно-зеленый цвет */
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 9px; /* Единый радиус закругления */
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 10px;
}

.continue-explanation-btn:hover {
    background-color: #005c1f; /* Более темный оттенок для hover */
}

/* Обновляем стиль для кнопки "Начать объяснение" с таким же закруглением */
.start-explanation-btn {
    background-color: #005c1f; /* Тот же яркий темно-зеленый цвет */
    border-radius: 9px; /* Единый радиус закругления */
}

.start-explanation-btn:hover {
    background-color: #005c1f; /* Более темный оттенок для hover */
}

.image-preview-container {
    position: relative;
    display: inline-block;
    margin: 3px;
    max-width: 60px;
    max-height: 60px;
    vertical-align: middle;
    overflow: hidden;
    border-radius: 4px;
}

.image-preview {
    max-width: 100%;
    max-height: 60px;
    height: auto;
    border-radius: 4px;
    object-fit: cover;
}

.remove-image-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: rgba(100, 100, 100, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    font-size: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.remove-image-btn:hover {
    background: rgba(80, 80, 80, 0.9);
}

.send-btn.stop-btn {
    background-color: white;
    border: 2px solid #33583d;
}

.send-btn.stop-btn:hover {
    background-color: #f5f5f5;
}

/* Стили для отключенного текстового поля */
#message-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* Добавляем новые стили для контейнера превью изображений */
.message-input-container {
    position: relative;
}

/* Создаем горизонтальный контейнер для превью изображений */
.image-previews-wrapper {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 5px;
    max-width: 320px; /* Ограничиваем максимальную ширину */
    gap: 2px; /* Добавляем немного пространства между изображениями */
}

/* --- Кастомные стили для мобильного меню предметов --- */
.desktop-subjects { display: flex; }
.mobile-subjects { display: none; }

@media screen and (max-width: 1230px) {
    .welcome-content {
        padding: 30px 15px;
    }

    .main-title {
        font-size: 2.5rem;
        margin-bottom: 40px;
        margin-top: 40px;
    }

    .subtitle {
        font-size: 1.6rem;
    }

    .section {
        padding: 25px 15px;
        margin-bottom: 50px;
    }

    .section h2 {
        font-size: 2rem;
    }

    .section h3 {
        font-size: 1.5rem;
    }

    .benefits-grid {
        grid-template-columns: 1fr;
    }

    .audience-grid {
        grid-template-columns: 1fr;
    }

    .step {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .step-number {
        margin: 0 0 15px 0;
    }

    .final-cta {
        padding: 30px 15px;
        margin: -20px -15px;
    }

    .cta-button.primary {
        padding: 12px 35px;
        font-size: 1.1rem;
    }

    .section p,
    .benefit-card p,
    .benefit-card li,
    .audience-item,
    .step p,
    .start-steps li {
        font-size: 1.25rem;
    }

    .grade-select {
        width: 180px;
    }

    .auth-container {
        padding: 20px;
    }

    .auth-container form {
        padding: 40px 25px;
    }

    .auth-container h1 {
        font-size: 24px;
    }

    .form-group input,
    .google-btn {
        padding: 10px 14px;
    }

    .auth-container .btn {
        padding: 12px;
    }

    .welcome-modal-content {
        padding: 30px 20px;
        width: 95%;
    }

    .welcome-message p {
        font-size: 16px;
    }

    .welcome-message p:first-child {
        font-size: 20px;
    }

    .welcome-btn {
        padding: 10px 30px;
        font-size: 15px;
    }

    .upload-btn {
        width: 24px;
        height: 24px;
        padding: 5px;
    }

    .upload-btn svg {
        width: 14px;
        height: 14px;
    }

    .paragraph-messages {
        padding: 20px 0 0 0;
        padding-bottom: 175px;
    }

    .messages-area {
        padding-left: 27px;
        padding-right: 27px;
        padding-top: 20px;
        padding-bottom: 0px;
        margin-top: 0;
        position: relative;
    }

    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 10px 15px;
        background: #d3ced4;
        z-index: 100;
    }

    .message-input-container {
        width: 100%;
        margin: 0 auto;
        max-width: 100%;
    }

    .main-container {
        margin-top: 60px;
        height: calc(100vh - 60px);
        padding-top: 0;
    }

    .chat-container {
        height: calc(100vh - 60px);
        margin-top: 0;
        position: relative;
    }

    .site-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        height: 60px;
        padding: 0.5rem 1rem;
    }
    
    .header-container {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: 5px;
        width: 100%;
        position: relative;
        height: 100%;
    }
    
    .logo {
        flex-shrink: 0;
        margin-right: 5px;
        order: 0;
        flex: 0 0 auto;
    }
    
    .logo h1 {
        font-size: 1.4rem;
        line-height: 1.1;
        text-align: left;
        margin: 0;
    }
    
    .header-subject-dropdown-wrapper {
        position: relative;
        display: inline-block !important; /* Включаем отображение на мобильных */
        margin-right: 0;
        margin-left: 0;
        order: 0;
        position: absolute;
        left: calc(50% - 35px); /* ИЗМЕНЕНО: было calc(50% - 12px) */
        transform: translateX(-50%);
        z-index: 100;
    }
    
    .header-subject-btn,
    .nav-btn.register {
        display: flex !important;
        /* min-width: 90px;
           This will be handled by specific rules or inherited if not overridden for .header-subject-btn */
        background: rgba(255,255,255,0.15);
        border: none;
        border-radius: 6px;
        /* padding: 8px 12px;
           This will be handled by specific rules or inherited */
        cursor: pointer;
        align-items: center;
        justify-content: center;
        height: 41px;
        color: #ffffff;
        font-size: 14px;
        font-weight: 500;
        box-sizing: border-box;
        margin-right: 8px; /* Общий правый отступ */
        /* margin-left: 8px;  УДАЛЕНО отсюда, будет задано специфично */
    }
    
    .header-subject-btn { /* Специфичное правило для кнопки "Предмет" на мобильных */
        min-width: 75px;
        padding: 8px 10px;
        margin-left: 0; /* ДОБАВЛЕНО: убираем нежелательный левый отступ для кнопки "Предмет" */
    }
    
    .nav-btn.register { /* Специфичные стили для кнопки "Регистрация/Вход" */
        min-width: 90px; /* Ширина для кнопки "Регистрация/Вход" */
        padding: 8px 12px; /* Отступы для кнопки "Регистрация/Вход" */
        margin-left: 8px; /* ДОБАВЛЕНО: левый отступ для кнопки "Регистрация/Вход" */
    }
    
    .login-nav {
        order: 2;
        margin-left: auto;
        flex: 0 0 auto;
    }
    
    .login-nav ul {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0;
        padding: 0;
    }
    
    .header-new-chat {
        padding: 8px;
        width: 41px;
        height: 41px;
    }
    
    .header-nav ul {
        display: flex;
        align-items: center;
        gap: 15px;
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .icon-btn {
        background: none;
        border: none;
        padding: 8px;
        cursor: pointer;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.3s;
    }
    .icon-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .profile-icon {
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.3s;
    }
    .profile-icon:hover {
        background: rgba(255, 255, 255, 0.25);
    }

    .contents-toggle:not(.icon-btn),
    .new-chat-btn:not(.icon-btn) {
        display: none;
    }

    .contents-container {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 60px);
        background: white;
        transition: left 0.3s ease;
        z-index: 990;
        overflow-y: auto;
    }

    .contents-container.active {
        left: 0;
    }

    .message-actions {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        padding-left: 27px; /* Добавляем отступ слева, соответствующий отступу сообщений */
        flex-direction: column; 
        align-items: flex-start;
        margin-top: 0px;
        margin-bottom: 15px; 
    }

    .header-new-chat {
        padding: 8px;
    }

    .new-chat-icon {
        width: 28px;
        height: 28px;
    }

    .send-btn {
        width: 36px;
        height: 36px;
    }

    .send-btn svg {
        width: 32px;
        height: 32px;
    }

    .nav-btn {
        padding: 8px 7px;
        font-size: 15px;
    }

    .login-nav ul {
        gap: 10px;
        display: flex;
        align-items: center;
    }

    .button-text {
        display: none;
    }

    .header-textbook-btn,
    .header-new-chat {
        width: 41px;
        height: 41px;
        padding: 7px;
    }

    .new-chat-icon {
        width: 27px;
        height: 27px;
    }

    .header-textbook-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .chat-and-saved-container {
        height: calc(100vh - 60px);
    }

    .message {
        max-width: 98%;
    }

    .chatgpt-message {
        max-width: 98%;
    }
    .system-message {
        max-width: 98%;
        background: #d9e4d9;
    }
    .user-message {
        position: static;
        left: auto;
        transform: none;
        margin-left: auto;
        margin-right: 0;
        align-self: flex-end;
        max-width: 98%;
    }

    .header-book-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 41px;
        height: 41px;
        padding: 7px;
        background: rgba(255, 255, 255, 0.15);
        border: none;
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .header-book-btn:hover {
        background: rgba(255, 255, 255, 0.25);
    }

    .book-icon {
        width: 27px;
        height: 27px;
    }

    .mobile-only {
        display: block;
    }

    .saved-chats-container {
        display: none !important;
    }

    .feedback-form {
        padding: 40px 25px;
    }

    .feedback-form h1 {
        font-size: 24px;
    }

    .feedback-form textarea,
    .feedback-form input {
        padding: 10px 14px;
    }

    .feedback-form .btn {
        padding: 12px;
    }

    .close-contents-btn {
        display: flex;
    }

    .section.fade-in ul li {
        font-size: 18px;
        margin-left: 30px;
    }
    .section.fade-in p {
        font-size: 18px;
        
    }

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

    .desktop-subjects { display: none !important; }
    .mobile-subjects { display: block !important; position: relative; }
    .mobile-subjects .subjects-menu-btn {
        width: auto;
        min-width: 90px;
        margin: 0 4px 0 0;
        background: #573f5f;
        color: #fff;
        border: none;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 500;
        padding: 4px 10px;
        height: 32px;
        line-height: 1;
        box-shadow: none;
        cursor: pointer;
        transition: background 0.2s;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .mobile-subjects .subjects-menu-btn:active,
    .mobile-subjects .subjects-menu-btn:focus {
        background: #4a344c;
    }

    .logo {
        flex-shrink: 0;
        margin-right: 5px;
        order: 0;
        flex: 0 0 auto;
    }
    
    .logo h1 {
        font-size: 1.4rem;
        line-height: 1.1;
        text-align: left;
    }

    .user-menu-trigger.mobile-icon {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 41px;
        height: 41px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 6px;
        padding: 8px;
    }
}

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

.user-menu-trigger.desktop-icon { display: inline-flex; }
.user-menu-trigger.mobile-icon { display: none; }

@media screen and (max-width: 1230px) {
  .user-menu-trigger.desktop-icon { display: none !important; }
  .user-menu-trigger.mobile-icon { display: inline-flex !important; }
}

.desktop-only { display: flex; }
@media screen and (max-width: 1230px) {
  .desktop-only { display: none !important; }
}

@media screen and (max-width: 1230px) {
    .main-nav .subjects-menu-btn { display: none !important; }
}

.user-menu-trigger.mobile-icon {
    width: 44px;
    height: 44px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.user-menu-trigger.mobile-icon {
    display: none !important;
}
@media screen and (max-width: 1230px) {
    .user-menu-trigger.mobile-icon {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        vertical-align: middle;
    }
}

/* Скрыть крестик на ПК */
.close-contents-btn {
    display: none !important;
}

/* Показать крестик только на мобильных устройствах */
@media screen and (max-width: 1230px) {
    .close-contents-btn {
        display: flex !important;
    }
}

/* Активная кнопка предмета — тусклее */
.active-subject {
    opacity: 0.6;
    color: #e0e0e0 !important;
    font-weight: 700;
    pointer-events: none;
    filter: grayscale(0.2);
}

/* Скрываем кнопки "Выбрать учебник" и "Сохранённые чаты" в мобильной версии 
   на всех страницах, кроме страницы чата */
@media (max-width: 1230px) {
    body:not(.chat-page) .mobile-only .dropdown-textbook-link,
    body:not(.chat-page) .mobile-only .dropdown-saved-chats-link {
        display: none !important;
    }

    /* Также скрываем горизонтальную линию, если обе кнопки скрыты */
    body:not(.chat-page) .mobile-only hr {
        display: none !important;
    }
}

.desktop-subjects { display: flex; }
.mobile-subjects { display: none; }

@media screen and (max-width: 1230px) {
    .welcome-content {
        padding: 30px 15px;
    }

    .main-title {
        font-size: 2.5rem;
        margin-bottom: 40px;
        margin-top: 40px;
    }

    .subtitle {
        font-size: 1.6rem;
    }

    /* ... existing code ... */

    .desktop-subjects { display: none !important; }
    .mobile-subjects { display: block !important; position: relative; }
    
    /* ... existing code ... */
}

.subjects-dropdown-menu {
    display: none;
    position: absolute;
    left: auto;
    right: 0;
    top: 110%;
    width: 140px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(87,63,95,0.13);
    z-index: 2000;
    padding: 0;
    flex-direction: column;
    gap: 0;
    animation: fadeInSubjects 0.18s;
}
.subjects-dropdown-menu.show {
    display: flex;
}
.subjects-dropdown-menu .nav-btn {
    color: #573f5f;
    background: none;
    border-radius: 0;
    width: 100%;
    justify-content: flex-start;
    padding: 8px 12px;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.18s;
}
.subjects-dropdown-menu .nav-btn:hover {
    background: #f5eef5;
    color: #33583d;
}

.mobile-subjects .subjects-menu-btn {
    min-width: 90px; /* Минимальная ширина для размещения названия предмета */
    justify-content: center; /* Центрирование текста */
}

.header-subject-btn {
    display: none; /* Скрываем кнопку в ПК версии по умолчанию */
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    margin-left: auto;
    margin-right: 10px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    height: 41px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
}
.header-subject-btn .subject-icon {
    width: 24px;
    height: 24px;
}

.header-subject-dropdown-wrapper {
    display: none; /* Скрываем на ПК версии по умолчанию */
    position: relative;
}

@media (max-width: 1230px) {
    .header-subject-dropdown-wrapper {
        position: relative;
        display: inline-block !important; /* Включаем отображение на мобильных */
        margin-right: 0;
        margin-left: 0;
        order: 0;
        position: absolute;
        left: calc(50% - 12px); /* ИЗМЕНЕНО: было left: 50%; */
        transform: translateX(-50%);
        z-index: 100;
    }
    
    .header-subject-btn,
    .nav-btn.register {
        display: flex !important;
        min-width: 90px;
        background: rgba(255,255,255,0.15);
        border: none;
        border-radius: 6px;
        padding: 8px 12px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        height: 41px;
        color: #ffffff;
        font-size: 14px;
        font-weight: 500;
        box-sizing: border-box;
        margin-right: 8px;
        margin-left: 8px;
    }
    
    .header-subject-btn { /* Специфичное правило для кнопки "Предмет" на мобильных, чтобы сделать ее короче */
        min-width: 75px; 
        padding: 8px 10px; /* Уменьшаем горизонтальные отступы, сохраняя вертикальные */
    }
    
    .header-subjects-dropdown {
        display: none;
        position: absolute;
        top: calc(100% + 6px);
        left: 0;
        right: auto;
        min-width: 100%;
        width: 140px;
        background: #fff;
        border-radius: 10px;
        box-shadow: 0 6px 24px rgba(87,63,95,0.13);
        z-index: 2000;
        flex-direction: column;
        gap: 0;
        padding: 0;
        animation: fadeInSubjects 0.18s;
    }
    
    .header-subjects-dropdown.show {
        display: flex;
    }
    
    .header-subjects-dropdown .nav-btn {
        color: #573f5f;
        background: none;
        border-radius: 0;
        width: 100%;
        justify-content: flex-start;
        padding: 8px 12px;
        font-size: 15px;
        font-weight: 500;
        transition: background 0.18s;
    }
    
    .header-subjects-dropdown .nav-btn:hover {
        background: #f5eef5;
        color: #33583d;
    }
    
    .login-nav {
        order: 2;
        margin-left: auto;
    }
    
    .header-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
    }
    
    .logo {
        flex-shrink: 0;
        margin-right: 10px;
        order: 0;
    }
}

/* Скрыть переключатель режима для биологии */
.chat-page[data-subject="5"] .switch-button {
    display: none !important;
}



.term {
}

.vk-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 50px; /* Set fixed height */
    padding: 8px 20px; /* Add padding */
    box-sizing: border-box; /* Include padding in height */
    background: white;
    border: 2px solid rgba(87, 63, 95, 0.1);
    border-radius: 12px;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.vk-btn:hover {
    background: white;
    border-color: #573f5f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.vk-btn img {
    width: 30px; /* Set fixed width */
    height: 30px; /* Set fixed height */
    object-fit: contain; /* Ensure image scales correctly */
}

#yandex-one-tap-container {
    margin-top: 20px; /* Add margin to separate from VK button */
}

/* ---------------- KaTeX readability tweaks in chat ---------------- */
/* Make inline formulas slightly larger for readability */
.message .katex {
    font-size: 1.15em;
    line-height: 1.4;
}

/* Make display formulas larger and add vertical spacing */
.message .katex-display {
    margin-top: 16px;
    margin-bottom: 16px;
    line-height: 1.6;
}
.message .katex-display .katex {
    font-size: 1.28em;
}

/* Add a bit of horizontal breathing room around fractions */
.message .katex .mfrac {
    margin-left: 0.14em;
    margin-right: 0.14em;
}

/* Slightly thicken the fraction bar for clarity */
.message .katex .frac-line {
    border-top-width: 2px;
}
/* ------------------------------------------------------------------ */

/* ---------------- Streamdown typography utility mappings ----------- */
/* Ensure bold/strong emitted by Streamdown are actually bold */
.message .font-semibold,
.message [data-streamdown="strong"] {
    font-weight: 600;
}

/* Optional: if Streamdown ever emits .font-bold */
.message .font-bold {
    font-weight: 700;
}

/* Italic/emphasis */
.message .italic,
.message [data-streamdown="em"] {
	font-style: italic;
}

/* Underline and strikethrough */
.message .underline {
	text-decoration: underline;
	text-underline-offset: 2px;
}
.message del,
.message .line-through,
.message [data-streamdown="del"] {
	text-decoration: line-through;
}

/* Inline code and code blocks */
.message code,
.message [data-streamdown="code"] {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	background-color: #f6f8fa;
	padding: 0.15em 0.35em;
	border-radius: 4px;
	font-size: 0.95em;
}
.message pre {
	background-color: #f6f8fa;
	padding: 12px;
	border-radius: 8px;
	overflow-x: auto;
	line-height: 1.5;
}
.message pre code {
	background: transparent;
	padding: 0;
	font-size: 0.95em;
}

/* Blockquotes */
.message blockquote,
.message [data-streamdown="blockquote"] {
	margin: 12px 0;
	padding: 8px 12px;
	border-left: 4px solid #cbb7cf;
	background: #f7f2f9;
	color: #4a3b57;
	border-radius: 6px;
}

/* Links */
.message a {
	color: #33583d;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* Tables */
.message table {
	width: 100%;
	border-collapse: collapse;
	margin: 12px 0;
}
.message th,
.message td {
	border: 1px solid #e5e7eb;
	padding: 6px 10px;
	text-align: left;
}
.message thead th {
	background: #f5eef5;
}

/* Horizontal rule */
.message hr {
	border: none;
	border-top: 1px solid #e5e7eb;
	margin: 16px 0;
}
/* ------------------------------------------------------------------ */