#spcw-chat-root {
    position: relative;
    z-index: 9998;
}

.spcw-chat-container {
    position: fixed;
    z-index: 9999;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.spcw-chat-container.spcw-hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.spcw-chat-container.spcw-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Кнопка */

.spcw-chat-button {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: #229ED9; /* Telegram blue */
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0;
    padding: 0;
    position: relative;
}

.spcw-chat-button:hover {
    filter: brightness(1.05);
}

.spcw-chat-button-open {
    box-shadow: 0 0 0 rgba(0,0,0,0.1);
}

/* Бейдж */

.spcw-chat-badge {
    position: absolute;
    bottom: 70px;
    right: 0;
    max-width: 260px;
    background: #fff;
    color: #111;
    padding: 8px 12px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    font-size: 13px;
    cursor: pointer;
}

.spcw-chat-badge::after {
    content: "";
    position: absolute;
    bottom: -6px;
    right: 16px;
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
}

/* Окно чата */

.spcw-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 320px;
    max-width: 90vw;
    max-height: 70vh;
    background: #f5f5f5;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.spcw-chat-window-open {
    display: flex;
    animation: spcw-slide-up .2s ease-out;
}

@keyframes spcw-slide-up {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.spcw-chat-header {
    padding: 10px 14px;
    background: #229ED9;
    color: #fff;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    position: relative;
}

.spcw-chat-title {
    font-size: 14px;
    font-weight: 600;
}

.spcw-chat-subtitle {
    font-size: 12px;
    opacity: 0.9;
}

.spcw-chat-close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

.spcw-chat-body {
    padding: 8px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.spcw-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
}

.spcw-msg {
    max-width: 85%;
    padding: 6px 10px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.35;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.spcw-msg-operator {
    background: #e3f1fb;
    color: #111;
    align-self: flex-start;
}

.spcw-msg-user {
    background: #d0f5c3;
    color: #111;
    align-self: flex-end;
}

.spcw-msg-system {
    background: #eee;
    color: #555;
    align-self: center;
}

/* Быстрые ответы */

.spcw-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.spcw-quick-btn {
    border: none;
    border-radius: 999px;
    background: #fff;
    font-size: 11px;
    padding: 4px 8px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.spcw-quick-btn:hover {
    background: #f0f0f0;
}

/* Футер / ввод */

.spcw-chat-footer {
    padding: 8px 10px;
    border-top: 1px solid #ddd;
    background: #fafafa;
}

.spcw-login-wrapper {
    text-align: center;
}

.spcw-input-wrapper {
    display: flex;
    gap: 6px;
    align-items: center;
}

.spcw-input-wrapper.spcw-hidden {
    display: none;
}

.spcw-input {
    flex: 1;
    resize: none;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid #ccc;
    min-height: 40px;
    max-height: 80px;
}

.spcw-send-btn {
    border: none;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    background: #229ED9;
    color: #fff;
    cursor: pointer;
}

.spcw-send-btn:hover {
    filter: brightness(1.05);
}

/* Мобильная адаптация */

@media (max-width: 767px) {
    .spcw-chat-container {
        /* иконка остаётся в углу, окно — как нижний лист */
    }

    .spcw-chat-window {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 80vh;
        border-radius: 16px 16px 0 0;
    }

    .spcw-chat-badge {
        right: 16px;
        left: auto;
        max-width: 70vw;
    }

    .spcw-chat-body {
        max-height: calc(80vh - 110px); /* чуть меньше, чтобы влез футер */
    }

    .spcw-chat-messages {
        max-height: none;
    }

    .spcw-input {
        font-size: 14px;
    }

    .spcw-send-btn {
        font-size: 14px;
        padding: 8px 14px;
    }
}
/* Общий текст в окне чата */
.spcw-chat-window,
.spcw-chat-body,
.spcw-chat-footer,
.spcw-chat-messages {
    color: #111 !important;
}

/* Сообщения */
.spcw-msg-operator {
    background: #e3f1fb;
    color: #111 !important;
}

.spcw-msg-user {
    background: #d0f5c3;
    color: #111 !important;
}

/* Поле ввода */
.spcw-input {
    background-color: #ffffff !important;
    color: #111111 !important;
    caret-color: #111111 !important;
    border: 1px solid #ccc;
}

/* Плейсхолдер, чтобы не был белым */
.spcw-input::placeholder {
    color: #888888 !important;
}