@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

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

/*
   Важно для iOS Safari/Yandex Browser:
   делаем высоту через цепочку html->body->.chat (как в эталоне psyai),
   чтобы flex-раскладка корректно рассчитывала доступную высоту.
*/
html,
body {
    height: 100%;
}

:root {
    --primary: #7B6AAF;
    --primary-light: #9B8FCF;
    --primary-bg: #F0EBF8;
    --accent: #5BBAA8;
    --accent-light: #E8F5F1;
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #EEEEEE;
    --gray-300: #E0E0E0;
    --gray-400: #BDBDBD;
    --gray-500: #9E9E9E;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    --white: #FFFFFF;
    --danger: #E53935;
    --danger-light: #FFEBEE;
    --font-heading: Roboto, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

h1, h2, h3 {
    font-family: var(--font-heading);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    overflow: hidden;
    /* safe-area обрабатываем на header/footer, чтобы не ломать расчёт высоты */
    padding: 0;
}

/* Утилита как в эталоне psyai (Bootstrap-совместимая): display:none */
.d-none {
    display: none !important;
}

/* Chat Layout */
.chat {
    display: flex;
    height: 100%;
    min-height: 100dvh; /* Dynamic viewport height для мобильных браузеров */
}

/* Sidebar */
.chat-aside {
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    -webkit-appearance: none;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.aside-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.aside-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    text-decoration: none;
}

.aside-logo img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.aside-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    /* Минимальная высота для скролла */
    min-height: 0;
}

/* Кастомный скроллбар для списка чатов */
.aside-body::-webkit-scrollbar {
    width: 6px;
}

.aside-body::-webkit-scrollbar-track {
    background: transparent;
}

.aside-body::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.aside-body::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Firefox */
.aside-body {
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}

.aside-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.75rem;
}

/* =========================
   Role Selector Buttons
   ========================= */
.role-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.role-btn {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border: 2px solid #d4d4d4;
    border-radius: 24px;
    background: var(--white);
    color: var(--gray-700);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    text-decoration: none;
    display: block;
}

.role-btn:hover {
    border-color: transparent;
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.role-btn.active {
    border-color: transparent;
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.role-btn:active {
    transform: scale(0.98);
}

.btn-add-dialog {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1rem;
}

.btn-add-dialog:hover {
    background: var(--primary-light);
}

.btn-add-dialog svg {
    width: 18px;
    height: 18px;
}

/* Dialog List */
.dialog-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.dialog-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.2rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dialog-item:hover {
    background: var(--gray-100);
}

.dialog-item.active {
    background: var(--gray-100);
}

.dialog-name {
    font-size: 0.875rem;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.dialog-name-input {
    font-size: 0.875rem;
    color: var(--gray-800);
    border: 1px solid var(--primary);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    outline: none;
    flex: 1;
    display: none;
}

.dialog-item.editing .dialog-name {
    display: none;
}

.dialog-item.editing .dialog-name-input {
    display: block;
}

.dialog-menu-btn {
    background: transparent;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 4px;
    color: var(--gray-500);
    transition: all 0.2s;
    position: relative;
}

.dialog-menu-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.dialog-menu-btn svg {
    width: 18px;
    height: 18px;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    -webkit-appearance: none;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 150px;
    z-index: 100;
    display: none;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background: var(--danger-light);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0.5rem;
    background: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--gray-200);
    /*
       Ключевой фикс для iOS Safari/Yandex:
       шапка должна быть частью flex-потока, иначе она перекрывает первое сообщение.
       Скролл идёт внутри .chat-body-scroll, поэтому шапка и так остаётся сверху.
    */
    position: relative;
    z-index: 20;
}

@media (max-width: 768px) {
    /* учитываем «чёлку»/safe-area на iPhone */
    .chat-header {
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
        padding-bottom: 0.75rem;
    }
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.remaining-count {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.875rem;
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
}

.remaining-count #remainingCountValue {
    color: var(--primary);
    font-weight: 700;
    min-width: 24px;
    text-align: center;
}

.btn-profile {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-600);
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-profile:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.btn-profile svg {
    width: 24px;
    height: 24px;
}

.profile-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    -webkit-appearance: none;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 200px;
    z-index: 100;
    display: none;
    overflow: hidden;
}

.profile-menu.show {
    display: block;
    animation: menuSlideIn 0.2s ease;
}

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

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    font-size: 0.9375rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.2s;
}

.profile-menu-item:hover {
    background: var(--gray-100);
}

.profile-menu-item-danger {
    color: var(--danger);
}

.profile-menu-item-danger:hover {
    background: var(--danger-light);
}

.profile-menu-item svg {
    width: 18px;
    height: 18px;
}

.btn-mobile-menu {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-mobile-menu svg {
    width: 20px;
    height: 20px;
}

.chat-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.chat-title-brand {
    display: none;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    color: var(--primary);
}

.chat-title-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.chat-title-sep {
    color: var(--gray-400);
    margin-left: 0.125rem;
}

.chat-title-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-close-chat {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close-chat:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-close-chat svg {
    width: 24px;
    height: 24px;
}

/* Chat Body */
/*
   Делаем структуру как в эталоне psyai:
   - .chat-body = контейнер (overflow:hidden; position:relative)
   - Кнопка scroll-bottom внутри .chat-body
   - Скролл привязан к #chatBody (дочерний элемент)
*/
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

/* scroll container (аналог .srollable-y из psyai) */
.chat-body-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* без искусственного top-padding: шапка в потоке и не перекрывает сообщения */
    padding: 1rem 1.5rem 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    background: transparent;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.chat-messages {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}


/* Message */
.message {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.message-ai {
    align-items: flex-start;
}

.message-user {
    align-items: flex-end;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 500;
}

.message-header svg {
    width: 16px;
    height: 16px;
}

.message-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.message-content {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    -webkit-appearance: none;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    max-width: 85%;
    line-height: 1.6;
    color: var(--gray-800);
    font-size: 1.1rem;
}

.message-ai .message-content {
    border-top-left-radius: 4px;
}

.message-user .message-content {
    background: var(--gray-100);
    border-top-right-radius: 4px;
}

.message-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.message-cost {
    color: var(--gray-500);
}

.btn-message-action {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: transparent;
    border: none;
    color: var(--gray-500);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-message-action:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-message-action.danger:hover {
    background: var(--danger-light);
    color: var(--danger);
}

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

/* Scroll to Bottom Button */
/* поддерживаем оба класса: старый .btn-scroll-bottom и эталонный .scroll-bottom */
.btn-scroll-bottom,
.scroll-bottom {
    position: absolute;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    -webkit-appearance: none;
    border: 1px solid var(--gray-300);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 15;
}

/* скрываем кнопку через d-none (как в эталоне psyai) */
.btn-scroll-bottom.d-none,
.scroll-bottom.d-none {
    display: none !important;
}

.btn-scroll-bottom:hover,
.scroll-bottom:hover {
    background: var(--gray-50);
    border-color: var(--primary);
}

.btn-scroll-bottom svg,
.scroll-bottom svg {
    width: 20px;
    height: 20px;
    color: var(--gray-600);
}

/* Chat Footer */
.chat-footer {
    padding: 1rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    background: var(--white);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 10;
}

.chat-footer-inner {
    max-width: 800px;
    margin: 0 auto;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: 16px;
    padding: 0.75rem 1rem;
    transition: border-color 0.2s;
    position: relative;
    min-height: 52px;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
}

.chat-input-icon {
    color: var(--accent);
    flex-shrink: 0;
}

.chat-input-icon svg {
    width: 20px;
    height: 20px;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    color: var(--gray-800);
    resize: none;
    outline: none;
    max-height: 150px;
    line-height: 1.5;
    min-height: 24px;
    -webkit-appearance: none;
    appearance: none;
}

.chat-input::placeholder {
    color: var(--gray-500);
}

.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-voice {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-voice:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

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

.btn-send {
    background: var(--primary);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--white);
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-send:hover {
    background: var(--primary-light);
}

.btn-send:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

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

.chat-disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.75rem;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: flex-start;
    justify-content: center;
    backdrop-filter: blur(5px);
    padding: 20px 20px;
    overflow-y: auto;
}

/* Centered small modals (confirm/delete) */
.modal-overlay.modal-overlay-center {
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 24px;
    padding: 3rem;
    max-width: 1000px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
    margin: auto;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.modal.modal-confirm {
    max-width: 560px;
    padding: 2.5rem 2.75rem;
}

.modal > h3,
.modal > .bonus-banner,
.modal > .modal-tabs,
.modal > .tab-content {
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-600);
    transition: color 0.3s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--gray-800);
}

.modal h3 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--gray-800);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
}

/* Confirm/Delete modal buttons (Да/Нет) */
.modal-title {
    text-align: center;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin-top: 1.25rem;
}

.btn-modal {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.9rem 1.25rem;
    min-width: 140px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn-modal:active {
    transform: translateY(1px);
}

.btn-modal:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(123, 106, 175, 0.25);
}

.btn-modal-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-modal-danger:hover {
    background: #d93431;
    box-shadow: 0 10px 25px rgba(229, 57, 53, 0.25);
}

.btn-modal-cancel {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    -webkit-appearance: none;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-modal-cancel:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

@media (max-width: 480px) {
    .modal-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-modal {
        width: 100%;
        min-width: 0;
    }
}

.bonus-banner {
    background: linear-gradient(135deg, #FFF7ED 0%, #FEF3E8 100%);
    border: 2px solid #FFE4CC;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.bonus-banner p {
    margin: 0;
    color: var(--gray-800);
    font-size: 0.95rem;
    line-height: 1.5;
}

.bonus-amount {
    font-weight: 700;
    color: var(--gray-900);
}

.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--gray-200);
}

.tab-button {
    flex: 1;
    background: none;
    border: none;
    padding: 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    position: relative;
    bottom: -2px;
}

.tab-button.active {
    color: var(--gray-900);
    border-bottom-color: #5B52E8;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.info-text {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.security-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #5B52E8;
    text-decoration: none;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.security-link:hover {
    text-decoration: underline;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

.form-group label {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.95rem;
}

.phone-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.phone-prefix {
    padding: 0.9rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    background: var(--gray-100);
    color: var(--gray-800);
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.phone-input-wrapper input {
    flex: 1;
}

.form-group input,
.form-group textarea {
    padding: 0.9rem 1.2rem;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: var(--gray-50);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #5B52E8;
}

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

.password-requirements {
    margin-top: 0.75rem;
    padding: 0;
}

.password-requirements li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.4rem;
    list-style: none;
}

.password-requirements li::before {
    content: '✓';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-600);
    font-size: 0.7rem;
    font-weight: bold;
}

.toggle-password {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    padding: 0.5rem;
}

.register-button {
    background: #5B52E8;
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 50px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.register-button:hover {
    background: #4942C7;
    transform: translateY(-2px);
}

.login-link {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--gray-600);
    font-size: 0.95rem;
}

.login-link a {
    color: #5B52E8;
    text-decoration: none;
    font-weight: 600;
}

.login-link a:hover {
    text-decoration: underline;
}

.terms-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-top: 1.5rem;
    line-height: 1.5;
}

.terms-text a {
    color: #5B52E8;
    text-decoration: none;
}

.terms-text a:hover {
    text-decoration: underline;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: var(--white);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
}

.sidebar-overlay.show {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-aside {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 300;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .chat-title-brand {
        display: inline-flex;
    }

    .chat-aside.open {
        transform: translateX(0);
    }

    .btn-mobile-menu {
        display: flex;
    }

    .chat-title {
        font-size: 0.875rem;
    }
    
    .remaining-count {
        font-size: 0.75rem;
        padding: 0.4rem 0.625rem;
        gap: 0.25rem;
    }
    
    .remaining-count-label {
        display: none;
    }
    
    .remaining-count #remainingCountValue {
        min-width: 20px;
    }

    .chat-body-scroll {
        padding: 1rem 1rem 2rem 1rem;
    }

    .message-content {
        max-width: 95%;
    }

    .btn-scroll-bottom {
        bottom: 1rem;
    }

    .chat-footer {
        padding: 0.75rem 1rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }
    
    .chat-input-wrapper {
        min-height: 48px;
    }
    
    .chat-input {
        font-size: 16px; /* iOS не будет зумить при фокусе */
        -webkit-text-size-adjust: 100%;
    }

    .chat-disclaimer {
        display: none;
    }

    .modal {
        padding: 2.5rem 2rem;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    /* Confirm/Delete modal should stay centered (not full-screen) */
    .modal-overlay.modal-overlay-center {
        padding: 20px;
        align-items: center;
    }

    .modal {
        max-width: 100%;
        width: 100%;
        border-radius: 0;
        padding: 2rem 1.5rem;
        max-height: 100vh;
        margin: 0;
    }

    .modal.modal-confirm {
        width: 100%;
        max-width: 560px;
        border-radius: 24px;
        padding: 2.25rem 1.75rem;
        max-height: calc(100vh - 40px);
        margin: auto;
    }

    .modal-close {
        top: 1rem;
        right: 1rem;
    }
}

/* Круглый спиннер для генерации текста */
.typing-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 4px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinTyping 0.8s linear infinite;
    vertical-align: middle;
}

/* Спиннер + подпись "Уже скоро" (используется в non-streaming regenerate loader) */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    vertical-align: middle;
}

.typing-label {
    font-size: 0.8125rem;
    color: var(--gray-500);
    user-select: none;
    white-space: nowrap;
}

@keyframes spinTyping {
    to {
        transform: rotate(360deg);
    }
}

/* Кнопка "Стоп" */
.btn-stop {
    background: var(--gray-600);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--white);
    border-radius: 8px;
    transition: all 0.2s;
    animation: stopPulse 1.5s ease-in-out infinite;
}

.btn-stop:hover {
    background: var(--gray-700);
}

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

@keyframes stopPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(117, 117, 117, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(117, 117, 117, 0);
    }
}

.char-limit-alert {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #E53935;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.char-limit-alert span {
    display: flex;
    align-items: center;
    gap: 8px;
}

#currentCharCount {
    font-weight: 700;
}

/*
   Важно: раньше здесь был iOS-хак с фиксированным footer и большим padding-bottom,
   который создавал лишнее «серое поле» и большой зазор над полем ввода.
   Оставляем только фикс против автозума (уже есть в @media max-width:768px).
*/

/* Android Chrome фиксы */
@media screen and (max-width: 768px) {
    /* Для всех мобильных устройств */
    .chat-input-wrapper {
        -webkit-tap-highlight-color: transparent;
    }
    
    .chat-input {
        /* Убираем outline на Android */
        -webkit-tap-highlight-color: transparent;
        /* Размер шрифта для предотвращения автозума */
        font-size: max(16px, 0.9375rem);
    }
    
    /* Фикс для Android Chrome при появлении клавиатуры */
    .chat-footer {
        background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    -webkit-appearance: none;
    }
}

/* =========================
   Lazy Loading Indicators
   ========================= */

/* Индикатор загрузки старых сообщений */
.lazy-load-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.lazy-load-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Индикатор что все сообщения загружены */
.all-messages-loaded {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: var(--gray-400);
    font-size: 0.8125rem;
    font-style: italic;
    margin-bottom: 1rem;
}

.all-messages-loaded span {
    padding: 0.5rem 1.25rem;
    background: var(--gray-100);
    border-radius: 20px;
}

/* Мобильная адаптация индикаторов */
@media (max-width: 768px) {
    .lazy-load-indicator,
    .all-messages-loaded {
        padding: 0.75rem;
        font-size: 0.8125rem;
    }
    
    .lazy-load-spinner {
        width: 18px;
        height: 18px;
    }
}

/* =========================
   Coming Soon Modal
   ========================= */
.modal.modal-coming-soon {
    max-width: 600px;
    padding: 2.5rem;
    text-align: center;
}

.coming-soon-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.coming-soon-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: rocketBounce 2s ease-in-out infinite;
}

@keyframes rocketBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.modal-coming-soon h3 {
    font-size: 2rem;
    color: var(--gray-900);
    margin-bottom: 0;
}

.coming-soon-subtitle {
    color: var(--gray-600);
    font-size: 1rem;
    margin: 0;
}

.coming-soon-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    margin-top: 0.5rem;
}

.coming-soon-feature {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: 16px;
    text-align: left;
    transition: all 0.3s ease;
}

.coming-soon-feature.highlighted {
    background: linear-gradient(135deg, #F0EBF8 0%, #E8E3F5 100%);
    border-color: var(--primary-light);
    box-shadow: 0 4px 15px rgba(123, 106, 175, 0.15);
}

.coming-soon-feature .feature-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.coming-soon-feature .feature-content {
    flex: 1;
}

.coming-soon-feature .feature-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 0.5rem 0;
}

.coming-soon-feature .feature-content p {
    font-size: 0.9375rem;
    color: var(--gray-600);
    line-height: 1.5;
    margin: 0;
}

.btn-coming-soon-ok {
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    color: white;
    padding: 1rem 3rem;
    border: none;
    border-radius: 50px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.btn-coming-soon-ok:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(128, 90, 213, 0.45);
}

.btn-coming-soon-ok:active {
    transform: translateY(0);
}

/* Мобильная адаптация Coming Soon Modal */
@media (max-width: 480px) {
    .modal.modal-coming-soon {
        padding: 2rem 1.5rem;
        border-radius: 24px;
    }
    
    .coming-soon-icon {
        font-size: 2.5rem;
    }
    
    .modal-coming-soon h3 {
        font-size: 1.5rem;
    }
    
    .coming-soon-feature {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .coming-soon-feature .feature-icon {
        font-size: 1.5rem;
    }
    
    .coming-soon-feature .feature-content h4 {
        font-size: 1rem;
    }
    
    .coming-soon-feature .feature-content p {
        font-size: 0.875rem;
    }
    
    .btn-coming-soon-ok {
        padding: 0.875rem 2rem;
        font-size: 1rem;
        width: 100%;
    }
}

/* =========================
   Audio Recording Interface
   ========================= */
.chat-audio-recorder {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--gray-50);
    border: 2px solid var(--primary);
    border-radius: 16px;
    margin-bottom: 0.75rem;
}

.btn-audio-cancel {
    background: var(--gray-200);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-700);
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-audio-cancel:hover {
    background: var(--gray-600);
    color: var(--white);
}

.btn-audio-cancel svg {
    width: 20px;
    height: 20px;
}

.audio-wave-container {
    flex: 1;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
    min-height: 40px;
}

.audio-wave {
    width: 100%;
    height: 40px;
}

.audio-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.audio-indicator {
    width: 8px;
    height: 8px;
    background: #be1111;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.audio-time {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    min-width: 45px;
}

/* Контейнер с кнопками отмены и отправки */
.audio-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Кнопка отправки аудио (галочка) */
.btn-audio-send {
    background: var(--accent);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--white);
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: sendPulse 1.5s ease-in-out infinite;
}

.btn-audio-send:hover {
    background: #4AA897;
}

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

@keyframes sendPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(91, 186, 168, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(91, 186, 168, 0);
    }
}

/* Кнопка отправки при активной записи */
.btn-send.recording-active {
    background: var(--accent);
    animation: recordingPulse 1.5s ease-in-out infinite;
}

.btn-send.recording-active:hover {
    background: #4AA897;
}

@keyframes recordingPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(91, 186, 168, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(91, 186, 168, 0);
    }
}

/* Кнопка микрофона при активной записи (скрыта) */
.btn-voice.recording-hidden {
    display: none;
}

/* Мобильная адаптация аудио-записи */
@media (max-width: 768px) {
    .chat-audio-recorder {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .audio-wave-container {
        min-height: 35px;
    }
    
    .audio-wave {
        height: 35px;
    }
    
    .btn-audio-cancel {
        padding: 0.4rem;
    }
    
    .btn-audio-cancel svg {
        width: 18px;
        height: 18px;
    }
}

/* =========================
   Loop Interrupted Alert Modal
   ========================= */
.modal-loop-alert {
    max-width: 500px;
    padding: 2.5rem;
    text-align: center;
}

.loop-alert-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.loop-alert-icon {
    font-size: 3.5rem;
    animation: warningPulse 2s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.loop-alert-message {
    color: var(--gray-700);
    font-size: 1rem;
    line-height: 1.7;
    margin: 0;
    max-width: 400px;
}

.btn-loop-alert-ok {
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    color: white;
    padding: 1rem 3rem;
    border: none;
    border-radius: 50px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.btn-loop-alert-ok:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(128, 90, 213, 0.45);
}

.btn-loop-alert-ok:active {
    transform: translateY(0);
}

/* Мобильная адаптация Loop Alert Modal */
@media (max-width: 480px) {
    .modal.modal-loop-alert {
        padding: 2rem 1.5rem;
        border-radius: 24px;
    }
    
    .loop-alert-icon {
        font-size: 2.5rem;
    }
    
    .loop-alert-message {
        font-size: 0.9375rem;
    }
    
    .btn-loop-alert-ok {
        padding: 0.875rem 2rem;
        font-size: 1rem;
        width: 100%;
    }
}

/* =========================
   Microphone Permission Modal
   ========================= */
.modal.modal-microphone {
    max-width: 480px;
    padding: 2.5rem;
    text-align: center;
}

.microphone-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.microphone-modal-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: micPulse 2s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.85;
    }
}

.modal-microphone h3 {
    font-size: 1.5rem;
    color: var(--gray-900);
    margin: 0;
}

.microphone-modal-text {
    color: var(--gray-700);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
    max-width: 380px;
}

.microphone-modal-hint {
    color: var(--gray-500);
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-radius: 12px;
    max-width: 380px;
}

.microphone-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.5rem;
}

.btn-microphone-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--gray-100);
    border: 2px solid var(--gray-300);
    border-radius: 50px;
    color: var(--gray-700);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-microphone-help:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
    color: var(--gray-800);
}

.btn-microphone-help svg {
    width: 18px;
    height: 18px;
}

.btn-microphone-retry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.btn-microphone-retry:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(128, 90, 213, 0.45);
}

.btn-microphone-retry:active {
    transform: translateY(0);
}

.btn-microphone-retry svg {
    width: 18px;
    height: 18px;
}

/* Мобильная адаптация Microphone Permission Modal */
@media (max-width: 480px) {
    .modal.modal-microphone {
        padding: 2rem 1.5rem;
        border-radius: 24px;
    }
    
    .microphone-modal-icon {
        font-size: 2.5rem;
    }
    
    .modal-microphone h3 {
        font-size: 1.25rem;
    }
    
    .microphone-modal-text {
        font-size: 0.9375rem;
    }
    
    .microphone-modal-hint {
        font-size: 0.8125rem;
    }
    
    .btn-microphone-help,
    .btn-microphone-retry {
        width: 100%;
    }
}

/* =========================
   Transcription Status
   ========================= */
.transcription-status {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(135deg, #F0EBF8 0%, #E8E3F5 100%);
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    margin-top: 0.75rem;
    animation: slideIn 0.3s ease;
}

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

.transcription-status span {
    color: var(--gray-700);
    font-size: 0.9375rem;
    font-weight: 500;
}

.transcription-loader {
    width: 20px;
    height: 20px;
    border: 3px solid var(--primary-bg);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: transcriptionSpin 0.8s linear infinite;
}

@keyframes transcriptionSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Мобильная адаптация статуса транскрибации */
@media (max-width: 768px) {
    .transcription-status {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    
    .transcription-status span {
        font-size: 0.875rem;
    }
    
    .transcription-loader {
        width: 18px;
        height: 18px;
        border-width: 2.5px;
    }
}

/* =========================
   Recording Warning Banner
   ========================= */
.recording-warning-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.35);
    animation: slideDownBanner 0.3s ease;
}

.recording-warning-banner.show {
    display: flex;
}

@keyframes slideDownBanner {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.recording-warning-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 800px;
    color: white;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
}

.recording-warning-content svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    stroke: white;
    animation: warningIconPulse 1.5s ease-in-out infinite;
}

@keyframes warningIconPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* Мобильная адаптация баннера предупреждения */
@media (max-width: 768px) {
    .recording-warning-banner {
        padding: 0.625rem 0.75rem;
    }
    
    .recording-warning-content {
        font-size: 0.8125rem;
        gap: 0.5rem;
    }
    
    .recording-warning-content svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .recording-warning-content {
        font-size: 0.75rem;
        text-align: left;
    }
    
    .recording-warning-content svg {
        width: 16px;
        height: 16px;
    }
}

/* =========================
   Connection Lost Banner
   ========================= */
.connection-lost-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    display: none;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #E53935 0%, #C62828 100%);
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.35);
    animation: slideDownBanner 0.3s ease;
}

.connection-lost-banner.show {
    display: flex;
}

.connection-lost-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 800px;
    color: white;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
}

.connection-lost-content svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    stroke: white;
    animation: wifiPulse 2s ease-in-out infinite;
}

@keyframes wifiPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Мобильная адаптация баннера потери соединения */
@media (max-width: 768px) {
    .connection-lost-banner {
        padding: 0.625rem 0.75rem;
    }
    
    .connection-lost-content {
        font-size: 0.8125rem;
        gap: 0.5rem;
    }
    
    .connection-lost-content svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .connection-lost-content {
        font-size: 0.75rem;
        text-align: left;
    }
    
    .connection-lost-content svg {
        width: 16px;
        height: 16px;
    }
}

/* =========================
   Message Failed & Retry Button
   ========================= */

/* Сообщение с ошибкой */
.message-ai.message-failed .message-content {
    background: linear-gradient(135deg, #FFF5F5 0%, #FFF0F0 100%);
    border: 1px solid #FFCDD2;
}

/* Кнопка "Повторить" */
.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
}

.btn-retry:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.btn-retry:active {
    transform: translateY(0);
}

.btn-retry:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.btn-retry:disabled:hover {
    background: var(--gray-400);
    transform: none;
}

.btn-retry svg {
    width: 12px;
    height: 12px;
}

/* Мобильная адаптация кнопки "Повторить" */
@media (max-width: 768px) {
    .btn-retry {
        padding: 0.3rem 0.625rem;
        font-size: 0.6875rem;
    }
    
    .btn-retry svg {
        width: 11px;
        height: 11px;
    }
}
