#ai-chat-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: inherit;
}

#ai-chat-fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    transition: background 0.2s, transform 0.15s;
    margin-left: auto;
}

#ai-chat-fab:hover {
    background: #2563eb;
    transform: scale(1.06);
}

#ai-chat-fab.ai-chat-fab-active {
    background: #1d4ed8;
}

#ai-chat-fab svg {
    width: 24px;
    height: 24px;
}

#ai-chat-panel {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 360px;
    max-height: 520px;
    background: #1e1e2e;
    border: 1px solid #333;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    overflow: hidden;
    transition: opacity 0.2s, transform 0.2s;
}

#ai-chat-panel.ai-chat-hidden {
    display: none;
}

#ai-chat-header {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: #16162a;
    border-bottom: 1px solid #2a2a3e;
    gap: 8px;
}

#ai-chat-header span {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    color: #e2e8f0;
}

#ai-chat-header button {
    background: none;
    border: none;
    color: #888;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

#ai-chat-header button:hover {
    color: #e2e8f0;
    background: #2a2a3e;
}

#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 360px;
}

.ai-chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-msg-user {
    background: #3b82f6;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}

.ai-chat-msg-assistant {
    background: #2a2a3e;
    color: #e2e8f0;
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}

.ai-chat-thinking::after {
    content: '●●●';
    animation: ai-chat-blink 1.2s infinite;
    font-size: 0.6rem;
    letter-spacing: 2px;
    vertical-align: middle;
}

@keyframes ai-chat-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

#ai-chat-input-row {
    display: flex;
    align-items: flex-end;
    padding: 10px 12px;
    border-top: 1px solid #2a2a3e;
    gap: 8px;
    background: #16162a;
}

#ai-chat-input {
    flex: 1;
    background: #1e1e2e;
    border: 1px solid #3a3a4e;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.875rem;
    padding: 8px 10px;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.15s;
}

#ai-chat-input:focus {
    border-color: #3b82f6;
}

#ai-chat-input::placeholder {
    color: #555;
}

#ai-chat-input:disabled {
    opacity: 0.5;
}

#ai-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #3b82f6;
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

#ai-chat-send:hover {
    background: #2563eb;
}

#ai-chat-send:disabled {
    background: #334;
    cursor: default;
}

#ai-chat-send svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 480px) {
    #ai-chat-panel {
        width: calc(100vw - 32px);
        right: 0;
    }
}
