/* Apex chat: audience-selector palette, typography and interaction style. */
#apex-ai {
    --ai-ink: #181a1d;
    --ai-paper: #fbfcfc;
    --ai-accent: #477c78;
    --ai-line: #d9e1df;
    --ai-muted: #56606a;
    position: fixed;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 99990;
    color: var(--ai-ink);
    font: 14px/1.55 "Avenir Next", Avenir, "Helvetica Neue", Helvetica, Arial, sans-serif;
    text-align: left;
    letter-spacing: normal;
    -webkit-font-smoothing: antialiased;
}
#apex-ai *, #apex-ai *::before, #apex-ai *::after { box-sizing: border-box; }
#apex-ai[hidden], #apex-ai [hidden] { display: none !important; }
#apex-ai button, #apex-ai input, #apex-ai textarea { font: inherit; letter-spacing: normal; text-shadow: none; }
#apex-ai button { margin: 0; cursor: pointer; text-transform: none; }
#apex-ai button:disabled { opacity: .5; cursor: wait; }
#apex-ai a, #apex-ai a:visited { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#apex-ai :focus-visible { outline: 2px solid #447f7a; outline-offset: 4px; }
#apex-ai .apex-ai-dot { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%; background: #79aaa6; }
#apex-ai .apex-ai-launch {
    display: flex; align-items: center; justify-content: center; gap: 11px;
    min-height: 56px; padding: 13px 19px;
    border: 1px solid var(--ai-line); border-radius: 16px;
    background: var(--ai-paper); color: var(--ai-ink);
    font-size: 14px; font-weight: 600;
    box-shadow: 0 8px 30px rgba(15, 24, 27, .12);
    transition: background .22s ease, border-color .22s ease, transform .22s ease, box-shadow .22s ease;
}
#apex-ai .apex-ai-launch:hover { background: #edf5f3; border-color: #83aba6; transform: translateY(-3px); box-shadow: 0 12px 30px rgba(24,26,29,.12); }
#apex-ai .apex-ai-launch[aria-expanded="true"] { background: #edf5f3; border-color: #83aba6; }
#apex-ai-panel {
    position: absolute; right: 0; bottom: 72px;
    display: flex; flex-direction: column;
    width: min(660px, calc(100vw - 32px));
    height: min(660px, calc(var(--ai-viewport-height, 100dvh) - 116px));
    max-height: calc(var(--ai-viewport-height, 100dvh) - 116px);
    padding: 0; margin: 0; overflow: hidden;
    border: 1px solid rgba(255,255,255,.65); border-radius: 24px;
    background: var(--ai-paper); color: var(--ai-ink);
    box-shadow: 0 24px 100px rgba(0,0,0,.24);
    transform-origin: bottom right;
    animation: apexAIIn .34s cubic-bezier(.22,1,.36,1) both;
}
#apex-ai .apex-ai-header {
    position: relative; display: block; flex: none; width: auto;
    padding: 30px 28px 21px; margin: 0;
    border: 0; border-bottom: 1px solid var(--ai-line);
    background: var(--ai-paper); color: var(--ai-ink);
}
#apex-ai .apex-ai-close {
    position: absolute; top: 16px; right: 16px;
    display: grid; place-items: center; width: 38px; height: 38px;
    padding: 0; border: 1px solid rgba(24,26,29,.14); border-radius: 50%;
    background: transparent; color: var(--ai-ink);
    transition: background .18s ease, transform .18s ease;
}
#apex-ai .apex-ai-close:hover { background: #e8efed; transform: rotate(90deg); }
#apex-ai .apex-ai-eyebrow {
    display: flex; align-items: center; gap: 8px;
    padding: 0; margin: 0 34px 22px 0;
    color: #506566; font-size: 9px; font-weight: 700; line-height: 1.4; letter-spacing: .13em;
}
#apex-ai h2 {
    max-width: 360px; padding: 0; margin: 0 0 12px;
    color: var(--ai-ink); font-family: "Newsreader", Georgia, "Times New Roman", serif;
    font-size: clamp(28px, 5vw, 40px); font-weight: 400; line-height: 1.06;
    letter-spacing: -.035em; text-transform: none;
}
#apex-ai h2 em { color: var(--ai-accent); font-weight: 400; }
#apex-ai .apex-ai-header p { padding: 0; margin: 0; color: var(--ai-muted); font-size: 13px; font-weight: 400; line-height: 1.6; }
#apex-ai .apex-ai-messages { flex: 1 1 auto; min-height: 0; padding: 20px 22px 6px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #cadbd7 transparent; }
#apex-ai .apex-ai-bubble {
    width: fit-content; max-width: 92%; padding: 13px 15px; margin: 0 0 12px;
    border: 1px solid var(--ai-line); border-radius: 14px 14px 14px 4px;
    background: #fff; color: var(--ai-ink); font-size: 14px; line-height: 1.6;
    white-space: pre-wrap; overflow-wrap: anywhere;
}
#apex-ai .apex-ai-bubble[data-role="user"] { margin-left: auto; border-color: #c7dcd6; border-radius: 14px 14px 4px 14px; background: #edf5f3; color: #244943; }
#apex-ai .apex-ai-status { flex: none; margin: 0; padding: 0 24px; color: #775349; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
#apex-ai .apex-ai-status:not(:empty) { padding-top: 5px; padding-bottom: 8px; max-height: 96px; overflow-y: auto; }
#apex-ai .apex-ai-form { flex: none; display: block; padding: 14px 22px 10px; margin: 0; border: 0; border-top: 1px solid var(--ai-line); background: var(--ai-paper); }
#apex-ai .apex-ai-composer { display: flex; align-items: center; gap: 7px; padding: 5px; border: 1px solid var(--ai-line); border-radius: 14px; background: #fff; transition: border-color .2s ease, box-shadow .2s ease; }
#apex-ai .apex-ai-composer:focus-within { border-color: #83aba6; box-shadow: 0 0 0 3px rgba(121,170,166,.12); }
#apex-ai textarea { display: block; flex: 1; width: 0; min-width: 0; height: 44px; max-height: 88px; padding: 11px 8px; margin: 0; resize: none; border: 0; border-radius: 8px; outline: none; box-shadow: none; background: #fff; color: var(--ai-ink); font-size: 16px; line-height: 22px; }
#apex-ai textarea::placeholder { color: #7b8686; opacity: 1; }
#apex-ai .apex-ai-composer button { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; padding: 0; border: 1px solid #d1e1dc; border-radius: 10px; background: #edf5f3; color: var(--ai-accent); transition: background .2s ease, border-color .2s ease; }
#apex-ai .apex-ai-composer button:hover { background: #dfede8; border-color: #83aba6; }
#apex-ai .apex-ai-composer button svg { transition: transform .22s ease; }
#apex-ai .apex-ai-composer button:hover svg { transform: translateX(3px); }
#apex-ai .apex-ai-footer { position: static; display: flex; flex: none; align-items: center; justify-content: space-between; gap: 8px; width: auto; padding: 0 24px 18px; margin: 0; border: 0; background: transparent; color: #7b8686; font-size: 11px; line-height: 1.45; letter-spacing: .015em; }
#apex-ai .apex-ai-reset { min-height: 26px; padding: 4px 0; border: 0; background: transparent; color: #596b68; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
#apex-ai .apex-ai-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@keyframes apexAIIn { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (max-width: 600px) {
    body.apex-ai-chat-open { overflow: hidden; }
    #apex-ai { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
    #apex-ai-panel {
        position: fixed;
        top: calc(var(--ai-viewport-top, 0px) + max(8px, env(safe-area-inset-top)));
        right: max(8px, env(safe-area-inset-right));
        left: max(8px, env(safe-area-inset-left));
        bottom: auto;
        width: auto;
        height: calc(var(--ai-viewport-height, 100dvh) - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
        max-height: calc(var(--ai-viewport-height, 100dvh) - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
        border-radius: 18px;
    }
    #apex-ai .apex-ai-launch[aria-expanded="true"] { visibility: hidden; pointer-events: none; }
    #apex-ai .apex-ai-header { padding: 24px 22px 18px; }
    #apex-ai .apex-ai-eyebrow { font-size: 9px; gap: 7px; margin: 0 40px 18px 0; }
    #apex-ai .apex-ai-close { top: 12px; right: 12px; width: 44px; height: 44px; }
    #apex-ai h2 { font-size: clamp(29px, 7.5vw, 40px); }
    #apex-ai .apex-ai-messages { padding: 16px 16px 4px; }
    #apex-ai .apex-ai-form { padding: 12px 12px 8px; }
    #apex-ai .apex-ai-footer { padding: 0 16px 10px; }
    #apex-ai .apex-ai-launch { min-height: 52px; padding: 12px 17px; }
}
@media (max-height: 620px) {
    #apex-ai .apex-ai-header { padding: 16px 22px 12px; }
    #apex-ai .apex-ai-eyebrow { margin-bottom: 12px; }
    #apex-ai h2 { font-size: 28px; margin-bottom: 0; }
    #apex-ai .apex-ai-header p { display: none; }
}
/* This also applies when the keyboard shrinks only the visual viewport. */
#apex-ai.apex-ai-compact .apex-ai-header { padding: 14px 22px 12px; }
#apex-ai.apex-ai-compact .apex-ai-eyebrow, #apex-ai.apex-ai-compact .apex-ai-header p { display: none; }
#apex-ai.apex-ai-compact h2 { margin: 0 38px 0 0; font-size: 25px; }
#apex-ai.apex-ai-compact .apex-ai-title-break { display: none; }
#apex-ai.apex-ai-compact .apex-ai-footer { padding-bottom: 6px; }
#apex-ai.apex-ai-compact .apex-ai-status:not(:empty) { max-height: 44px; }
@media (prefers-reduced-motion: reduce) {
    #apex-ai-panel { animation: none; }
    #apex-ai *, #apex-ai *::before, #apex-ai *::after { transition: none !important; }
}
.apex-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 2px;
}

.apex-typing > span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #477c78;
    animation: apex-typing-dot 1.2s ease-in-out infinite;
}

.apex-typing > span:nth-child(2) {
    animation-delay: .15s;
}

.apex-typing > span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes apex-typing-dot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: .35;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .apex-typing > span {
        animation: none;
        opacity: .7;
    }
}
