/**
 * Enhanced Chat File Upload & Voice Memo Styles
 * Modern UI with animations and better UX
 */

/* ============================================
   File Preview Area
   ============================================ */

.chat-file-preview-area {
    padding: 12px 16px 8px 16px;
    background: transparent;
    animation: slideDown 0.2s ease;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    flex-shrink: 0;
    position: relative;
}

.chat-file-preview-area::-webkit-scrollbar {
    height: 6px;
}

.chat-file-preview-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-file-preview-area::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chat-file-preview-area::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-file-preview-list {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
    box-sizing: border-box;
    height: 100%;
}

.chat-file-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    flex-shrink: 0;
}

.chat-file-preview-item.uploading {
    opacity: 0.7;
}

.chat-voice-preview-item {
    width: auto !important;
    max-width: 300px !important;
    height: 48px !important;
    min-width: 180px;
    border-radius: 24px !important;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 10px !important;
    overflow: hidden !important;
    position: relative !important;
    flex-shrink: 0 !important;
}

/* Play/Pause Button */
.chat-voice-preview-play {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    color: white !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    transition: background 0.2s ease !important;
}

.chat-voice-preview-play:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

.chat-voice-preview-play svg {
    width: 16px !important;
    height: 16px !important;
}

/* Waveform Container (Preview - consistent style) */
.chat-voice-preview-waveform-container {
    flex: 1 !important;
    position: relative !important;
    height: 24px !important;
    min-width: 100px !important;
    max-width: 280px !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.chat-voice-preview-waveform {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.chat-voice-preview-waveform-svg {
    width: auto !important;
    max-width: 100% !important;
    height: 24px !important;
    display: block !important;
}

.chat-voice-preview-waveform-svg .waveform-bar {
    transition: opacity 0.2s ease, fill 0.2s ease !important;
}

/* Duration Display */
.chat-voice-preview-duration {
    color: white !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    font-variant-numeric: tabular-nums !important;
    min-width: 35px !important;
    text-align: right !important;
    flex-shrink: 0 !important;
}

.chat-file-preview-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    color: #1a1a1a;
    font-weight: 600;
    font-size: 24px;
}

.chat-file-preview-icon.image {
    background: #d1e7dd;
    color: #0f5132;
}

.chat-file-preview-icon.video {
    background: #cfe2ff;
    color: #084298;
}

.chat-file-preview-icon.pdf {
    background: #f8d7da;
    color: #842029;
}

.chat-file-preview-icon.document {
    background: #fff3cd;
    color: #664d03;
}

.chat-voice-preview-item .chat-file-preview-size {
    position: static !important;
    background: transparent !important;
    color: white !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 0 !important;
    flex: 1 !important;
    text-align: left !important;
}

.chat-file-preview-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-file-preview-size {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    backdrop-filter: blur(4px);
}

.chat-file-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.chat-file-preview-remove svg {
    width: 14px;
    height: 14px;
}

.chat-voice-preview-item .chat-file-preview-remove {
    position: static !important;
    width: 20px !important;
    height: 20px !important;
    background: rgba(255, 255, 255, 0.3) !important;
    flex-shrink: 0 !important;
    margin-left: 4px !important;
}

.chat-voice-preview-item .chat-file-preview-remove:hover {
    background: rgba(255, 255, 255, 0.5) !important;
}

/* ============================================
   Voice Recording Interface (Transforms Input Bar)
   ============================================ */

.chat-input-wrapper.recording {
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%) !important;
    border-color: transparent !important;
    padding: 6px !important;
    box-shadow: 0 4px 12px rgba(52, 58, 64, 0.3) !important;
}

/* Voice Recording Content (während Aufnahme) */
.chat-voice-recording-content {
    flex: 1 !important;
    display: none; /* Hidden by default, shown only when recording via inline style */
    align-items: center !important;
    gap: 10px !important;
    margin: 0 !important;
    position: relative !important;
}

/* Show when recording (inline style will override, but this ensures it works) */
.chat-input-wrapper.recording .chat-voice-recording-content {
    display: flex !important;
}

.chat-voice-waveform {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50px;
    padding: 6px 10px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Canvas is hidden by default - shown when recording */
#chatVoiceCanvas {
    width: 100%;
    height: 36px;
    display: none;
    border-radius: 8px;
}

/* Show canvas when recording - both via inline style and class */
.chat-input-wrapper.recording #chatVoiceCanvas {
    display: block !important;
}

.chat-voice-timer {
    font-size: 15px;
    font-weight: 600;
    color: white;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    min-width: 50px;
    text-align: center;
}

/* ============================================
   Enhanced Input Area - Unified Design
   ============================================ */

/* Composer: Pill-Höhe; Header: Profilbild 40px — Anruf-Buttons gleich groß wie der Header-Avatar */
#chatMain {
    --chat-pill-min-height: 48px;
    --chat-header-avatar-size: 40px;
    /* Kreis neben der Bubble (Familien-Chat); nicht über den Inhalt hinaus (s. align-items an .chat-message) */
    --chat-message-line-avatar-size: 30px;
}

.chat-input-container {
    border-top: none !important;
    padding: 0 !important;
    background: transparent !important;
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Prevent container from expanding */
    position: relative;
}

.chat-input-container.chat-composer-has-reply {
    gap: 3px !important;
}

/* Reply preview grows upward into the message list (padding reserve), not by shoving the field down */
.chat-input-container.chat-composer-has-reply {
    flex-direction: column !important;
    justify-content: flex-end !important;
}

/* Composer: gleiche Token wie Nachrichten-Zitatkarten (#chatMessages) */
#chatMain .chat-input-container,
.chat-reply-ui {
    --kinma-chat-reply-bg: #93c5fd;
    --kinma-chat-referenzen-bg: #fef3c7;
    --chat-quote-context-bg: #fef3c7;
    --kinma-chat-composer-close-bg: #1a1a1a;
    --kinma-quote-collapse-duration: 0.28s;
    --kinma-quote-collapse-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reply/Referenz nur über der Eingabe-Pille, nicht über Anhang/Mikro */
.chat-composer-pill-stack {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
    align-self: flex-end !important;
    position: relative !important;
    overflow: visible !important;
}

/* Composer: gestapelte Karten — Antwort → Referenz → Eingabe (kompakt, ohne Rahmen) */
.chat-reply-ui {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    border-left: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
}

.chat-reply-ui-inner {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.chat-reply-stack {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
    overflow: visible !important;
}

.chat-reply-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 999px !important;
    padding: 3px 6px 3px 8px !important;
    text-align: left !important;
    opacity: 1 !important;
    background-clip: padding-box !important;
}

.chat-reply-card--quote {
    background-color: var(--kinma-chat-reply-bg, #93c5fd) !important;
    border-radius: 999px !important;
    position: relative !important;
    z-index: 2 !important;
}

.chat-input-container.chat-composer-has-reply #chatReplyUI .chat-reply-card--quote {
    cursor: pointer;
}

.chat-popup:has(.chat-composer-has-reply) .chat-message-base-reply,
.chat-popup:has(.chat-composer-has-reply) .chat-message-quote-block--primary {
    cursor: pointer;
}

.chat-reply-card--refs {
    background-color: var(--chat-quote-context-bg, #fef3c7) !important;
    border-radius: 999px !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Referenzen der Nachricht, auf die geantwortet wird (zwischen Antwort-Zeile und eigenen Referenzen) */
.chat-reply-card--target-refs {
    background-color: color-mix(in srgb, var(--kinma-chat-reply-bg, #93c5fd) 72%, #ffffff) !important;
    border-radius: 16px !important;
    position: relative !important;
    z-index: 1 !important;
}

.chat-reply-card--target-refs .chat-reply-inline-row--readonly {
    cursor: default !important;
}

.chat-reply-card--target-refs:not(.chat-reply-card--expanded) {
    padding: 3px 6px 3px 8px !important;
}

.chat-reply-card--target-refs.chat-reply-card--expanded {
    border-radius: 12px !important;
    padding: 4px 6px 4px 8px !important;
}

.chat-reply-card--target-refs.chat-reply-card--expanded .chat-reply-refs-head,
.chat-reply-card--target-refs.chat-reply-card--expanded .chat-reply-refs-toggle {
    min-height: 22px !important;
    height: 22px !important;
    max-height: 22px !important;
}

.chat-reply-card--target-refs.chat-reply-card--expanded .chat-reply-references-collapsible {
    position: relative !important;
    margin-top: 3px !important;
    padding-top: 3px !important;
    border-top: 1px solid rgba(26, 26, 26, 0.08) !important;
    background-color: color-mix(in srgb, var(--kinma-chat-reply-bg, #93c5fd) 72%, #ffffff) !important;
    border-radius: 0 0 10px 10px !important;
    max-height: 120px !important;
    box-shadow: none !important;
}

/* Zugeklappte Gruppe: gleiche Höhe wie eine einzelne Referenz-Zeile */
.chat-reply-card--refs:not(.chat-reply-card--expanded) {
    padding: 3px 6px 3px 8px !important;
}

.chat-reply-card--refs:not(.chat-reply-card--expanded) .chat-reply-references-body {
    gap: 0 !important;
}

.chat-reply-card--refs:not(.chat-reply-card--expanded) .chat-reply-refs-head,
.chat-reply-card--refs:not(.chat-reply-card--expanded) .chat-reply-refs-toggle {
    min-height: 22px !important;
    height: 22px !important;
    max-height: 22px !important;
}

.chat-reply-card--refs,
.chat-reply-card--target-refs {
    transition:
        border-radius var(--kinma-quote-collapse-duration) var(--kinma-quote-collapse-ease),
        padding var(--kinma-quote-collapse-duration) var(--kinma-quote-collapse-ease);
}

.chat-reply-references-collapse {
    display: block;
    max-height: 200px;
    opacity: 1;
    overflow: hidden;
    min-height: 0;
    transition:
        max-height var(--kinma-quote-collapse-duration) var(--kinma-quote-collapse-ease),
        opacity calc(var(--kinma-quote-collapse-duration) * 0.85) var(--kinma-quote-collapse-ease);
}

.chat-reply-references-collapse--collapsed:not(.kinma-collapse-panel-animating) {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.chat-reply-references-collapse.kinma-collapse-panel-animating {
    max-height: none !important;
    transition: none !important;
}

.chat-reply-references-collapse-inner {
    min-height: 0;
    overflow: hidden;
}

.chat-reply-references-collapse--collapsed .chat-reply-references-collapsible {
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: none !important;
    max-height: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .chat-reply-ui {
        --kinma-quote-collapse-duration: 0.01ms;
    }

    .chat-reply-card--refs,
    .chat-reply-card--target-refs,
    .chat-reply-references-collapse,
    .chat-reply-refs-toggle .toggle-icon {
        transition-duration: 0.01ms !important;
    }
}

.chat-reply-card-kicker {
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    color: #1d4ed8 !important;
    margin: 0 0 6px 0 !important;
    line-height: 1.2 !important;
}

.chat-reply-card-kicker--muted {
    color: #64748b !important;
}

.chat-reply-ui .chat-reply-header {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #1e40af !important;
}

.chat-reply-ui .chat-reply-name {
    color: inherit !important;
}

.chat-reply-ui .chat-reply-text {
    margin-top: 4px !important;
    font-size: 13px !important;
    color: #1a1a1a !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.4 !important;
    max-height: 5.6em !important;
    overflow: hidden !important;
}

.chat-reply-references-body {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
}

.chat-reply-ui .chat-reply-inline-glyph {
    display: none !important;
}

.chat-reply-inline-glyph {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    width: 14px !important;
    height: 14px !important;
    color: rgba(26, 26, 26, 0.55) !important;
    margin-right: 1px !important;
}

.chat-reply-inline-glyph svg {
    display: block !important;
    width: 12px !important;
    height: 12px !important;
}

.chat-reply-references-body .chat-reply-reference-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 5px !important;
    font-size: 12px !important;
    padding-top: 3px !important;
    border-top: none !important;
}

.chat-reply-references-body .chat-reply-reference-item:first-child {
    padding-top: 0 !important;
    border-top: none !important;
}

.chat-reply-references-body .chat-reply-reference-item .chat-reply-inline-body,
.chat-reply-references-body .chat-reply-reference-item .chat-reply-inline-text {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

.chat-reply-references-body .chat-reply-reference-item .chat-reply-ref-remove {
    margin-left: auto !important;
}

.chat-reply-references-body .chat-reply-reference-name {
    font-weight: 600 !important;
    color: #1a1a1a !important;
}

.chat-reply-references-body .chat-reply-reference-text {
    color: #64748b !important;
    line-height: 1.35 !important;
    word-break: break-word !important;
    white-space: normal !important;
}

.chat-reply-ui .chat-reply-close:not(.chat-reply-close--inside) {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    margin: 2px 0 0 0 !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
    align-self: flex-start !important;
    border: none !important;
    background: rgba(26, 26, 26, 0.06) !important;
    color: #1a1a1a !important;
}

.chat-reply-ui .chat-reply-close--inside,
.chat-reply-ui .chat-reply-ref-remove {
    box-sizing: border-box !important;
    margin: 0 0 0 4px !important;
    width: auto !important;
    height: 20px !important;
    min-width: 36px !important;
    min-height: 20px !important;
    max-width: none !important;
    max-height: 20px !important;
    padding: 0 11px !important;
    flex: 0 0 auto !important;
    align-self: center !important;
    border: none !important;
    border-radius: 999px !important;
    aspect-ratio: auto !important;
    overflow: hidden !important;
    background: var(--kinma-chat-composer-close-bg, #1a1a1a) !important;
    color: #ffffff !important;
    display: inline-grid !important;
    place-items: center !important;
    line-height: 0 !important;
    cursor: pointer !important;
}

.chat-reply-ui .chat-reply-close--inside svg,
.chat-reply-ui .chat-reply-ref-remove svg {
    width: 11px !important;
    height: 11px !important;
    display: block !important;
    flex-shrink: 0 !important;
}

.chat-reply-inline-row,
.chat-reply-references-body .chat-reply-reference-item {
    container-type: inline-size !important;
    container-name: chat-reply-inline !important;
}

.chat-reply-inline-row {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    min-width: 0 !important;
    min-height: 22px !important;
}

.chat-reply-inline-avatar {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
}

.chat-reply-inline-row .chat-message-avatar.chat-reply-inline-avatar,
.chat-reply-reference-item .chat-message-avatar.chat-reply-inline-avatar,
.chat-reply-refs-person-slot .chat-message-avatar {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;
    font-size: 8px !important;
    line-height: 1 !important;
}

.chat-reply-inline-row .chat-message-avatar.chat-reply-inline-avatar .chat-message-avatar-img,
.chat-reply-reference-item .chat-message-avatar.chat-reply-inline-avatar .chat-message-avatar-img,
.chat-reply-refs-person-slot .chat-message-avatar .chat-message-avatar-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.chat-reply-refs-person-slot {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

.chat-reply-refs-person-slot + .chat-reply-refs-person-slot {
    margin-left: -4px !important;
}

.chat-reply-inline-body,
.chat-reply-inline-text {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    display: inline-flex !important;
    align-items: baseline !important;
    gap: 4px !important;
    font-size: 11px !important;
    color: rgba(26, 26, 26, 0.88) !important;
    line-height: 1.2 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.chat-reply-inline-name {
    font-weight: 700 !important;
    color: #1a1a1a !important;
    flex: 0 1 auto !important;
    max-width: 42% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.chat-reply-inline-preview {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    color: rgba(26, 26, 26, 0.88) !important;
}

@container chat-reply-inline (max-width: 128px) {
    .chat-reply-inline-name {
        display: none !important;
    }
}

.chat-reply-ui .chat-reply-close:not(.chat-reply-close--inside):hover {
    background: rgba(26, 26, 26, 0.1) !important;
    color: #1a1a1a !important;
}

.chat-reply-ui.chat-reply-ui-reference-active .chat-reply-card--quote {
    background-color: var(--kinma-chat-reply-bg, #93c5fd) !important;
}

.chat-reply-ui.chat-reply-ui-reference-active .chat-reply-card--refs {
    background-color: var(--chat-quote-context-bg, #fef3c7) !important;
}

/* Aufgeklappt: Liste wächst nach unten — Antwort-Zeile darüber bleibt sichtbar */
.chat-reply-card--refs.chat-reply-card--expanded {
    border-radius: 12px !important;
    padding: 4px 6px 4px 8px !important;
}

.chat-reply-card--refs.chat-reply-card--expanded .chat-reply-refs-head,
.chat-reply-card--refs.chat-reply-card--expanded .chat-reply-refs-toggle {
    min-height: 22px !important;
    height: 22px !important;
    max-height: 22px !important;
}

.chat-reply-card--refs.chat-reply-card--expanded .chat-reply-references-collapsible {
    position: relative !important;
    margin-top: 3px !important;
    padding-top: 3px !important;
    border-top: 1px solid rgba(26, 26, 26, 0.08) !important;
    background-color: var(--chat-quote-context-bg, #fef3c7) !important;
    border-radius: 0 0 10px 10px !important;
    max-height: 120px !important;
    box-shadow: none !important;
}

.chat-reply-refs-toggle {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    color: rgba(26, 26, 26, 0.88) !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 0 !important;
    cursor: pointer !important;
    min-height: 22px !important;
}

.chat-reply-refs-toggle .toggle-icon {
    transition: transform var(--kinma-quote-collapse-duration) var(--kinma-quote-collapse-ease) !important;
    order: 3 !important;
    margin-left: auto !important;
    color: #1a1a1a !important;
    width: 12px !important;
    height: 12px !important;
    flex-shrink: 0 !important;
}

.chat-reply-refs-toggle[data-expanded="1"] .toggle-icon {
    transform: rotate(90deg) !important;
}

.chat-reply-refs-label {
    order: 2 !important;
}

.chat-reply-refs-toggle .chat-reply-inline-glyph {
    order: 0 !important;
}

.chat-reply-references-collapsible {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
    max-height: 66px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-width: thin;
    scrollbar-color: rgba(26, 26, 26, 0.35) transparent;
}

.chat-reply-references-collapsible::-webkit-scrollbar {
    width: 4px;
}

.chat-reply-references-collapsible::-webkit-scrollbar-thumb {
    background: rgba(26, 26, 26, 0.35);
    border-radius: 999px;
}

.chat-reply-refs-head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    min-height: 20px !important;
    flex-wrap: nowrap !important;
}

.chat-reply-refs-people {
    display: inline-flex !important;
    align-items: center !important;
    margin-right: 2px !important;
    order: 1 !important;
}

.chat-reply-refs-person {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    border-radius: 999px !important;
    border: none !important;
    color: #ffffff !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.chat-reply-refs-person + .chat-reply-refs-person {
    margin-left: -4px !important;
}

.chat-reply-ref-remove:hover,
.chat-reply-ui .chat-reply-close--inside:hover {
    background: color-mix(in srgb, var(--kinma-chat-composer-close-bg, #1a1a1a) 82%, #ffffff) !important;
    color: #ffffff !important;
}

.chat-reply-refs-clear-all {
    border: none !important;
    background: transparent !important;
    color: rgba(26, 26, 26, 0.55) !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    padding: 0 0 0 6px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
}

.chat-reply-refs-toggle {
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

.chat-reply-refs-clear-all:hover {
    color: #dc2626 !important;
}

/* Eingabefeld behält Standard-Rahmen — kein extra schwerer Rand bei Antwort/Referenz */
.chat-input-container.chat-composer-has-reply .chat-input-wrapper {
    border: 1px solid #dee2e6 !important;
    box-shadow: none !important;
}

.chat-input-container.chat-composer-has-reply .chat-input-wrapper:focus-within {
    border-color: #1a1a1a !important;
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.05) !important;
}

.chat-create-menu {
    position: absolute !important;
    z-index: 2600 !important;
    min-width: 200px !important;
    padding: 8px !important;
    border-radius: 18px !important;
    background: #ffffff !important;
    box-shadow: 0 18px 40px rgba(26, 26, 26, 0.18) !important;
    border: 1px solid rgba(148, 163, 184, 0.22) !important;
}

.chat-create-menu-item {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    color: #1a1a1a !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-align: left !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
    cursor: pointer !important;
}

.chat-create-menu-item:hover {
    background: #f1f5f9 !important;
}

.chat-group-create-modal {
    width: min(460px, calc(100vw - 32px)) !important;
}

.chat-group-create-modal-body {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
}

.chat-group-create-field {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.chat-group-create-label {
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #1a1a1a !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
}

.chat-group-create-input {
    width: 100% !important;
}

.chat-group-create-members-head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
}

.chat-group-create-members-count {
    min-width: 24px !important;
    height: 24px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #e2e8f0 !important;
    color: #1a1a1a !important;
    font-size: 12px !important;
    font-weight: 700 !important;
}

.chat-group-create-members {
    max-height: 300px !important;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.chat-group-create-member {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 10px 12px !important;
    border-radius: 16px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    cursor: pointer !important;
}

.chat-group-create-member:hover {
    background: #eef2f7 !important;
}

.chat-group-create-member input {
    margin: 0 !important;
}

.chat-group-create-member-avatar {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-weight: 700 !important;
}

.chat-group-create-member-name {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    color: #1a1a1a !important;
    font-size: 14px !important;
    font-weight: 600 !important;
}

.chat-group-create-empty {
    padding: 18px 12px !important;
    text-align: center !important;
    color: #64748b !important;
    font-size: 14px !important;
    background: #f8fafc !important;
    border-radius: 16px !important;
}

/* Legacy-Referenzsuche (dynamisch) — durch Dock unter Header ersetzt */
.chat-reference-search-bar {
    display: none !important;
}

/* Referenzmodus: kinma-ai-search-pill unter der Header-Zeile (ohne Dock-Hintergrund/Schatten) */
#chatMain .chat-reference-search-dock:not([hidden]) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px 10px;
    background: transparent;
    border: none;
    box-shadow: none;
    position: relative;
    z-index: 11;
}

#chatMain .chat-reference-search-dock[hidden] {
    display: none !important;
}

#chatMain .chat-reference-search-dock-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

#chatMain .chat-reference-search-scope-island {
    display: flex;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}

#chatMain .chat-reference-search-scope-inner {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    padding: 3px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(26, 26, 26, 0.08);
    box-sizing: border-box;
}

#chatMain .chat-reference-search-scope-seg {
    border: none;
    padding: 6px 12px;
    min-height: 32px;
    border-radius: 9999px;
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    color: #1a1a1a;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

#chatMain .chat-reference-search-scope-seg:hover {
    background: rgba(26, 26, 26, 0.06);
}

#chatMain .chat-reference-search-scope-seg--active {
    background: #1a1a1a;
    color: #fff;
}

#chatMain .chat-reference-search-scope-seg--active:hover {
    background: #1a1a1a;
    color: #fff;
}

#chatMain .chat-reference-search-pill {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    min-height: var(--chat-pill-min-height, 48px);
    border-radius: 9999px;
    background: #ffffff;
    border: 1px solid rgba(26, 26, 26, 0.1);
    box-shadow: none;
    box-sizing: border-box;
}

#chatMain .chat-reference-search-pill .kinma-ai-search-pill__inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px 0 12px;
    min-height: var(--chat-pill-min-height, 48px);
    width: 100%;
    box-sizing: border-box;
}

#chatMain .chat-reference-search-input {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 14px;
    color: #1a1a1a;
    outline: none;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
}

#chatMain .chat-reference-search-input::placeholder {
    color: #94a3b8;
}

#chatMain .chat-reference-search-close-btn {
    flex: 0 0 auto;
    width: var(--chat-pill-min-height, 48px);
    height: var(--chat-pill-min-height, 48px);
    min-width: var(--chat-pill-min-height, 48px);
    min-height: var(--chat-pill-min-height, 48px);
    border: none;
    border-radius: 50%;
    background: #1a1a1a;
    color: #f8fafc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    padding: 0;
    box-sizing: border-box;
}

body.dark-mode #chatMain .chat-reference-search-scope-inner {
    background: rgba(26, 26, 26, 0.92);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode #chatMain .chat-reference-search-scope-seg {
    color: #f1f5f9;
}

body.dark-mode #chatMain .chat-reference-search-scope-seg--active {
    background: #f8fafc;
    color: #1a1a1a;
}

body.dark-mode #chatMain .chat-reference-search-pill {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode #chatMain .chat-reference-search-input {
    color: #f1f5f9;
}

@media (max-width: 1024px) {
    body.kinma-chat-reply-header-search #chatMain .chat-reference-search-dock {
        display: none !important;
    }

    .chat-message-reference-checkbox {
        display: none !important;
    }
}

/* Row: attachment (outside) | pill (camera + textarea + send) | voice (outside) */
.chat-input-bar-row {
    /* Eine Zeile mit Anhang | Pill | Mikro — gleiche Außenhöhe wie die Pill (Header-Zeile nutzt dieselbe Zahl) */
    --chat-pill-min-height: 48px;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    justify-content: center !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    /* Kein festes Bottom-Padding — nur Safe-Area (sonst schwebt die Zeile über dem unteren Rand) */
    padding: 0 12px max(0px, env(safe-area-inset-bottom, 0px)) !important;
    margin: 0 !important;
}

.chat-input-external {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    align-self: flex-end !important;
    position: relative !important;
}

/* Rechte Spalte (Mikrofon) darf nicht auf 0 kollabieren; Taste bleibt neben der Pill sichtbar */
.chat-input-bar-row .chat-input-external--right {
    min-width: var(--chat-pill-min-height, 46px) !important;
    justify-content: center !important;
}

/* Mikrofon immer sichtbar (nicht mit Send in derselben absolute-Position überlagern) */
#chatVoiceBtn.chat-voice-btn {
    position: relative !important;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    right: auto !important;
    left: auto !important;
    top: auto !important;
    bottom: auto !important;
}

.chat-input-bar-row.recording .chat-input-external--left .chat-attachment-btn,
.chat-input-bar-row.recording .chat-composer-attachment-host .chat-attachment-btn,
.chat-input-bar-row.recording .chat-input-attachment-slot .chat-attachment-btn,
.chat-input-wrapper.recording .chat-attachment-btn--in-pill {
    display: none !important;
    pointer-events: none !important;
}

.chat-composer-attachment-host {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    align-self: flex-end;
}

.chat-composer-attachment-host--external .chat-input-attachment-slot {
    display: inline-flex !important;
    align-items: center;
    align-self: center;
}

.chat-composer-attachment-host--external .chat-attachment-btn--in-pill {
    width: var(--chat-pill-min-height, 48px) !important;
    height: var(--chat-pill-min-height, 48px) !important;
    min-width: var(--chat-pill-min-height, 48px) !important;
    min-height: var(--chat-pill-min-height, 48px) !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

.chat-composer-attachment-host--external .chat-attachment-btn--in-pill:hover {
    transform: scale(1.05) !important;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

.chat-composer-attachment-host--external .chat-attachment-btn--in-pill svg {
    width: 22px !important;
    height: 22px !important;
}

.chat-composer-attachment-host.has-chat-quick-access.show-chat-quick-access {
    position: relative;
    z-index: 2000;
}

.chat-composer-attachment-host.has-chat-quick-access.show-chat-quick-access .chat-attachment-quick-access-bar {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.chat-input-attachment-slot {
    position: relative;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    align-self: center;
}

.chat-attachment-btn--in-pill {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    background: transparent !important;
    color: #495057 !important;
    box-shadow: none !important;
}

.chat-attachment-btn--in-pill:hover {
    background: rgba(26, 26, 26, 0.06) !important;
    transform: none !important;
    box-shadow: none !important;
}

.chat-attachment-btn--in-pill svg {
    width: 20px !important;
    height: 20px !important;
}

.chat-composer-mobile-back-btn {
    display: none;
    width: var(--chat-pill-min-height, 46px);
    height: var(--chat-pill-min-height, 46px);
    min-width: var(--chat-pill-min-height, 46px);
    min-height: var(--chat-pill-min-height, 46px);
    border-radius: 50%;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.chat-composer-mobile-back-btn svg {
    width: 22px;
    height: 22px;
    pointer-events: none;
}

.chat-composer-mobile-back-btn:hover {
    transform: scale(1.05);
}

.chat-composer-mobile-back-btn:active {
    transform: scale(0.95);
}

@media (max-width: 1024px) {
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-main-header-back-island {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        overflow: hidden !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }

    /* Mobile: Anhang nur in der Pill (links), nicht als zweiter Kreis außerhalb */
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        .chat-input-external--left
        > .chat-composer-attachment-host {
        display: none !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        overflow: hidden !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }

    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-input-bar-row {
        transition: gap 0.22s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-input-external--left {
        display: inline-flex !important;
        align-items: center !important;
        gap: 8px !important;
        max-width: calc(var(--chat-pill-min-height, 48px) + 8px);
        overflow: hidden !important;
        transition:
            max-width 0.22s cubic-bezier(0.25, 0.8, 0.25, 1),
            gap 0.22s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    body.mobile-chat-input-focused
        .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        .chat-input-external--left {
        max-width: 0 !important;
        gap: 0 !important;
    }

    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        .chat-composer-mobile-back-btn:not([hidden]) {
        display: inline-flex !important;
        flex-shrink: 0 !important;
        max-width: var(--chat-pill-min-height, 48px);
        opacity: 1;
        margin: 0;
        overflow: hidden;
        transition:
            max-width 0.22s cubic-bezier(0.25, 0.8, 0.25, 1),
            opacity 0.22s cubic-bezier(0.25, 0.8, 0.25, 1),
            transform 0.22s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    body.mobile-chat-input-focused
        .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        .chat-composer-mobile-back-btn {
        max-width: 0 !important;
        opacity: 0 !important;
        pointer-events: none !important;
        transform: scale(0.88);
    }

    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-composer-pill-stack {
        transition: flex 0.22s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-composer-attachment-host--in-pill,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-composer-attachment-host--in-pill .chat-input-attachment-slot,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        .chat-input-wrapper
        .chat-composer-attachment-host--in-pill
        .chat-attachment-btn--in-pill {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        .chat-input-wrapper
        .chat-composer-attachment-host--in-pill
        .chat-attachment-btn--in-pill {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        background: transparent !important;
        color: #495057 !important;
        box-shadow: none !important;
    }
}

@media (max-width: 1024px) and (prefers-reduced-motion: reduce) {
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-input-bar-row,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-input-external--left,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-composer-mobile-back-btn,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact .chat-composer-pill-stack {
        transition: none !important;
    }
}

@media (min-width: 1025px) {
    .chat-composer-mobile-back-btn {
        display: none !important;
    }

    .chat-composer-attachment-host--external {
        display: inline-flex !important;
    }
}

.chat-input-wrapper {
    position: relative !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    /* Allow flex children (textarea) to shrink so text cannot paint under side buttons */
    flex: 1 1 0% !important;
    min-width: 0 !important;
    gap: 6px !important;
    padding: 6px 10px !important;
    background: white !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 50px !important;
    width: auto !important;
    max-width: 100% !important;
    min-height: var(--chat-pill-min-height, 48px) !important;
    box-shadow: none !important;
    transform: none !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.chat-input-wrapper:hover {
    border-color: #dee2e6 !important;
    box-shadow: none !important;
    transform: none !important;
}

.chat-input-wrapper:focus-within {
    border-color: #1a1a1a !important;
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.05) !important;
    transform: none !important;
}

/* Verlaufssuche: Framework ersetzt die Composer-Zeile (KI-Lupe in der Pille wie Stammbaum, X rechts) */
#chatMain.chat-main--desktop-history-search #chatInputBarRow {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/*
 * Grid statt Flex: Pille in Spalte 1 mit justify-self:center — max-width 54px ↔ 100% animiert von der Mitte
 * (Ladekreis → volle Suchleiste), nicht mit fixiertem linken Rand wie bei flex:1 + width:100%.
 */
#chatMain.chat-main--desktop-history-search
    .chat-composer-history-search-dock:not([hidden]):not(.chat-composer-history-search-dock--in-header) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch !important;
    gap: 8px !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

#chatMain.chat-main--desktop-history-search:not(.chat-main--reply-header-search):not(.chat-main--header-history-search)
    .chat-input-external--left,
#chatMain.chat-main--desktop-history-search:not(.chat-main--reply-header-search):not(.chat-main--header-history-search)
    .chat-input-wrapper,
#chatMain.chat-main--desktop-history-search:not(.chat-main--reply-header-search):not(.chat-main--header-history-search)
    .chat-input-external--right {
    display: none !important;
}

/* Mobile Antwortmodus: Dock nur im Header-Slot, nicht im Composer */
@media (max-width: 1024px) {
    body.kinma-chat-reply-header-search
        .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        #chatMain.chat-main--reply-header-search
        #chatInputBarRow
        > .chat-main-header-desktop-history-search-dock {
        display: none !important;
    }

    body.kinma-chat-reply-header-search
        #chatMain.chat-main--reply-header-search
        .chat-main-header-history-search-slot
        .chat-composer-history-search-dock--in-header:not([hidden]) {
        display: block !important;
        flex: none !important;
        grid-template: none !important;
        grid-template-columns: none !important;
        width: 100% !important;
        max-width: none !important;
    }

    body.kinma-chat-reply-header-search
        #chatMain.chat-main--reply-header-search
        .chat-main-header-history-search-slot
        #chatDesktopConversationSearch:not([hidden]):not(.kinma-ai-search-pill--ai-busy) {
        justify-self: stretch !important;
        align-self: center !important;
        width: 100% !important;
        max-width: none !important;
    }

    body.kinma-chat-reply-header-search
        #chatMain.chat-main--reply-header-search
        .chat-main-header-history-search-slot
        .chat-composer-history-search-dock--in-header
        .chat-composer-history-search-close-btn {
        display: none !important;
    }

    body.kinma-chat-reply-header-search
        #chatMain.chat-main--reply-header-search
        #chatInputBarRow
        > .kinma-ai-search-pill-feedback-consent {
        display: none !important;
    }
}

/* Mobile Vollbild: keine leere Composer-Pille über der Verlaufssuche; Eingabezeile über Kanten-Fade (#chatMain::after z-index 2) */
@media (max-width: 1024px) {
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact #chatMain.chat-main--desktop-history-search .chat-input-container {
        z-index: 10 !important;
    }
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact #chatMain.chat-main--desktop-history-search #chatInputBarRow {
        justify-content: flex-start !important;
    }
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        #chatMain.chat-main--desktop-history-search:not(.chat-main--reply-header-search)
        .chat-input-external--left,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        #chatMain.chat-main--desktop-history-search:not(.chat-main--reply-header-search)
        .chat-input-wrapper,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        #chatMain.chat-main--desktop-history-search:not(.chat-main--reply-header-search)
        .chat-input-external--right {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        flex: 0 0 0 !important;
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        height: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        border: none !important;
        opacity: 0 !important;
        position: absolute !important;
    }
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact
        #chatMain.chat-main--desktop-history-search:not(.chat-main--reply-header-search)
        .chat-composer-history-search-dock:not([hidden]) {
        position: relative !important;
        z-index: 1 !important;
        flex: 1 1 0% !important;
        min-width: 0 !important;
    }
}

#chatMain.chat-main--desktop-history-search
    .chat-composer-history-search-dock:not(.chat-composer-history-search-dock--in-header)
    .chat-composer-history-search-close-btn {
    grid-column: 2;
    grid-row: 1;
    flex: 0 0 auto !important;
    align-self: stretch !important;
    justify-self: end;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 9999px !important;
    background: #1a1a1a !important;
    color: #f8fafc !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
}

#chatMain.chat-main--desktop-history-search
    .chat-composer-history-search-dock:not(.chat-composer-history-search-dock--in-header)
    .chat-composer-history-search-close-btn:hover,
#chatMain.chat-main--desktop-history-search
    .chat-composer-history-search-dock:not(.chat-composer-history-search-dock--in-header)
    .chat-composer-history-search-close-btn:focus-visible {
    background: #1a1a1a !important;
    outline: none !important;
}

#chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch:not([hidden]) {
    display: flex !important;
    flex-direction: row !important;
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
    flex: none !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    align-items: stretch !important;
    align-self: stretch !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Kein transparent/border:none bei --ai-*: sonst überschreibt das den RGB-Verlauf aus kinma-ai-search-pill.css */
#chatMain.chat-main--desktop-history-search
    #chatDesktopConversationSearch.kinma-ai-search-pill:not([hidden]):not(.kinma-ai-search-pill--ai-active):not(.kinma-ai-search-pill--ai-busy) {
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
}

/* Chat-Verlauf KI: Morph Pille → Kreis (kinma-ai-search-pill.css) + RGB-Halo bei --ai-active */
#chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch.kinma-ai-search-pill {
    position: relative;
    transition:
        flex 0.38s ease,
        min-width 0.38s ease,
        max-width 0.38s ease,
        width 0.38s ease,
        border-radius 0.38s ease,
        height 0.38s ease,
        min-height 0.38s ease,
        max-height 0.38s ease,
        padding 0.38s ease;
}

#chatMain.chat-main--desktop-history-search
    #chatDesktopConversationSearch.kinma-ai-search-pill.kinma-ai-search-pill--ai-active:not(.kinma-ai-search-pill--ai-busy) {
    overflow: visible;
}

/*
 * RGB-Halo (::before inset -11px): .chat-input-container hat global overflow:hidden — schneidet den Schein oben ab.
 * Nur Verlaufssuche + KI/Busy: Kette sichtbar lassen (analog Galerie-Kommentar in kinma-ai-search-pill.css).
 */
#chatMain.chat-main--desktop-history-search:has(#chatDesktopConversationSearch.kinma-ai-search-pill--ai-active)
    .chat-input-container,
#chatMain.chat-main--desktop-history-search:has(#chatDesktopConversationSearch.kinma-ai-search-pill--ai-busy)
    .chat-input-container,
#chatMain.chat-main--desktop-history-search:has(#chatDesktopConversationSearch.kinma-ai-search-pill--ai-active)
    #chatInputBarRow,
#chatMain.chat-main--desktop-history-search:has(#chatDesktopConversationSearch.kinma-ai-search-pill--ai-busy)
    #chatInputBarRow,
#chatMain.chat-main--desktop-history-search:has(#chatDesktopConversationSearch.kinma-ai-search-pill--ai-active)
    .chat-composer-history-search-dock:not([hidden]),
#chatMain.chat-main--desktop-history-search:has(#chatDesktopConversationSearch.kinma-ai-search-pill--ai-busy)
    .chat-composer-history-search-dock:not([hidden]) {
    overflow: visible !important;
}

/* RGB-Rand / Pastell-Busy: assets/css/kinma-ai-search-pill.css — keine flachen background/border hier (würden den Verlauf überschreiben) */

/* Framework-Hook: kinmaStartChatConversationAiBusyUi setzt .chat-composer-history-search-dock--kinma-ai-busy am Dock */
#chatMain.chat-main--desktop-history-search
    .chat-composer-history-search-dock.chat-composer-history-search-dock--kinma-ai-busy
    .chat-composer-history-search-close-btn {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    flex: 0 0 0 !important;
    border: none !important;
    box-shadow: none !important;
    aspect-ratio: auto !important;
}

#chatMain.chat-main--desktop-history-search
    .chat-composer-history-search-dock.chat-composer-history-search-dock--kinma-ai-busy {
    align-items: center !important;
    position: relative;
}

/*
 * Pille → Kreis: Framework setzt u. a. width/max-width 54px auf .kinma-ai-search-pill--ai-busy — Chat überschreibt mit
 * width:100% + max-width:54px + justify-self:center (Grid), damit max-width zu 100% animieren von der Mitte aus kann.
 */
#chatMain.chat-main--desktop-history-search
    #chatDesktopConversationSearch.kinma-ai-search-pill.kinma-ai-search-pill--ai-busy:not([hidden]) {
    flex: none !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 54px !important;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    justify-self: center !important;
    align-self: center !important;
}

/*
 * Busy: Chat setzt display:flex !important aufs Inner — sonst bleibt die Leiste sichtbar trotz Framework visibility.
 * visibility/opacity !important wie kinma-ai-search-pill.css, damit Ladekreis + RGB am äußeren Wrapper greifen.
 */
#chatMain.chat-main--desktop-history-search
    #chatDesktopConversationSearch.kinma-ai-search-pill--ai-busy
    .kinma-ai-search-pill__inner {
    width: auto !important;
    max-width: none !important;
    flex: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    display: block !important;
}

#chatMain.chat-main--desktop-history-search
    .chat-main-header-desktop-history-search-dock:has(#chatDesktopConversationSearch.kinma-ai-search-pill--ai-busy) {
    align-items: center;
}

#chatMain.chat-main--desktop-history-search .chat-desktop-conversation-search-inner-right .kinma-ai-search-pill__rating:not([hidden]) {
    flex-shrink: 0;
    max-width: 148px;
}

@media (prefers-reduced-motion: reduce) {
    #chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch.kinma-ai-search-pill {
        transition: none;
    }
}

#chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch .kinma-ai-search-pill__inner {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: 100% !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 6px 10px !important;
        min-height: var(--chat-pill-min-height, 48px) !important;
        box-sizing: border-box !important;
        background: #ffffff !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 50px !important;
        box-shadow: none !important;
    }

    /* Gleiche Fläche wie Framework; !important wegen Weiß/Border im Block darüber */
    #chatMain.chat-main--desktop-history-search
        #chatDesktopConversationSearch
        .kinma-ai-search-pill__inner.kinma-ai-search-pill__inner--rating-surface-up {
        background: rgba(220, 252, 231, 0.97) !important;
        border-color: rgba(34, 197, 94, 0.35) !important;
        box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.28) !important;
    }

    #chatMain.chat-main--desktop-history-search
        #chatDesktopConversationSearch
        .kinma-ai-search-pill__inner.kinma-ai-search-pill__inner--rating-surface-down {
        background: rgba(254, 226, 226, 0.97) !important;
        border-color: rgba(248, 113, 113, 0.4) !important;
        box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.35) !important;
    }

    #chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch .kinma-ai-search-pill__search-icon {
        display: none !important;
    }

    #chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch .chat-desktop-conversation-search-inner-right {
        display: contents;
    }

    #chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch .chat-main-header-desktop-history-ai-btn {
        order: 1;
        flex-shrink: 0;
    }

    #chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch .mobile-bottom-nav-chat-history-search-meta {
        order: 2;
        flex-shrink: 0;
    }

    #chatMain.chat-main--desktop-history-search .chat-desktop-conversation-search-input {
        order: 3;
        flex: 1 1 0% !important;
        min-width: 0 !important;
        border: none !important;
        background: transparent !important;
        font-size: 14px !important;
        line-height: 1.25;
        padding: 4px 4px;
        outline: none !important;
        color: #1a1a1a;
        box-shadow: none !important;
    }

    #chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch .kinma-ai-search-pill__rating {
        order: 4;
    }

    #chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch .mobile-bottom-nav-chat-history-voice-btn {
        order: 5;
    }

    #chatMain.chat-main--desktop-history-search .chat-desktop-conversation-search-input::placeholder {
        color: #94a3b8;
        font-size: 13px;
        opacity: 1;
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-search-meta {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0;
        flex-shrink: 0;
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-search-nav-col {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0;
        flex-shrink: 0;
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-search-count {
        font-size: 11px;
        font-weight: 600;
        color: #64748b;
        min-width: 28px;
        text-align: center;
        padding: 0 2px;
        line-height: 1;
        align-self: center;
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-search-nav-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 18px;
        min-width: 30px;
        min-height: 18px;
        padding: 0;
        border: none;
        border-radius: 8px;
        background: transparent;
        color: #1a1a1a;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-search-nav-btn:hover,
    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-search-nav-btn:active {
        background: #f1f5f9;
        color: #1a1a1a;
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: #f1f5f9;
        color: #1a1a1a;
        cursor: pointer;
        transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn:hover,
    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn:focus-visible {
        background: #e2e8f0;
        color: #1a1a1a;
        outline: none;
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn.mobile-bottom-nav-chat-history-voice-btn--hidden {
        display: none !important;
    }

    body.dark-mode #chatMain.chat-main--desktop-history-search #chatDesktopConversationSearch .kinma-ai-search-pill__inner {
        background: #262626 !important;
        border-color: #444 !important;
    }

    body.dark-mode
        #chatMain.chat-main--desktop-history-search
        #chatDesktopConversationSearch
        .kinma-ai-search-pill__inner.kinma-ai-search-pill__inner--rating-surface-up {
        background: rgba(20, 83, 45, 0.55) !important;
        border-color: rgba(74, 222, 128, 0.35) !important;
        box-shadow: inset 0 0 0 1px rgba(74, 222, 128, 0.28) !important;
    }

    body.dark-mode
        #chatMain.chat-main--desktop-history-search
        #chatDesktopConversationSearch
        .kinma-ai-search-pill__inner.kinma-ai-search-pill__inner--rating-surface-down {
        background: rgba(127, 29, 29, 0.45) !important;
        border-color: rgba(252, 165, 165, 0.35) !important;
        box-shadow: inset 0 0 0 1px rgba(252, 165, 165, 0.3) !important;
    }

    body.dark-mode #chatMain.chat-main--desktop-history-search .kinma-ai-search-pill__search-icon {
        color: #94a3b8;
    }

    body.dark-mode #chatMain.chat-main--desktop-history-search .chat-desktop-conversation-search-input {
        color: #e2e8f0;
    }

    body.dark-mode #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-search-count {
        color: #94a3b8;
    }

    body.dark-mode #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-search-nav-btn:hover,
    body.dark-mode #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-search-nav-btn:active {
        background: rgba(255, 255, 255, 0.08);
        color: #e2e8f0;
    }

    body.dark-mode #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn {
        background: rgba(255, 255, 255, 0.1);
        color: #e2e8f0;
    }

    body.dark-mode #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn:hover,
    body.dark-mode #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn:focus-visible {
        background: rgba(255, 255, 255, 0.16);
        color: #f8fafc;
    }

    @keyframes kinma-hist-voice-rec-pulse-desktop {
        0%,
        100% {
            transform: scale(1);
        }
        50% {
            transform: scale(1.04);
        }
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn.recording {
        background: #fee2e2;
        color: #b91c1c;
        box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.35);
        animation: kinma-hist-voice-rec-pulse-desktop 1.1s ease-in-out infinite;
    }

    #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn.uploading {
        opacity: 0.65;
        pointer-events: none;
    }

    body.dark-mode #chatMain.chat-main--desktop-history-search .mobile-bottom-nav-chat-history-voice-btn.recording {
        background: rgba(127, 29, 29, 0.45);
        color: #fecaca;
    }

body.dark-mode #chatMain.chat-main--desktop-history-search .chat-composer-history-search-close-btn {
    background: #f8fafc !important;
    color: #1a1a1a !important;
    border: 1px solid rgba(148, 163, 184, 0.35) !important;
}

.chat-input {
    /* flex:1 + min-width:0 is required so long lines wrap inside the middle column, not under icons */
    flex: 1 1 0% !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100%;
    min-height: 34px;
    /* One visible line: overflow + scrollbar as soon as text wraps to a second row */
    --chat-input-visible-lines: 1;
    max-height: calc(var(--chat-input-visible-lines) * 1.5em + 16px);
    /* Override modules/chat.css absolute-icon padding (92px / 50px) — icons are flex siblings */
    padding: 8px 12px !important;
    border: none;
    border-radius: 0;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    resize: none;
    overflow-y: auto !important;
    overflow-x: hidden;
    line-height: 1.5;
    background: transparent;
    box-sizing: border-box !important;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Hide scrollbar for placeholder text - never show scrollbar when only placeholder is visible */
.chat-input:placeholder-shown {
    overflow: hidden !important;
}

.chat-input:not(:placeholder-shown) {
    overflow-y: auto !important;
}

/* Also hide scrollbar when input is empty (not just placeholder) */
.chat-input:not(:focus):empty {
    overflow: hidden;
}

/* Composer-Textarea: nur dunkles Handle, kein weißer Scrollbar-Track */
.chat-input-wrapper textarea.chat-input,
textarea.chat-input {
    scrollbar-width: thin !important;
    scrollbar-color: #282a2e transparent !important;
}

.chat-input-wrapper textarea.chat-input::-webkit-scrollbar,
textarea.chat-input::-webkit-scrollbar {
    width: 3px !important;
    background: transparent !important;
}

.chat-input-wrapper textarea.chat-input::-webkit-scrollbar-track,
.chat-input-wrapper textarea.chat-input::-webkit-scrollbar-track-piece,
textarea.chat-input::-webkit-scrollbar-track,
textarea.chat-input::-webkit-scrollbar-track-piece {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.chat-input-wrapper textarea.chat-input::-webkit-scrollbar-thumb,
textarea.chat-input::-webkit-scrollbar-thumb {
    background: #282a2e !important;
    border: none !important;
    border-radius: 999px !important;
    box-shadow: none !important;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-input:disabled {
    background: transparent;
    cursor: not-allowed;
}

/* Camera + file: flex row with voice/send — modules/chat.css still absolute on camera without this */
.chat-camera-inline-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%) !important;
    color: #ffffff !important;
    border: none !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    transition: all 0.2s ease !important;
    z-index: 1 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

.chat-camera-inline-btn:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

.chat-camera-inline-btn:active {
    transform: scale(0.95) !important;
}

.chat-attachment-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%) !important;
    color: #ffffff !important;
    border: none !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    transition: all 0.2s ease !important;
    z-index: 1 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

.chat-attachment-btn:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

.chat-attachment-btn:active {
    transform: scale(0.95) !important;
}

/* Outside the pill: match single-line bar height, 1:1 circles (not the old 34px size). */
.chat-input-external .chat-attachment-btn,
.chat-input-external .chat-voice-btn {
    width: var(--chat-pill-min-height, 46px) !important;
    height: var(--chat-pill-min-height, 46px) !important;
    min-width: var(--chat-pill-min-height, 46px) !important;
    min-height: var(--chat-pill-min-height, 46px) !important;
    aspect-ratio: 1 / 1 !important;
    box-sizing: border-box !important;
}

.chat-input-external .chat-attachment-btn svg,
.chat-input-external .chat-voice-btn svg {
    width: 22px !important;
    height: 22px !important;
}

/* display must not use !important — JS toggles mic vs send via inline style */
.chat-voice-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%) !important;
    color: #ffffff !important;
    border: none !important;
    cursor: pointer !important;
    display: inline-flex;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    transition: all 0.2s ease !important;
    z-index: 1 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

.chat-voice-btn:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

.chat-voice-btn:active {
    transform: scale(0.95) !important;
}

.chat-attachment-btn svg,
.chat-camera-inline-btn svg,
.chat-voice-btn svg {
    flex-shrink: 0;
    pointer-events: none;
}

/* Voice button becomes cancel button when recording (mic sits outside pill) */
.chat-input-wrapper.recording .chat-voice-btn,
.chat-input-bar-row.recording .chat-voice-btn {
    color: white !important;
    background: transparent !important;
    position: static !important;
    box-shadow: none !important;
}

.chat-send-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%) !important;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    display: inline-flex;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    position: static !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    transition: none !important;
}

/* Send in der Pill: groß wie die Außen-Tasten (weniger Innen-Padding wenn Send sichtbar) */
.chat-input-wrapper--send-visible {
    padding: 4px 8px !important;
}

.chat-input-wrapper .chat-send-btn.chat-send-btn--in-pill {
    width: calc(var(--chat-pill-min-height, 48px) - 8px) !important;
    height: calc(var(--chat-pill-min-height, 48px) - 8px) !important;
    min-width: calc(var(--chat-pill-min-height, 48px) - 8px) !important;
    min-height: calc(var(--chat-pill-min-height, 48px) - 8px) !important;
    max-width: calc(var(--chat-pill-min-height, 48px) - 8px) !important;
    max-height: calc(var(--chat-pill-min-height, 48px) - 8px) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

.chat-send-btn svg {
    flex-shrink: 0;
    pointer-events: none;
}

.chat-input-wrapper .chat-send-btn.chat-send-btn--in-pill svg {
    width: 22px !important;
    height: 22px !important;
}

/* Send lives only inside the pill (separate from the external mic). */
.chat-input-send-slot {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    min-width: 0 !important;
}

.chat-input-wrapper--send-visible .chat-send-btn.chat-send-btn--in-pill {
    animation: chatInputSendPopIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@media (prefers-reduced-motion: reduce) {
    .chat-input-wrapper--send-visible .chat-send-btn.chat-send-btn--in-pill {
        animation: none;
    }
}

@keyframes chatInputSendPopIn {
    from {
        opacity: 0;
        transform: scale(0.88);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Send button becomes confirm button when recording */
.chat-input-wrapper.recording .chat-send-btn {
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a1a;
}

.chat-send-btn:disabled {
    background: #e5e7eb !important;
    color: #9ca3af !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

/* ============================================
   Voice Message Display (in chat messages)
   ============================================ */

.chat-message-voice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%);
    border-radius: 24px;
    max-width: 300px;
    min-width: 180px;
    height: 48px;
    margin-top: 4px;
}

.chat-message.mine .chat-message-voice,
.chat-message-user .chat-message-voice {
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%) !important;
}

.chat-voice-play-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    color: white !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: background 0.2s ease !important;
    padding: 0 !important;
}

.chat-voice-play-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

.chat-voice-play-btn.playing {
    background: rgba(255, 255, 255, 0.3) !important;
}

.chat-voice-play-btn svg {
    width: 16px !important;
    height: 16px !important;
}

/* Waveform Container (consistent with preview) */
.chat-voice-waveform-container {
    flex: 1 !important;
    position: relative !important;
    height: 24px !important;
    min-width: 100px !important;
    max-width: 280px !important;
    overflow: visible !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.chat-voice-waveform {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.chat-voice-waveform .chat-voice-preview-waveform-svg {
    width: auto !important;
    max-width: 100% !important;
    height: 24px !important;
    display: block !important;
}

.chat-voice-waveform .chat-voice-preview-waveform-svg .waveform-bar {
    transition: opacity 0.2s ease, fill 0.2s ease !important;
}

.chat-voice-duration {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: white !important;
    font-variant-numeric: tabular-nums !important;
    min-width: 35px !important;
    text-align: right !important;
    flex-shrink: 0 !important;
}

/* ============================================
   File Attachment Display (in chat messages)
   ============================================ */

.chat-message-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    margin-top: 6px;
    cursor: pointer;
}

.chat-message.mine .chat-message-attachment {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Image attachments - resized to prevent overflow */
.chat-attachment-image {
    display: block;
    max-width: 100%;
    margin-top: 6px;
    border-radius: 8px;
    overflow: hidden;
}

.chat-attachment-img {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chat-attachment-img:hover {
    transform: scale(1.02);
}

.chat-attachment-image-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    width: min(100%, 320px);
    margin-top: 0;
    border-radius: var(--attachment-radius-tl) var(--attachment-radius-tr) var(--attachment-radius-br) var(--attachment-radius-bl);
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(26, 26, 26, 0.14);
}

.chat-attachment-image-group--count-1 {
    grid-template-columns: minmax(0, 1fr);
}

.chat-attachment-image-group-item {
    position: relative;
    display: block;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
    min-width: 0;
    aspect-ratio: 1 / 1;
}

.chat-attachment-image-group--count-1 .chat-attachment-image-group-item {
    aspect-ratio: auto;
}

.chat-attachment-image-group--count-3 .chat-attachment-image-group-item:first-child {
    grid-column: span 2;
    aspect-ratio: 2 / 1;
}

.chat-attachment-image-group-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-attachment-image-group-item--more::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(26, 26, 26, 0.45);
}

.chat-attachment-image-group-more {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
}

.chat-message-content.chat-message-content--attachment-only {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    width: fit-content;
    max-width: 100%;
    position: relative;
    --attachment-radius-tl: 18px;
    --attachment-radius-tr: 18px;
    --attachment-radius-br: 18px;
    --attachment-radius-bl: 18px;
}

.chat-message-user .chat-message-content.chat-message-content--attachment-only {
    align-self: flex-end;
    margin-left: auto;
}

.chat-message-bot .chat-message-content.chat-message-content--attachment-only {
    align-self: flex-start;
    margin-right: auto;
}

.chat-message-content.chat-message-content--attachment-only .chat-message-body {
    gap: 0;
    width: fit-content;
    max-width: 100%;
}

.chat-message-user .chat-message-content.chat-message-content--attachment-only .chat-message-body {
    align-items: flex-end;
}

.chat-message-content.chat-message-content--attachment-only .chat-message-attachments {
    margin: 0 !important;
    display: block;
    width: fit-content;
    max-width: 100%;
    position: relative;
}

.chat-message-user .chat-message-content.chat-message-content--attachment-only .chat-message-attachments {
    margin-left: auto !important;
}

.chat-message-content.chat-message-content--attachment-only .chat-attachment-image,
.chat-message-content.chat-message-content--attachment-only .chat-attachment-image-group,
.chat-message-content.chat-message-content--attachment-only .chat-attachment-video,
.chat-message-content.chat-message-content--attachment-only .chat-message-attachment,
.chat-message-content.chat-message-content--attachment-only .chat-attachment-document-preview {
    margin-top: 0 !important;
}

.chat-message-content.chat-message-content--attachment-only .chat-attachment-image {
    border-radius: var(--attachment-radius-tl) var(--attachment-radius-tr) var(--attachment-radius-br) var(--attachment-radius-bl);
    overflow: hidden;
    position: relative;
    box-shadow: 0 6px 16px rgba(26, 26, 26, 0.14);
}

.chat-message-content.chat-message-content--attachment-only .chat-attachment-video,
.chat-message-content.chat-message-content--attachment-only .chat-message-attachment,
.chat-message-content.chat-message-content--attachment-only .chat-attachment-document-preview {
    border-radius: var(--attachment-radius-tl) var(--attachment-radius-tr) var(--attachment-radius-br) var(--attachment-radius-bl);
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(26, 26, 26, 0.14);
}

.chat-message-content.chat-message-content--attachment-only .chat-attachment-img,
.chat-message-content.chat-message-content--attachment-only .chat-attachment-video-player {
    display: block;
    border-radius: var(--attachment-radius-tl) var(--attachment-radius-tr) var(--attachment-radius-br) var(--attachment-radius-bl);
}

.chat-message-user.chat-message-cluster-only .chat-message-content.chat-message-content--attachment-only,
.chat-message-user.chat-message-first-after-system.chat-message-cluster-only .chat-message-content.chat-message-content--attachment-only {
    --attachment-radius-tl: 18px;
    --attachment-radius-tr: 18px;
    --attachment-radius-br: 6px;
    --attachment-radius-bl: 18px;
}

.chat-message-user.chat-message-cluster-first .chat-message-content.chat-message-content--attachment-only,
.chat-message-user.chat-message-first-after-system.chat-message-cluster-first .chat-message-content.chat-message-content--attachment-only {
    --attachment-radius-tl: 18px;
    --attachment-radius-tr: 18px;
    --attachment-radius-br: 0;
    --attachment-radius-bl: 18px;
}

.chat-message-user.chat-message-cluster-middle .chat-message-content.chat-message-content--attachment-only,
.chat-message-user.chat-message-first-after-system.chat-message-cluster-middle .chat-message-content.chat-message-content--attachment-only {
    --attachment-radius-tl: 18px;
    --attachment-radius-tr: 0;
    --attachment-radius-br: 0;
    --attachment-radius-bl: 18px;
}

.chat-message-user.chat-message-cluster-last .chat-message-content.chat-message-content--attachment-only,
.chat-message-user.chat-message-first-after-system.chat-message-cluster-last .chat-message-content.chat-message-content--attachment-only {
    --attachment-radius-tl: 18px;
    --attachment-radius-tr: 0;
    --attachment-radius-br: 6px;
    --attachment-radius-bl: 18px;
}

.chat-message-bot.chat-message-cluster-only .chat-message-content.chat-message-content--attachment-only,
.chat-message-bot.chat-message-first-after-system.chat-message-cluster-only .chat-message-content.chat-message-content--attachment-only {
    --attachment-radius-tl: 18px;
    --attachment-radius-tr: 18px;
    --attachment-radius-br: 18px;
    --attachment-radius-bl: 0;
}

.chat-message-bot.chat-message-cluster-first .chat-message-content.chat-message-content--attachment-only,
.chat-message-bot.chat-message-first-after-system.chat-message-cluster-first .chat-message-content.chat-message-content--attachment-only {
    --attachment-radius-tl: 18px;
    --attachment-radius-tr: 18px;
    --attachment-radius-br: 18px;
    --attachment-radius-bl: 0;
}

.chat-message-bot.chat-message-cluster-middle .chat-message-content.chat-message-content--attachment-only,
.chat-message-bot.chat-message-first-after-system.chat-message-cluster-middle .chat-message-content.chat-message-content--attachment-only {
    --attachment-radius-tl: 0;
    --attachment-radius-tr: 18px;
    --attachment-radius-br: 18px;
    --attachment-radius-bl: 0;
}

.chat-message-bot.chat-message-cluster-last .chat-message-content.chat-message-content--attachment-only,
.chat-message-bot.chat-message-first-after-system.chat-message-cluster-last .chat-message-content.chat-message-content--attachment-only {
    --attachment-radius-tl: 0;
    --attachment-radius-tr: 18px;
    --attachment-radius-br: 18px;
    --attachment-radius-bl: 0;
}

.chat-message-user .chat-message-content.chat-message-content--attachment-only:has(.chat-message-delivery-footer) .chat-message-delivery-footer {
    position: absolute;
    right: 10px;
    bottom: 10px;
    margin-top: 0;
    padding: 4px 6px;
    border-radius: 999px;
    background: rgba(26, 26, 26, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.chat-message-user .chat-message-content.chat-message-content--attachment-only:has(.chat-message-delivery-footer) {
    align-items: flex-end !important;
}

.chat-message-user .chat-message-content.chat-message-content--attachment-only:has(.chat-message-delivery-footer) .chat-message-delivery-status {
    color: rgba(255, 255, 255, 0.95);
}

.chat-message-user .chat-message-content.chat-message-content--attachment-only:has(.chat-message-delivery-footer) .chat-message-delivery-status--read {
    color: #7dd3fc;
}

.chat-attachment-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.08);
    color: #1a1a1a;
}

.chat-attachment-icon.image {
    background: #d1e7dd;
    color: #0f5132;
}

.chat-attachment-icon.video {
    background: #cfe2ff;
    color: #084298;
}

.chat-attachment-icon.pdf {
    background: #f8d7da;
    color: #842029;
}

.chat-attachment-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.chat-attachment-info {
    flex: 1;
    min-width: 0;
}

.chat-attachment-name {
    font-size: 13px;
    font-weight: 500;
    color: inherit;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attachment-size {
    font-size: 11px;
    opacity: 0.7;
}

.chat-attachment-download {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-message-attachment--previewable:hover {
    border-color: rgba(99, 102, 241, 0.28);
    background: rgba(99, 102, 241, 0.06);
}

.chat-attachment-open {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
}

.chat-attachment-document-preview {
    position: relative;
    display: block;
    width: min(100%, 320px);
    margin-top: 6px;
    border: 1px solid rgba(26, 26, 26, 0.1);
    border-radius: 18px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(26, 26, 26, 0.12);
    max-width: 100%;
}

.chat-attachment-document-preview-body {
    position: relative;
    display: block;
    cursor: pointer;
    background: #f8fafc;
}

.chat-attachment-document-preview-frame {
    display: block;
    width: 100%;
    height: 280px;
    border: none;
    background: #ffffff;
}

.chat-attachment-document-preview--pdf {
    width: min(100%, 320px);
}

.chat-attachment-document-preview-body--pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: #1f2937;
}

.chat-pdf-preview-stage {
    width: 100%;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-pdf-preview-canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(26, 26, 26, 0.25);
    background: #ffffff;
}

.chat-pdf-preview-loading,
.chat-pdf-preview-error {
    width: 100%;
    border-radius: 12px;
    padding: 16px 14px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.96);
    color: #1a1a1a;
}

.chat-pdf-preview-error {
    color: #991b1b;
    background: #fef2f2;
}

.chat-attachment-document-preview-frame--browser {
    width: 100%;
    height: 260px;
}

.chat-attachment-document-preview-footer {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(26, 26, 26, 0.08);
}

/* PDF: nur Titel + Größe + zwei Aktionen unter der Vorschau */
.chat-attachment-document-preview-footer--pdf {
    align-items: center;
}

.chat-attachment-document-preview-main--pdf {
    gap: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.chat-attachment-document-preview-footer--pdf .chat-attachment-info {
    min-width: 0;
}

.chat-attachment-document-preview-footer--pdf .chat-attachment-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attachment-document-preview-footer--pdf .chat-attachment-size {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

/* App-Standard Dunkelgrau (z. B. Sektions-Kreise in chat.css: #1a1a1a), kein Slate-Blau */
.chat-attachment-document-preview-footer--pdf .chat-attachment-doc-action-btn,
.chat-attachment-document-preview-footer--pdf a.chat-attachment-open.chat-attachment-doc-action-btn,
.chat-attachment-document-preview-footer--pdf a.chat-attachment-download.chat-attachment-doc-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a1a1a !important;
    border: none !important;
    color: #ffffff !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.12s ease;
}

.chat-attachment-document-preview-footer--pdf .chat-attachment-doc-action-btn:hover,
.chat-attachment-document-preview-footer--pdf a.chat-attachment-open.chat-attachment-doc-action-btn:hover,
.chat-attachment-document-preview-footer--pdf a.chat-attachment-download.chat-attachment-doc-action-btn:hover {
    background: #1a1a1a !important;
    color: #ffffff !important;
}

.chat-attachment-document-preview-footer--pdf .chat-attachment-doc-action-btn:active {
    transform: scale(0.96);
}

body.dark-mode .chat-attachment-document-preview-footer--pdf .chat-attachment-size {
    color: rgba(226, 232, 240, 0.72);
}

body.dark-mode .chat-attachment-document-preview-footer--pdf {
    background: rgba(26, 26, 26, 0.96);
    border-top-color: rgba(148, 163, 184, 0.12);
}

body.dark-mode .chat-attachment-document-preview-footer--pdf .chat-attachment-name {
    color: #f1f5f9;
}

body.dark-mode .chat-attachment-document-preview-footer--pdf .chat-attachment-doc-action-btn,
body.dark-mode .chat-attachment-document-preview-footer--pdf a.chat-attachment-open.chat-attachment-doc-action-btn,
body.dark-mode .chat-attachment-document-preview-footer--pdf a.chat-attachment-download.chat-attachment-doc-action-btn {
    background: #1a1a1a !important;
    color: #ffffff !important;
}

body.dark-mode .chat-attachment-document-preview-footer--pdf .chat-attachment-doc-action-btn:hover,
body.dark-mode .chat-attachment-document-preview-footer--pdf a.chat-attachment-open.chat-attachment-doc-action-btn:hover,
body.dark-mode .chat-attachment-document-preview-footer--pdf a.chat-attachment-download.chat-attachment-doc-action-btn:hover {
    background: #1a1a1a !important;
    color: #ffffff !important;
}

.chat-attachment-document-preview-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.chat-attachment-document-preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .chat-attachment-document-preview {
        width: min(100%, 260px, calc(100vw - 156px));
        max-width: calc(100vw - 156px);
    }

    .chat-attachment-document-preview-frame {
        height: 240px;
    }

    .chat-attachment-document-preview--pdf {
        width: min(100%, 260px, calc(100vw - 156px));
        max-width: calc(100vw - 156px);
    }

    .chat-attachment-document-preview-body--pdf {
        padding: 8px;
    }

    .chat-attachment-document-preview-footer {
        align-items: flex-start;
    }

    .chat-attachment-document-preview-main {
        min-width: 0;
    }
}

/* ============================================
   Drag & Drop Overlay
   ============================================ */

.chat-drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 26, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.chat-drag-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.chat-drag-content {
    text-align: center;
    color: white;
}

.chat-drag-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.chat-drag-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.chat-drag-hint {
    font-size: 14px;
    opacity: 0.8;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

/* ============================================
   AI Mode Overrides
   ============================================ */

.chat-popup.ai-mode .chat-send-btn {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
}

.chat-popup.ai-mode .chat-send-btn:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%) !important;
}

.chat-popup.ai-mode .chat-send-btn:disabled {
    background: #ddd6fe !important;
    color: #9ca3af !important;
}

.chat-popup.ai-mode .chat-input-wrapper:focus-within {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

/* ============================================
   Loading States
   ============================================ */

.chat-file-uploading {
    position: relative;
    overflow: hidden;
}

.chat-file-uploading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    to {
        left: 100%;
    }
}

/* ============================================
   Accessibility
   ============================================ */

.chat-attachment-btn:focus,
.chat-camera-inline-btn:focus,
.chat-voice-btn:focus,
.chat-send-btn:focus,
.chat-voice-play-btn:focus {
    outline: none;
}

/* Reduced motion */
/* ============================================
   Image Modal for Chat
   ============================================ */

.chat-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-image-modal.active {
    display: flex;
    opacity: 1;
}

.chat-image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
}

.chat-image-modal-container {
    position: relative;
    width: 90%;
    max-width: 1200px;
    height: 90%;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.chat-image-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.chat-image-modal-img {
    max-width: 100%;
    max-height: calc(100% - 80px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.chat-image-modal-info {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: white;
}

.chat-image-modal-counter {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.9;
}

.chat-image-modal-name {
    font-size: 13px;
    opacity: 0.7;
    max-width: 600px;
    text-align: center;
    word-break: break-word;
}

.chat-image-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.2s;
}

.chat-image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.chat-image-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.2s;
}

.chat-image-modal-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.chat-image-modal-prev {
    left: 20px;
}

.chat-image-modal-next {
    right: 20px;
}

/* ============================================
   Story View Screen
   ============================================ */

.chat-story-view {
    display: none; /* Hidden by default */
    flex: 1; /* Nimmt verfügbaren Platz ein (wie Story-Creation) */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.95);
    position: relative;
    z-index: 3000;
}

/* Inline unter der Story-Reihe (kein Overlay): nimmt Restplatz im Panel ein */
.chat-story-view-inline {
    flex: 1;
    min-height: 0;
    z-index: 0;
    border-radius: 12px;
    overflow: hidden;
}

.chat-story-view-inline .chat-story-view-header {
    position: relative;
    padding: 10px 12px;
}

.chat-story-view-inline .chat-story-view-content {
    padding: 12px 16px 80px;
}

.chat-story-view-inline .chat-story-view-close {
    top: 12px;
    right: 12px;
}

.chat-story-view-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    z-index: 3001;
}

.chat-story-progress-container {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ============================================================================
   STORY PROGRESS BARS - NEU GESCHRIEBEN
   ============================================================================ */

/* Base Progress Bar (alle States) */
.chat-story-progress-bar {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.2s ease;
    position: relative;
    overflow: hidden;
}

.chat-story-progress-bar:hover {
    opacity: 0.8;
}

/* PENDING State: Stories die noch nicht erreicht wurden (0%) */
.chat-story-progress-bar.pending {
    background: rgba(255, 255, 255, 0.3);
}

/* COMPLETED State: Stories die bereits abgeschlossen sind (100%) */
.chat-story-progress-bar.completed {
    background: rgba(255, 255, 255, 0.9);
}

/* ACTIVE State: Story die gerade angezeigt wird (animiert 0% → 100%) */
.chat-story-progress-bar.active {
    background: rgba(255, 255, 255, 0.3);
}

.chat-story-progress-bar.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.9);
    animation: storyProgress var(--story-duration, 5s) linear forwards;
}

/* PAUSED State: Animation wird pausiert */
.chat-story-progress-bar.active.paused::after {
    animation-play-state: paused;
}

@keyframes storyProgress {
    to {
        width: 100%;
    }
}

/* Legacy: .viewed für Kompatibilität (wird nicht mehr verwendet) */
.chat-story-progress-bar.viewed {
    background: rgba(255, 255, 255, 0.6);
}

.chat-story-view-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3001;
    transition: all 0.2s ease;
}

.chat-story-view-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.chat-story-view-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px 120px 20px;
    box-sizing: border-box;
}

.chat-story-media-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 600px;
    width: 100%;
    position: relative;
}

/* ============================================================================
   NAVIGATION ICONS - ZENTRIERT IN IHREN BEREICHEN
   Back (0-30%), Pause (30-70%), Forward (70-100%)
   ============================================================================ */

/* Pause Icon (Mitte des Pause-Bereichs = 50% des Screens) */
.chat-story-pause-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    pointer-events: none;
    animation: fadeInPulse 0.3s ease-out;
}

/* Back Icon (Mitte des Back-Bereichs = 15% des Screens) */
.chat-story-back-icon {
    position: absolute;
    top: 50%;
    left: 15%; /* Mitte von 0-30% = 15% */
    transform: translate(-50%, -50%);
    z-index: 100;
    pointer-events: none;
    animation: slideInFromLeft 0.3s ease-out;
}

/* Forward Icon (Mitte des Forward-Bereichs = 85% des Screens) */
.chat-story-forward-icon {
    position: absolute;
    top: 50%;
    left: 85%; /* Mitte von 70-100% = 85% */
    transform: translate(-50%, -50%);
    z-index: 100;
    pointer-events: none;
    animation: slideInFromRight 0.3s ease-out;
}

/* Animations */
@keyframes fadeInPulse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes slideInFromLeft {
    0% {
        opacity: 0;
        transform: translate(-150%, -50%) scale(0.8);
    }
    60% {
        transform: translate(-45%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes slideInFromRight {
    0% {
        opacity: 0;
        transform: translate(50%, -50%) scale(0.8);
    }
    60% {
        transform: translate(-55%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.chat-story-media {
    max-width: 100%;
    max-height: calc(100vh - 250px);
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.chat-story-caption {
    margin-top: 16px;
    color: white;
    font-size: 16px;
    text-align: center;
    max-width: 600px;
    line-height: 1.5;
    padding: 0 20px;
}

.chat-story-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(10px);
    padding: 0px 10px 16px 10px;
    display: flex;
    flex-direction: column;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Persistent Reactions Container - Above reaction button, outside story */
.chat-story-persistent-reactions {
    position: absolute;
    bottom: 80px; /* Further away from the reaction button */
    left: 10px; /* Aligned with the reaction button */
    display: flex;
    flex-direction: column; /* Stack vertically */
    gap: 4px; /* Small gap between stacked reactions */
    z-index: 10;
    pointer-events: none; /* Don't block clicks */
    align-items: flex-start;
    justify-content: flex-end;
}

.chat-story-persistent-reaction {
    font-size: 32px;
    line-height: 1;
    display: block; /* Block instead of inline-block for better vertical stacking */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    animation: reactionAppear 0.3s ease-out;
    pointer-events: none;
    margin-bottom: 2px; /* Small margin to prevent tight stacking */
}

@keyframes reactionAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.reaction-appear {
    animation: reactionAppear 0.3s ease-out;
}

/* ============================================================================
   STORY REACTIONS & REPLY - INNERHALB DER INPUT-BAR
   ============================================================================ */

/* Emoji Picker (erscheint über der Input-Bar) */
.chat-story-reaction-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px;
    background: rgba(0, 0, 0, 0);
    border-radius: 12px;
    justify-content: center;
}

.chat-story-emoji-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-story-emoji-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.2);
}

/* Reply Container (Input-Bar mit allen Buttons INNERHALB) */
.chat-story-reply-container {
    display: flex;
    gap: 0;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    padding: 4px;
    transition: all 0.2s ease;
}

.chat-story-reply-container:focus-within {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Reaction Button (LINKS INNERHALB der Input-Bar) */
.chat-story-reaction-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.chat-story-reaction-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-story-reaction-preview {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Input Field (MITTE der Input-Bar) */
.chat-story-reply-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 12px;
    color: white;
    font-size: 14px;
    outline: none;
}

.chat-story-reply-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Send Button (RECHTS INNERHALB der Input-Bar) */
.chat-story-reply-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-story-reply-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(52, 58, 64, 0.4);
}

/* Flying emoji animation */
.flying-emoji {
    position: absolute;
    font-size: 32px;
    pointer-events: none;
    z-index: 10000;
    will-change: transform, opacity;
    user-select: none;
}

/* ============================================
   Story Creation Menu
   ============================================ */

/* ============================================================================
   PERSONAL CHAT SETTINGS MENU
   ============================================================================ */

.chat-nav-settings {
    position: relative;
}

/* Chat Settings Panel - Sidebar style, appears to the right of navigation */
.chat-settings-panel {
    position: relative;
    flex: 1;
    min-width: 0;
    background: #ffffff;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
}

.chat-settings-panel[style*="display: none"] {
    flex: 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    border-right: none;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

/* Settings as dedicated section: when popup has view-settings, show panel and collapse content wrapper */
.chat-popup.active.view-settings .chat-settings-panel,
.chat-popup.active.view-settings #chatSettingsMenu {
    display: flex !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    visibility: visible !important;
}
.chat-popup.active.view-settings .chat-popup-content-wrapper {
    flex: 0 0 0 !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

.chat-settings-menu {
    position: absolute;
    left: calc(100% + 12px);
    top: 0;
    width: 400px;
    min-height: 44px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.08);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.chat-settings-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Settings Panel Header */
.chat-settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    min-height: 60px;
    border-bottom: 1px solid #e9ecef;
    background: #ffffff;
    flex-shrink: 0;
}

.chat-settings-panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.chat-settings-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    transition: all 0.2s ease;
    border-radius: 8px;
    width: 36px;
    height: 36px;
}

.chat-settings-panel-close:hover {
    color: #1a1a1a;
    background: #f8f9fa;
}

.chat-settings-panel-close svg {
    width: 20px;
    height: 20px;
}

.chat-settings-panel-content {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.chat-settings-panel-content::-webkit-scrollbar {
    width: 6px;
}

.chat-settings-panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.chat-settings-panel-content::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.chat-settings-panel-content::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

.chat-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    min-height: 44px;
    border-bottom: 1px solid #f0f0f0;
    background: #ffffff;
    flex-shrink: 0;
}

.chat-settings-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.chat-settings-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    transition: all 0.2s ease;
    border-radius: 8px;
    width: 32px;
    height: 32px;
}

.chat-settings-close:hover {
    color: #1a1a1a;
    background: #f8f9fa;
    transform: rotate(90deg);
}

.chat-settings-close svg {
    width: 18px;
    height: 18px;
}

.chat-settings-content {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.chat-settings-content::-webkit-scrollbar {
    width: 6px;
}

.chat-settings-content::-webkit-scrollbar-track {
    background: transparent;
}

.chat-settings-content::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 3px;
}

.chat-settings-content::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

.chat-settings-section {
    padding: 16px 12px;
    border-bottom: 1px solid #f8f9fa;
}

.chat-settings-section:last-child {
    border-bottom: none;
}

.chat-settings-section h3 {
    margin: 0 0 16px 0;
    font-size: 12px;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.chat-settings-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.chat-settings-option:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.chat-settings-option-label {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    flex: 1;
}

.chat-settings-option input[type="checkbox"] {
    width: 44px;
    height: 24px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background: #dee2e6;
    border-radius: 12px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-settings-option input[type="checkbox"]:checked {
    background: #1a1a1a;
}

.chat-settings-option input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chat-settings-option input[type="checkbox"]:checked::before {
    left: 22px;
}

.chat-settings-option-full {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 10px;
}

.chat-settings-option-full label {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    display: flex;
    align-items: center;
}

.chat-settings-option-full label svg {
    color: #6c757d;
}

.chat-settings-device-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-settings-device-row .chat-settings-select {
    flex: 1;
}

.chat-settings-test-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #ffffff;
    border: 2px solid #dee2e6;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-settings-test-btn:hover {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #ffffff;
    transform: scale(1.05);
}

.chat-settings-test-btn:active {
    transform: scale(0.95);
}

.chat-settings-test-btn.testing {
    background: #28a745;
    border-color: #28a745;
    color: #ffffff;
    animation: pulse-test 1s infinite;
}

@keyframes pulse-test {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

.chat-settings-audio-level {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.chat-settings-audio-level-bar {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #ffc107 70%, #dc3545 100%);
    width: 0%;
    transition: width 0.1s ease;
    border-radius: 4px;
}

.chat-settings-select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    background: #ffffff;
    cursor: pointer;
    font-weight: 500;
    color: #1a1a1a;
    transition: all 0.2s ease;
}

.chat-settings-select:hover {
    border-color: #1a1a1a;
}

.chat-settings-select:focus {
    outline: none;
    border-color: #1a1a1a;
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.1);
}

.chat-settings-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    resize: vertical;
    min-height: 80px;
    color: #1a1a1a;
    transition: all 0.2s ease;
}

.chat-settings-textarea:hover {
    border-color: #1a1a1a;
}

.chat-settings-textarea:focus {
    outline: none;
    border-color: #1a1a1a;
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.1);
}

.chat-settings-textarea::placeholder {
    color: #adb5bd;
}

/* Story Creation - Ersetzt Kontakte/Chat rechts neben Story-Leiste */
.chat-story-creation {
    display: none; /* Hidden by default, shown via JS */
    flex: 1; /* Nimmt verfügbaren Platz ein */
    flex-direction: column;
    background: #ffffff;
    border-left: 1px solid #e9ecef;
    position: relative;
    overflow: hidden;
}

.chat-story-creation-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
}

.chat-story-creation-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.chat-story-creation-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-story-creation-close:hover {
    background: #e9ecef;
    color: #1a1a1a;
}

.chat-story-creation-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 80px; /* Space for fixed buttons at bottom */
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.chat-story-creation-upload {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-story-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.chat-story-upload-area:hover {
    border-color: #1a1a1a;
    background: #f0f4ff;
}

.chat-story-upload-area svg {
    color: #6c757d;
    margin-bottom: 12px;
}

.chat-story-upload-area p {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}

.chat-story-upload-area span {
    font-size: 13px;
    color: #6c757d;
}

.chat-story-preview {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    max-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
}

.chat-story-preview img,
.chat-story-preview video {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.chat-story-preview-remove {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-story-preview-remove:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.chat-story-creation-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-story-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-story-form-group label {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}

.chat-story-form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-story-form-group textarea:focus {
    border-color: #1a1a1a;
}

.chat-story-creation-actions {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 1000;
    /* Responsive sizing based on chatbox size (1000x600px) */
    padding: 0;
}

.chat-story-cancel-btn,
.chat-story-publish-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    min-width: 120px;
    /* Responsive sizing - adjust based on chatbox dimensions (1000x600px) */
    white-space: nowrap;
    box-sizing: border-box;
}

/* Responsive button sizing for smaller chatbox */
.chat-story-cancel-btn {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.chat-story-cancel-btn:hover {
    background: #e9ecef;
    color: #1a1a1a;
}

.chat-story-publish-btn {
    background: linear-gradient(135deg, #1a1a1a 0%, #1a1a1a 100%);
    color: white;
}

.chat-story-publish-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 58, 64, 0.4);
}

.chat-story-publish-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   Chat Message Context Menu (Right Click)
   ============================================ */

.chat-message-context-menu {
    position: fixed;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 6px;
    z-index: 100120 !important;
    min-width: 160px;
    animation: contextMenuFadeIn 0.15s ease;
    pointer-events: auto;
    overflow: hidden;
}

@media (max-width: 768px) {
    .chat-message-context-menu.chat-message-context-menu--mobile {
        min-width: min(320px, calc(100vw - 24px));
        max-width: calc(100vw - 24px);
        border-radius: 22px;
        box-shadow: 0 14px 40px rgba(26, 26, 26, 0.22);
        padding: 8px;
    }

    .chat-message-context-menu.chat-message-context-menu--mobile .context-menu-item {
        min-height: 50px;
        padding: 12px 14px;
        font-size: 15px;
    }
}

.chat-message-context-reactions {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 8px;
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.chat-message-context-reaction-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 999px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: background 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-message-context-reaction-btn:hover {
    background: #f8fafc;
    transform: scale(1.08);
}

.chat-message-context-reaction-btn:active {
    transform: scale(1.02);
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    min-height: 44px;
    box-sizing: border-box;
    border: none;
    background: transparent;
    color: #1a1a1a;
    font-size: 14px;
    cursor: pointer;
    border-radius: 14px;
    transition: background 0.15s ease;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.context-menu-item:hover {
    background: #f8f9fa;
}

.context-menu-item:active {
    background: #e9ecef;
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #6c757d;
}

.context-menu-item:hover svg {
    color: #1a1a1a;
}

.context-menu-item span {
    flex: 1;
}

.context-menu-item.context-menu-item-danger {
    color: #dc3545;
}

.context-menu-item.context-menu-item-danger svg {
    color: #dc3545;
}

.context-menu-item.context-menu-item-danger:hover,
.context-menu-item.context-menu-item-danger:active {
    background: #fff1f2;
    color: #b91c1c;
}

.context-menu-item.context-menu-item-danger:hover svg,
.context-menu-item.context-menu-item-danger:active svg {
    color: #b91c1c;
}

/* Call Buttons in Chat Header */
.chat-call-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.chat-call-btn {
    width: var(--chat-header-avatar-size, 40px);
    height: var(--chat-header-avatar-size, 40px);
    min-width: var(--chat-header-avatar-size, 40px);
    min-height: var(--chat-header-avatar-size, 40px);
    border-radius: 50%;
    background: #f8f9fa;
    border: none;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-call-btn:hover {
    background: #1a1a1a;
    color: #ffffff;
    transform: scale(1.05);
}

.chat-call-btn:active {
    transform: scale(0.95);
}

.chat-call-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.chat-call-btn.rejoin-call {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    color: white !important;
    border-radius: 9999px !important; /* Fully rounded pill shape */
    padding: 8px 16px !important;
    width: auto !important;
    min-width: 120px;
    height: auto !important;
    gap: 8px;
    flex-direction: row !important;
    align-items: center !important;
}

.chat-call-btn.rejoin-call svg {
    flex-shrink: 0;
}

.chat-call-btn.rejoin-call:hover {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

.chat-call-btn.rejoin-call svg path {
    fill: currentColor;
}

.chat-call-btn.rejoin-call .reconnect-text {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

/* Mobile Responsive for Call Buttons */
/* Call View - Inside Chat; füllt #chatMain, Gradient-Hintergrund immer sichtbar */
.chat-call-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 100%;
    /* Fallback-Hintergrund falls Container nicht sichtbar ist */
    background: linear-gradient(165deg, hsl(240, 32%, 28%) 0%, hsl(280, 36%, 20%) 50%, hsl(265, 28%, 14%) 100%);
    z-index: 100;
    display: none;
}

.chat-call-view.active {
    display: flex;
    /* Über Header-Insel (Sticky z-index 10) und Kanten-Fades */
    z-index: 120 !important;
}

.chat-call-view.active .chat-call-container {
    min-height: 100%;
}

/* Wenn Call-View aktiv: #chatMain mit Anruf-Hintergrund (kein Weiß) */
.chat-popup-content-wrapper #chatMain.chat-call-view-visible,
.chat-popup-content-wrapper #chatMain:has(.chat-call-view.active) {
    background: #1a202c !important;
}

/* Keine weißen Kanten-Fades über dem Vollbild-Anruf */
.chat-popup-content-wrapper #chatMain.chat-call-view-visible::before,
.chat-popup-content-wrapper #chatMain.chat-call-view-visible::after,
.chat-popup-content-wrapper #chatMain:has(.chat-call-view.active)::before,
.chat-popup-content-wrapper #chatMain:has(.chat-call-view.active)::after {
    opacity: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
}

/* Anruf-Container: Gradient-Hintergrund (wird von JS dynamisch angepasst) */
.chat-call-view.active .chat-call-container,
.chat-call-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    --chat-call-pip-bottom-offset: 72px; /* Oberkante Control-Bar (16 + 8+40+8), PiP sitzt direkt darüber */
    --call-bg-hue: 240;
    --call-bg-hue2: 280;
    --call-bg-pulse: 0;
    --call-bg-sat: 32;
    --call-bg-angle: 165deg;
    --call-bg-lightness: 28;
    background: linear-gradient(var(--call-bg-angle),
        hsl(var(--call-bg-hue), var(--call-bg-sat), var(--call-bg-lightness)) 0%,
        hsl(var(--call-bg-hue2), calc(var(--call-bg-sat) + 4), calc(var(--call-bg-lightness) - 8)) 50%,
        hsl(calc(var(--call-bg-hue) + 25), calc(var(--call-bg-sat) - 4), 14%) 100%) !important;
    transition: background 0.25s ease;
}

/* Remote-Video: füllt den gesamten Anruf-Bereich; transparenter Hintergrund damit Gradient sichtbar bleibt */
.chat-call-remote-video {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: transparent;
    z-index: 1;
}

/* Eigene Kamera-Vorschau im Haupt-Video (bis Gegenüber antwortet): wie Spiegelselfie */
.chat-call-remote-video.chat-call-remote-self-preview {
    transform: scaleX(-1);
}

/* Lokales Video: 16:9, frei ziehbar, beim Loslassen Snap in die nächste Ecke (alle Ecken mit top/left für Animation) */
.chat-call-local-video-wrapper {
    --chat-call-pip-w: 160px;
    --chat-call-pip-h: 90px; /* 16:9 */
    display: none;
    position: absolute;
    width: var(--chat-call-pip-w);
    height: var(--chat-call-pip-h);
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.4);
    z-index: 10;
    cursor: move;
    transition: top 0.22s ease-out, left 0.22s ease-out;
}
.chat-call-local-video-wrapper.visible {
    display: block !important;
}
/* Alle Ecken mit top/left, damit die Snap-Animation in jede Richtung läuft (nicht nur TL) */
.chat-call-local-video-wrapper.chat-call-local-corner-tl { top: 16px;  left: 16px;  right: auto; bottom: auto; }
.chat-call-local-video-wrapper.chat-call-local-corner-tr { top: 16px;  left: calc(100% - 16px - var(--chat-call-pip-w)); right: auto; bottom: auto; }
.chat-call-local-video-wrapper.chat-call-local-corner-bl { top: calc(100% - var(--chat-call-pip-bottom-offset, 72px) - var(--chat-call-pip-h)); left: 16px;  right: auto; bottom: auto; }
.chat-call-local-video-wrapper.chat-call-local-corner-br { top: calc(100% - var(--chat-call-pip-bottom-offset, 72px) - var(--chat-call-pip-h)); left: calc(100% - 16px - var(--chat-call-pip-w)); right: auto; bottom: auto; }

.chat-call-local-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #2a2a2a;
    display: block;
    pointer-events: none;
}
.chat-call-local-video-wrapper.dragging {
    transition: none;
}

.chat-call-info-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
    z-index: 5; /* unter der Kamera-PiP (10), damit Avatar/Name/Timer hinter dem Kamerafenster liegen */
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}
.chat-call-info-overlay .chat-call-contact-info {
    pointer-events: auto;
}

/* Einziger Teil über der Kamera: Minimize-Button (direkt im Container, hoher z-index) */
.chat-call-minimize-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    z-index: 20; /* über Kamera-PiP (10), nur dieser Button bleibt sichtbar/klickbar darüber */
}

.chat-call-minimize-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

.chat-call-minimize-btn:active {
    transform: scale(0.95);
}

.chat-call-minimize-btn svg {
    width: 28px;
    height: 28px;
}

.chat-call-contact-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 64px; /* Abstand zum Minimize-Button */
}

.chat-call-contact-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Rotes Stumm-Mikrofon auf Avatar, wenn die andere Person stumm ist */
.chat-call-avatar-mute-icon {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #dc3545;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.chat-call-avatar-mute-icon svg {
    width: 24px;
    height: 24px;
}

.chat-call-contact-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-call-contact-name {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.chat-call-status {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.chat-call-timer {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    margin-top: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.chat-call-controls {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border-radius: 999px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
    z-index: 20; /* über Info-Overlay (15), damit Mikro/Kamera/Auflegen immer klickbar sind */
}

.chat-call-control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.chat-call-control-btn svg {
    width: 18px;
    height: 18px;
}

.chat-call-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
}

.chat-call-control-btn:active {
    transform: scale(0.95);
}

.chat-call-control-btn.active {
    background: #ffc107;
}

.chat-call-control-btn.muted {
    background: #dc3545;
}

.chat-call-end-btn {
    background: #dc3545 !important;
}

.chat-call-end-btn:hover {
    background: #c82333 !important;
    transform: scale(1.08);
}

/* ========== Sprach- vs. Videoanruf: unterschiedliches Layout ========== */

/* Videoanruf: Gegenseite füllt den gesamten Bereich; eigenes Bild nur als PiP wenn Kamera an */
.chat-call-container.video-call .chat-call-remote-video {
    display: block;
}
.chat-call-container.video-call .chat-call-local-video-wrapper.visible .chat-call-local-video {
    display: block;
}
.chat-call-container.video-call .chat-call-info-overlay {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
    flex-direction: column;
    align-items: flex-start;
}

/* Sprachanruf: großer Avatar in der Mitte, gleicher Morpheffekt wie Videoanruf */
.chat-call-container.voice-call {
    background: linear-gradient(var(--call-bg-angle),
        hsl(var(--call-bg-hue), var(--call-bg-sat), calc(var(--call-bg-lightness) + 2)) 0%,
        hsl(var(--call-bg-hue2), calc(var(--call-bg-sat) + 4), calc(var(--call-bg-lightness) - 6)) 50%,
        hsl(calc(var(--call-bg-hue) + 25), calc(var(--call-bg-sat) - 4), 16%) 100%);
}
.chat-call-container.voice-call .chat-call-remote-video,
.chat-call-container.voice-call .chat-call-local-video-wrapper:not(.visible) {
    display: none !important;
}
.chat-call-container.voice-call .chat-call-info-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0;
    background: transparent;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-left: 0;
}
.chat-call-container.voice-call .chat-call-contact-info {
    flex-direction: column;
    margin-left: 0;
    gap: 16px;
}
.chat-call-container.voice-call .chat-call-contact-avatar {
    width: 120px;
    height: 120px;
    font-size: 48px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.chat-call-container.voice-call .chat-call-avatar-mute-icon svg {
    width: 48px;
    height: 48px;
}
.chat-call-container.voice-call .chat-call-contact-details {
    align-items: center;
    text-align: center;
}
.chat-call-container.voice-call .chat-call-contact-name {
    font-size: 22px;
}
.chat-call-container.voice-call .chat-call-status,
.chat-call-container.voice-call .chat-call-timer {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.85);
}
.chat-call-container.voice-call .chat-call-minimize-btn {
    top: 12px;
    left: 12px;
}

/* Incoming Call Modal */
.incoming-call-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.incoming-call-container {
    background: #ffffff;
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.incoming-call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    margin: 0 auto 24px;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(99, 102, 241, 0);
    }
}

.incoming-call-name {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.incoming-call-type {
    font-size: 16px;
    color: #6c757d;
    margin-bottom: 32px;
}

.incoming-call-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.incoming-call-decline-btn,
.incoming-call-accept-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 32px;
    border-radius: 50px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.incoming-call-decline-btn {
    background: #dc3545;
    color: #ffffff;
}

.incoming-call-decline-btn:hover {
    background: #c82333;
    transform: scale(1.05);
}

.incoming-call-accept-btn {
    background: #28a745;
    color: #ffffff;
}

.incoming-call-accept-btn:hover {
    background: #218838;
    transform: scale(1.05);
}

/* Responsive Call UI */
/* Responsive Chat Settings */
/* ============================================
   Incoming Call Popup (Draggable) – Redesign
   ============================================ */

.incoming-call-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    max-width: 92vw;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.06);
    z-index: 2147483647 !important;
    animation: incomingCallPopupIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes incomingCallPopupIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.incoming-call-header {
    background: linear-gradient(180deg, #f5f5f7 0%, #ebebed 100%);
    border-bottom: 1px solid #e5e5e7;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: move;
    user-select: none;
}

.incoming-call-drag-icon {
    color: #8e8e93;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: grab;
}

.incoming-call-header:active .incoming-call-drag-icon {
    cursor: grabbing;
}

.incoming-call-title {
    color: #3a3a3c;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.incoming-call-content {
    padding: 28px 20px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.incoming-call-avatar-wrapper {
    position: relative;
    width: 88px;
    height: 88px;
}

.incoming-call-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: linear-gradient(145deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.35);
    position: relative;
    z-index: 2;
}

.incoming-call-pulse {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(102, 126, 234, 0.35);
    animation: callPulse 2.2s ease-out infinite;
}

@keyframes callPulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

.incoming-call-name {
    color: #1d1d1f;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin: 0;
    line-height: 1.2;
}

.incoming-call-type {
    color: #86868b;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.incoming-call-type svg {
    flex-shrink: 0;
    animation: callRing 1.5s ease-in-out infinite;
}

@keyframes callRing {
    0%, 100% { transform: rotate(0deg); }
    15%, 35% { transform: rotate(-12deg); }
    25%, 45% { transform: rotate(12deg); }
    55% { transform: rotate(0deg); }
}

.incoming-call-actions {
    display: flex;
    gap: 20px;
    margin-top: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.incoming-call-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
}

.incoming-call-btn:hover {
    transform: scale(1.06);
}

.incoming-call-btn:active {
    transform: scale(0.96);
}

.incoming-call-btn.decline-btn {
    background: #ff3b30;
    color: #fff;
    box-shadow: 0 4px 14px rgba(255, 59, 48, 0.35);
}

.incoming-call-btn.decline-btn:hover {
    background: #e6352b;
    box-shadow: 0 6px 18px rgba(255, 59, 48, 0.4);
}

.incoming-call-btn.accept-btn {
    background: #34c759;
    color: #fff;
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.35);
}

.incoming-call-btn.accept-btn:hover {
    background: #2db84d;
    box-shadow: 0 6px 18px rgba(52, 199, 89, 0.4);
}

.incoming-call-btn svg {
    width: 24px;
    height: 24px;
}

/* Video call actions: decline, video toggle, accept */
.incoming-call-video-actions {
    gap: 18px;
    width: 100%;
    max-width: 280px;
}

/* Video toggle button */
.incoming-call-btn.video-toggle-btn {
    background: #28a745;
    color: white;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25);
    transition: all 0.3s ease;
}

.incoming-call-btn.video-toggle-btn.video-on {
    background: #28a745;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25);
}

.incoming-call-btn.video-toggle-btn.video-on:hover {
    background: #218838;
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.35);
}

.incoming-call-btn.video-toggle-btn.video-off {
    background: #dc3545;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.25);
}

.incoming-call-btn.video-toggle-btn.video-off:hover {
    background: #c82333;
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.35);
}

/* Mobile Responsive */
/* ============================================
   Call Notification Messages & Call Back Button
   ============================================ */

/* System message container - centered pill bar, no avatar */
.chat-message-system {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 0 auto !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    align-self: center !important;
    flex-direction: column !important;
    gap: 0 !important;
}

/* Override any user/bot specific styles */
.chat-message-system.chat-message-user,
.chat-message-system.chat-message-bot {
    align-self: center !important;
    margin-left: auto !important;
    margin-right: auto !important;
    max-width: 100% !important;
}

.chat-message-system .chat-message-wrapper {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 100% !important;
}

.chat-message-system .chat-message-content {
    border-radius: 20px !important;
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    text-align: center !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    display: inline-block !important;
    max-width: fit-content !important;
    margin: 0 auto !important;
    align-self: center !important;
    background: rgba(108, 117, 125, 0.1) !important;
    color: #1a1a1a !important;
    border: none !important;
}

.chat-message-system .chat-message-time {
    display: none !important; /* Hide time for system messages */
}

.chat-message-system .chat-message-actions {
    display: none !important; /* Hide actions for system messages */
}

/* Style for call notification messages - different colors based on status (pill bar style) */
.chat-message-system .chat-call-notification {
    background: rgba(0, 123, 255, 0.12) !important;
    color: #0056b3 !important;
    border: none !important;
}

.chat-message-system .chat-call-connecting {
    background: rgba(0, 123, 255, 0.15) !important;
    color: #0056b3 !important;
    border: none !important;
}

.chat-message-system .chat-call-active {
    background: rgba(40, 167, 69, 0.15) !important;
    color: #1e7e34 !important;
    border: none !important;
}

.chat-message-system .chat-call-ended {
    background: rgba(220, 53, 69, 0.15) !important;
    color: #c82333 !important;
    border: none !important;
}

.chat-message-system .chat-call-declined {
    background: rgba(220, 53, 69, 0.15) !important;
    color: #c82333 !important;
    border: none !important;
}

.chat-message-system .chat-call-missed {
    background: rgba(108, 117, 125, 0.15) !important;
    color: #1a1a1a !important;
    border: none !important;
}

.chat-message-system .chat-deletion-notice {
    background: transparent !important;
    color: #6b7280 !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.chat-message-system .chat-deletion-notice .chat-message-text {
    font-size: 12px !important;
    font-weight: 500 !important;
    color: #6b7280 !important;
    letter-spacing: 0.01em;
}

.chat-message-system .chat-call-notification .chat-message-text,
.chat-message-system .chat-call-connecting .chat-message-text,
.chat-message-system .chat-call-active .chat-message-text,
.chat-message-system .chat-call-ended .chat-message-text,
.chat-message-system .chat-call-declined .chat-message-text,
.chat-message-system .chat-call-missed .chat-message-text,
.chat-message-system .chat-deletion-notice .chat-message-text {
    font-weight: 500 !important;
}

/* Ensure callback button is visible in system messages */
.chat-message-system .chat-callback-btn {
    display: inline-flex !important;
    margin-top: 8px !important;
    width: auto !important;
}

/* Missed call date/time - below message, above callback button */
.chat-missed-call-datetime {
    font-size: 12px;
    color: rgba(0, 0, 0, 0.6);
    margin-top: 6px;
    margin-bottom: 4px;
}
.chat-message-system .chat-missed-call-datetime {
    color: rgba(255, 255, 255, 0.75);
}

/* Call back button */
.chat-callback-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.chat-callback-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1aa179 100%);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.35);
    transform: translateY(-1px);
}

.chat-callback-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.25);
}

.chat-callback-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Mobile responsive for callback button */

/* ============================================
   AI Mode Button – Disabled State (Desktop + Mobile + Chatbox)
   Ausgegraut, nicht klickbar; Gradient-Animation des Icons läuft weiter.
   ============================================ */
.ai-btn-disabled {
    cursor: not-allowed !important;
    opacity: 0.65 !important;
    /* Hover erlaubt, damit Tooltip „In Arbeit“ und Block-Cursor sichtbar sind; Klick wird per onclick="return false;" blockiert */
}
.ai-btn-disabled:hover,
.ai-btn-disabled:active,
.ai-btn-disabled:focus {
    transform: none !important;
    background: inherit !important;
    box-shadow: none !important;
}
/* Desktop: linker Nav-Cluster — kein grauer Kasten (wie Chat / andere Insel-Buttons) */
.left-nav-cluster .nav-item.ai-chat-btn.ai-btn-disabled {
    background: transparent !important;
    color: #64748b !important;
}
/* Chatbox: Button in der Chat-Nav */
.chat-nav-ai.ai-btn-disabled {
    background: #e9ecef !important;
    color: #6c757d !important;
}
/* Mobile Top Nav: AI — Hintergrund siehe mobile-top-nav.css (einheitlich mit anderen Items) */
/* Mobile Bottom Nav: runder AI-Button neben der Chat-Nav */
.mobile-bottom-nav-chat-ai-btn.ai-btn-disabled,
.mobile-bottom-nav-chat-left-action-btn.ai-btn-disabled {
    background: #e9ecef !important;
}
body.dark-mode .left-nav-cluster .nav-item.ai-chat-btn.ai-btn-disabled {
    background: transparent !important;
    color: #94a3b8 !important;
}
body.dark-mode .chat-nav-ai.ai-btn-disabled,
body.dark-mode .mobile-bottom-nav-chat-ai-btn.ai-btn-disabled,
body.dark-mode .mobile-bottom-nav-chat-left-action-btn.ai-btn-disabled {
    background: #1a1a1a !important;
    color: #9ca3af !important;
}
/* ============================================
   Menü-Optik: Feinschliff für Mobile + Desktop
   ============================================ */
/* Chatbox-Nav: kein 1px-Schatten am Front-Layer (erzeugt sonst sichtbare Linien auf rail-back) */
@media (min-width: 1025px) {
    .chat-popup:not(.chat-popup-mobile-fullscreen) .chat-nav-rail-front {
        box-shadow: none;
    }
}
/* Chat-Nav-Buttons: einheitliche Hover-Transition */
.chat-nav-btn:not(.ai-btn-disabled) {
    transition: background-color 0.15s ease, color 0.15s ease;
}
/* Mobile Top Nav: gleiche Pill-Schatten wie .mobile-bottom-nav-island (mobile-top-nav.css) */
@media (max-width: 1024px) {
    .mobile-chat-ai-island,
    .mobile-top-nav-island {
        box-shadow:
            0 2px 12px rgba(0, 0, 0, 0.08),
            0 2px 8px rgba(0, 0, 0, 0.04),
            inset 0 1px 0 rgba(255, 255, 255, 0.85);
    }
}
