.h2o-ai-agent {
    --h2o-ai-agent-size: clamp(92px, 8.5vw, 132px);
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 2147483000;
    width: var(--h2o-ai-agent-size);
    font: inherit;
    line-height: 1.25;
    pointer-events: none;
    transform-origin: 50% 100%;
}

.h2o-ai-agent__button {
    appearance: none;
    -webkit-appearance: none;
    display: block;
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    pointer-events: auto;
    transform-origin: 50% 100%;
    -webkit-tap-highlight-color: transparent;
}

.h2o-ai-agent__button:focus-visible,
.h2o-ai-agent__chat button:focus-visible,
.h2o-ai-agent__input:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

.h2o-ai-agent__robot {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    transform-origin: 50% 85%;
}

.h2o-ai-agent__bubble {
    position: absolute;
    right: 76%;
    bottom: 78%;
    min-width: max-content;
    max-width: min(240px, 70vw);
    padding: 10px 14px;
    border: 1px solid rgba(15, 23, 42, .10);
    border-radius: 18px 18px 5px 18px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 12px 34px rgba(15, 23, 42, .16);
    color: #172033;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
    opacity: 0;
    transform: translate3d(8px, 8px, 0) scale(.88);
    transform-origin: 100% 100%;
    transition: opacity 180ms ease, transform 260ms cubic-bezier(.2,.8,.2,1.15);
    pointer-events: none;
}

.h2o-ai-agent__bubble[aria-hidden="false"] {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
}

.h2o-ai-agent__chat {
    position: absolute;
    right: 0;
    bottom: calc(100% + 14px);
    width: min(360px, calc(100vw - 30px));
    height: min(460px, calc(100vh - 150px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 22px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
    color: #172033;
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    transform: translate3d(0, 12px, 0) scale(.96);
    transform-origin: 100% 100%;
    transition: opacity 180ms ease, transform 220ms ease, visibility 180ms ease;
}

.h2o-ai-agent__chat[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0, 0, 0) scale(1);
}

.h2o-ai-agent__chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(15, 23, 42, .09);
    font-size: 15px;
}

.h2o-ai-agent__chat-close {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.h2o-ai-agent__messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    overscroll-behavior: contain;
}

.h2o-ai-agent__message {
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 16px;
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.h2o-ai-agent__message--assistant {
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    background: #eef2ff;
    color: #172033;
}

.h2o-ai-agent__message--user {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    background: #172033;
    color: #fff;
}

.h2o-ai-agent__chat-status {
    min-height: 20px;
    padding: 0 16px 4px;
    color: rgba(23, 32, 51, .65);
    font-size: 12px;
}

.h2o-ai-agent__form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(15, 23, 42, .09);
    background: rgba(255, 255, 255, .98);
}

.h2o-ai-agent__input {
    min-width: 0;
    flex: 1;
    height: 42px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid rgba(15, 23, 42, .18);
    border-radius: 12px;
    background: #fff;
    color: #172033;
    font: inherit;
    font-size: 14px;
}

.h2o-ai-agent__send {
    appearance: none;
    height: 42px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    background: #172033;
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.h2o-ai-agent__send:disabled,
.h2o-ai-agent__input:disabled {
    opacity: .6;
    cursor: wait;
}

.h2o-ai-agent__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;
}

.h2o-ai-agent[data-state="hidden"] {
    opacity: 0;
    transform: translate3d(0, 150%, 0) scale(.86);
}

.h2o-ai-agent[data-state="entering"] {
    pointer-events: auto;
    animation: h2o-ai-agent-enter 950ms cubic-bezier(.22,.95,.28,1.15) both;
}

.h2o-ai-agent[data-state="idle"] {
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0) scale(1);
}

.h2o-ai-agent[data-state="idle"] .h2o-ai-agent__robot {
    animation: h2o-ai-agent-float 3.2s ease-in-out infinite;
}

.h2o-ai-agent[data-state="idle"] .h2o-ai-agent__eyes {
    transform-origin: center;
    animation: h2o-ai-agent-blink 5.2s infinite;
}

.h2o-ai-agent[data-state="hello"] .h2o-ai-agent__arm--right,
.h2o-ai-agent.is-waving .h2o-ai-agent__arm--right {
    transform-box: fill-box;
    transform-origin: 15% 80%;
    animation: h2o-ai-agent-wave 620ms ease-in-out 2;
}

.h2o-ai-agent.is-bouncing .h2o-ai-agent__button {
    animation: h2o-ai-agent-tap-bounce 520ms cubic-bezier(.2,.8,.2,1.2);
}

.h2o-ai-agent.is-thinking .h2o-ai-agent__eyes {
    animation: h2o-ai-agent-thinking 900ms ease-in-out infinite;
}

@keyframes h2o-ai-agent-enter {
    0%   { opacity: 0; transform: translate3d(0, 150%, 0) scale(.84,.92); }
    52%  { opacity: 1; transform: translate3d(0, -18%, 0) scale(1.03,.97); }
    70%  { transform: translate3d(0, 5%, 0) scale(.98,1.03); }
    84%  { transform: translate3d(0, -5%, 0) scale(1.01,.99); }
    100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes h2o-ai-agent-float {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(-.5deg); }
    50%      { transform: translate3d(0, -5px, 0) rotate(.5deg); }
}

@keyframes h2o-ai-agent-wave {
    0%, 100% { transform: rotate(0deg); }
    35%      { transform: rotate(-24deg); }
    70%      { transform: rotate(14deg); }
}

@keyframes h2o-ai-agent-blink {
    0%, 44%, 47%, 100% { transform: scaleY(1); }
    45%, 46%           { transform: scaleY(.08); }
}

@keyframes h2o-ai-agent-tap-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    45%      { transform: translateY(-12px) scale(1.03,.97); }
    68%      { transform: translateY(2px) scale(.99,1.01); }
}

@keyframes h2o-ai-agent-thinking {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(4px); }
}

@media (max-width: 600px) {
    .h2o-ai-agent {
        --h2o-ai-agent-size: 96px;
        right: max(12px, env(safe-area-inset-right));
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .h2o-ai-agent__chat {
        position: fixed;
        right: 12px;
        left: 12px;
        bottom: calc(var(--h2o-ai-agent-size) + 24px);
        width: auto;
        height: min(430px, calc(100vh - 150px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .h2o-ai-agent,
    .h2o-ai-agent *,
    .h2o-ai-agent *::before,
    .h2o-ai-agent *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}
