.oggy-chat-launcher {
    position: fixed;
    right: 22px;
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 2147483000;
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #536dfe, #3045bd);
    box-shadow: 0 12px 34px rgba(31, 53, 151, .38);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.oggy-chat-launcher:hover,
.oggy-chat-launcher:focus-visible {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 16px 40px rgba(31, 53, 151, .46);
}

.oggy-chat-launcher svg { width: 29px; height: 29px; }
.oggy-chat-launcher[aria-expanded="true"] { opacity: 0; pointer-events: none; transform: scale(.8); }

.oggy-chat-panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 2147483001;
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 32px));
    height: min(620px, calc(100dvh - 44px));
    overflow: hidden;
    border: 1px solid rgba(215, 221, 236, .95);
    border-radius: 22px;
    color: #172033;
    background: #fff;
    box-shadow: 0 24px 75px rgba(20, 37, 88, .3);
    font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(38px) scale(.94);
    transform-origin: bottom right;
    transition: opacity .25s ease, transform .32s cubic-bezier(.2,.8,.2,1), visibility .25s;
}

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

.oggy-chat-head {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 11px;
    padding: 16px 17px;
    color: #fff;
    background: linear-gradient(135deg, #3f51b5, #26378e);
}

.oggy-chat-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: rgba(255,255,255,.15); font-weight: 900; }
.oggy-chat-title { flex: 1; min-width: 0; }
.oggy-chat-title strong, .oggy-chat-title small { display: block; }
.oggy-chat-title small { margin-top: 2px; opacity: .82; font-size: 12px; }
.oggy-chat-close { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 10px; color: #fff; background: transparent; font-size: 25px; cursor: pointer; }
.oggy-chat-close:hover, .oggy-chat-close:focus-visible { background: rgba(255,255,255,.13); }

.oggy-chat-notice { display: none; flex: 0 0 auto; padding: 9px 14px; color: #785400; background: #fff2c7; font-size: 12px; }
.oggy-chat-notice.is-visible { display: block; }
.oggy-chat-messages { flex: 1 1 0; width: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 15px; background: #f6f7fb; -webkit-overflow-scrolling: touch; }
.oggy-chat-empty { margin: 90px 20px 0; color: #7b8498; text-align: center; }
.oggy-chat-row { display: flex; margin: 9px 0; }
.oggy-chat-row.customer { justify-content: flex-end; }
.oggy-chat-bubble { max-width: 82%; padding: 10px 12px; border-radius: 14px 14px 14px 4px; background: #fff; box-shadow: 0 1px 5px rgba(20,35,80,.1); white-space: pre-wrap; overflow-wrap: anywhere; }
.oggy-chat-row.customer .oggy-chat-bubble { color: #fff; background: #3f51b5; border-radius: 14px 14px 4px 14px; }
.oggy-chat-row.system .oggy-chat-bubble { max-width: 100%; margin: auto; color: #778196; background: transparent; box-shadow: none; text-align: center; font-size: 12px; }
.oggy-chat-by { display: block; margin-bottom: 3px; opacity: .68; font-size: 10px; }
.oggy-chat-link { color: #2e4cca; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.oggy-chat-row.customer .oggy-chat-link { color: #fff; }
.oggy-chat-row.typing { align-items: flex-end; }
.oggy-chat-row.typing .oggy-chat-bubble { display: flex; align-items: center; gap: 5px; min-width: 58px; padding: 13px 15px; border-radius: 16px 16px 16px 4px; }
.oggy-chat-typing-dot { width: 7px; height: 7px; border-radius: 50%; background: #8791a6; animation: oggy-chat-typing 1.25s ease-in-out infinite; }
.oggy-chat-typing-dot:nth-child(2) { animation-delay: .16s; }
.oggy-chat-typing-dot:nth-child(3) { animation-delay: .32s; }
@keyframes oggy-chat-typing { 0%, 60%, 100% { opacity: .42; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.oggy-chat-form { box-sizing: border-box; display: grid; grid-template-columns: minmax(0, 1fr) 68px; grid-template-rows: 48px 13px; align-items: center; flex: 0 0 91px; width: 100%; height: 91px; min-height: 91px; max-height: 91px; column-gap: 8px; row-gap: 5px; overflow: hidden; margin: 0; padding: 10px 12px 8px; border-top: 1px solid #e1e5ed; background: #fff; }
.oggy-chat-input { box-sizing: border-box; flex: 1 1 auto; width: auto; min-width: 0; height: 48px; min-height: 48px; max-height: 105px; margin: 0; resize: none; padding: 12px; border: 1px solid #cbd2df; border-radius: 12px; outline: 0; font: 16px/1.35 system-ui, sans-serif; }
.oggy-chat-input:focus { border-color: #536dfe; box-shadow: 0 0 0 3px rgba(83,109,254,.13); }
.oggy-chat-send { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 68px; align-self: flex-end; width: 68px; min-width: 68px; height: 48px; min-height: 48px; max-height: 48px; margin: 0 !important; padding: 0 12px; border: 0 !important; border-radius: 12px; color: #fff; background: #3f51b5; font: 800 14px/1 system-ui, sans-serif; text-transform: none; cursor: pointer; }
.oggy-chat-send:disabled { opacity: .42; cursor: default; }
.oggy-chat-disclaimer { grid-column: 1 / -1; display: block; overflow: hidden; color: #9299a8; font: 10px/13px system-ui, sans-serif; text-align: center; white-space: nowrap; text-overflow: ellipsis; }

@media (max-width: 600px) {
    html:has(body.oggy-chat-open),
    body.oggy-chat-open {
        overflow: hidden !important;
        background: #fff !important;
    }
    body.oggy-chat-open > :not(.oggy-chat-panel):not(.oggy-chat-launcher):not(script) {
        visibility: hidden !important;
    }
    body.oggy-chat-open::before {
        content: "";
        position: fixed;
        top: -200px;
        right: 0;
        bottom: -1200px;
        left: 0;
        z-index: 2147482999;
        background: #fff;
    }
    .oggy-chat-launcher { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
    .oggy-chat-panel {
        top: var(--oggy-chat-viewport-top, 0px);
        right: 0;
        bottom: auto;
        left: 0;
        width: 100vw;
        height: var(--oggy-chat-viewport-height, 100dvh);
        min-height: 0;
        max-width: none;
        max-height: none;
        border: 0;
        border-radius: 0;
        background: #fff;
        transform: translateY(100%);
        transform-origin: bottom center;
    }
    .oggy-chat-panel.is-open { transform: translateY(0); }
    .oggy-chat-head { padding-top: max(15px, env(safe-area-inset-top)); }
    .oggy-chat-bubble { max-width: 86%; }
    .oggy-chat-form {
        flex-basis: calc(91px + env(safe-area-inset-bottom));
        height: calc(91px + env(safe-area-inset-bottom));
        min-height: calc(91px + env(safe-area-inset-bottom));
        max-height: calc(91px + env(safe-area-inset-bottom));
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .oggy-chat-launcher, .oggy-chat-panel { transition-duration: .01ms; }
    .oggy-chat-typing-dot { animation: none; }
}
