.ai-container {
    max-width: 900px;
    margin: 0 auto;
    height: calc(100vh - var(--navbar-height) - 100px);
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.ai-chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
    border-radius: 20px;
}

/* ── Messages ── */

.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar {
    width: 5px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

/* ── Welcome ── */

.ai-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 20px;
    gap: 12px;
}

.ai-welcome-icon {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(139, 92, 246, .3);
    margin-bottom: 4px;
}

.ai-welcome-icon svg {
    width: 36px;
    height: 36px;
    color: #fff;
}

.ai-welcome h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.ai-welcome p {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 440px;
    line-height: 1.6;
    margin: 0;
}

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
    max-width: 520px;
}

.ai-suggestion {
    padding: 8px 16px;
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    background: rgba(255, 255, 255, .04);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}

.ai-suggestion:hover {
    border-color: rgba(139, 92, 246, .4);
    background: rgba(139, 92, 246, .08);
    color: var(--text-primary);
}

/* ── Message bubbles ── */

.ai-msg {
    display: flex;
    gap: 12px;
    max-width: 100%;
    animation: aiMsgIn .3s ease both;
}

@keyframes aiMsgIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-msg-user {
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
}

.ai-msg-user .ai-msg-avatar {
    background: linear-gradient(135deg, var(--emerald), var(--emerald-light));
    color: #fff;
}

.ai-msg-ai .ai-msg-avatar {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: #fff;
}

.ai-msg-bubble {
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.65;
    min-width: 0;
    max-width: 75%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-msg-user .ai-msg-bubble {
    background: rgba(5, 150, 105, .15);
    border: 1px solid rgba(52, 211, 153, .15);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.ai-msg-ai .ai-msg-bubble {
    background: rgba(139, 92, 246, .08);
    border: 1px solid rgba(139, 92, 246, .12);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.ai-msg-bubble p {
    margin: 0 0 8px;
}

.ai-msg-bubble p:last-child {
    margin-bottom: 0;
}

.ai-msg-bubble pre {
    background: rgba(0, 0, 0, .3);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 10px;
    padding: 14px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
    font-family: 'Space Mono', monospace;
    line-height: 1.5;
}

.ai-msg-bubble code {
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    background: rgba(255, 255, 255, .06);
    padding: 2px 6px;
    border-radius: 4px;
}

.ai-msg-bubble pre code {
    background: none;
    padding: 0;
}

.ai-msg-bubble ul,
.ai-msg-bubble ol {
    padding-left: 20px;
    margin: 8px 0;
}

.ai-msg-bubble li {
    margin-bottom: 4px;
}

.ai-msg-bubble strong {
    color: var(--text-primary);
    font-weight: 600;
}

.ai-msg-bubble h1,
.ai-msg-bubble h2,
.ai-msg-bubble h3,
.ai-msg-bubble h4 {
    margin: 12px 0 6px;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-msg-bubble h1 { font-size: 18px; }
.ai-msg-bubble h2 { font-size: 16px; }
.ai-msg-bubble h3 { font-size: 15px; }

.ai-msg-bubble blockquote {
    border-left: 3px solid rgba(139, 92, 246, .4);
    padding-left: 14px;
    margin: 8px 0;
    color: var(--text-secondary);
}

/* ── Typing indicator ── */

.ai-typing {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(139, 92, 246, .5);
    animation: typingBounce .6s ease-in-out infinite;
}

.ai-typing-dot:nth-child(2) { animation-delay: .15s; }
.ai-typing-dot:nth-child(3) { animation-delay: .3s; }

@keyframes typingBounce {
    0%, 100% { transform: translateY(0); opacity: .4; }
    50% { transform: translateY(-6px); opacity: 1; }
}

/* ── Error ── */

.ai-msg-error .ai-msg-bubble {
    background: rgba(239, 68, 68, .1);
    border-color: rgba(239, 68, 68, .2);
    color: #fca5a5;
}

/* ── Input ── */

.ai-input-area {
    padding: 16px 20px 14px;
    border-top: 1px solid var(--glass-border);
    background: rgba(10, 15, 13, .5);
}

.ai-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-input {
    flex: 1;
    resize: none;
    padding: 12px 16px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    max-height: 150px;
    overflow-y: auto;
    transition: border-color .2s;
}

.ai-input::placeholder {
    color: var(--text-muted);
}

.ai-input:focus {
    outline: none;
    border-color: rgba(139, 92, 246, .4);
    box-shadow: 0 0 16px rgba(139, 92, 246, .1);
}

.ai-send-btn {
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .25s;
    box-shadow: 0 4px 16px rgba(139, 92, 246, .3);
}

.ai-send-btn svg {
    width: 20px;
    height: 20px;
}

.ai-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(139, 92, 246, .45);
}

.ai-send-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-input-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.ai-model-select {
    padding: 4px 10px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background-color: #0f1914;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    color-scheme: dark;
    transition: border-color .2s;
}

.ai-model-select:focus {
    border-color: rgba(139, 92, 246, .4);
}

.ai-model-select option {
    background-color: #0f1914;
    color: #e2e8f0;
}

.ai-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all .2s;
}

.ai-clear-btn svg {
    width: 13px;
    height: 13px;
}

.ai-clear-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, .1);
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .ai-container {
        height: calc(100vh - 140px);
        min-height: 400px;
    }

    .ai-messages {
        padding: 16px;
    }

    .ai-msg-bubble {
        max-width: 88%;
        font-size: 14px;
    }

    .ai-welcome h2 {
        font-size: 20px;
    }

    .ai-welcome p {
        font-size: 14px;
    }

    .ai-welcome-icon {
        width: 56px;
        height: 56px;
        border-radius: 18px;
    }

    .ai-welcome-icon svg {
        width: 28px;
        height: 28px;
    }

    .ai-suggestions {
        gap: 6px;
    }

    .ai-suggestion {
        font-size: 12px;
        padding: 6px 12px;
    }

    .ai-input-area {
        padding: 12px 14px 10px;
    }

    .ai-input {
        font-size: 14px;
        padding: 10px 14px;
    }

    .ai-send-btn {
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 480px) {
    .ai-msg-avatar {
        width: 30px;
        height: 30px;
        border-radius: 10px;
        font-size: 12px;
    }

    .ai-msg {
        gap: 8px;
    }

    .ai-msg-bubble {
        padding: 10px 14px;
        border-radius: 14px;
    }
}
