.chatpanel-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chatpanel-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatpanel-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.5);
}

.chatpanel-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 340px;
    max-height: 420px;
    min-height: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatpanel-slideUp 0.25s ease;
}

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

.chatpanel-header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 14px 16px;
    font-weight: 600;
}

.chatpanel-header h3 {
    margin: 0;
    font-size: 15px;
}

.chatpanel-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8fafc;
    min-height: 120px;
}

.chatpanel-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
}

/* Preserve definition-list newlines/indent from labschatbim (textContent, no Markdown) */
.chatpanel-message.bot {
    white-space: pre-wrap;
    word-break: break-word;
    background: #e2e8f0;
    color: #1e293b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chatpanel-message.user {
    background: #2563eb;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatpanel-error {
    padding: 8px 12px;
    font-size: 12px;
    color: #b91c1c;
    background: #fef2f2;
    border-top: 1px solid #fecaca;
}

.chatpanel-input-form {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    background: white;
}

.chatpanel-input-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.chatpanel-input-form input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.chatpanel-input-form button {
    background: #2563eb;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
}

.chatpanel-input-form button:hover:not(:disabled) {
    background: #1d4ed8;
}

.chatpanel-input-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
