#aiChatWidget{
    --aiw-accent:#F1346A;
    --aiw-accent-dark:#db1e53;
    --aiw-accent-darker:#d00942;
    --aiw-orange-1:#3079E8;
    --aiw-orange-2:#1a65d5;
    --aiw-muted:#0b1220;
    --aiw-border:#e6e9ee;
    --aiw-gap:max(12px, env(safe-area-inset-right));
    --aiw-bottom:max(12px, env(safe-area-inset-bottom));
    position:fixed;
    right:var(--aiw-gap);
    bottom:var(--aiw-bottom);
    z-index:9999;
    font-family:Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-sizing:border-box;
}
#aiChatWidget *, #aiChatWidget *::before, #aiChatWidget *::after{box-sizing:border-box;}
.aiw-bubble a{
    color: var(--aiw-accent);
    text-decoration: underline;
    word-break: break-word;
}
.aiw-bubble a:hover{
    opacity: 0.9;
    text-decoration: none;
}
.aiw-bubble ul, .aiw-bubble ol{
    margin:8px 0 0;
    padding-left:1.2em;
    white-space:normal;
}
.aiw-bubble li{margin:0 0 4px;}

.aiw-toggle{
    position:relative;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:72px;
    height:72px;
    border-radius:50%;
    border:none;
    cursor:pointer;
    box-shadow:0 14px 36px rgba(241,52,106,0.28), inset 0 -6px 18px rgba(255,255,255,0.05);
    outline:none;
    background:linear-gradient(90deg,var(--aiw-accent) 0%,var(--aiw-accent-dark) 50%,var(--aiw-accent-darker) 100%);
    transition:transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.aiw-toggle img{width:44px;height:44px;}
.aiw-toggle:focus{box-shadow:0 0 0 4px rgba(241,52,106,0.22);}
.aiw-toggle:hover{transform:scale(1.04);box-shadow:0 18px 42px rgba(241,52,106,0.34);}
.aiw-toggle.aiw-open{opacity:0;pointer-events:none;transform:scale(.9);}

.aiw-quick{
    flex:0 0 auto;
    display:flex;
    flex-direction:column;
    gap:10px;
    padding:12px 14px;
    border-top:1px solid rgba(16,24,40,0.06);
    background:#f7f8fa;
}
.aiw-quick-grid{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:8px;
    width:100%;
}
.aiw-donate{
    width:100%;
    min-height:48px;
    padding:14px 16px;
    border-radius:12px;
    border:none;
    cursor:pointer;
    background:linear-gradient(90deg, var(--aiw-orange-1), var(--aiw-orange-2));
    color:#fff;
    font-size:16px;
    font-weight:600;
    text-align:center;
    box-shadow:0 10px 28px rgba(48,121,232,0.16);
    appearance:none;
    -webkit-appearance:none;
    margin:0;
}
.aiw-donate:hover{box-shadow:0 14px 32px rgba(48,121,232,0.22);}
.aiw-quick-question{
    width:100%;
    min-width:0;
    min-height:44px;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:12px 10px;
    border-radius:12px;
    border:1px solid var(--aiw-border);
    background:#fff;
    color:var(--aiw-muted);
    text-align:center;
    font-size:14px;
    line-height:1.25;
    cursor:pointer;
    appearance:none;
    -webkit-appearance:none;
    margin:0;
    white-space:normal;
}
.aiw-quick-question:hover{
    background:linear-gradient(90deg,var(--aiw-orange-1),var(--aiw-orange-2));
    color:#fff;
    border-color:transparent;
}

.aiw-modal{
    width:min(440px, 100vw);
    height:100dvh;
    max-height:100dvh;
    position:fixed;
    right:0;
    bottom:0;
    top:0;
    display:flex;
    flex-direction:column;
    border-radius:18px 0 0 18px;
    overflow:hidden;
    background:#ffffff;
    color:var(--aiw-muted);
    box-shadow:0 20px 50px rgba(2,6,23,0.12),0 2px 8px rgba(0,0,0,0.12);
    transform-origin:100% 100%;
    transform:translateY(18px) scale(.96);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transition:opacity .28s ease, transform .28s cubic-bezier(.22,1,.36,1), visibility 0s linear .28s;
}
.aiw-modal.aiw-show{
    opacity:1;
    visibility:visible;
    pointer-events:auto;
    transform:translateY(0) scale(1);
    transition:opacity .28s ease, transform .28s cubic-bezier(.22,1,.36,1), visibility 0s;
}

.aiw-header{
    flex:0 0 auto;
    padding:16px 18px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    background:linear-gradient(90deg,var(--aiw-accent) 0%,var(--aiw-accent-dark) 50%,var(--aiw-accent-darker) 100%);
    color:#fff;
    border-bottom:1px solid rgba(0,0,0,0.06);
}
.aiw-title{font-weight:600;font-size:18px;line-height:1.2;margin:0;color:#fff;}
.aiw-close{
    background:transparent;
    border:none;
    color:#fff;
    width:44px;
    height:44px;
    padding:0;
    border-radius:10px;
    cursor:pointer;
    display:inline-flex;
    align-items:center;
    justify-content:center;
}
.aiw-close:hover{background:rgba(255,255,255,0.12);}
.aiw-close-icon{width:22px;height:22px;stroke:white;}

.aiw-messages{
    flex:1 1 auto;
    min-height:120px;
    padding:16px;
    overflow-y:auto;
    overscroll-behavior:contain;
    display:flex;
    flex-direction:column;
    gap:12px;
    background:#ffffff;
}
.aiw-messages::-webkit-scrollbar{width:8px}
.aiw-messages::-webkit-scrollbar-thumb{background:rgba(0,0,0,0.06);border-radius:99px}
.aiw-empty{text-align:center;color:#6b7280;font-size:15px;padding:8px 0}

.aiw-msg{display:flex;width:100%}
.aiw-msg.aiw-user{justify-content:flex-end}
.aiw-msg.aiw-bot{justify-content:flex-start}
.aiw-bubble{
    max-width:86%;
    padding:12px 14px;
    border-radius:12px;
    line-height:1.45;
    white-space:pre-wrap;
    overflow-wrap:anywhere;
    word-break:break-word;
    font-size:15px;
    box-shadow:0 6px 18px rgba(10,14,20,0.04);
}
.aiw-bubble.aiw-user{background:linear-gradient(180deg,var(--aiw-accent),var(--aiw-accent-dark));color:#fff;border-bottom-right-radius:4px}
.aiw-bubble.aiw-bot{background:#f8fafc;color:var(--aiw-muted);border:1px solid rgba(15,23,42,0.04);border-bottom-left-radius:4px}

.aiw-loading-bubble{display:inline-flex;align-items:center;padding:12px 14px;border-radius:12px;background:#f8fafc;border:1px solid rgba(15,23,42,0.04);color:#6b7280;font-size:15px;}

.aiw-input-wrap{
    flex:0 0 auto;
    padding:12px 14px calc(12px + env(safe-area-inset-bottom));
    border-top:1px solid rgba(16,24,40,0.06);
    background:#fff;
}
.aiw-cooldown{margin:0 0 10px;}
.aiw-cooldown-bar{height:6px;border-radius:99px;background:#eceff3;overflow:hidden;}
.aiw-cooldown-fill{height:100%;width:100%;border-radius:99px;background:linear-gradient(90deg,var(--aiw-accent),var(--aiw-accent-dark));transform-origin:left center;transform:scaleX(1);}
.aiw-input:disabled,.aiw-send:disabled,.aiw-quick-question:disabled,.aiw-donate:disabled{opacity:.55;cursor:not-allowed;}
.aiw-cooldown-label{margin-top:6px;font-size:13px;color:#6b7280;text-align:center;}
.aiw-form{display:flex;gap:10px;align-items:center}
.aiw-input{
    flex:1;
    min-height:48px;
    padding:12px 14px;
    border-radius:12px;
    border:1px solid var(--aiw-border);
    background:#fff;
    color:var(--aiw-muted);
    font-size:16px;
    outline:none;
}
.aiw-input:focus{box-shadow:0 0 0 3px rgba(241,52,106,0.14);border-color:var(--aiw-accent)}

.aiw-send{
    flex:0 0 48px;
    width:48px;
    height:48px;
    background:linear-gradient(180deg,var(--aiw-accent),var(--aiw-accent-dark));
    border:none;
    border-radius:12px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
}
.aiw-send:hover{background:linear-gradient(90deg,var(--aiw-orange-1),var(--aiw-orange-2));}
.aiw-send-icon{width:22px;height:22px;color:#fff;stroke:white}

@media (max-width:720px){
    .aiw-modal{
        width:100vw;
        height:100dvh;
        max-height:100dvh;
        right:0;
        left:0;
        top:0;
        bottom:0;
        border-radius:0;
        transform-origin:50% 100%;
    }
    .aiw-toggle{width:64px;height:64px;}
    .aiw-toggle img{width:40px;height:40px;}
}
@media (max-width:480px){
    .aiw-title{font-size:17px;}
    .aiw-quick-question{min-height:48px;font-size:15px;}
}
@media (prefers-reduced-motion:reduce){
    .aiw-modal,.aiw-toggle{transition:none;}
}
