.chatbot-panel {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    width: 420px;
    height: min(38rem, 80vh);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.25);
    z-index: 1050;
    overflow: hidden;
}

.chatbot-panel--fullscreen {
    top: 0.75rem !important;
    right: 0.75rem !important;
    bottom: 0.75rem !important;
    left: auto !important;
    width: min(760px, calc(100vw - 1.5rem)) !important;
    height: auto !important;
}

/* Frei verschoben: Position kommt aus left/top (Chatbot.js) */
.chatbot-panel--floating {
    right: auto;
    bottom: auto;
}

.chatbot-panel--dragging {
    user-select: none;
}

/* Im eigenen Fenster (Document Picture-in-Picture) füllt das Panel das Fenster */
.chatbot-panel--pip {
    position: static;
    width: 100% !important;
    height: 100vh !important;
    border-radius: 0;
    box-shadow: none;
}

.chatbot-panel--pip .chatbot-panel__header,
.chatbot-panel--fullscreen .chatbot-panel__header {
    cursor: default;
}

.chatbot-panel--pip .chatbot-panel__grip,
.chatbot-panel--pip .chatbot-panel__fullscreen,
.chatbot-panel--fullscreen .chatbot-panel__grip {
    display: none;
}

body.chatbot-pip-body {
    margin: 0;
    background: #fff;
}

.chatbot-panel__header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0.75rem 0.7rem 1rem;
    background: linear-gradient(135deg, #212529 0%, #2b3a55 100%);
    color: #fff;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.chatbot-panel--dragging .chatbot-panel__header {
    cursor: grabbing;
}

.chatbot-panel__avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.chatbot-panel__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.chatbot-panel__status {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #212529;
}

.chatbot-panel__heading {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    line-height: 1.25;
}

.chatbot-panel__title {
    font-weight: 600;
}

.chatbot-panel__subtitle {
    font-size: 0.75rem;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-panel__grip {
    position: absolute;
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    touch-action: none;
    z-index: 2;
}

.chatbot-panel__grip::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 7px;
    height: 7px;
    border-top: 2px solid rgba(255, 255, 255, 0.35);
    border-left: 2px solid rgba(255, 255, 255, 0.35);
    border-top-left-radius: 3px;
}

/* --- Begrüßung mit Einstiegen --- */
.chatbot-welcome__hello {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2b3a55;
}

.chatbot-welcome__intro,
.chatbot-welcome__hint {
    font-size: 0.85rem;
    color: var(--lr-muted, #4b5262);
    margin: 0.25rem 0 0.75rem;
}

.chatbot-welcome__hint {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
}

.chatbot-welcome__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
}

.chatbot-capability {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    text-align: left;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: #212529;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.chatbot-capability:hover,
.chatbot-capability:focus-visible {
    border-color: #0d6efd;
    background: #eef4ff;
    transform: translateY(-1px);
    outline: none;
}

.chatbot-capability i {
    color: #0d6efd;
    font-size: 1rem;
    margin-bottom: 0.15rem;
}

.chatbot-capability strong {
    font-size: 0.82rem;
}

.chatbot-capability span {
    font-size: 0.72rem;
    color: var(--lr-muted, #4b5262);
    line-height: 1.3;
}

.chatbot-panel__actions {
    display: flex;
    gap: 0.25rem;
}

.chatbot-panel__actions button {
    background: none;
    border: none;
    color: #fff;
    opacity: 0.8;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.4rem;
}

.chatbot-panel__actions button[hidden] {
    display: none;
}

.chatbot-panel__actions button:hover,
.chatbot-panel__actions button:focus-visible {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.chatbot-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chatbot-message {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.9rem;
}

.chatbot-message--user {
    align-self: flex-end;
    background: #0d6efd;
    color: #fff;
}

.chatbot-message--assistant {
    align-self: flex-start;
    background: #f1f3f5;
    color: #212529;
}

.chatbot-message--assistant p {
    margin: 0 0 0.5rem;
}

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

.chatbot-message--assistant h1,
.chatbot-message--assistant h2,
.chatbot-message--assistant h3,
.chatbot-message--assistant h4,
.chatbot-message--assistant h5,
.chatbot-message--assistant h6 {
    margin: 0.75rem 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.chatbot-message--assistant h1:first-child,
.chatbot-message--assistant h2:first-child,
.chatbot-message--assistant h3:first-child {
    margin-top: 0;
}

.chatbot-message--assistant ul,
.chatbot-message--assistant ol {
    margin: 0 0 0.5rem;
    padding-left: 1.25rem;
}

.chatbot-message--assistant code {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 0.25rem;
    padding: 0.1rem 0.3rem;
    font-size: 0.85em;
}

.chatbot-message--assistant pre {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
    margin: 0 0 0.5rem;
}

.chatbot-message--assistant pre code {
    background: none;
    padding: 0;
}

.chatbot-message--assistant a {
    color: #0d6efd;
    text-decoration: underline;
}

.chatbot-message--assistant table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    border-collapse: collapse;
    margin: 0 0 0.5rem;
    font-size: 0.85em;
    white-space: normal;
}

.chatbot-message--assistant th,
.chatbot-message--assistant td {
    border: 1px solid rgba(0, 0, 0, 0.15);
    padding: 0.35rem 0.6rem;
    text-align: left;
    vertical-align: top;
}

.chatbot-message--assistant thead th {
    background: rgba(0, 0, 0, 0.06);
    font-weight: 600;
}

.chatbot-message--assistant tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
}

.chatbot-panel__form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid #e9ecef;
}

.chatbot-panel__input {
    flex: 1;
    resize: none;
    border: 1px solid #ced4da;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    max-height: 8rem;
    overflow-y: auto;
}

.chatbot-panel__send {
    background: #0d6efd;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0 0.9rem;
}

.chatbot-panel__mic {
    background: #f1f3f5;
    color: #212529;
    border: none;
    border-radius: 0.5rem;
    padding: 0 0.9rem;
}

.chatbot-panel__mic--recording {
    background: #dc3545;
    color: #fff;
    animation: chatbot-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes chatbot-mic-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.chatbot-message--pending {
    opacity: 0.6;
    font-style: italic;
}

.chatbot-message--typing {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.65rem 0.9rem;
}

.chatbot-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #868e96;
    opacity: 0.4;
    animation: chatbot-typing-bounce 1s infinite;
}

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

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

@keyframes chatbot-typing-bounce {
    0%, 80%, 100% {
        opacity: 0.4;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (max-width: 576px) {
    /* Auf dem Handy immer bildschirmfüllend, ohne Verschieben */
    .chatbot-panel,
    .chatbot-panel--floating,
    .chatbot-panel--fullscreen {
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        top: 0 !important;
        width: auto !important;
        height: auto !important;
        border-radius: 0;
    }

    .chatbot-panel__grip,
    .chatbot-panel__fullscreen,
    .chatbot-panel__popout {
        display: none !important;
    }

    .chatbot-panel__header {
        cursor: default;
    }
}

/* Diagramme in Antworten (```chart, gezeichnet von HkjCharts.js) */
.chatbot-message--assistant:has(.chatbot-chart) {
    width: 85%;
}

.chatbot-chart {
    width: 100%;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: #fff;
    border-radius: 0.5rem;
    white-space: normal;
}
