#scdev-ai-bubble {
    position: fixed;
    bottom: 14px;
    left: 12px;
    width: 30px;
    height: 30px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.2s;
}
#scdev-ai-bubble:hover {
    transform: scale(1.15);
}
#scdev-ai-bubble .bubble-icon {
    font-size: 32px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Float window */
#scdev-ai-float-window {
    position: fixed;
    bottom: 90px;
    left: 24px;
    width: 560px;
    height: 500px;
    z-index: 9998;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

/* Chat window */
.scdev-ai-window {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.scdev-ai-inline {
    width: 100%;
}

/* Chat container */
.scdev-ai-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.scdev-ai-header {
    background: #3b82f6;
    color: white;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.scdev-ai-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}
.scdev-ai-close:hover { opacity: 1; }

/* Messages */
.scdev-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
    scrollbar-width: thin;
    scrollbar-color: #f59e0b transparent;
}
.scdev-ai-messages::-webkit-scrollbar { width: 4px; }
.scdev-ai-messages::-webkit-scrollbar-track { background: transparent; }
.scdev-ai-messages::-webkit-scrollbar-thumb { background: #f59e0b; border-radius: 4px; }

.scdev-ai-msg {
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}
.scdev-ai-msg.user {
    background: #3b82f6;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.scdev-ai-msg.ai {
    background: white;
    color: #111;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e7eb;
}
.scdev-ai-msg.error {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}
.scdev-ai-msg code {
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 13px;
    color: #374151;
}

/* Thinking dots */
.scdev-ai-msg.thinking {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 14px;
}
.scdev-ai-msg.thinking span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: scdev-bounce 1.2s infinite;
}
.scdev-ai-msg.thinking span:nth-child(2) { animation-delay: 0.2s; }
.scdev-ai-msg.thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes scdev-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* Input area */
.scdev-ai-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
}
.scdev-ai-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.2s;
    scrollbar-width: thin;
    scrollbar-color: #f59e0b transparent;
}
.scdev-ai-input::-webkit-scrollbar { width: 4px; }
.scdev-ai-input::-webkit-scrollbar-track { background: transparent; }
.scdev-ai-input::-webkit-scrollbar-thumb { background: #f59e0b; border-radius: 4px; }
.scdev-ai-input:focus {
    border-color: #3b82f6;
}
.scdev-ai-send {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    align-self: flex-end;
}
.scdev-ai-send:hover { background: #2563eb; }

/* Page list from load: command */
.scdev-ai-page-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.scdev-ai-page-link {
    display: block;
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    color: #3b82f6;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s;
}
.scdev-ai-page-link:hover {
    background: #e0e7ff;
    color: #2563eb;
}
body.night-mode .scdev-ai-page-link,
body.dark-mode .scdev-ai-page-link {
    background: #2d2d44;
    color: #a5b4fc;
}
body.night-mode .scdev-ai-page-link:hover,
body.dark-mode .scdev-ai-page-link:hover {
    background: #3d3d5c;
}

/* Dark mode - picks up theme's night-mode class */
body.night-mode .scdev-ai-window,
body.dark-mode .scdev-ai-window {
    background: #1a1a2e;
    border-color: #2d2d44;
}
body.night-mode .scdev-ai-messages,
body.dark-mode .scdev-ai-messages {
    background: #12121f;
}
body.night-mode .scdev-ai-msg.ai,
body.dark-mode .scdev-ai-msg.ai {
    background: #1e1e35;
    color: #e0e0e0;
    border-color: #2d2d44;
}
body.night-mode .scdev-ai-msg.user,
body.dark-mode .scdev-ai-msg.user {
    background: #2563eb;
}
body.night-mode .scdev-ai-input-area,
body.dark-mode .scdev-ai-input-area {
    background: #1a1a2e;
    border-color: #2d2d44;
}
body.night-mode .scdev-ai-input,
body.dark-mode .scdev-ai-input {
    background: #12121f;
    border-color: #2d2d44;
    color: #e0e0e0;
}
body.night-mode .scdev-ai-input::placeholder,
body.dark-mode .scdev-ai-input::placeholder {
    color: #6b7280;
}
body.night-mode .scdev-ai-msg code,
body.dark-mode .scdev-ai-msg code {
    background: #0f0f1a;
    color: #a5b4fc;
}

/* Responsive */
@media (max-width: 768px) {
    #scdev-ai-float-window {
        width: calc(100vw - 20px);
        height: 85vh;
        left: 10px;
        bottom: 80px;
    }
}

@media (max-width: 480px) {
    #scdev-ai-float-window {
        width: calc(100vw - 16px);
        height: 75vh;
        left: 8px;
        bottom: 75px;
    }
    .scdev-ai-msg {
        max-width: 90%;
    }
}
