#ai-chat-root {
    --aichat-dark-bg: #0e1420;
    --aichat-darker-bg: #0a0f18;
    --aichat-primary: #12213a;
    --aichat-accent: #e8b93f;
    --aichat-border: #1e2839;
    --aichat-text: #ffffff;
    --aichat-text-dim: #8a92a6;
    --z-aichat: 999999;
}

.aichat-widget {
    position: fixed;
    bottom: 80px;
    right: 80px;
    z-index: 30;
}
.aichat-widget.aichat-open { z-index: var(--z-aichat); }

.aichat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    border: 1px solid #4b5563;
    background: rgba(14, 20, 32, 0.7);
    backdrop-filter: blur(4px);
    color: var(--aichat-text);
    box-shadow: 0 10px 25px rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    cursor: pointer;
    transition: transform .15s ease, background-color .15s ease;
}
.aichat-toggle:hover { transform: scale(1.1); background-color: #2563eb; }
.aichat-toggle:active { transform: scale(0.95); }

.aichat-window {
    display: none;
    flex-direction: column;
    position: absolute;
    width: 400px;
    height: 600px;
    bottom: 64px;
    right: 0;
    border: 1px solid var(--aichat-border);
    background: rgba(14, 20, 32, 0.7);
    backdrop-filter: blur(6px);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,.4);
    overflow: hidden;
}
.aichat-open .aichat-window { display: flex; }

.aichat-header {
    position: relative;
    display: flex;
    align-items: center;
    padding: 20px;
    background: var(--aichat-primary);
    color: var(--aichat-text);
}
.aichat-close-mobile { display: none; }

.aichat-avatar, .aichat-avatar-sm {
    background: #ffffff;
    border-radius: 999px;
    overflow: hidden;
    flex-shrink: 0;
}
.aichat-avatar { width: 40px; height: 40px; margin-right: 12px; }
.aichat-avatar-sm { width: 32px; height: 32px; margin-right: 8px; }
.aichat-avatar img, .aichat-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

.aichat-title { font-weight: 600; font-size: 1rem; }
.aichat-subtitle { font-size: .75rem; opacity: .9; }

.aichat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.aichat-disclaimer {
    background: var(--aichat-darker-bg);
    color: var(--aichat-text-dim);
    font-size: .75rem;
    text-align: center;
    border-radius: 12px;
    margin: 0 0 12px;
    padding: 12px;
}

.aichat-row { display: flex; margin-bottom: 8px; }
.aichat-row-user { justify-content: flex-end; }
.aichat-row-bot { justify-content: flex-start; }

.aichat-bubble {
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 260px;
    word-wrap: break-word;
    color: var(--aichat-text);
}
.aichat-bubble-user { background: var(--aichat-primary); }
.aichat-bubble-bot { background: var(--aichat-darker-bg); }
.aichat-bubble p { margin: 0 0 6px; }
.aichat-bubble p:last-child { margin-bottom: 0; }
.aichat-bubble ul, .aichat-bubble ol { margin: 0 0 6px 18px; padding: 0; }
.aichat-bubble h2, .aichat-bubble h3, .aichat-bubble h4 { margin: 0 0 6px; font-size: 1em; font-weight: 600; }
.aichat-bubble a.aichat-link { color: var(--aichat-accent); text-decoration: underline; word-break: break-all; }
.aichat-inline-code {
    background: rgba(255,255,255,.1);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: .9em;
}
.aichat-code-block {
    background: rgba(255,255,255,.08);
    padding: 8px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: monospace;
    font-size: .85em;
    margin: 0 0 6px;
}

.aichat-time { font-size: .75rem; color: var(--aichat-text-dim); margin-top: 4px; }

.aichat-typing {
    background: var(--aichat-darker-bg);
    color: var(--aichat-text);
    padding: 16px 12px;
    border-radius: 10px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.aichat-typing span {
    width: 8px; height: 8px;
    background: var(--aichat-text);
    border-radius: 999px;
    animation: aichat-bounce .6s infinite;
}
.aichat-typing span:nth-child(2) { animation-delay: .2s; }
.aichat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aichat-bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-50%); } }

.aichat-input-wrapper {
    display: flex;
    padding: 12px;
    background: var(--aichat-primary);
    border-radius: 0 0 12px 12px;
}
.aichat-input {
    flex: 1;
    background: var(--aichat-darker-bg);
    color: var(--aichat-text);
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    margin-right: 8px;
}
.aichat-input:focus { outline: 2px solid var(--aichat-text); outline-offset: 0; }
.aichat-send {
    background: var(--aichat-accent);
    color: var(--aichat-text);
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 500;
}

@media (max-width: 640px) {
    .aichat-widget { bottom: 64px; right: 20px; }
    .aichat-open .aichat-window {
        position: fixed;
        inset: 0;
        margin: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    .aichat-header { border-radius: 12px 12px 0 0; }
    .aichat-close-mobile {
        display: block;
        position: absolute;
        top: 8px;
        right: 8px;
        background: none;
        border: none;
        color: var(--aichat-text);
        font-size: 1.75rem;
        font-weight: 700;
        cursor: pointer;
    }
}

body.aichat-body-fixed { position: fixed; width: 100%; }
