:root {
    --ccai-orange: #e87519;
    --ccai-orange-dark: #c9590b;
    --ccai-navy: #183b56;
    --ccai-green: #109b22;
    --ccai-green-dark: #0b7a1a;
    --ccai-ink: #17212b;
    --ccai-muted: #647381;
    --ccai-line: #e3e8ec;
    --ccai-soft: #f4f7f9;
    --ccai-white: #ffffff;
    --ccai-success: #28a96b;
}

.ccai-root,
.ccai-root * {
    box-sizing: border-box;
}

.ccai-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2147483000;
    color: var(--ccai-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

.ccai-launcher {
    min-height: 58px;
    padding: 8px 20px 8px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 999px;
    background: var(--ccai-orange);
    color: var(--ccai-white);
    font: inherit;
    font-weight: 750;
    letter-spacing: .01em;
    box-shadow: 0 12px 32px rgba(20, 45, 65, .24), 0 3px 8px rgba(20, 45, 65, .14);
    cursor: pointer;
    overflow: hidden;
    transition: transform .18s ease, background-color .18s ease, box-shadow .18s ease, max-width .18s ease, min-height .18s ease, padding .18s ease;
}

.ccai-launcher:hover {
    background: var(--ccai-orange-dark);
    transform: translateY(-2px);
    box-shadow: 0 15px 36px rgba(20, 45, 65, .28), 0 4px 9px rgba(20, 45, 65, .16);
}

.ccai-launcher:focus-visible,
.ccai-close:focus-visible,
.ccai-send:focus-visible,
.ccai-action:focus-visible,
.ccai-suggestion:focus-visible,
.ccai-input:focus-visible {
    outline: 3px solid rgba(232, 117, 25, .32);
    outline-offset: 2px;
}

.ccai-launcher-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .17);
}

.ccai-launcher-label {
    white-space: nowrap;
}

.ccai-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: min(390px, calc(100vw - 28px));
    height: min(640px, calc(100vh - 118px));
    height: min(640px, calc(100dvh - 118px));
    min-height: 470px;
    display: grid;
    grid-template-rows: auto 1fr auto auto auto auto;
    overflow: hidden;
    border: 1px solid rgba(19, 59, 86, .12);
    border-radius: 22px;
    background: var(--ccai-white);
    box-shadow: 0 24px 70px rgba(17, 39, 56, .28), 0 5px 18px rgba(17, 39, 56, .12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px) scale(.975);
    transform-origin: right bottom;
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}

.ccai-root.ccai-open .ccai-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.ccai-root.ccai-open .ccai-launcher {
    visibility: hidden;
    pointer-events: none;
}

.ccai-header {
    min-height: 74px;
    padding: 13px 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--ccai-white);
    background: linear-gradient(135deg, var(--ccai-green-dark), var(--ccai-green));
}

.ccai-avatar {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    border: 2px solid rgba(255, 255, 255, .58);
    border-radius: 50%;
    color: var(--ccai-white);
    background: var(--ccai-orange);
    font-size: 20px;
    font-weight: 850;
}

.ccai-header-copy {
    min-width: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
}

.ccai-header-copy strong {
    overflow: hidden;
    font-size: 16px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ccai-header-copy > span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, .82);
    font-size: 12.5px;
}

.ccai-status-dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
    background: #4ce39a;
    box-shadow: 0 0 0 3px rgba(76, 227, 154, .17);
}

.ccai-close {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    border: 0;
    border-radius: 50%;
    color: var(--ccai-white);
    background: rgba(255, 255, 255, .1);
    cursor: pointer;
}

.ccai-close:hover {
    background: rgba(255, 255, 255, .19);
}

.ccai-messages {
    min-height: 0;
    padding: 17px 14px 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: linear-gradient(180deg, #f9fbfc 0%, var(--ccai-white) 30%);
    scrollbar-width: thin;
    scrollbar-color: #bdc8cf transparent;
}

.ccai-message-row {
    margin: 0 0 10px;
    display: flex;
}

.ccai-message-row.ccai-user {
    justify-content: flex-end;
}

.ccai-message {
    max-width: 84%;
    padding: 10px 12px;
    border-radius: 15px 15px 15px 5px;
    color: var(--ccai-ink);
    background: var(--ccai-soft);
    box-shadow: 0 1px 1px rgba(20, 45, 65, .05);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    -webkit-user-select: text;
    user-select: text;
}

.ccai-user .ccai-message {
    border-radius: 15px 15px 5px 15px;
    color: var(--ccai-white);
    background: var(--ccai-green-dark);
}

.ccai-message a {
    color: var(--ccai-orange-dark);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    -webkit-user-select: text;
    user-select: text;
}

.ccai-user .ccai-message a {
    color: var(--ccai-white);
}

.ccai-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 48px;
    min-height: 21px;
}

.ccai-typing i {
    width: 7px;
    height: 7px;
    display: block;
    border-radius: 50%;
    background: #8a98a3;
    animation: ccai-bounce 1.15s infinite ease-in-out;
}

.ccai-typing i:nth-child(2) { animation-delay: .13s; }
.ccai-typing i:nth-child(3) { animation-delay: .26s; }

@keyframes ccai-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.ccai-suggestions {
    padding: 3px 12px 9px;
    display: flex;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    cursor: grab;
    background: var(--ccai-white);
}

.ccai-suggestions.ccai-dragging,
.ccai-suggestions.ccai-dragging .ccai-suggestion {
    cursor: grabbing;
    user-select: none;
}

.ccai-suggestions::-webkit-scrollbar { display: none; }

.ccai-suggestion {
    padding: 7px 10px;
    flex: 0 0 auto;
    border: 1px solid rgba(232, 117, 25, .34);
    border-radius: 999px;
    color: #9c4809;
    background: #fff8f2;
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}

.ccai-suggestion:hover {
    border-color: var(--ccai-orange);
    background: #fff1e5;
}

.ccai-suggestion:disabled {
    opacity: .55;
    cursor: wait;
}

.ccai-actions {
    padding: 0 12px 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: var(--ccai-white);
}

.ccai-action {
    min-height: 37px;
    padding: 8px 9px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 800;
    text-align: center;
    text-decoration: none !important;
}

.ccai-action-primary {
    color: var(--ccai-white) !important;
    background: var(--ccai-orange);
}

.ccai-action-primary:hover { background: var(--ccai-orange-dark); }

.ccai-action-secondary {
    border: 1px solid #cbd6dc;
    color: var(--ccai-navy) !important;
    background: var(--ccai-white);
}

.ccai-action-secondary:hover { background: var(--ccai-soft); }

.ccai-form {
    margin: 0 12px;
    padding: 5px 5px 5px 12px;
    display: flex;
    align-items: flex-end;
    gap: 7px;
    border: 1px solid #ccd7dd;
    border-radius: 14px;
    background: var(--ccai-white);
    box-shadow: 0 2px 8px rgba(24, 59, 86, .06);
}

.ccai-form:focus-within {
    border-color: var(--ccai-orange);
    box-shadow: 0 0 0 3px rgba(232, 117, 25, .12);
}

.ccai-input {
    width: 100%;
    min-height: 37px;
    max-height: 92px;
    padding: 8px 0 6px;
    resize: none;
    overflow-y: auto;
    border: 0;
    outline: 0 !important;
    color: var(--ccai-ink);
    background: transparent;
    box-shadow: none !important;
    font: inherit;
    line-height: 1.35;
}

.ccai-input::placeholder { color: #84919b; }

.ccai-send {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    border: 0;
    border-radius: 11px;
    color: var(--ccai-white);
    background: var(--ccai-orange);
    cursor: pointer;
}

.ccai-send:hover { background: var(--ccai-orange-dark); }
.ccai-send:disabled { opacity: .48; cursor: wait; }

.ccai-privacy {
    margin: 0;
    padding: 7px 12px 10px;
    color: var(--ccai-muted);
    background: var(--ccai-white);
    font-size: 10.5px;
    line-height: 1.3;
    text-align: center;
}

.ccai-privacy a {
    margin-left: 4px;
    color: var(--ccai-navy);
    font-weight: 700;
}

.ccai-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 540px) {
    .ccai-root {
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .ccai-launcher {
        min-height: 48px;
        max-width: 104px;
        padding: 6px 13px 6px 6px;
        gap: 7px;
    }

    .ccai-launcher-icon {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    .ccai-root.ccai-launcher-expanded .ccai-launcher {
        min-height: 54px;
        max-width: 260px;
        padding: 6px 17px 6px 7px;
    }

    .ccai-panel {
        position: fixed;
        right: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
        height: min(720px, calc(100vh - 20px));
        height: min(720px, calc(100dvh - 20px));
        min-height: 0;
        border-radius: 20px;
        transform-origin: right bottom;
    }

    .ccai-root.ccai-open .ccai-launcher { display: none; }

    .ccai-message-row.ccai-assistant .ccai-message {
        color: #10171e;
        font-weight: 300;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ccai-panel,
    .ccai-launcher,
    .ccai-typing i {
        animation: none !important;
        transition: none !important;
    }
}
