.co-chat {
    --co-chat-color: #201a36;
    --co-chat-muted: #584e6d;
    --co-chat-border: #ddd8e8;
    --co-chat-soft: #f6f3fc;
    --co-chat-brand: var(--co-chat-accent, #5138bb);
    --co-chat-gap: clamp(12px, 2.4vw, 24px);
    --co-chat-bottom: calc(var(--co-chat-gap) + var(--co-chat-bottom-offset, 0px) + env(safe-area-inset-bottom, 0px));
    --co-chat-window-height: 100vh;
    color: var(--co-chat-color);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.55;
}

.co-chat *,
.co-chat *::before,
.co-chat *::after {
    box-sizing: border-box;
}

.co-chat [hidden] {
    display: none !important;
}

.co-chat button,
.co-chat textarea {
    font: inherit;
}

.co-chat button {
    cursor: pointer;
}

.co-chat button:disabled {
    cursor: default;
    opacity: 0.6;
}

.co-chat :where(button, a, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--co-chat-brand);
    outline-offset: 3px;
}

.co-chat__trigger {
    position: fixed;
    z-index: var(--co-chat-z-index, 1000);
    inset-inline-end: var(--co-chat-gap);
    inset-block-end: var(--co-chat-bottom);
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-block-size: 48px;
    padding: 9px 17px;
    border: 1px solid transparent;
    border-radius: 99px;
    background: var(--co-chat-brand);
    box-shadow: 0 8px 22px #25155630;
    color: #fff;
    white-space: nowrap;
}

.co-chat .co-chat__trigger {
    font-weight: 700;
}

.co-chat__trigger[aria-expanded="true"] {
    visibility: hidden;
}

.co-chat:has(.co-chat__dialog:not([hidden])) .co-chat__trigger {
    visibility: hidden;
}

.co-chat__icon {
    position: relative;
    inline-size: 18px;
    block-size: 15px;
    margin-block-end: 3px;
    border: 1.6px solid currentColor;
    border-radius: 5px;
}

.co-chat__icon::before {
    position: absolute;
    inset-inline-start: 3px;
    inset-block-end: -4px;
    inline-size: 5px;
    block-size: 5px;
    transform: skewY(-36deg);
    border-block-end: 1.6px solid currentColor;
    border-inline-start: 1.6px solid currentColor;
    background: var(--co-chat-brand);
    content: "";
}

.co-chat__icon::after {
    position: absolute;
    inset-inline-start: 3px;
    inset-block-start: 4px;
    inline-size: 2px;
    block-size: 2px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 4px 0 currentColor, 8px 0 currentColor;
    content: "";
}

.co-chat__backdrop {
    position: fixed;
    z-index: calc(var(--co-chat-z-index, 1000) + 1);
    inset: 0;
    background: #1a122d38;
}

.co-chat__dialog {
    position: fixed;
    z-index: calc(var(--co-chat-z-index, 1000) + 2);
    inset-inline-end: var(--co-chat-gap);
    inset-block-end: var(--co-chat-bottom);
    display: flex;
    flex-direction: column;
    inline-size: min(416px, calc(100% - 2 * var(--co-chat-gap)));
    block-size: 620px;
    max-block-size: calc(var(--co-chat-window-height) - var(--co-chat-bottom) - var(--co-chat-gap));
    overflow: hidden;
    border: 1px solid var(--co-chat-border);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 18px 60px #2515563b;
}

.co-chat__header,
.co-chat__footer {
    flex: none;
    background: #fff;
}

.co-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px 10px 16px;
    border-block-end: 1px solid var(--co-chat-border);
}

.co-chat__title {
    margin: 0;
    color: var(--co-chat-color);
    font-size: clamp(16px, 4vw, 19px);
    font-weight: 750;
    line-height: 1.3;
    word-break: keep-all;
}

.co-chat__header-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 4px;
}

.co-chat__header-actions button {
    min-block-size: 44px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--co-chat-color);
}

.co-chat__header-actions button:hover {
    background: var(--co-chat-soft);
}

.co-chat .co-chat__reset {
    padding: 0 9px;
    color: var(--co-chat-muted);
    font-size: 13px;
}

.co-chat .co-chat__close {
    inline-size: 44px;
    padding: 0;
    font-size: 24px;
    line-height: 1;
}

.co-chat__scroll {
    flex: 1 1 auto;
    min-block-size: 0;
    overflow-y: auto;
    padding: 18px 16px;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.co-chat__scroll:focus-visible {
    outline-offset: -3px;
}

.co-chat__messages {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.co-chat__message {
    max-inline-size: 94%;
    padding: 10px 12px;
    border-radius: 12px 12px 12px 4px;
    background: var(--co-chat-soft);
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.co-chat__message[data-role="user"] {
    align-self: flex-end;
    border-radius: 12px 12px 4px 12px;
    background: var(--co-chat-brand);
    color: #fff;
}

.co-chat__message-actions,
.co-chat__prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-block-start: 10px;
    white-space: normal;
}

.co-chat__message-actions a,
.co-chat__prompts button {
    display: inline-flex;
    align-items: center;
    min-block-size: 38px;
    padding: 5px 9px;
    border: 1px solid var(--co-chat-border);
    border-radius: 8px;
    background: #fff;
    color: var(--co-chat-brand);
    font-size: 13px;
    text-align: start;
    text-decoration: none;
}

.co-chat__message-actions a:hover,
.co-chat__prompts button:hover {
    border-color: var(--co-chat-brand);
}

.co-chat__footer {
    padding: 9px 13px 6px;
    border-block-start: 1px solid var(--co-chat-border);
}

.co-chat__status {
    margin-block-end: 6px;
    color: var(--co-chat-muted);
    font-size: 13px;
}

.co-chat__status:empty {
    margin-block-end: 0;
}

.co-chat__image-status {
    margin-block-end: 6px;
    color: var(--co-chat-muted);
    font-size: 13px;
}

.co-chat__image-status:empty {
    margin-block-end: 0;
}

.co-chat__attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-block-end: 6px;
    padding: 4px 6px;
    border: 1px solid var(--co-chat-border);
    border-radius: 8px;
    font-size: 13px;
}

.co-chat__attachment[hidden] {
    display: none;
}

.co-chat__attachment img {
    inline-size: 34px;
    block-size: 34px;
    border-radius: 4px;
    object-fit: cover;
}

.co-chat__attachment span {
    flex: 1;
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.co-chat__attachment button,
.co-chat .co-chat__attach {
    flex: none;
    min-inline-size: 48px;
    min-block-size: 44px;
    padding: 4px 6px;
    border: 1px solid var(--co-chat-border);
    border-radius: 8px;
    background: #fff;
    color: var(--co-chat-brand);
    font-size: 13px;
    font-weight: 650;
}

.co-chat .co-chat__attach {
    display: inline-grid;
    place-items: center;
    min-inline-size: 44px;
    inline-size: 44px;
    padding: 0;
}

.co-chat__message-image {
    display: block;
    max-inline-size: min(230px, 100%);
    max-block-size: 150px;
    margin-block: 4px;
    border-radius: 6px;
    object-fit: contain;
}

.co-chat__composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
}

.co-chat__composer textarea {
    flex: 1 1 auto;
    min-inline-size: 0;
    min-block-size: 44px;
    max-block-size: 84px;
    padding: 8px 10px;
    resize: vertical;
    border: 1px solid var(--co-chat-border);
    border-radius: 9px;
    background: #fff;
    color: var(--co-chat-color);
    field-sizing: content;
}

.co-chat__composer textarea::placeholder {
    color: var(--co-chat-muted);
}

.co-chat .co-chat__send {
    min-inline-size: 56px;
    min-block-size: 44px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--co-chat-brand);
    color: #fff;
    font-weight: 700;
}

.co-chat__support {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 14px;
}

.co-chat__support a {
    display: inline-flex;
    align-items: center;
    min-block-size: 32px;
    color: var(--co-chat-brand);
    font-size: 13px;
    text-underline-offset: 0.22em;
}

.co-chat__sr-only {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@supports (height: 100dvh) {
    .co-chat {
        --co-chat-window-height: 100dvh;
    }
}

@media (max-width: 640px), (hover: none) and (max-height: 600px) {
    html:has(.co-chat__dialog:not([hidden])) {
        overflow: hidden;
    }

    .co-chat__dialog {
        inset-inline: 0;
        inset-block: var(--co-chat-viewport-top, 0px) auto;
        inline-size: 100%;
        block-size: var(--co-chat-viewport-height, var(--co-chat-window-height));
        max-block-size: unset;
        border: 0;
        border-radius: 0;
    }

    .co-chat__header {
        padding-block-start: max(6px, env(safe-area-inset-top, 0px));
    }

    .co-chat__footer {
        padding-block-end: max(4px, env(safe-area-inset-bottom, 0px));
    }

    .co-chat .co-chat__composer textarea {
        resize: none;
        font-size: 16px;
    }
}


