.gcub-ai-chat {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1200;
    font-family: inherit;
    color: #07111f;
}

.gcub-ai-chat__button {
    display: inline-flex;
    align-items: center;
    gap: 0;
    min-height: 54px;
    padding: 0 20px;
    border: 0;
    border-radius: 999px;
    background: #2073f8;
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    box-shadow: 0 18px 45px rgba(32, 115, 248, .28);
    cursor: pointer;
}

.gcub-ai-chat__button-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    font-size: 17px;
}

.gcub-ai-chat__panel {
    position: absolute;
    right: 0;
    bottom: 70px;
    display: none;
    width: min(380px, calc(100vw - 32px));
    height: min(590px, calc(100vh - 110px));
    overflow: hidden;
    border: 1px solid rgba(16, 31, 54, .1);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 28px 80px rgba(7, 17, 31, .2);
}

.gсub-ai-chat--open .gcub-ai-chat__panel,
.gcub-ai-chat--open .gcub-ai-chat__panel {
    display: flex;
    flex-direction: column;
}

.gcub-ai-chat__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 18px 14px;
    background: linear-gradient(135deg, #eef6ff 0%, #f7ffe9 100%);
}

.gcub-ai-chat__identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
}

.gcub-ai-chat__title {
    margin: 0;
    font-size: 18px;
    line-height: 1.12;
    font-weight: 900;
}

.gcub-ai-chat__status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: #c7ff4a;
    color: #1b5b00;
    font-size: 11px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: 0;
}

.gcub-ai-chat__close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(16, 31, 54, .12);
    border-radius: 50%;
    background: rgba(255, 255, 255, .74);
    color: #07111f;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.gcub-ai-chat__messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
    padding: 16px;
    background: #f5f8fc;
}

.gcub-ai-chat__message {
    max-width: 88%;
    padding: 11px 13px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.38;
    white-space: pre-wrap;
}

.gcub-ai-chat__message--assistant {
    align-self: flex-start;
    background: #fff;
    border: 1px solid rgba(16, 31, 54, .08);
    font-size: 14px;
    line-height: 1.42;
}

.gcub-ai-chat__message--assistant p,
.gcub-ai-chat__message--assistant li {
    font-size: inherit;
    line-height: inherit;
}

.gcub-ai-chat__message p {
    margin: 0 0 8px;
}

.gcub-ai-chat__message p:last-child {
    margin-bottom: 0;
}

.gcub-ai-chat__message ul {
    margin: 8px 0;
    padding-left: 18px;
}

.gcub-ai-chat__message li {
    margin: 5px 0;
    padding-left: 2px;
}

.gcub-ai-chat__message strong {
    font-weight: 900;
}


.gcub-ai-chat__message--assistant a {
    color: #2073f8;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}

.gcub-ai-chat__message--user {
    align-self: flex-end;
    background: #2073f8;
    color: #fff;
}

.gcub-ai-chat__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 14px;
    background: #f5f8fc;
}

.gcub-ai-chat__chips--hidden {
    display: none;
}

.gcub-ai-chat__chip {
    border: 1px solid rgba(32, 115, 248, .2);
    border-radius: 999px;
    background: #fff;
    color: #206fe6;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.gcub-ai-chat__form {
    display: flex;
    gap: 8px;
    padding: 14px;
    border-top: 1px solid rgba(16, 31, 54, .08);
    background: #fff;
}

.gcub-ai-chat__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    border: 1px solid rgba(16, 31, 54, .12);
    border-radius: 12px;
    padding: 0 12px;
    font: inherit;
    font-size: 13px;
    outline: none;
}

.gcub-ai-chat__input:focus {
    border-color: rgba(32, 115, 248, .5);
    box-shadow: 0 0 0 3px rgba(32, 115, 248, .12);
}

.gcub-ai-chat__send {
    flex: 0 0 auto;
    min-width: 48px;
    border: 0;
    border-radius: 12px;
    background: #2073f8;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

.gcub-ai-chat__send:disabled {
    opacity: .55;
    cursor: wait;
}

@media (max-width: 767px) {
    .gcub-ai-chat {
        right: 14px;
        bottom: 14px;
    }

    .gcub-ai-chat__button {
        min-height: 50px;
        padding: 0 14px;
        font-size: 14px;
    }

    .gcub-ai-chat__panel {
        position: fixed;
        left: 0;
        top: var(--gcub-ai-chat-top, 0px);
        bottom: auto;
        display: none;
        width: 100vw;
        height: var(--gcub-ai-chat-height, 100vh);
        min-height: 0;
        max-height: none;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        background: #f5f8fc;
        box-shadow: none;
    }

    .gcub-ai-chat--open::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: -1;
        background: #f5f8fc;
    }

    .gcub-ai-chat--open .gcub-ai-chat__panel {
        display: flex;
        flex-direction: column;
    }

    .gcub-ai-chat__head {
        flex: 0 0 auto;
        padding: calc(16px + env(safe-area-inset-top)) 16px 14px;
    }

    .gcub-ai-chat__messages {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
    }

    .gcub-ai-chat__chips,
    .gcub-ai-chat__form {
        flex: 0 0 auto;
    }

    .gcub-ai-chat__form {
        position: relative;
        z-index: 2;
        align-items: center;
        min-height: calc(72px + var(--gcub-ai-chat-bottom-guard, 0px) + env(safe-area-inset-bottom));
        padding-bottom: calc(14px + var(--gcub-ai-chat-bottom-guard, 0px) + env(safe-area-inset-bottom));
        background: #fff;
    }

    .gcub-ai-chat__form::after {
        content: "";
        position: fixed;
        left: 0;
        right: 0;
        bottom: -180px;
        height: 220px;
        background: #fff;
        pointer-events: none;
    }

    .gcub-ai-chat__input {
        flex: 1 1 auto;
        height: 44px;
        min-height: 44px;
        max-height: 44px;
        font-size: 13px;
        line-height: 44px;
    }

    .gcub-ai-chat__send {
        width: 48px;
        height: 44px;
        min-height: 44px;
    }
}


@supports selector(html:has(.gcub-ai-chat--open)) {
    @media (max-width: 767px) {
        html:has(.gcub-ai-chat--open),
        body:has(.gcub-ai-chat--open) {
            overflow: hidden;
            height: 100%;
        }
    }
}

.gcub-ai-chat .gcub-ai-chat__input,
.gcub-ai-chat .gcub-ai-chat__input:focus {
    font-size: 13px !important;
    line-height: 44px !important;
}

/* Mobile chat keyboard stability: make the opened chat a real viewport layer */
@media (max-width: 767px) {
    .gcub-ai-chat.gcub-ai-chat--open {
        left: 0 !important;
        right: auto !important;
        top: var(--gcub-ai-chat-top, 0px) !important;
        bottom: auto !important;
        width: 100vw !important;
        height: var(--gcub-ai-chat-height, 100dvh) !important;
        min-height: 0 !important;
        overflow: hidden !important;
        background: #f5f8fc !important;
        pointer-events: auto !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__button {
        display: none !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__panel {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: none !important;
        transform: translateZ(0);
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__messages {
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__form {
        min-height: calc(72px + env(safe-area-inset-bottom)) !important;
        padding-top: 12px !important;
        padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__form::after {
        content: none !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__input {
        font-size: 13px !important;
        line-height: 20px !important;
    }
}

@media (max-width: 767px) {
    html.gcub-ai-chat-lock,
    body.gcub-ai-chat-lock {
        height: var(--gcub-ai-chat-height, 100dvh) !important;
        overflow: hidden !important;
        overscroll-behavior: none !important;
    }
}

/* Mobile chat keyboard mode: keep input above iOS browser/keyboard bars */
@media (max-width: 767px) {
    .gcub-ai-chat,
    .gcub-ai-chat *,
    .gcub-ai-chat *::before,
    .gcub-ai-chat *::after {
        box-sizing: border-box !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open,
    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__panel {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__chips {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__chip {
        max-width: calc(100vw - 32px) !important;
        white-space: normal !important;
        text-align: left !important;
    }

    .gcub-ai-chat.gcub-ai-chat--keyboard .gcub-ai-chat__head {
        padding-top: calc(12px + env(safe-area-inset-top)) !important;
        padding-bottom: 12px !important;
    }

    .gcub-ai-chat.gcub-ai-chat--keyboard .gcub-ai-chat__messages {
        flex: 0 0 auto !important;
        max-height: 34vh !important;
        min-height: 0 !important;
        padding-bottom: 10px !important;
        overflow: auto !important;
    }

    .gcub-ai-chat.gcub-ai-chat--keyboard .gcub-ai-chat__chips {
        display: none !important;
    }

    .gcub-ai-chat.gcub-ai-chat--keyboard .gcub-ai-chat__form {
        flex: 0 0 auto !important;
        min-height: 68px !important;
        margin-top: 0 !important;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom)) !important;
        border-top: 1px solid rgba(16, 31, 54, .1) !important;
        box-shadow: 0 -10px 28px rgba(7, 17, 31, .06) !important;
    }

    .gcub-ai-chat.gcub-ai-chat--keyboard .gcub-ai-chat__input {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 13px !important;
        line-height: 20px !important;
    }

    .gcub-ai-chat.gcub-ai-chat--keyboard .gcub-ai-chat__send {
        width: 48px !important;
        min-width: 48px !important;
    }
}

/* iOS Safari: prevent input-focus zoom and horizontal drift */
@media (max-width: 767px) {
    html.gcub-ai-chat-lock,
    body.gcub-ai-chat-lock {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        overflow-x: hidden !important;
        position: fixed !important;
        inset: 0 !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open {
        left: var(--gcub-ai-chat-left, 0px) !important;
        width: var(--gcub-ai-chat-width, 100vw) !important;
        max-width: var(--gcub-ai-chat-width, 100vw) !important;
        overflow: hidden !important;
        overflow-x: hidden !important;
        touch-action: pan-y !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__panel,
    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__head,
    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__messages,
    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__chips,
    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__form {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
    }

    .gcub-ai-chat .gcub-ai-chat__input,
    .gcub-ai-chat .gcub-ai-chat__input:focus,
    .gcub-ai-chat.gcub-ai-chat--keyboard .gcub-ai-chat__input {
        font-size: 16px !important;
        line-height: 20px !important;
        -webkit-text-size-adjust: 100% !important;
    }
}

/* Mobile chat keyboard mode: keep the conversation area full-height */
@media (max-width: 767px) {
    .gcub-ai-chat.gcub-ai-chat--keyboard .gcub-ai-chat__messages {
        flex: 1 1 auto !important;
        max-height: none !important;
        min-height: 0 !important;
        overflow-y: auto !important;
    }

    .gcub-ai-chat.gcub-ai-chat--keyboard .gcub-ai-chat__form {
        flex: 0 0 auto !important;
        margin-top: auto !important;
        min-height: calc(72px + env(safe-area-inset-bottom)) !important;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom)) !important;
    }
}

/* Mobile chat: prevent scroll anchoring from keeping old messages in view */
@media (max-width: 767px) {
    .gcub-ai-chat__messages,
    .gcub-ai-chat__message {
        overflow-anchor: none !important;
    }

    .gcub-ai-chat.gcub-ai-chat--open .gcub-ai-chat__messages {
        scroll-padding-bottom: 18px !important;
    }
}

