.mbai-chat {
    max-width: 760px;
    border: 1px solid #dcdcde;
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
    font-family: inherit;
}
.mbai-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid #eee;
}
.mbai-chat__header strong,
.mbai-chat__header span { display: block; }
.mbai-chat__header > div:first-child > span { font-size: 12px; opacity: .7; margin-top: 2px; }
.mbai-chat__header-actions { display: flex; align-items: center; gap: 10px; }
.mbai-chat__status { font-size: 12px; opacity: .65; }
.mbai-chat__reset { border: 0; background: transparent; padding: 4px 6px; cursor: pointer; font: inherit; font-size: 12px; opacity: .65; }
.mbai-chat__reset:hover { opacity: 1; text-decoration: underline; }
.mbai-chat__messages {
    min-height: 180px;
    max-height: 520px;
    overflow-y: auto;
    padding: 18px;
    background: #fafafa;
}
.mbai-message {
    max-width: 82%;
    padding: 12px 14px;
    border-radius: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin-bottom: 10px;
}
.mbai-message--assistant { background: #fff; border: 1px solid #e4e4e4; }
.mbai-message--user { margin-left: auto; background: #1d2327; color: #fff; }
.mbai-message:last-child { margin-bottom: 0; }
.mbai-message-wrap { margin-bottom: 10px; }
.mbai-message-wrap--user { display: flex; justify-content: flex-end; }
.mbai-message-wrap--assistant { display: block; }
.mbai-message-wrap .mbai-message { margin-bottom: 0; }
.mbai-chat__form { padding: 14px; }
.mbai-chat__input-row { display: flex; gap: 8px; align-items: flex-end; }
.mbai-chat textarea { flex: 1; min-height: 48px; resize: vertical; border: 1px solid #c8c8c8; border-radius: 10px; padding: 10px 12px; font: inherit; }
.mbai-btn { border: 0; border-radius: 10px; min-height: 44px; padding: 0 14px; cursor: pointer; font: inherit; }
.mbai-btn--mic { min-width: 46px; background: #f1f1f1; transition: transform .15s ease, box-shadow .15s ease; }
.mbai-btn--mic.is-recording { background: #f6d4d4; transform: scale(1.03); box-shadow: 0 0 0 3px rgba(180,0,0,.08); }
.mbai-btn--send { background: #1d2327; color: #fff; }
.mbai-btn:disabled { cursor: not-allowed; opacity: .45; }
.mbai-chat__notice { min-height: 20px; margin-top: 8px; font-size: 12px; opacity: .75; }
@media (max-width: 640px) {
    .mbai-chat { border-radius: 12px; }
    .mbai-chat__input-row { flex-wrap: wrap; }
    .mbai-chat textarea { flex-basis: 100%; }
    .mbai-btn--send { flex: 1; }
    .mbai-chat__header { align-items: flex-start; }
    .mbai-chat__header-actions { flex-direction: column-reverse; align-items: flex-end; gap: 2px; }
}

/* 0.8.1: klare Statusführung für Spracheingabe */
.mbai-btn--mic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    white-space: nowrap;
}
.mbai-mic__icon { font-size: 16px; line-height: 1; }
.mbai-mic__label { font-size: 13px; }
.mbai-btn--mic.is-recording {
    background: #b42318;
    color: #fff;
    min-width: 154px;
    box-shadow: 0 0 0 4px rgba(180,35,24,.12);
}
.mbai-voice-status {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    margin-top: 10px;
    padding: 8px 11px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fafafa;
    font-size: 13px;
    line-height: 1.35;
}
.mbai-voice-status[hidden] { display: none !important; }
.mbai-voice-status__dot {
    display: none;
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: #b42318;
}
.mbai-voice-status.is-recording .mbai-voice-status__dot {
    display: block;
    animation: mbai-recording-pulse 1.1s ease-in-out infinite;
}
.mbai-voice-status__spinner {
    display: none;
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    border: 2px solid rgba(29,35,39,.2);
    border-top-color: #1d2327;
    border-radius: 50%;
}
.mbai-voice-status.is-starting .mbai-voice-status__spinner,
.mbai-voice-status.is-processing .mbai-voice-status__spinner {
    display: block;
    animation: mbai-spin .8s linear infinite;
}
.mbai-voice-status.is-error { border-color: #e7b8b4; background: #fff7f6; }
.mbai-voice-status.is-success { border-color: #b8d7c0; background: #f6fbf7; }
.mbai-voice-status__text { flex: 1; }
.mbai-voice-status__timer {
    margin-left: auto;
    min-width: 42px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
@keyframes mbai-recording-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .35; transform: scale(.82); }
}
@keyframes mbai-spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
    .mbai-btn--mic { flex: 1; }
    .mbai-btn--mic.is-recording { min-width: 0; }
    .mbai-voice-status { align-items: flex-start; }
}


/* 0.8.3: Mobile Pull-to-Refresh für die Major-Bud-Seite */
html,
body {
    overscroll-behavior-y: auto !important;
}
.mbai-chat,
.mbai-chat__messages {
    touch-action: pan-y;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
}
.mbai-pull-refresh {
    height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    background: #f6f7f7;
    color: #50575e;
    font-size: 13px;
    line-height: 1.2;
    opacity: 0;
    transition: height .16s ease, opacity .16s ease;
    will-change: height, opacity;
}
.mbai-pull-refresh.is-visible {
    opacity: 1;
}
.mbai-pull-refresh.is-ready {
    color: #1d2327;
    font-weight: 600;
}
.mbai-pull-refresh.is-refreshing {
    height: 46px !important;
    opacity: 1;
}
.mbai-pull-refresh__icon {
    font-size: 18px;
    line-height: 1;
    transition: transform .16s ease;
}
.mbai-pull-refresh.is-ready .mbai-pull-refresh__icon {
    transform: rotate(180deg);
}
.mbai-pull-refresh__spinner {
    display: none;
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    border: 2px solid rgba(29,35,39,.2);
    border-top-color: #1d2327;
    border-radius: 50%;
}
.mbai-pull-refresh.is-refreshing .mbai-pull-refresh__spinner {
    display: inline-block;
    animation: mbai-spin .8s linear infinite;
}
.mbai-pull-refresh.is-refreshing .mbai-pull-refresh__icon {
    display: none;
}
@media (hover: hover) and (pointer: fine) {
    .mbai-pull-refresh { display: none; }
}

.mbai-chat__status.is-offline { opacity: .75; }

/* 1.1.0: Sprachausgabe für Major-Bud-Antworten */
.mbai-message-actions {
    margin-top: 5px;
    padding-left: 4px;
}
.mbai-speak-button {
    border: 0;
    background: transparent;
    padding: 3px 5px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    opacity: .68;
}
.mbai-speak-button:hover,
.mbai-speak-button:focus { opacity: 1; text-decoration: underline; }
.mbai-speak-button.is-playing { opacity: 1; font-weight: 600; }
.mbai-speak-button.is-loading { cursor: wait; }
.mbai-speak-button:disabled { opacity: .5; cursor: wait; }

/* 1.2.0: persönlicher Sprache-an/aus-Schalter und Streaming-Status */
.mbai-speech-toggle {
    border: 1px solid #dcdcde;
    background: #fff;
    border-radius: 999px;
    padding: 5px 9px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.mbai-speech-toggle:hover,
.mbai-speech-toggle:focus {
    border-color: #8c8f94;
    background: #f6f7f7;
}
.mbai-speech-toggle.is-off {
    opacity: .62;
    background: #f6f7f7;
}
@media (max-width: 640px) {
    .mbai-chat__header-actions {
        max-width: 52%;
    }
    .mbai-speech-toggle {
        font-size: 11px;
        padding: 4px 7px;
    }
}
