#chatbot-widget {
    display: flex;
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 3000;
    align-items: flex-end;
    flex-direction: column;
    font-family: Inter, system-ui, -apple-system, sans-serif;
}

#chatbot-toggle {
    display: inline-flex;
    width: 3.5rem;
    height: 3.5rem;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: #121c27;
    color: #fff;
    box-shadow: 0 16px 35px rgba(15, 23, 42, 0.24);
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
    align-self: flex-end;
    margin-left: auto;
    flex: 0 0 auto;
    position: relative;
    z-index: 3001;
}

#chatbot-toggle:hover,
#chatbot-toggle:focus-visible {
    background: #1a2840;
    transform: translateY(-1px);
}

#chatbot-panel {
    display: flex;
    width: min(23rem, calc(100vw - 2rem));
    height: min(32rem, calc(100vh - 4rem));
    min-height: 32rem;
    margin-bottom: 0.75rem;
    flex-direction: column;
    flex: 0 0 auto;
    overflow: hidden;
    border: 0;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
    position: relative;
    z-index: 3001;
}

#chatbot-panel[hidden] {
    display: none;
}

.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: #121c27;
    color: #fff;
}

.chatbot-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.chatbot-ai-icon {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    flex: 0 0 1rem;
    background: currentColor;
    -webkit-mask: url("/static/chatbot/ai-solid.c2bf8ee835dd.svg") center / contain no-repeat;
    mask: url("/static/chatbot/ai-solid.c2bf8ee835dd.svg") center / contain no-repeat;
}

.chatbot-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
}

.chatbot-icon-button {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
}

.chatbot-icon-button:hover,
.chatbot-icon-button:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

#chatbot-messages {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.chatbot-message {
    max-width: 92%;
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.84rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.chatbot-message--user {
    white-space: pre-wrap;
}

.chatbot-message-content > :first-child {
    margin-top: 0;
}

.chatbot-message-content > :last-child {
    margin-bottom: 0;
}

.chatbot-message-content p,
.chatbot-message-content ol,
.chatbot-message-content ul,
.chatbot-message-content blockquote,
.chatbot-message-content pre {
    margin: 0 0 0.6rem;
}

.chatbot-message-content ol,
.chatbot-message-content ul {
    padding-left: 1.25rem;
}

.chatbot-message-content a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chatbot-message-content code {
    padding: 0.1rem 0.25rem;
    border-radius: 0.25rem;
    background: rgba(15, 23, 42, 0.08);
    font-size: 0.9em;
}

.chatbot-message-content pre {
    padding: 0.6rem;
    overflow-x: auto;
    border-radius: 0.45rem;
    background: rgba(15, 23, 42, 0.08);
}

.chatbot-message-content pre code {
    padding: 0;
    background: transparent;
}

.chatbot-thinking {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    color: #64748b;
}

.chatbot-thinking-label {
    margin-right: 0.15rem;
}

.chatbot-thinking-dot {
    width: 0.32rem;
    height: 0.32rem;
    border-radius: 50%;
    background: currentColor;
    animation: chatbot-thinking 1.1s infinite ease-in-out;
}

.chatbot-thinking-dot:nth-child(2) {
    animation-delay: 0.14s;
}

.chatbot-thinking-dot:nth-child(3) {
    animation-delay: 0.28s;
}

@keyframes chatbot-thinking {
    0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-0.16rem); }
}

.chatbot-message:last-child {
    margin-bottom: 0;
}

.chatbot-message--assistant {
    background: #f1f5f9;
    color: #334155;
}

.chatbot-message--user {
    margin-left: auto;
    background: #121c27;
    color: #fff;
}

.chatbot-sources {
    margin-top: 0.65rem;
    padding-top: 0.55rem;
    border-top: 1px solid #cbd5e1;
    font-size: 0.72rem;
}

.chatbot-sources-label {
    margin: 0 0 0.25rem;
    color: #64748b;
    font-weight: 700;
}

.chatbot-source-link {
    display: block;
    color: #121c27;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chatbot-form {
    padding: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.chatbot-input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

#chatbot-input {
    min-height: 2.5rem;
    max-height: 8rem;
    flex: 1;
    resize: vertical;
    padding: 0.6rem 0.7rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.7rem;
    color: #0f172a;
    font: inherit;
    font-size: 0.84rem;
}

#chatbot-input:focus {
    border-color: #121c27;
    outline: 2px solid rgba(18, 28, 39, 0.15);
    outline-offset: 1px;
}

#chatbot-submit {
    display: inline-flex;
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.7rem;
    background: #121c27;
    color: #fff;
    cursor: pointer;
}

#chatbot-submit:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

@media (max-width: 640px) {
    #chatbot-widget {
        right: 0.75rem;
        bottom: 0.75rem;
    }

    #chatbot-panel {
        width: min(23rem, calc(100vw - 1.5rem));
        height: min(32rem, calc(100vh - 4rem));
        min-height: min(32rem, calc(100vh - 5rem));
    }
}
