/**
 * Chat content area: alles rechts von der Nav-Bar der Chatbox.
 * Gilt für Desktop und Mobile – eine konsistente Layout-Logik, damit
 * Chat-Section, Neue Kontakte und Konversation immer korrekt angezeigt werden.
 */

/* ========== Wrapper rechts der Nav ========== */
.chat-popup.active .chat-popup-content-wrapper {
    display: flex !important;
    flex-direction: row !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    background: #ffffff !important;
}

/* Vertikale Trennlinie zwischen linker Nav und Inhalt */
.chat-popup.active:not(.chat-popup-mobile-fullscreen) .chat-popup-body > .chat-popup-content-wrapper {
    border-left: 1px solid #e9ecef !important;
    box-sizing: border-box !important;
}

body.dark-mode .chat-popup.active:not(.chat-popup-mobile-fullscreen) .chat-popup-body > .chat-popup-content-wrapper {
    border-left-color: #1a1a1a !important;
}
/* view-chat/view-new-contacts: Wrapper nicht auf 0 schrumpfen (nur Desktop; Mobile Fullscreen = 100% Breite) */
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-chat .chat-popup-content-wrapper,
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-new-contacts .chat-popup-content-wrapper,
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-archived .chat-popup-content-wrapper {
    min-width: 280px !important;
    min-height: 220px !important;
    flex: 1 1 auto !important;
}
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-chat:not(.has-active-contact):not(.ai-mode) .chat-popup-content-wrapper #chatChatView,
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-new-contacts:not(.view-new-contacts-selected) .chat-popup-content-wrapper #chatNewContactsView {
    width: 100% !important;
    min-width: 280px !important;
    min-height: 220px !important;
    flex: 1 1 auto !important;
}

/* Calls, Main, Split per Default ausblenden – Chat/Neue Kontakte werden vom JS (display) gesteuert */
.chat-popup .chat-popup-content-wrapper #chatCallsView,
.chat-popup .chat-popup-content-wrapper #chatMain,
.chat-popup .chat-popup-content-wrapper #chatViewSplit {
    display: none !important;
}

/* ========== Sichtbarkeit pro View (nur eine View gleichzeitig sichtbar) ========== */

/* Calls */
.chat-popup.active.view-calls .chat-popup-content-wrapper #chatCallsView {
    display: flex !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #fff !important;
}

/* Bei Anruf-Ansicht: Split & andere Sections hart aus (gegen verwaistes Inline-display:flex vom Chat) */
.chat-popup.active.view-calls .chat-popup-content-wrapper #chatViewSplit,
.chat-popup.active.view-calls .chat-popup-content-wrapper #chatNewContactsView {
    display: none !important;
}

/* Anrufe: schwebende Insel-Suche + FAB über der Liste (keine volle Breiten-Leiste unten). */
.chat-popup.active.view-calls .chat-calls-bottom-dock {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    z-index: 8;
    pointer-events: none;
    background: transparent;
    border: 0;
}
.chat-popup.active.view-calls .chat-calls-search-bar-wrap.chat-calls-search-island {
    flex: 0 1 min(400px, calc(100% - 88px));
    min-width: 0;
    margin: 0 auto;
    padding: 5px 6px 5px 14px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(26, 26, 26, 0.08);
    box-shadow:
        0 4px 22px rgba(26, 26, 26, 0.12),
        0 1px 3px rgba(26, 26, 26, 0.06);
    box-sizing: border-box;
    pointer-events: auto;
}
.chat-popup.active.view-calls .chat-calls-search-bar-input {
    width: 100%;
    box-sizing: border-box;
    border-radius: 999px;
    border: 0;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
    background: transparent;
    box-shadow: none;
}
.chat-popup.active.view-calls .chat-calls-search-bar-input:focus {
    box-shadow: none;
}
.chat-popup.active.view-calls .chat-calls-search-bar-input::placeholder {
    color: #94a3b8;
}
.chat-popup.active.view-calls .chat-calls-voicemail-fab-wrap {
    position: absolute;
    right: calc(14px + env(safe-area-inset-right, 0px));
    top: 0;
    bottom: 0;
    margin: auto 0;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}
.chat-popup.active.view-calls .chat-calls-voicemail-fab-wrap .chat-calls-voicemail-fab {
    pointer-events: auto;
    box-shadow:
        0 4px 22px rgba(26, 26, 26, 0.18),
        0 1px 3px rgba(26, 26, 26, 0.08);
}
body.dark-mode .chat-popup.active.view-calls .chat-calls-search-bar-wrap.chat-calls-search-island {
    background: #262626;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.45),
        0 1px 2px rgba(0, 0, 0, 0.3);
}
body.dark-mode .chat-popup.active.view-calls .chat-calls-search-bar-input {
    color: #e2e8f0;
}
body.dark-mode .chat-popup.active.view-calls .chat-calls-search-bar-input::placeholder {
    color: #64748b;
}

.chat-popup.active.view-calls .chat-calls-history {
    flex: 1;
    min-height: 0;
}

/*
 * Desktop breit: vier Säulen; schmale Chatbox (.chat-calls-narrow-desktop): eine Säule wie Mobile-Karussell.
 */
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-history {
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-columns {
    display: flex !important;
    flex-direction: row !important;
    flex: 1;
    min-height: 0;
    overflow: hidden !important;
    overflow-x: hidden !important;
    scroll-snap-type: none;
    scroll-behavior: auto;
}
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col {
    flex: 1 1 0% !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    scroll-snap-align: unset;
    border-right: 1px solid #e9ecef !important;
    box-sizing: border-box;
}
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col:last-child {
    border-right: none !important;
}
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col-header {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px;
    padding: 8px 10px;
    min-height: auto;
}
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col-header-prev,
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col-header-next {
    display: none !important;
}
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col-header-prev::before,
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col-header-next::after {
    content: none !important;
    display: none !important;
}
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col-header-center {
    flex: 0 0 auto;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px;
}
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col-label {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
}
.chat-popup.active.view-calls:not(.chat-popup-mobile-fullscreen):not(.chat-calls-narrow-desktop) .chat-calls-col-list {
    flex: 1;
    min-height: 120px;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/*
 * Mobile Vollbild oder schmale Desktop-Chatbox: eine Kategorie, Karussell, Pfeile (safe-area nur mobile-bottom-nav.css).
 */
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-history,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-history {
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-columns,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-columns {
    display: flex !important;
    flex-direction: row !important;
    flex: 1;
    min-height: 0;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: thin;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col {
    flex: 0 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    border-right: none !important;
    box-sizing: border-box;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    min-height: auto;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-prev,
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-next,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-prev,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-next {
    display: flex;
    flex: 1;
    min-width: 0;
    align-items: flex-end;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.1;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-prev,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-prev {
    justify-content: flex-start;
    text-align: left;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-next,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-next {
    justify-content: flex-end;
    text-align: right;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-prev::before,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-prev::before {
    content: "\25C0";
    display: inline-block;
    margin-right: 6px;
    font-size: 12px;
    line-height: 1;
    opacity: 0.55;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-next::after,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-next::after {
    content: "\25B6";
    display: inline-block;
    margin-left: 6px;
    font-size: 12px;
    line-height: 1;
    opacity: 0.55;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-center,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-center {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-label,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-label {
    text-align: center;
    font-size: 13px;
}
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-hint-called,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-hint-called { color: #3f7dcf; opacity: 0.72; }
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-hint-accepted,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-hint-accepted { color: #2f8b61; opacity: 0.72; }
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-hint-declined,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-hint-declined { color: #bf5b67; opacity: 0.72; }
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-header-hint-missed,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-header-hint-missed { color: #7b8794; opacity: 0.72; }
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-col-list,
.chat-popup.active.view-calls.chat-calls-narrow-desktop:not(.chat-popup-mobile-fullscreen) .chat-calls-col-list {
    flex: 1 1 0%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile Vollbild: Dock als Flex-Fußzeile (Details in mobile-bottom-nav.css) */
.chat-popup.active.chat-popup-mobile-fullscreen.view-calls .chat-calls-bottom-dock {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
}

/* Chat-View: Split anzeigen (links Kontakte, rechts Chat/Platzhalter) — nur Desktop; Mobile Fullscreen: mobile-bottom-nav.css */
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-chat .chat-popup-content-wrapper #chatViewSplit,
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-archived .chat-popup-content-wrapper #chatViewSplit {
    display: flex !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex-direction: row !important;
    overflow: hidden !important;
    background: #ffffff !important;
}
.chat-popup.active.view-chat .chat-popup-content-wrapper #chatCallsView,
.chat-popup.active.view-chat .chat-popup-content-wrapper #chatNewContactsView,
.chat-popup.active.view-archived .chat-popup-content-wrapper #chatCallsView,
.chat-popup.active.view-archived .chat-popup-content-wrapper #chatNewContactsView {
    display: none !important;
}
/* Kontakte-Panel links (Desktop-Split; nicht Mobile-Fullscreen) */
.chat-popup:not(.chat-popup-mobile-fullscreen) .chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel {
    flex: 0 0 280px !important;
    min-width: 240px !important;
    max-width: 360px !important;
    width: 280px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #fff !important;
    border-right: 1px solid #e9ecef !important;
}
.chat-popup:not(.chat-popup-mobile-fullscreen) .chat-popup-content-wrapper #chatViewSplit.chat-view-split-no-contacts .chat-contacts-panel {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    flex: 0 0 0 !important;
    border-right: 0 !important;
}
.chat-popup:not(.chat-popup-mobile-fullscreen) .chat-popup-content-wrapper #chatViewSplit.chat-view-split-no-contacts .chat-chat-right-panel {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 0 !important;
}
/* Kontakte-Panel: Liste volle Höhe, Toolbar schwebt unten (z-index) */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    position: relative !important;
    --kinma-chat-contacts-toolbar-reserve: 64px;
    --kinma-chat-contacts-fade-bg: #ffffff;
}

/* Scroll-Fades: oben/unten weiß → transparent (sichtbar je nach Scrollposition) */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel::before,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    z-index: 4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.32s ease;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel::before {
    top: 0;
    height: 44px;
    background: linear-gradient(
        to bottom,
        var(--kinma-chat-contacts-fade-bg) 0%,
        var(--kinma-chat-contacts-fade-bg) 6%,
        rgba(255, 255, 255, 0.94) 18%,
        rgba(255, 255, 255, 0.72) 38%,
        rgba(255, 255, 255, 0.42) 58%,
        rgba(255, 255, 255, 0.14) 78%,
        rgba(255, 255, 255, 0) 100%
    );
}

/* Unten am Panelende (hinter Suche/Buttons), nicht darüber */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel::after {
    bottom: 0;
    height: calc(var(--kinma-chat-contacts-toolbar-reserve, 64px) + 48px);
    z-index: 3;
    background: linear-gradient(
        to top,
        var(--kinma-chat-contacts-fade-bg) 0%,
        var(--kinma-chat-contacts-fade-bg) 14%,
        rgba(255, 255, 255, 0.94) 32%,
        rgba(255, 255, 255, 0.72) 52%,
        rgba(255, 255, 255, 0.42) 70%,
        rgba(255, 255, 255, 0.14) 86%,
        rgba(255, 255, 255, 0) 100%
    );
}

body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel::before {
    background: linear-gradient(
        to bottom,
        #1a1a1a 0%,
        #1a1a1a 6%,
        rgba(26, 26, 26, 0.94) 18%,
        rgba(26, 26, 26, 0.72) 38%,
        rgba(26, 26, 26, 0.42) 58%,
        rgba(26, 26, 26, 0.14) 78%,
        rgba(26, 26, 26, 0) 100%
    );
}

body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel::after {
    background: linear-gradient(
        to top,
        #1a1a1a 0%,
        #1a1a1a 6%,
        rgba(26, 26, 26, 0.94) 18%,
        rgba(26, 26, 26, 0.72) 38%,
        rgba(26, 26, 26, 0.42) 58%,
        rgba(26, 26, 26, 0.14) 78%,
        rgba(26, 26, 26, 0) 100%
    );
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.kinma-contacts-scroll-up::before {
    opacity: 1;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.kinma-contacts-scroll-down::after {
    opacity: 1;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.chat-contacts-panel-placeholder-only::before,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.chat-contacts-panel-placeholder-only::after {
    display: none !important;
}

body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel {
    --kinma-chat-contacts-fade-bg: #1a1a1a;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar-bottom,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-search-wrapper-top {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 6 !important;
    flex-shrink: 0 !important;
    margin-top: 0 !important;
    padding: 8px 10px 10px 10px !important;
    border-top: none !important;
    border-bottom: none !important;
    background: transparent !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    pointer-events: auto !important;
    box-sizing: border-box !important;
}

body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar-bottom {
    background: transparent !important;
    box-shadow: none !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar,
#chatContactsToolbar {
    --kinma-toolbar-motion-dur: 0.4s;
    --kinma-toolbar-motion-dur-fast: 0.18s;
    --kinma-toolbar-ease: cubic-bezier(0.33, 1, 0.68, 1);
    --kinma-toolbar-pad-x: 10px;
    --kinma-toolbar-pad-top: 8px;
    transition: gap var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease);
}

/* Suche: schrumpft von rechts (dort sitzt der +) wenn Add-Bereich wächst */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar-search-slot,
#chatContactsToolbar .chat-contacts-toolbar-search-slot {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
    display: flex !important;
    align-items: center !important;
    overflow: hidden !important;
    opacity: 1 !important;
    margin-right: 0 !important;
    order: 1;
    z-index: 1;
    transform-origin: 100% 50%;
    transition:
        flex var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease),
        max-width var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease),
        padding var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease),
        margin var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease);
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar-search-slot .chat-contacts-search-dock,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar-search-slot .chat-contacts-search-pill {
    width: 100%;
    min-width: 0;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded {
    gap: 0 !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contacts-toolbar-search-slot,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded .chat-contacts-toolbar-search-slot {
    flex: 0 1 0% !important;
    min-width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar #normalChatSearchContainer,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-search-dock {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar #chatSearchBackBtn,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar #aiConversationsSearchContainer {
    order: 0;
    flex: 0 0 auto;
}

.chat-popup:not(.ai-mode) .chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar #aiConversationsSearchContainer {
    display: none !important;
}

.chat-popup.ai-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar #aiConversationsSearchContainer {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-search-pill {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: 100% !important;
    min-height: 40px !important;
    border-radius: 9999px !important;
    background: #ffffff !important;
    border: 1px solid rgba(26, 26, 26, 0.1) !important;
    box-shadow:
        0 4px 16px rgba(26, 26, 26, 0.08),
        0 0 0 1px rgba(26, 26, 26, 0.04) !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-search-pill .kinma-ai-search-pill__inner {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 0 14px 0 12px !important;
    min-height: 40px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-search-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    border: none !important;
    background: transparent !important;
    font-size: 14px !important;
    color: #1a1a1a !important;
    outline: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-search-input::placeholder {
    color: #94a3b8 !important;
}

body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-search-pill {
    background: #1a1a1a !important;
    border-color: #1a1a1a !important;
}

body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-search-input {
    color: #f1f5f9 !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-search-wrapper .chat-search-input.chat-search-input-pill {
    display: none !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-search-wrapper.chat-search-wrapper-top {
    flex-shrink: 0 !important;
    padding: 0 !important;
    border-bottom: none !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-search-wrapper .chat-search-input.chat-search-input-pill {
    flex: 1 !important;
    min-width: 0 !important;
    padding: 10px 16px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 9999px !important;
    font-size: 14px !important;
    background: #fff !important;
}
.chat-popup-content-wrapper #chatViewSplit .chat-search-wrapper .chat-search-input.chat-search-input-pill:focus {
    outline: none !important;
    border-color: #adb5bd !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-refresh-btn,
#chatNewContactsView .chat-contacts-refresh-btn {
    display: flex !important;
    flex-shrink: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 50% !important;
    background: #fff !important;
    color: #1a1a1a !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-refresh-btn:hover,
#chatNewContactsView .chat-contacts-refresh-btn:hover {
    background: #f8f9fa !important;
    border-color: #adb5bd !important;
    color: #1a1a1a !important;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-refresh-btn:disabled,
#chatNewContactsView .chat-contacts-refresh-btn:disabled {
    opacity: 0.55 !important;
    cursor: not-allowed !important;
}
@keyframes kinma-chat-contacts-refresh-spin {
    to {
        transform: rotate(360deg);
    }
}
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-refresh-btn.is-loading svg,
#chatNewContactsView .chat-contacts-refresh-btn.is-loading svg {
    animation: kinma-chat-contacts-refresh-spin 0.75s linear infinite !important;
}
body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-refresh-btn,
body.dark-mode #chatNewContactsView .chat-contacts-refresh-btn {
    background: #2d3339 !important;
    border-color: #1a1a1a !important;
    color: #e9ecef !important;
}
body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-refresh-btn:hover,
body.dark-mode #chatNewContactsView .chat-contacts-refresh-btn:hover {
    background: #1a1a1a !important;
    border-color: #6c757d !important;
}
body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-close {
    background: #2d3339 !important;
    border-color: #94a3b8 !important;
    color: #e9ecef !important;
}
body.dark-mode .chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-close:hover {
    background: #1a1a1a !important;
    border-color: #6c757d !important;
}
/* Kontaktliste: volle Panelhöhe, scrollt unter der schwebenden Toolbar durch */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-list.chat-contacts-list-no-separators,
.chat-popup.ai-mode .chat-popup-content-wrapper #chatViewSplit #aiConversationsList.ai-conversations-list {
    position: absolute !important;
    inset: 0 !important;
    flex: none !important;
    width: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    padding-top: 0 !important;
    padding-bottom: calc(var(--kinma-chat-contacts-toolbar-reserve, 64px) + 6px) !important;
    box-sizing: border-box !important;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-list.chat-contacts-list-no-separators .chat-contact-item {
    border-bottom: none !important;
}
/* Add-Bereich: eingeklappt 40px rechts; aufgeklappt wächst im Flex — Suche schrumpft parallel */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand,
#chatContactsToolbar .chat-contacts-add-expand {
    position: relative;
    order: 2;
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 40px;
    overflow: hidden;
    z-index: 2;
    transition:
        flex var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease),
        min-width var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease),
        max-width var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease);
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand {
    position: relative;
    flex: 1 1 0%;
    width: auto;
    min-width: 0;
    max-width: none;
    height: 40px;
    z-index: 2;
}

/* Pill: rechter Rand fix (= Position des +), Breite wächst nach links */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-pill,
#chatContactsToolbar .chat-contacts-add-expand-pill {
    position: absolute;
    top: 0;
    right: 0;
    left: auto;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    margin: 0;
    border-radius: 999px;
    background: #1a1a1a;
    overflow: hidden;
    box-sizing: border-box;
    z-index: 2;
    transition:
        right var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease),
        width var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease),
        border-radius var(--kinma-toolbar-motion-dur-fast) ease,
        background-color 0.15s ease;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-pill,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-pill {
    right: 48px;
    left: 0;
    width: auto;
    min-width: 40px;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar:not(.chat-contacts-toolbar--add-expanded) .chat-contacts-add-expand-actions {
    display: none !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-actions,
#chatContactsToolbar .chat-contacts-add-expand-actions {
    display: none;
    align-items: stretch;
    flex: 1 1 0%;
    min-width: 0;
    width: 100%;
    height: 100%;
    opacity: 1;
    overflow: hidden;
    pointer-events: none;
    padding: 0;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-action {
    flex: 1 1 0%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity var(--kinma-toolbar-motion-dur-fast) var(--kinma-toolbar-ease);
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-action-icon,
#chatContactsToolbar .chat-contacts-add-expand-action-icon {
    display: block;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-action:hover,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-action:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    transition-delay: 0s;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-action:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 1px;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-close,
#chatContactsToolbar .chat-contacts-add-expand-close {
    position: absolute;
    right: 0;
    top: 0;
    z-index: 4;
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    background: #fff;
    color: #1a1a1a;
    cursor: pointer;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transform: translateX(calc(100% + 10px));
    transition:
        transform var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease),
        opacity var(--kinma-toolbar-motion-dur-fast) var(--kinma-toolbar-ease);
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-close,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-close {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
    transition-property: transform, opacity;
    transition-delay: 0.1s, 0.08s;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar:not(.chat-contacts-toolbar--add-expanded) .chat-contacts-add-expand-close,
#chatContactsToolbar:not(.chat-contacts-toolbar--add-expanded) .chat-contacts-add-expand-close {
    transition-property: transform, opacity;
    transition-delay: 0s, 0s;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-close[hidden] {
    visibility: hidden;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-close:hover,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-close:focus-visible {
    background: #f8f9fa;
    border-color: #adb5bd;
    transition: none;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-close:focus-visible {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded #chatSearchBackBtn,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded #aiConversationsSearchContainer {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity var(--kinma-toolbar-motion-dur) var(--kinma-toolbar-ease);
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-actions,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-actions {
    display: flex !important;
    pointer-events: auto;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-action,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-action {
    opacity: 1;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-action--person,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-action--person {
    border-radius: 999px 0 0 999px !important;
    transition-property: opacity;
    transition-delay: 0.16s;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-action--folder,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-action--folder {
    border-radius: 0 999px 999px 0 !important;
    transition-property: opacity;
    transition-delay: 0.22s;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contacts-add-expand-action + .chat-contacts-add-expand-action {
    box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.12);
}

/* Eingeklappt: nur „+“ sichtbar in der Pill */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar:not(.chat-contacts-toolbar--add-expanded) .chat-contact-add-placeholder,
#chatContactsToolbar:not(.chat-contacts-toolbar--add-expanded) .chat-contact-add-placeholder {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
}

/* Aufgeklappt: „+“ weg, Person/Ordner füllen die wachsende Pill */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar.chat-contacts-toolbar--add-expanded .chat-contact-add-placeholder,
#chatContactsToolbar.chat-contacts-toolbar--add-expanded .chat-contact-add-placeholder {
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    border: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar,
    #chatContactsToolbar {
        --kinma-toolbar-motion-dur: 0.01ms;
        --kinma-toolbar-motion-dur-fast: 0.01ms;
    }
    .chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar-search-slot,
    .chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand,
    .chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-action,
    .chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-close,
    .chat-popup-content-wrapper #chatViewSplit .chat-contact-add-placeholder,
    #chatContactsToolbar .chat-contacts-toolbar-search-slot,
    #chatContactsToolbar .chat-contacts-add-expand,
    #chatContactsToolbar .chat-contacts-add-expand-action,
    #chatContactsToolbar .chat-contacts-add-expand-close {
        transition-delay: 0s !important;
    }
}

.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-disabled,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-disabled .chat-contact-add-placeholder {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.chat-popup.ai-mode.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-actions,
.chat-popup.ai-mode.chat-popup-content-wrapper #chatViewSplit .chat-contacts-add-expand-close {
    display: none !important;
}

/* „+“: runder Kreis mit SVG-Plus (gleiche Größe wie Refresh) */
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar .chat-contact-add-placeholder {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    margin: 0;
    padding: 0;
    background: #1a1a1a;
    border: none;
    border-radius: 50%;
    aspect-ratio: 1;
    cursor: pointer;
    color: #fff;
    box-sizing: border-box;
    transform: scale(1) rotate(0deg);
    transition: background-color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.chat-popup-content-wrapper #chatViewSplit .chat-contact-add-placeholder:hover {
    background-color: #1a1a1a;
}

/* KI-Modus: „+“ in der Unterhaltungsliste = Violett wie KI-Akzent */
.chat-popup.ai-mode.chat-popup-content-wrapper #chatViewSplit .chat-contact-add-placeholder:not(.chat-contact-add-placeholder-disabled) {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    background-color: #6366f1;
}
.chat-popup.ai-mode.chat-popup-content-wrapper #chatViewSplit .chat-contact-add-placeholder:not(.chat-contact-add-placeholder-disabled):hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    background-color: #4f46e5;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contact-add-placeholder:focus-visible {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar .chat-contact-add-placeholder-icon {
    display: block;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    stroke: currentColor;
    color: #fff;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar:not(.chat-contacts-toolbar--add-expanded) .chat-contact-add-placeholder:hover {
    transform: scale(1.04);
}
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-toolbar:not(.chat-contacts-toolbar--add-expanded) .chat-contact-add-placeholder:hover .chat-contact-add-placeholder-icon {
    color: #fff;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contact-add-placeholder.chat-contact-add-placeholder-disabled,
.chat-popup-content-wrapper #chatViewSplit .chat-contact-add-placeholder.chat-contact-add-placeholder-disabled:hover {
    opacity: 0.45;
    cursor: not-allowed;
    background: #9ca3af;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contact-add-placeholder.chat-contact-add-placeholder-disabled .chat-contact-add-placeholder-icon {
    color: #f3f4f6;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.chat-contacts-panel-placeholder-only #chatContactsToolbar,
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.chat-contacts-panel-placeholder-only #chatContactsList {
    display: none !important;
}
.chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.chat-contacts-panel-placeholder-only #chatContactsAddExpand {
    margin: auto 12px 16px auto !important;
}
.chat-popup:not(.chat-popup-mobile-fullscreen) .chat-popup-content-wrapper #chatViewSplit .chat-chat-right-panel {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #fff !important;
}

/*
 * Desktop: Kein geöffneter Chat — nur Kontaktliste (Suchfeld + Einträge + FAB), kein leeres rechtes Panel.
 * Nicht bei „keine Kontakte“-Solo (.chat-view-split-no-contacts): dort bleibt das rechte Platzhalter-Layout.
 */
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-chat:not(.has-active-contact)
    #chatViewSplit:not(.chat-view-split-no-contacts)
    .chat-chat-right-panel,
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-archived:not(.has-active-contact)
    #chatViewSplit:not(.chat-view-split-no-contacts)
    .chat-chat-right-panel {
    display: none !important;
}
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-chat:not(.has-active-contact)
    #chatViewSplit:not(.chat-view-split-no-contacts)
    .chat-contacts-panel,
.chat-popup.active:not(.chat-popup-mobile-fullscreen).view-archived:not(.has-active-contact)
    #chatViewSplit:not(.chat-view-split-no-contacts)
    .chat-contacts-panel {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    border-right: none !important;
}

.chat-popup.active.view-archived #chatContactsPanel .chat-contacts-add-expand {
    display: none !important;
}

/* Chat ↔ Archiv (andere Sidebar-Tabs): Kurz Ladezustand ohne alte Einträge */
#chatContactsList .chat-contacts-switch-loading {
    flex: 1 1 0%;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    box-sizing: border-box;
}
#chatContactsList .chat-contacts-switch-loading-inner {
    display: flex;
    align-items: center;
    justify-content: center;
}
#chatContactsList .chat-contacts-switch-loading-spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #e9ecef;
    border-top-color: #1a1a1a;
    animation: kinma-chat-contacts-tab-switch-spin 0.65s linear infinite;
    display: block;
}
@keyframes kinma-chat-contacts-tab-switch-spin {
    to {
        transform: rotate(360deg);
    }
}
body.dark-mode #chatContactsList .chat-contacts-switch-loading-spinner {
    border-color: #1a1a1a;
    border-top-color: #adb5bd;
}

/*
 * Archivierte Chats: Bei „Solo“/Platzhalter-Panel blendet das normale Chat-Layout #chatContactsList + Toolbar aus
 * (rechts: leerer Hinweis). Im Archiv gibt es keinen #chatChatView-Platzhalter → ohne Override bleibt nur Weiß.
 */
.chat-popup.active.view-archived .chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.chat-contacts-panel-placeholder-only #chatContactsList,
.chat-popup.active.view-archived .chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.chat-contacts-panel-placeholder-only #chatContactsToolbar {
    display: flex !important;
}
.chat-popup.active.view-archived .chat-popup-content-wrapper #chatViewSplit .chat-contacts-panel.chat-contacts-panel-placeholder-only #chatContactsList {
    flex-direction: column !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* .chat-view-split-no-contacts versteckt sonst die linke Spalte komplett → Archiv zeigt Liste Vollbreite */
.chat-popup.active.view-archived .chat-popup-content-wrapper #chatViewSplit.chat-view-split-no-contacts .chat-contacts-panel {
    display: flex !important;
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    border-right: none !important;
}
.chat-popup.active.view-archived .chat-popup-content-wrapper #chatViewSplit.chat-view-split-no-contacts .chat-chat-right-panel {
    display: none !important;
}

/* KI-Modus: Familien-Leerzustand „Deine Unterhaltungen“ nie (nur KI-Liste / KI-Verlauf) */
.chat-popup.ai-mode .chat-popup-content-wrapper #chatChatView {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

.chat-popup.ai-mode:not(.has-active-contact):not(.chat-popup-mobile-fullscreen)
    .chat-popup-content-wrapper #chatViewSplit .chat-chat-right-panel {
    display: none !important;
}

.chat-popup.ai-mode:not(.has-active-contact):not(.chat-popup-mobile-fullscreen)
    .chat-popup-content-wrapper #chatViewSplit.chat-view-split-no-contacts .chat-contacts-panel {
    display: flex !important;
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    border-right: none !important;
}

/* Chat-Section (Deine Unterhaltungen / leerer Zustand) – Mindestgröße damit Platzhalter sichtbar ist */
.chat-popup.active.view-chat:not(.has-active-contact):not(.ai-mode) .chat-popup-content-wrapper #chatChatView {
    display: flex !important;
    flex: 1 1 0% !important;
    min-width: 240px !important;
    min-height: 200px !important;
    width: 100% !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #fff !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Archiv ohne Kontakt: wie Chat — leere Chat-Section ausblenden (Liste nutzt #chatViewSplit) */
.chat-popup.active.view-archived:not(.has-active-contact) .chat-popup-content-wrapper #chatChatView {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    pointer-events: none !important;
}

/* Konversation (Chat mit gewähltem Kontakt) – Split auch bei view-new-contacts-selected anzeigen */
.chat-popup.active.view-new-contacts-selected .chat-popup-content-wrapper #chatViewSplit {
    display: flex !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex-direction: row !important;
    overflow: hidden !important;
    background: #ffffff !important;
}
.chat-popup.active.view-new-contacts-selected .chat-popup-content-wrapper #chatNewContactsView {
    display: none !important;
}
.chat-popup.active.view-chat.has-active-contact .chat-popup-content-wrapper #chatMain,
.chat-popup.active.view-archived.has-active-contact .chat-popup-content-wrapper #chatMain,
.chat-popup.active.view-new-contacts-selected .chat-popup-content-wrapper #chatMain {
    display: flex !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #fff !important;
}

/* Neue Kontakte (Liste) – Mindestgröße damit Platzhalter/Liste sichtbar ist */
.chat-popup.active.view-new-contacts:not(.view-new-contacts-selected) .chat-popup-content-wrapper #chatNewContactsView {
    display: flex !important;
    flex: 1 1 0% !important;
    min-width: 240px !important;
    min-height: 200px !important;
    width: 100% !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #fff !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Fallback: Popup aktiv ohne View-Klasse (z. B. vor JS) → Split + Chat-Section anzeigen (nicht Mobile-Fullscreen) */
.chat-popup.active:not(.chat-popup-mobile-fullscreen):not(.view-calls):not(.view-stories):not(.view-new-contacts):not(.view-new-contacts-selected):not(.view-settings) .chat-popup-content-wrapper #chatViewSplit {
    display: flex !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex-direction: row !important;
    overflow: hidden !important;
    background: #ffffff !important;
}
.chat-popup.active:not(.ai-mode):not(.view-calls):not(.view-stories):not(.view-new-contacts):not(.view-new-contacts-selected):not(.view-settings):not(.view-archived):not(.has-active-contact) .chat-popup-content-wrapper #chatChatView {
    display: flex !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #fff !important;
}
/* Konkurrenz: Bei view-chat mit Kontakt oder view-new-contacts-selected Platzhalter komplett ausblenden (kein Flickern beim Wechseln) */
.chat-popup.active.view-chat.has-active-contact .chat-popup-content-wrapper #chatChatView,
.chat-popup.active.view-archived.has-active-contact .chat-popup-content-wrapper #chatChatView,
.chat-popup.active.view-new-contacts-selected .chat-popup-content-wrapper #chatChatView {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    pointer-events: none !important;
}

/* ========== Interne Layouts der Views ========== */

/* #chatChatView: Platzhalter ohne "Chat"-Header (nur leerer Zustand / Hinweis) */
.chat-popup-content-wrapper #chatChatView {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex-direction: column !important;
    overflow: hidden !important;
}
/* Platzhalter-Bereich ohne eigenen "Chat"-Header (überschüssig neben Kontaktliste) */
#chatChatView .chat-chat-view-header {
    display: none !important;
}
#chatChatView .chat-chat-view-title {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
}
#chatChatView .chat-chat-view-content {
    flex: 1 1 0% !important;
    min-height: 160px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 24px !important;
    display: flex !important;
    flex-direction: column !important;
    background: #ffffff !important;
}
#chatChatView .chat-chat-view-empty {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    min-height: 160px !important;
    text-align: center !important;
    flex: 1 !important;
    padding: 24px 16px !important;
}
#chatChatView .chat-chat-view-empty .chat-chat-view-empty-intro {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}
#chatChatView .chat-chat-view-empty.chat-chat-view-empty-solo-family {
    justify-content: center !important;
}
#chatChatView .chat-chat-view-empty.chat-chat-view-empty-list-mode {
    justify-content: flex-start !important;
    align-items: stretch !important;
}
/* Nur das statische Intro ausblenden; dynamisches „alle kontaktiert“ liegt in #chatNewContactsPreviewList */
#chatChatView .chat-chat-view-empty.chat-chat-view-empty-list-mode > .chat-chat-view-empty-intro {
    display: none !important;
}
#chatChatView .chat-chat-view-empty-icon { color: #adb5bd !important; margin-bottom: 16px !important; }
#chatChatView .chat-chat-view-empty-title { margin: 0 0 8px 0 !important; font-size: 16px !important; font-weight: 600 !important; color: #1a1a1a !important; }
#chatChatView .chat-chat-view-empty-hint { margin: 0 0 20px 0 !important; font-size: 14px !important; color: #6c757d !important; max-width: 280px !important; line-height: 1.5 !important; }
#chatChatView .chat-chat-view-cta {
    padding: 10px 20px !important;
    border-radius: 9999px !important;
    border: none !important;
    background: #1a1a1a !important;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
}
#chatChatView .chat-chat-view-cta:hover { background: #1a1a1a !important; }

/* Neue Kontakte Preview unter „Zu Neue Kontakte“ im Chat (scrollt im Chat-Content, nicht im Add-Contact-Panel) */
#chatChatView .chat-chat-view-empty-new-contacts-preview {
    width: 100% !important;
    max-width: 360px !important;
    margin-top: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
}
#chatChatView .chat-chat-view-empty.chat-chat-view-empty-list-mode .chat-chat-view-empty-new-contacts-preview {
    max-width: 460px !important;
    margin-top: 0 !important;
}

/* Voller Leer-Zustand „alle kontaktiert“: Vorschau-Bereich vertikal zentrieren */
#chatChatView .chat-chat-view-empty.chat-chat-view-empty-list-mode.chat-chat-view-empty--center-preview {
    justify-content: center !important;
    padding-top: 20px !important;
    padding-bottom: 32px !important;
}
#chatChatView .chat-chat-view-empty.chat-chat-view-empty-list-mode.chat-chat-view-empty--center-preview .chat-chat-view-empty-new-contacts-preview {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    max-width: none !important;
    margin-top: 0 !important;
    min-height: min(340px, 50vh) !important;
}
#chatChatView .chat-chat-view-empty.chat-chat-view-empty-list-mode.chat-chat-view-empty--center-preview .chat-chat-view-empty-new-contacts-preview-list {
    width: 100% !important;
    max-width: 440px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

/* „Alle kontaktiert“: gleiche Intro-Optik wie Solo-Leerzustand (#chatChatViewEmptyIntro) */
#chatChatView .chat-chat-view-empty-new-contacts-preview-list > .chat-chat-view-empty-intro {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Ohne Listen-Modus (z. B. nur du in der Familie): Intro als Karte */
#chatChatView .chat-chat-view-empty:not(.chat-chat-view-empty-list-mode) .chat-chat-view-empty-intro {
    max-width: 440px;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

body.dark-mode #chatChatView .chat-chat-view-content {
    background: linear-gradient(180deg, #1a1a1a 0%, #1a1a1a 70%) !important;
}
body.dark-mode #chatChatView .chat-chat-view-empty:not(.chat-chat-view-empty-list-mode) .chat-chat-view-empty-intro {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}
body.dark-mode #chatChatView .chat-chat-view-empty-title {
    color: #f1f5f9 !important;
}
body.dark-mode #chatChatView .chat-chat-view-empty-hint {
    color: #94a3b8 !important;
}
body.dark-mode #chatChatView .chat-chat-view-empty-icon {
    color: #a5b4fc !important;
}

#chatChatView .chat-chat-view-empty-new-contacts-preview-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    /* Wichtig: hier KEIN eigener Scroll. Scroll passiert über #chatChatView .chat-chat-view-content */
}

#chatChatView .chat-chat-view-empty-new-contacts-preview-status {
    margin-top: 10px !important;
    font-size: 12px !important;
    color: #6c757d !important;
    text-align: center !important;
    min-height: 14px !important;
}

/* #chatNewContactsView: Suchleiste sticky, Liste scrollt darunter */
.chat-popup-content-wrapper #chatNewContactsView {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}
#chatNewContactsView .chat-new-contacts-header {
    flex-shrink: 0 !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 1 !important;
    padding: 12px 16px !important;
    background: #fff !important;
}
#chatNewContactsView .chat-new-contacts-header-row {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}
#chatNewContactsView .chat-search-input,
#chatNewContactsView .chat-new-contacts-search-input {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 10px 16px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 9999px !important;
    font-size: 14px !important;
}
#chatNewContactsView .chat-new-contacts-search-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
}
#chatNewContactsView .chat-search-input:focus,
#chatNewContactsView .chat-new-contacts-search-input:focus {
    outline: none !important;
    border-color: #adb5bd !important;
}
#chatNewContactsView .chat-new-contacts-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 8px 16px 16px !important;
    background: #fff !important;
}

/* Empty State „Alle kontaktiert“: großes Platzhalter-Icon + Text */
.chat-new-contacts-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    padding: 40px 24px;
    text-align: center;
}
.chat-new-contacts-empty-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 320px;
}
.chat-new-contacts-empty-icon {
    color: #9ca3af;
    margin-bottom: 20px;
    line-height: 0;
}
.chat-new-contacts-empty-icon svg {
    display: block;
}
.chat-new-contacts-empty-title {
    font-weight: 600;
    font-size: 16px;
    color: #1a1a1a;
    margin: 0 0 8px 0;
    line-height: 1.4;
}
.chat-new-contacts-empty-hint {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

/* Kontaktliste (Chat / Archiv): leerer Zustand — sichtbar auf Mobile statt weißer Fläche */
#chatContactsList .chat-contacts-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 32px 20px;
    text-align: center;
    box-sizing: border-box;
}
#chatContactsList .chat-contacts-empty-inner {
    max-width: 280px;
}
#chatContactsList .chat-contacts-empty-title {
    font-weight: 600;
    font-size: 15px;
    color: #1a1a1a;
    margin: 0 0 8px 0;
    line-height: 1.4;
}
#chatContactsList .chat-contacts-empty-hint {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

/* #chatMain: Scrollbereich füllt alles; Header und Eingabe fix darüber, Inhalt scrollt dahinter */
.chat-popup-content-wrapper #chatMain {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #fff !important;
    border-radius: 0 !important;
    position: relative !important;
    /* Kanten-Fade (Nachrichten wirken unter Header/Eingabe auszublenden) */
    --chat-edge-fade: #ffffff;
    --kinma-chat-quote-gradient-fade: var(--chat-edge-fade, #ffffff);
    --kinma-chat-composer-bottom: 78px;
    --kinma-chat-reply-reserve: 0px;
    /* Header-Zeile: gleicher Randabstand oben/unten/links/rechts (Mobile + Desktop) */
    --kinma-chat-header-inset: 12px;
}

/* Header-Zeile: einheitlicher Außenabstand zur Chat-Fläche (Safe-Area zusätzlich links/rechts) */
#chatMain .chat-main-header-row {
    padding-top: var(--kinma-chat-header-inset, 12px) !important;
    padding-bottom: var(--kinma-chat-header-inset, 12px) !important;
    padding-left: calc(var(--kinma-chat-header-inset, 12px) + env(safe-area-inset-left, 0px)) !important;
    padding-right: calc(var(--kinma-chat-header-inset, 12px) + env(safe-area-inset-right, 0px)) !important;
    box-sizing: border-box !important;
}

body.dark-mode .chat-popup-content-wrapper #chatMain {
    --chat-edge-fade: #1a1a1a;
}

/* Über Scroll-Inhalt, unter Header-Inseln (z-index 3/10) und Eingabe (3); pointer-events none */
.chat-popup-content-wrapper #chatMain::before,
.chat-popup-content-wrapper #chatMain::after {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    pointer-events: none !important;
    z-index: 2 !important;
}
.chat-popup-content-wrapper #chatMain::before {
    top: 0 !important;
    height: 112px !important;
    /* Stärkerer Kanten-Fade: länger voll deckend, dann Ausblendung */
    background: linear-gradient(
        to bottom,
        var(--chat-edge-fade) 0%,
        var(--chat-edge-fade) 46%,
        transparent 100%
    ) !important;
}
.chat-popup-content-wrapper #chatMain::after {
    bottom: 0 !important;
    height: 152px !important;
    background: linear-gradient(
        to top,
        var(--chat-edge-fade) 0%,
        var(--chat-edge-fade) 46%,
        transparent 100%
    ) !important;
}

/* Desktop: schmalere Kanten-Fades — mehr sichtbarer Nachrichtenbereich */
@media (min-width: 1025px) {
    .chat-popup-content-wrapper #chatMain::before {
        height: 52px !important;
        background: linear-gradient(
            to bottom,
            var(--chat-edge-fade) 0%,
            var(--chat-edge-fade) 32%,
            transparent 100%
        ) !important;
    }
    .chat-popup-content-wrapper #chatMain::after {
        height: 64px !important;
        background: linear-gradient(
            to top,
            var(--chat-edge-fade) 0%,
            var(--chat-edge-fade) 32%,
            transparent 100%
        ) !important;
    }
}

#chatMain.chat-main-loading::before,
#chatMain.chat-main-loading::after {
    opacity: 0 !important;
    pointer-events: none !important;
}
/* Chat-Header: fix oben, Insel-optik – bewegt sich nicht beim Scrollen */
#chatMain .chat-main-header {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 3 !important;
    flex-shrink: 0 !important;
    background: #1a1a1a !important;
    border-radius: 9999px !important;
    margin: 6px 16px 0 16px !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
    padding: 5px !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    overflow: visible !important;
}
.chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact #chatMain .chat-main-header-row .chat-main-header,
.chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact #chatMain > .chat-main-header-row > #chatMainHeader.chat-main-header {
    margin: 0 !important;
    margin-left: 0 !important;
    left: 0 !important;
}
/* Mobile Vollbild: Header in der Zeile unter der App-Top-Nav (nicht an #chatMain top:0 kleben) */
@media (max-width: 1024px) {
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact #chatMain > .chat-main-header-row .chat-main-header,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact #chatMain > .chat-main-header-row > #chatMainHeader.chat-main-header {
        position: relative !important;
        top: auto !important;
        left: 0 !important;
        right: auto !important;
    }
}
/* Desktop: Header nah am oberen Rand, kein großer Abstand */
@media (min-width: 1025px) {
    .chat-popup-content-wrapper #chatMain .chat-main-header-row {
        position: absolute !important;
        top: calc(var(--kinma-chat-header-inset, 12px) + env(safe-area-inset-top, 0px)) !important;
        left: calc(var(--kinma-chat-header-inset, 12px) + env(safe-area-inset-left, 0px)) !important;
        right: calc(var(--kinma-chat-header-inset, 12px) + env(safe-area-inset-right, 0px)) !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: stretch !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
        min-height: calc(var(--kinma-chat-avatar-size, 44px) + 10px) !important;
        height: auto !important;
        align-items: center !important;
        z-index: 4 !important;
        overflow: visible !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        margin: 0 !important;
        height: auto !important;
        min-height: calc(var(--kinma-chat-avatar-size, 44px) + 10px) !important;
        width: auto !important;
        padding: 5px !important;
        box-sizing: border-box !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-row .chat-main-header {
        flex: 1 1 0% !important;
        margin: 0 !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-ghost-close-island {
        height: 100% !important;
        aspect-ratio: 1 / 1 !important;
        width: auto !important;
        flex: 0 0 auto !important;
        margin: 0 !important;
        border-radius: 9999px !important;
        background: #1a1a1a !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden !important;
        min-height: calc(var(--kinma-chat-avatar-size, 44px) + 10px) !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-ghost-close-btn {
        width: 100% !important;
        height: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        border: 1px solid rgba(255,255,255,0.35) !important;
        border-radius: inherit !important;
        background: #ffffff !important;
        color: #1a1a1a !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
    }
    /* Lupe rechts neben der Header-Pill (Desktop-Split, gleiche Zeile wie Ghost-Close) */
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-island {
        display: none;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        align-items: center !important;
        justify-content: center !important;
        align-self: center !important;
        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;
        max-width: var(--chat-pill-min-height, 48px) !important;
        min-height: var(--chat-pill-min-height, 48px) !important;
        max-height: var(--chat-pill-min-height, 48px) !important;
        aspect-ratio: 1 / 1 !important;
        margin: 0 !important;
        border-radius: 50% !important;
        background: #1a1a1a !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-island.chat-main-header-search-island--with-label {
        width: auto !important;
        max-width: min(280px, 42vw) !important;
        min-width: var(--chat-pill-min-height, 48px) !important;
        aspect-ratio: auto !important;
        border-radius: 999px !important;
        padding: 0 14px 0 0 !important;
        overflow: visible !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-island:not([hidden]) {
        display: inline-flex !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-btn {
        display: inline-flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: inherit !important;
        background: transparent !important;
        color: #e2e8f0 !important;
        cursor: pointer !important;
        box-sizing: border-box !important;
    }
    .chat-popup-content-wrapper
        #chatMain
        .chat-main-header-search-island.chat-main-header-search-island--with-label
        .chat-main-header-search-btn {
        padding: 0 12px 0 12px !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-btn-label {
        font-size: 13px !important;
        font-weight: 600 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 200px !important;
        color: #e2e8f0 !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-btn-icon {
        display: inline-flex !important;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 0 !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-btn:hover,
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-btn:focus-visible {
        background: rgba(255, 255, 255, 0.08) !important;
        outline: none !important;
    }
    .chat-popup-content-wrapper #chatMain .chat-main-header-search-btn svg {
        display: block !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
    }

    /* Desktop: Verlaufssuche ersetzt Kontakt-Header (Pille + Anruf), nicht die Composer-Zeile */
    body.kinma-chat-desktop-header-search .chat-popup-content-wrapper #chatMain .chat-main-header-row {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) var(--chat-pill-min-height, 48px) !important;
        grid-template-areas: 'search close' !important;
        align-items: center !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        height: var(--chat-pill-min-height, 48px) !important;
        min-height: var(--chat-pill-min-height, 48px) !important;
        max-height: var(--chat-pill-min-height, 48px) !important;
    }

    body.kinma-chat-desktop-header-search
        .chat-popup-content-wrapper
        #chatMain
        .chat-main-header-row
        > :not(.chat-main-header-history-search-slot):not(.chat-composer-history-search-close-btn) {
        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;
    }

    body.kinma-chat-desktop-header-search
        .chat-popup-content-wrapper
        #chatMain
        .chat-main-header-history-search-slot:not([hidden]) {
        grid-area: search !important;
        display: flex !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: 100% !important;
        max-width: none !important;
        align-items: center !important;
        align-self: center !important;
        justify-self: stretch !important;
        height: var(--chat-pill-min-height, 48px) !important;
        min-height: var(--chat-pill-min-height, 48px) !important;
        max-height: var(--chat-pill-min-height, 48px) !important;
        overflow: hidden !important;
    }

    body.kinma-chat-desktop-header-search
        #chatMain.chat-main--header-history-search
        .chat-main-header-history-search-slot
        .chat-composer-history-search-dock--in-header:not([hidden]) {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        height: var(--chat-pill-min-height, 48px) !important;
        min-height: var(--chat-pill-min-height, 48px) !important;
        max-height: var(--chat-pill-min-height, 48px) !important;
        margin: 0 !important;
        padding: 0 !important;
        grid-template: none !important;
    }

    body.kinma-chat-desktop-header-search
        #chatMain.chat-main--header-history-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-desktop-header-search
        .chat-popup-content-wrapper
        #chatMain
        .chat-main-header-row
        > .chat-composer-history-search-close-btn {
        grid-area: close !important;
        display: inline-flex !important;
        flex: none !important;
        align-items: center !important;
        justify-content: center !important;
        align-self: center !important;
        justify-self: end !important;
        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;
        max-width: var(--chat-pill-min-height, 48px) !important;
        max-height: var(--chat-pill-min-height, 48px) !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 50% !important;
        background: #1a1a1a !important;
        color: #f8fafc !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
        cursor: pointer !important;
        box-sizing: border-box !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    body.kinma-chat-desktop-header-search
        #chatMain.chat-main--header-history-search
        #chatDesktopConversationSearch:not([hidden]) {
        width: 100% !important;
        max-width: 100% !important;
    }

}

/* KI-Modus: Header-Insel violett (sonst gewinnt #1a1a1a oben mit !important) */
.chat-popup.ai-mode #chatMain .chat-main-header:not(.chat-main-header-call-active) {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
    box-shadow: 0 4px 22px rgba(79, 70, 229, 0.38), 0 2px 8px rgba(99, 102, 241, 0.22) !important;
}

.chat-popup.ai-mode #chatMain .chat-main-header:not(.chat-main-header-call-active):hover {
    background: linear-gradient(135deg, #5b5ee8 0%, #4338ca 100%) !important;
}

.chat-popup.ai-mode #chatMain .chat-main-header:not(.chat-main-header-call-active) .chat-user-avatar-status-dot {
    border: none !important;
    box-shadow: none !important;
}

@media (min-width: 1025px) {
    .chat-popup.ai-mode .chat-popup-content-wrapper #chatMain .chat-main-header-ghost-close-island {
        background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
        box-shadow: 0 4px 22px rgba(79, 70, 229, 0.38), 0 2px 8px rgba(99, 102, 241, 0.22) !important;
    }
    .chat-popup.ai-mode .chat-popup-content-wrapper #chatMain .chat-main-header-search-island {
        background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
        box-shadow: 0 4px 22px rgba(79, 70, 229, 0.38), 0 2px 8px rgba(99, 102, 241, 0.22) !important;
        border-color: rgba(255, 255, 255, 0.12) !important;
    }
}

/* „Zurück zu Kontakten“ nur bei Mobile/Tablet-Fullscreen (s. mobile-bottom-nav.css); auf Desktop nie anzeigen.
   Entspricht grob !isChatMobileFullscreen(): weder schmales Fenster noch niedrige Höhe. */
@media (min-width: 1025px) {
    .chat-popup-content-wrapper #chatMain .chat-main-header-back-island {
        display: none !important;
    }
}
#chatMain .chat-main-header .chat-user-name {
    color: #f0f0f0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}
#chatMain .chat-main-header--left-family .chat-user-name {
    color: var(--kinma-chat-left-family-name-color, #dc2626) !important;
}

#chatMain .chat-main-header--left-family .chat-user-header-exit-icon,
#chatMain .chat-main-header--left-family .chat-contact-exit-account-icon {
    color: var(--kinma-chat-left-family-name-color, #dc2626) !important;
}
#chatMain .chat-main-header .chat-user-details {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 2px !important;
    min-width: 0 !important;
    flex: 1 1 0% !important;
    max-width: 100% !important;
    padding: 0 !important;
}
#chatMain .chat-main-header .chat-user-last-seen {
    font-size: 12px !important;
    line-height: 1.25 !important;
    color: #a8a8a8 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}
#chatMain .chat-main-header .chat-user-last-seen:empty {
    display: none !important;
}
#chatMain .chat-main-header.chat-main-header-call-active .chat-user-last-seen {
    color: rgba(255, 255, 255, 0.88) !important;
}
/* Avatar + Status-Kugel unten rechts (kein Statustext neben dem Namen) */
#chatMain .chat-main-header .chat-user-avatar-wrap {
    position: relative !important;
    flex-shrink: 0 !important;
    width: var(--kinma-chat-avatar-size, 44px) !important;
    height: var(--kinma-chat-avatar-size, 44px) !important;
    overflow: visible !important;
}
#chatMain .chat-main-header .chat-user-info {
    overflow: visible !important;
}
#chatMain .chat-main-header .chat-user-avatar-wrap .chat-user-avatar {
    width: 100% !important;
    height: 100% !important;
    color: #ffffff !important;
    background-size: cover !important;
    background-position: center !important;
    overflow: hidden !important;
}
#chatMain .chat-main-header .chat-user-avatar-status-dot {
    z-index: 5 !important;
}
/* Hintergrund: Kontofarbe (inline style) oder Profilbild via background-image — kein fester Gradient */
#chatMain .chat-main-header .chat-user-avatar {
    color: #ffffff !important;
    background-size: cover !important;
    background-position: center !important;
}
#chatMain .chat-main-header .chat-call-btn {
    background: #ffffff !important;
    color: #1a1a1a !important;
    border: 1px solid rgba(148, 163, 184, 0.45) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06) !important;
}
#chatMain .chat-main-header .chat-call-btn:hover,
#chatMain .chat-main-header .chat-call-btn:focus-visible {
    background: #22c55e !important;
    color: #ffffff !important;
    border-color: rgba(34, 197, 94, 0.75) !important;
    box-shadow: 0 2px 10px rgba(34, 197, 94, 0.35) !important;
}
@media (max-width: 1024px) {
    /* In Zeile: kein eigener Außen-Margin — Abstand kommt von .chat-main-header-row (--kinma-chat-header-inset) */
    #chatMain .chat-main-header-row .chat-main-header,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact #chatMain .chat-main-header-row .chat-main-header,
    .chat-popup.active.chat-popup-mobile-fullscreen.has-active-contact #chatMain > .chat-main-header-row > #chatMainHeader.chat-main-header {
        border-radius: 9999px !important;
        margin: 0 !important;
        padding: 5px !important;
        top: auto !important;
        left: 0 !important;
        right: auto !important;
        box-sizing: border-box !important;
    }
}

/* Header-Layout: links User-Info, Mitte Anruf (Icon+Timer), rechts Call-Buttons – nur auf Mobile in der Zeile, Desktop bleibt absolute */
@media (max-width: 1024px) {
    #chatMain .chat-main-header {
        position: relative !important;
    }
}
#chatMain .chat-main-header .chat-main-header-normal {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    gap: 10px !important;
}
#chatMain .chat-main-header .chat-user-info {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    padding: 0 !important;
    gap: 10px !important;
}
#chatMain .chat-main-header .chat-call-buttons {
    flex-shrink: 0 !important;
    padding: 0 !important;
    gap: 8px !important;
}
/* Anruf-Icon + Timer: absolut zentriert in der Header-Mitte (kein Überlappen mit Buttons) */
#chatMain .chat-main-header .chat-main-header-call-center {
    display: none !important;
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 2 !important;
}
#chatMain .chat-main-header.chat-main-header-call-active .chat-main-header-call-center {
    display: flex !important;
}
#chatMain .chat-main-header .chat-main-header-call-center .chat-main-header-call-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}
#chatMain .chat-main-header .chat-main-header-call-center .chat-main-header-call-icon svg {
    width: 18px !important;
    height: 18px !important;
    color: #fff !important;
    display: block !important;
}
#chatMain .chat-main-header .chat-main-header-call-center .chat-main-header-call-timer {
    font-size: 14px !important;
    font-weight: 600 !important;
    font-variant-numeric: tabular-nums !important;
    color: #fff !important;
    min-width: 44px !important;
    text-align: center !important;
}

/* Aktiver Anruf: Header wird grün, Normal-Inhalt bleibt sichtbar */
#chatMain .chat-main-header.chat-main-header-call-active {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    box-shadow: 0 2px 12px rgba(40, 167, 69, 0.35) !important;
    cursor: pointer !important;
}
#chatMain .chat-main-header.chat-main-header-call-active .chat-user-name,
#chatMain .chat-main-header.chat-main-header-call-active .chat-user-avatar {
    color: #fff !important;
}
#chatMain .chat-main-header.chat-main-header-call-active .chat-user-avatar {
    background: rgba(255, 255, 255, 0.25) !important;
}
/* Bei aktivem Anruf: Telefon-/Video-Start-Buttons ausblenden */
#chatMain .chat-main-header.chat-main-header-call-active .chat-call-buttons {
    display: none !important;
}
/* Bei aktivem Anruf: Header-Anrufsteuerung anzeigen (Kamera, Stummschaltung, Auflegen) */
#chatMain .chat-main-header .chat-header-call-controls {
    display: none !important;
    flex-shrink: 0 !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 !important;
}
#chatMain .chat-main-header.chat-main-header-call-active .chat-header-call-controls {
    display: flex !important;
}
#chatMain .chat-main-header .chat-header-call-control-btn {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    border: none !important;
    background: rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}
#chatMain .chat-main-header .chat-header-call-control-btn:hover {
    background: rgba(255, 255, 255, 0.4) !important;
    color: #fff !important;
}
/* Stummschaltung aktiv: anderer Farbton als Hinweis */
#chatMain .chat-main-header .chat-header-call-control-btn.muted {
    background: rgba(220, 53, 69, 0.5) !important;
    color: #fff !important;
}
#chatMain .chat-main-header .chat-header-call-control-btn.muted:hover {
    background: rgba(220, 53, 69, 0.75) !important;
    color: #fff !important;
}
#chatMain .chat-main-header .chat-header-call-control-btn.chat-header-call-end-btn {
    background: rgba(220, 53, 69, 0.9) !important;
}
#chatMain .chat-main-header .chat-header-call-control-btn.chat-header-call-end-btn:hover {
    background: #dc3545 !important;
}

/* Scrollbereich: füllt gesamte #chatMain, scrollt hinter Header und Eingabe; Abstand oben/unten */
#chatMain .chat-messages,
#chatMain #chatMessages,
.chat-popup.active #chatMain > .chat-messages {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    scrollbar-width: thin !important;
    scrollbar-color: #282a2e transparent !important;
    /* Abstand oben zum Header (oben gescrollt), unten zur Eingabe (unten gescrollt) */
    padding-top: 78px !important;
    padding-bottom: calc(var(--kinma-chat-composer-bottom, 78px) + 4px) !important;
    scroll-padding-bottom: calc(var(--kinma-chat-composer-bottom, 78px) + 4px) !important;
    box-sizing: border-box !important;
    /* Häkchen/Metadaten bleiben unter Header (4) und Eingabe (3) */
    z-index: 1 !important;
    isolation: isolate !important;
}

#chatMain.chat-main-has-activity-strip .chat-messages,
.chat-popup.active #chatMain.chat-main-has-activity-strip > .chat-messages {
    padding-top: 142px !important;
}

#chatMain .chat-header-activity-strip {
    position: absolute !important;
    top: 74px !important;
    left: calc(var(--kinma-chat-header-inset, 12px) + env(safe-area-inset-left, 0px)) !important;
    right: calc(var(--kinma-chat-header-inset, 12px) + env(safe-area-inset-right, 0px)) !important;
    z-index: 4 !important;
    display: none;
    pointer-events: none;
}

#chatMain .chat-header-activity-strip-scroll {
    display: flex;
    align-items: stretch;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 4px 2px 4px;
    scrollbar-width: none !important;
    -ms-overflow-style: none;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
    touch-action: pan-x;
}

#chatMain .chat-header-activity-strip-scroll.is-dragging,
#chatMain .chat-header-activity-strip-scroll.is-pointer-down {
    cursor: grabbing;
}

#chatMain .chat-header-activity-strip-scroll::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
}

#chatMain .chat-header-activity-strip-scroll::-webkit-scrollbar-track,
#chatMain .chat-header-activity-strip-scroll::-webkit-scrollbar-thumb {
    display: none !important;
    background: transparent !important;
}
#chatMain.chat-main-loading .chat-main-header,
#chatMain.chat-main-loading .chat-input-container {
    display: none !important;
}
/* Eingabefeld: fix unten – bewegt sich nicht beim Scrollen */
#chatMain .chat-input-container {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 3 !important;
    flex-shrink: 0 !important;
    background: transparent !important;
}
@media (min-width: 1025px) {
    #chatMain .chat-input-container {
        bottom: 6px !important;
        left: 0 !important;
        right: 0 !important;
        padding: 0 12px 6px 12px !important;
        box-sizing: border-box !important;
    }
    #chatMain .chat-input-container .chat-input-bar-row {
        padding: 0 !important;
        margin: 0 !important;
    }
}
/* „Nach unten scrollen“: über der Eingabe (folgt bei Dateivorschau mit), nur gefülltes Dreieck in Dunkelgrau */
#chatMain .chat-input-container > .chat-new-messages-bar.chat-scroll-to-bottom {
    position: absolute !important;
    top: auto !important;
    left: auto !important;
    right: 12px !important;
    bottom: 100% !important;
    margin: 0 0 10px 0 !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    max-width: 42px !important;
    max-height: 42px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
    z-index: 6 !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    background: #ffffff !important;
    color: #52525b !important;
    border: 1px solid rgba(26, 26, 26, 0.1) !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12) !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    /* nicht mehr sticky oben in der Liste */
    align-self: unset !important;
}
#chatMain .chat-input-container > .chat-new-messages-bar.chat-scroll-to-bottom:hover {
    background: #f4f4f5 !important;
    color: #3f3f46 !important;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.14) !important;
}
#chatMain .chat-input-container > .chat-new-messages-bar.chat-scroll-to-bottom:active {
    transform: translateY(1px) !important;
}
#chatMain .chat-input-container > .chat-new-messages-bar.chat-scroll-to-bottom .chat-scroll-to-bottom-arrow {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    line-height: 0 !important;
}
#chatMain .chat-input-container > .chat-new-messages-bar.chat-scroll-to-bottom .chat-scroll-to-bottom-triangle {
    display: block !important;
    width: 14px !important;
    height: 10px !important;
}

/* ========== Schwebendes Kamera-Fenster (außerhalb Chatbox, 1x oder 2x 16:9, ziehbar) ========== */
/* Standard: ausgeblendet – nur per JS anzeigen wenn Anruf + Kamera aktiv */
.floating-call-video-window {
    display: none !important;
    position: fixed !important;
    z-index: 2147483646 !important;
    width: 320px !important;
    min-width: 280px !important;
    max-width: 90vw !important;
    background: #1a1a1a !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    flex-direction: column !important;
    left: 24px;
    top: 24px;
}
.floating-call-video-window.is-visible {
    display: flex !important;
}
.floating-call-video-window {
    cursor: move !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}
.floating-call-video-slots {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
}
.floating-call-video-slot {
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    background: #1a1a1a !important;
    overflow: hidden !important;
}
.floating-call-video-slot video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
    pointer-events: none !important;
}
.floating-call-video-slot-label {
    position: absolute !important;
    left: 50% !important;
    bottom: 8px !important;
    transform: translateX(-50%) !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: rgba(255, 255, 255, 0.95) !important;
    background: rgba(0, 0, 0, 0.55) !important;
    padding: 6px 14px !important;
    border-radius: 9999px !important;
    pointer-events: none !important;
}
.floating-call-video-window.single-slot .floating-call-video-slot:nth-child(2) {
    display: none !important;
}
.floating-call-video-window.two-slots .floating-call-video-slot {
    display: block !important;
}

/* Hover-Controls: Kamera, Stummschaltung, Auflegen, Andocken (X) – nur 1x über dem Fenster */
.floating-call-video-controls {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 10px 12px !important;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent) !important;
    opacity: 0 !important;
    transition: opacity 0.2s ease !important;
    pointer-events: none !important;
}
.floating-call-video-window:hover .floating-call-video-controls {
    opacity: 1 !important;
    pointer-events: auto !important;
}
.floating-call-video-ctrl-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    border: none !important;
    background: rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
}
.floating-call-video-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.4) !important;
}
.floating-call-video-ctrl-btn.muted {
    background: rgba(220, 53, 69, 0.5) !important;
}
.floating-call-video-ctrl-btn.muted:hover {
    background: rgba(220, 53, 69, 0.75) !important;
}
.floating-call-video-ctrl-btn.floating-call-video-ctrl-end {
    background: rgba(220, 53, 69, 0.9) !important;
}
.floating-call-video-ctrl-btn.floating-call-video-ctrl-end:hover {
    background: #dc3545 !important;
}
.floating-call-video-ctrl-btn.floating-call-video-ctrl-dock {
    margin-left: 4px !important;
}

/* Andocken: Fenster seitlich aus dem Bildschirm */
.floating-call-video-window.is-docked {
    left: 100vw !important;
    transform: translateX(0) !important;
    transition: left 0.25s ease !important;
}
.floating-call-video-window.is-docked .floating-call-video-controls {
    pointer-events: none !important;
}

/* Tab am rechten Rand – nur sichtbar wenn Kamera-Popup angedockt ist (nicht geöffnet), bei Anruf + Video */
.floating-call-video-dock-tab {
    display: none !important;
    position: fixed !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 2147483646 !important;
    width: 40px !important;
    height: 72px !important;
    background: #2a2a2a !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-right: none !important;
    border-radius: 12px 0 0 12px !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    color: #e0e0e0 !important;
    box-shadow: -4px 0 16px rgba(0,0,0,0.3) !important;
    transition: background 0.2s ease !important;
}
.floating-call-video-dock-tab.is-visible {
    display: flex !important;
}
.floating-call-video-dock-tab:hover {
    background: #383838 !important;
    color: #fff !important;
}

/* Nachrichtenabstand: nur >5 Min seit der vorherigen Nachricht (egal welche Seite) */
#chatMain .chat-messages > .chat-message,
.chat-popup.active #chatMain > .chat-messages > .chat-message {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

#chatMain .chat-messages > .chat-message-time-cluster-start,
.chat-popup.active #chatMain > .chat-messages > .chat-message-time-cluster-start,
#chatMain .chat-messages > .chat-message + .chat-message.chat-message-time-cluster-start,
#chatMessages > .chat-message + .chat-message.chat-message-time-cluster-start,
.chat-popup.active #chatMain > .chat-messages > .chat-message + .chat-message.chat-message-time-cluster-start {
    margin-top: 16px !important;
}

#chatMain .chat-messages > .chat-message + .chat-message.chat-message-after-side-break:not(.chat-message-time-cluster-start),
#chatMessages > .chat-message + .chat-message.chat-message-after-side-break:not(.chat-message-time-cluster-start) {
    margin-top: 10px !important;
}

/* Systemnachrichten (Anruf etc.): Abstand trotz Basis margin:0 auf allen .chat-message-Zeilen */
#chatMain .chat-messages > .chat-message.chat-message-system + .chat-message.chat-message-system,
.chat-popup.active #chatMain > .chat-messages > .chat-message.chat-message-system + .chat-message.chat-message-system,
#chatMessages > .chat-message.chat-message-system + .chat-message.chat-message-system {
    margin-top: 10px !important;
}

#chatMain .chat-messages > .chat-message.chat-message-system + .chat-message:not(.chat-message-system),
.chat-popup.active #chatMain > .chat-messages > .chat-message.chat-message-system + .chat-message:not(.chat-message-system),
#chatMessages > .chat-message.chat-message-system + .chat-message:not(.chat-message-system) {
    margin-top: 12px !important;
}

#chatMain .chat-messages > .chat-message:not(.chat-message-system) + .chat-message.chat-message-system,
.chat-popup.active #chatMain > .chat-messages > .chat-message:not(.chat-message-system) + .chat-message.chat-message-system,
#chatMessages > .chat-message:not(.chat-message-system) + .chat-message.chat-message-system {
    margin-top: 12px !important;
}

#chatMain .chat-messages > .chat-date-separator + .chat-message.chat-message-system,
.chat-popup.active #chatMain > .chat-messages > .chat-date-separator + .chat-message.chat-message-system,
#chatMessages > .chat-date-separator + .chat-message.chat-message-system {
    margin-top: 8px !important;
}
