.chat-button {
    position: fixed;
    right: 50px;
    bottom: 14%;
    z-index: 5;
    width: 40px;
    height: 40px;
    border: none;
    cursor: pointer;
    background-color: var(--color-accent-blue, #00B5E2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
}

/* Пульсация кнопки, когда чат закрыт */
.chat-button__active {
    animation: chatPulse 2.4s ease-in-out infinite;
}

.chat-button__image {
    width: 30px;
    position: relative;
    z-index: 2;
}

/* Контейнер волн */
.chat-button__waves {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

/* Анимация волн только когда кнопка активна */
.chat-button__active .chat-button__wave {
    animation: waveRipple 3s ease-out infinite;
}

.chat-button__wave {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
    opacity: 0;
    transform: scale(0.5);
}

.chat-button__wave:nth-child(1) {
    animation-delay: 0s;
}
.chat-button__wave:nth-child(2) {
    animation-delay: 1s;
}
.chat-button__wave:nth-child(3) {
    animation-delay: 2s;
}

@keyframes chatPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(0, 181, 226, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 18px 4px rgba(0, 181, 226, 0.9);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(0, 181, 226, 0.7);
    }
}

@keyframes waveRipple {
    0% {
        opacity: 0;
        transform: scale(0.7);
    }
    10% {
        opacity: 0.9;
    }
    60% {
        opacity: 0.3;
        transform: scale(1.8);
    }
    100% {
        opacity: 0;
        transform: scale(2.2);
    }
}

/* === ОКНО ЧАТА === */

.chat-window-wrapper {
    position: fixed;
    right: 50px;
    bottom: 20%;
    z-index: 5;
    max-width: 400px;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--background-color, #000000);
    padding: 20px;
    border: 1px solid var(--color-accent-blue, #00B5E2);
    box-shadow: 0 0 18px rgba(0, 181, 226, 0.5);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    max-height: 600px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-window-wrapper.chat-window-wrapper__open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.chat-header-close {
    border: none;
    background-color: transparent;
    color: var(--color-accent-white, #ffffff);
    font-size: 30px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin-bottom: 10px;
}

.chat-header-line {
    display: block;
    width: 100%;
    height: 2px;
    min-height: 2px;
    max-height: 2px;
    margin: 0 0 12px;
    background-color: var(--color-accent-blue, #00B5E2);
    box-shadow: 0 0 4px rgba(0, 181, 226, 0.6);
    position: relative;
    z-index: 3;
    transform: none !important;
}

.chat-window {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 12px 8px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-accent-blue, #00B5E2) transparent;
}

/* Chrome / Edge / Safari */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 181, 226, 0.7);
    border-radius: 3px;
}

.chat-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.chat-row__bot {
    justify-content: flex-start;
}

.chat-row__user {
    justify-content: flex-end;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-avatar__user {
    background-color: var(--color-accent-blue, #00B5E2);
}

.chat-message-box {
    border: 1px solid #ffffff;
    background-color: #202020;
    padding: 8px 10px;
    max-width: 240px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-message-box__user {
    border-color: var(--color-accent-blue, #00B5E2);
    background-color: #001219;
}

.text__chat {
    margin: 0;
    padding: 0;
}

/* ===== INPUT ===== */

.chat-input-row {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-top: 8px;
    transition: transform 0.2s ease-out;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--color-accent-blue, #00B5E2);
    background-color: #000000;
    padding: 9px 10px;
    box-sizing: border-box;
}

.chat-input-text {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    overflow-y: hidden;
    line-height: 1.4;
    margin-bottom: 0;
    min-height: 1.4em;
}

.chat-input-text::placeholder {
    color: var(--color-accent-average-gray, #B6B6B6);
}

.chat-send-button,
.chat-mic-button {
    width: 40px;
    height: 40px;
    border: none;
    background-color: var(--color-accent-blue, #00B5E2);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.chat-send-button {
    display: none;
}

/* Аватар с картинкой */
.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Для иконки пользователя */
.chat-avatar__user img {
    object-fit: contain;
}

/* Состояние input во время записи */
.chat-input.recording {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.record-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 3px;
}

.record-indicator__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ff4d4f;
    box-shadow: 0 0 0 4px rgba(255, 77, 79, 0.3);
    animation: record-pulse 1.1s infinite ease-in-out;
}

.record-indicator__label {
    margin-bottom: 0;
}

.record-indicator__time {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0;
}

@keyframes record-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 4px rgba(255, 77, 79, 0.3);
        opacity: 1;
    }
    70% {
        transform: scale(1.25);
        box-shadow: 0 0 0 8px rgba(255, 77, 79, 0);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 4px rgba(255, 77, 79, 0.3);
        opacity: 1;
    }
}

/* === ГОЛОСОВОЕ В СООБЩЕНИИ (визуализатор + кнопка) === */

.voice-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    max-width: 220px;
}

.voice-play-button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    outline: none;
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.18s ease-out, transform 0.12s ease-out;
}

.voice-play-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
}

.voice-play-button:active {
    transform: scale(0.97);
}

.voice-play-button img {
    width: 14px;
    height: 14px;
}

/* Визуализатор */

.visualizer-wrapper {
    position: relative;
    height: 20px;
    flex: 1;
    display: flex;
    align-items: center;
    max-width: 120px;
}

.bars-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    width: 100%;
    height: 100%;
}

.bar {
    width: 2px;
    border-radius: 999px;
    min-height: 10%;
    height: var(--bar-height, 50%);
    background: rgba(255, 255, 255, 0.16);
    position: relative;
    overflow: hidden;
}

.bar::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--bar-fill, 0%);
    background: linear-gradient(to top, #ffffff, rgba(255, 255, 255, 0.96));
    transition: width 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.voice-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: right;
    flex-shrink: 0;
}

/* === АДАПТИВ === */

@media (max-width: 1199px) {
    .chat-button {
        right: 40px;
        bottom: 10%;
        width: 38px;
        height: 38px;
    }

    .chat-window-wrapper {
        right: 40px;
        bottom: 16%;
        max-width: 360px;
        padding: 18px;
        max-height: min(600px, 80vh);
    }

    .chat-header-close {
        font-size: 26px;
    }

    .chat-message-box {
        max-width: 220px;
    }

    .chat-input {
        padding: 8px 9px;
    }

    .chat-send-button,
    .chat-mic-button {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 991px) {
    .chat-button {
        right: 30px;
        bottom: 10%;
        width: 36px;
        height: 36px;
    }

    .chat-window-wrapper {
        right: 30px;
        bottom: 16%;
        max-width: 320px;
        padding: 16px;
        max-height: min(580px, 78vh);
    }

    .chat-header-close {
        font-size: 24px;
    }

    .chat-avatar {
        width: 30px;
        height: 30px;
    }

    .chat-message-box {
        max-width: 210px;
        padding: 7px 9px;
    }

    .chat-input {
        padding: 5px 9px;
    }

    .chat-send-button,
    .chat-mic-button {
        width: 34px;
        height: 34px;
    }

    .voice-message {
        max-width: 210px;
    }

    .visualizer-wrapper {
        max-width: 110px;
    }
}

/* === МОБИЛКИ (главное поведение клавиатуры) === */
@media (max-width: 768px) {
    .chat-button {
        right: 30px;
        bottom: 10%;
        width: 34px;
        height: 34px;
    }

    .chat-window-wrapper {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        z-index: 9999;
        background-color: var(--background-color, #000000);
        padding: 14px;
        box-sizing: border-box;
        border-radius: 0;
        border: none;
        box-shadow: none;
        display: flex;
        flex-direction: column;
    }

    .chat-window {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
        padding-bottom: 52px; /* запас под фиксированный input-row */
    }

    .chat-messages {
        flex: 1 1 auto;
        min-height: 0;
    }

    .chat-button__image {
        width: 20px;
    }

    .chat-header-close {
        font-size: 22px;
    }

    .chat-message-box {
        max-width: 250px;
    }

    .chat-input-row {
        gap: 4px;

        /* главное: фиксируем к низу экрана поверх остального контента */
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 8px 10px;
        background-color: var(--background-color, #000000);
        box-sizing: border-box;
        z-index: 10000;

        /* плавный выезд вместе с клавой за счёт визуального смещения */
        transform: translateY(0);
    }

    .chat-send-button,
    .chat-mic-button {
        width: 32px;
        height: 32px;
    }

    .voice-message {
        max-width: 200px;
        gap: 6px;
        padding: 2px 0;
    }

    .visualizer-wrapper {
        max-width: 100px;
        height: 16px;
    }

    .bar {
        width: 2px;
    }

    .bars-container {
        gap: 1px;
    }

    .voice-time {
        font-size: 10px;
        min-width: 34px;
    }

    .chat-input-text {
        font-size: 14px;
    }

    .text__chat {
        font-size: 14px;
    }
}

@media (max-width: 575px) {
    .chat-button {
        right: 25px;
        bottom: 10%;
        width: 32px;
        height: 32px;
    }

    .chat-header-close {
        font-size: 20px;
        margin-bottom: 6px;
    }

    .chat-avatar {
        width: 28px;
        height: 28px;
    }

    .chat-message-box {
        max-width: 160px;
        padding: 4px 8px;
    }

    .chat-input {
        padding: 6px 8px;
    }

    .chat-input-text {
        font-size: 12px;
    }

    .text__chat {
        font-size: 12px;
    }

    .chat-send-button,
    .chat-mic-button {
        width: 30px;
        height: 30px;
    }
}

/* Кнопка консультации */
.button-with-blue-border.button-with-blue-border__filled {
    background-color: #00B5E2;
}

.button-with-blue-border.button-with-blue-border__filled:hover {
    background-color: #0092B8;
    border-color: #0092B8;
}