#ai-popup-btn {
    position: fixed;
    bottom: 20px;
    width: 100px; height: 100px;
    border-radius: 50%; border: none;
    cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.25);
    display: flex; align-items: center; justify-content: center;
    padding: 0; z-index: 9999;
    background: transparent;
}
body:not(.rtl) #ai-popup-btn { right: 85px; left: unset; }
body.rtl #ai-popup-btn { left: 85px; right: unset; }
#ai-popup-btn img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

.ai-popup {
    position: fixed;
    width: 380px; height: 400px;
    background: #fff; border-radius: 16px; border: 1px solid #ddd;
    box-shadow: 0 8px 20px rgba(0,0,0,.15);
    display: none; flex-direction: column; overflow: hidden;
    z-index: 10000; font-family: "Inter", sans-serif;
}
.ai-popup-header {
    padding: 10px; background: #f0f0f0; border-bottom: 1px solid #ddd;
    display: flex; justify-content: space-between; align-items: center;
    cursor: move; user-select: none; flex-shrink: 0;
}
.ai-header-icon { width:36px; height:36px; border-radius:50%; }
.ai-avatar-name { font-weight: bold; font-size:16px; color:#333; }
.ai-close-btn { background: transparent; border:none; font-size:28px; cursor:pointer; color:#333; line-height:1; padding:0; display:none; }

.ai-response {
    flex: 1; min-height: 0; padding:15px; overflow-y:auto;
    display:flex; flex-direction: column-reverse;
}
.ai-msg, .user-msg {
    padding:10px 14px; border-radius:12px; margin-bottom:10px; max-width:90%; line-height:1.5;
}
.ai-msg { background:#eef2ff; align-self:flex-start; }
.user-msg { background:#e9f7ef; align-self:flex-end; }

.ai-input-area {
    display:flex; align-items:center; gap:8px;
    padding:10px; border-top:1px solid #ddd; background:#fafafa; flex-shrink:0;
}
#ai-input { flex:1; border:1px solid #ccc; border-radius:8px; padding:8px 10px; font-size:14px; }
#voice-btn,#send-btn,#stop-audio-btn {
    width:38px; height:38px; border-radius:50%; border:none; background:#6366f1; color:#fff; cursor:pointer;
}
#voice-btn.recording { background:#dc2626; animation:pulse 1.5s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(220,38,38,.4);}70%{box-shadow:0 0 0 10px rgba(220,38,38,0);}100%{box-shadow:0 0 0 0 rgba(220,38,38,0);} }

/* RTL rotate send button */
body.rtl #send-btn { transform: rotate(180deg); }

/* MOBILE BOTTOM SHEET */
@media (max-width:768px){
    .ai-popup { width:100vw !important; height:55vh !important; left:0 !important; right:0 !important; bottom:0 !important; top:auto !important; border-radius:16px 16px 0 0; }
    .ai-popup-header { cursor:default; }
    .ai-close-btn { display:block; }
}