#shongshoy-ai-root {
    --shai-ink: #192c29;
    --shai-muted: #51615e;
    --shai-accent: #176557;
    --shai-deep: #123e36;
    --shai-line: #d9e2df;
    --shai-wash: #f4f7f6;
    --shai-left: max(20px, env(safe-area-inset-left));
    --shai-right: max(20px, env(safe-area-inset-right));
    --shai-bottom: max(20px, env(safe-area-inset-bottom));
    position: fixed;
    right: var(--shai-right);
    bottom: var(--shai-bottom);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    color: var(--shai-ink);
    font: 400 15px/1.65 "Noto Sans Bengali", "Nirmala UI", "Bangla Sangam MN", system-ui, sans-serif;
    text-align: start;
    letter-spacing: 0;
}

#shongshoy-ai-root *, #shongshoy-ai-root *::before, #shongshoy-ai-root *::after {
    box-sizing: border-box;
}

#shongshoy-ai-root [hidden] { display: none !important; }
#shongshoy-ai-root .shai-icon { display: block; width: 22px; height: 22px; flex: none; }
#shongshoy-ai-root :is(button, a, textarea):focus-visible {
    outline: 2px solid var(--shai-accent);
    outline-offset: 3px;
}

#shongshoy-ai-root :is(.shai-launcher, .shai-close, .shai-send) {
    appearance: none;
    margin: 0;
    border: 0;
    box-shadow: none;
    text-transform: none;
    font: inherit;
    letter-spacing: 0;
    cursor: pointer;
}

#shongshoy-ai-root .shai-launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 7px 17px 7px 8px;
    border-radius: 8px;
    background: var(--shai-deep);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(18, 62, 54, .24);
    white-space: nowrap;
}

#shongshoy-ai-root .shai-launcher:hover,
#shongshoy-ai-root .shai-launcher[aria-expanded="true"] { background: var(--shai-accent); }

#shongshoy-ai-root :is(.shai-launcher-icon, .shai-header-mark, .shai-notice-mark, .shai-welcome-mark) {
    display: grid;
    flex: none;
    place-items: center;
    border-radius: 8px;
}

#shongshoy-ai-root .shai-launcher-icon {
    width: 36px;
    height: 36px;
    color: #c6f4dc;
    background: rgba(255, 255, 255, .12);
}

#shongshoy-ai-root .shai-panel {
    order: -1;
    display: flex;
    flex-direction: column;
    width: min(434px, calc(100vw - var(--shai-left) - var(--shai-right)));
    height: min(584px, calc(100vh - var(--shai-bottom) - 76px));
    height: min(584px, calc(100dvh - var(--shai-bottom) - 76px));
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--shai-line);
    border-radius: 8px;
    background: var(--shai-wash);
    box-shadow: 0 18px 54px rgba(17, 43, 36, .22), 0 3px 12px rgba(17, 43, 36, .09);
    animation: shai-panel-in .16s ease-out;
}

#shongshoy-ai-root .shai-header {
    display: flex;
    flex: none;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--shai-deep);
    color: #fff;
}

#shongshoy-ai-root .shai-header-mark {
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, .26);
    background: rgba(255, 255, 255, .08);
    color: #c6f4dc;
}

#shongshoy-ai-root .shai-heading {
    flex: 1;
    display: grid;
    gap: 3px;
    min-width: 0;
    overflow-wrap: anywhere;
}

#shongshoy-ai-root .shai-heading strong { color: #fff; font-size: 20px; line-height: 1.3; }
#shongshoy-ai-root .shai-heading span { color: #cee0db; font-size: 12px; line-height: 1.5; }

#shongshoy-ai-root .shai-close,
#shongshoy-ai-root .shai-send {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 6px;
}

#shongshoy-ai-root .shai-close { background: transparent; color: #fff; }
#shongshoy-ai-root .shai-close:hover { background: rgba(255, 255, 255, .13); }
#shongshoy-ai-root .shai-close:focus-visible { outline-color: #e5f9eb; outline-offset: -2px; }

#shongshoy-ai-root .shai-messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    min-height: 0;
    padding: 18px 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: #a8b9b3 transparent;
}

#shongshoy-ai-root .shai-messages:empty { display: none; }

#shongshoy-ai-root .shai-message {
    flex: none;
    max-width: 94%;
    padding: 11px 14px;
    border: 1px solid var(--shai-line);
    border-radius: 8px;
    background: #fff;
    color: var(--shai-ink);
    font-size: 15px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

#shongshoy-ai-root .shai-message::before {
    content: 'সংশয় AI';
    display: block;
    margin-bottom: 2px;
    color: var(--shai-accent);
    font-size: 11px;
    font-weight: 700;
}

#shongshoy-ai-root .shai-message-user {
    align-self: flex-end;
    border-color: #c6dfd3;
    background: #e1f0e8;
}

#shongshoy-ai-root .shai-message-user::before { content: 'আপনি'; }
#shongshoy-ai-root .shai-message[data-state="pending"] { color: var(--shai-muted); }
#shongshoy-ai-root .shai-message[data-state="error"] { border-color: #e8c6b9; background: #fff4ef; color: #793a27; }
#shongshoy-ai-root .shai-message[data-state="error"]::before { color: inherit; }
#shongshoy-ai-root .shai-message-welcome:not(:only-child) .shai-welcome-mark { display: none; }

#shongshoy-ai-root .shai-message-welcome:only-child {
    align-self: center;
    margin: auto;
    padding: 12px 0;
    border: 0;
    background: transparent;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
}

#shongshoy-ai-root .shai-message-welcome:only-child::before { display: none; }
#shongshoy-ai-root :is(.shai-welcome-mark, .shai-notice-mark) {
    width: 54px;
    height: 54px;
    border: 1px solid #cfe3d8;
    background: #e5f1ea;
    color: var(--shai-accent);
}

#shongshoy-ai-root .shai-welcome-mark { margin: 0 auto 15px; }
#shongshoy-ai-root :is(.shai-welcome-mark, .shai-notice-mark) .shai-icon { width: 26px; height: 26px; }

#shongshoy-ai-root .shai-notice {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    gap: 14px;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 20px;
    text-align: center;
    overflow-wrap: anywhere;
}

#shongshoy-ai-root .shai-notice-copy { max-width: 310px; }
#shongshoy-ai-root .shai-notice-title { display: block; font-size: 20px; line-height: 1.4; }
#shongshoy-ai-root .shai-notice-text { margin: 6px 0 0; color: var(--shai-muted); font: inherit; }
#shongshoy-ai-root .shai-notice[data-state="error"] .shai-notice-mark,
#shongshoy-ai-root .shai-notice[data-state="blocked"] .shai-notice-mark {
    border-color: #ebd6be;
    background: #fcf0e0;
    color: #865017;
}

#shongshoy-ai-root .shai-notice[data-state="checking"] .shai-notice-mark .shai-icon { display: none; }
#shongshoy-ai-root .shai-notice[data-state="checking"] .shai-notice-mark::after {
    content: '';
    width: 22px;
    height: 22px;
    border: 2px solid #a5c7b8;
    border-top-color: var(--shai-accent);
    border-radius: 50%;
    animation: shai-spin .75s linear infinite;
}

#shongshoy-ai-root .shai-login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 20px;
    border-radius: 6px;
    background: var(--shai-accent);
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

#shongshoy-ai-root .shai-login:hover { background: var(--shai-deep); color: #fff; }
#shongshoy-ai-root .shai-form { flex: none; margin: 0; padding: 12px 14px 0; border-top: 1px solid var(--shai-line); background: #fff; }
#shongshoy-ai-root .shai-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

#shongshoy-ai-root .shai-composer {
    border: 1px solid #bbc9c4;
    border-radius: 8px;
    background: #fff;
}

#shongshoy-ai-root .shai-composer:focus-within { border-color: var(--shai-accent); box-shadow: 0 0 0 1px var(--shai-accent); }

#shongshoy-ai-root .shai-form textarea {
    display: block;
    width: 100%;
    height: 60px;
    min-height: 60px;
    margin: 0;
    padding: 10px 11px 0;
    resize: none;
    border: 0;
    border-radius: 8px;
    box-shadow: none;
    outline: none;
    background: transparent;
    color: var(--shai-ink);
    font: inherit;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
}

#shongshoy-ai-root .shai-form textarea::placeholder { color: #596b65; opacity: 1; }
#shongshoy-ai-root .shai-form-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px 6px 11px; }
#shongshoy-ai-root .shai-form-bottom small { color: var(--shai-muted); font-size: 11px; }
#shongshoy-ai-root .shai-send { background: var(--shai-accent); color: #fff; }
#shongshoy-ai-root .shai-send:hover { background: var(--shai-deep); }
#shongshoy-ai-root .shai-send:disabled { background: #647872; cursor: wait; }

#shongshoy-ai-root .shai-footnote {
    flex: none;
    margin: 0;
    padding: 9px 12px;
    border-top: 1px solid var(--shai-line);
    background: #fff;
    color: var(--shai-muted);
    font-family: inherit;
    font-weight: 400;
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
    overflow-wrap: anywhere;
}

#shongshoy-ai-root .shai-form:not([hidden]) + .shai-footnote { border-top: 0; }

@keyframes shai-panel-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shai-spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
    #shongshoy-ai-root {
        --shai-left: max(10px, env(safe-area-inset-left));
        --shai-right: max(10px, env(safe-area-inset-right));
        --shai-bottom: max(12px, env(safe-area-inset-bottom));
        gap: 8px;
    }
    #shongshoy-ai-root .shai-panel {
        height: min(584px, calc(100vh - var(--shai-bottom) - 72px));
        height: min(584px, calc(100dvh - var(--shai-bottom) - 72px));
    }
    #shongshoy-ai-root .shai-header { gap: 9px; padding: 12px; }
    #shongshoy-ai-root .shai-header-mark { width: 38px; height: 38px; }
    #shongshoy-ai-root .shai-messages { padding: 14px 12px; }
    #shongshoy-ai-root .shai-form { padding: 10px 10px 0; }
}

@media (max-height: 440px) {
    #shongshoy-ai-root .shai-panel { overflow-y: auto; }
    #shongshoy-ai-root .shai-messages { min-height: 92px; }
    #shongshoy-ai-root .shai-notice { min-height: 184px; }
}

@media (prefers-reduced-motion: reduce) {
    #shongshoy-ai-root .shai-panel,
    #shongshoy-ai-root .shai-notice[data-state="checking"] .shai-notice-mark::after { animation: none; }
}
