.chat-day-divider {
    text-align: center;
    padding: 0.5rem 0.8rem;
    color: #999;
    font-size: calc(var(--chat-font-size) - 0.04rem);
    font-weight: 600;
    user-select: none;
    letter-spacing: 0.02em;
    line-height: 1;
    margin: 0.15rem 0;
}
:root {
    --chat-font-size: 0.8rem;
    --sidebar-w: 250px;
    --subnav-w: 262px;
    --topbar-h: 82px;
    --composer-h: 44px;
    --sidebar-w-tablet: 200px;
    --subnav-w-tablet: 220px;
    --topbar-h-tablet: 64px;
}

html,
body {
    height: 100%;
    background: #ececec;
    overflow-x: hidden;
}

.app-main {
    flex-direction: row;
    background: #ececec;
    overflow: hidden !important;
}
.chat {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #ececec;
}
.chat-legacy-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0.8rem 0;
    background: #ececec;
    border-bottom: 1px solid #cfcfcf;
    flex-shrink: 0;
}
.chat-body {
    flex: 0.93;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#messages {
    display: flex;
    flex-direction: column;
    overflow-anchor: none;
    overflow-y: auto;
    overflow-x: hidden;
    background: #ededed;
    color: #444444;
    font-family: Arial, Helvetica, sans-serif;
    white-space: pre-wrap;
    padding: 0.55rem 1rem 0.15rem;
    font-size: var(--chat-font-size);
    margin-bottom: 0;
    flex: 1;
    min-height: 0;
    box-sizing: border-box;
}
#messages::before {
    content: '';
    flex: 1 1 auto;
    min-height: 0;
}
#chat-load-more,
#chat-history-end,
.chat-load-more,
.chat-history-end {
    flex: 0 0 auto;
}
.chat-line,
.chat-day-divider {
    flex: 0 0 auto;
}
#messages .chat-line:last-child {
    border-bottom: none;
}
.same-time {
    color: #ffffff;
}
.chat-line {
    position: relative;
    padding: 0;
    border: none;
    margin: 0;
    line-height: 1.2;
    font-size: var(--chat-font-size);
    color: #444444;
    word-break: break-word;
}
.chat-line.is-replying-to {
    background: rgba(255,255,255,0.75);
    border-radius: 8px;
    box-shadow: inset 3px 0 0 #8aaee0;
}
.chat-line.is-highlighted {
    animation: chat-message-highlight 1.4s ease;
}
@keyframes chat-message-highlight {
    0% { background: rgba(255,225,128,0.95); box-shadow: 0 0 0 3px rgba(255,199,44,0.42); }
    100% { background: transparent; box-shadow: none; }
}
.chat-line-header {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}
.chat-line-main {
    flex: 1 1 auto;
    min-width: 0;
}
.chat-line-time {
    flex: 0 0 48px;
    width: 48px;
    color: #777777;
    font-size: calc(var(--chat-font-size) - 0.02rem);
    line-height: 1.32;
    text-align: right;
    white-space: nowrap;
}
.chat-line-role-icon {
    vertical-align: middle;
    margin-right: 0.25rem;
}
.chat-line-nick {
    color: #555555;
    font-weight: 700;
}
.chat-line-separator {
    margin: 0 0.35rem 0 0.1rem;
    color: #777777;
}
.chat-line-content {
    display: inline;
}
.chat-line.has-image .chat-line-content {
    display: block;
    margin-top: 0.12rem;
}
.chat-line-content-system {
    color: #555555;
}
.chat-reply-chip {
    appearance: none;
    display: block;
    width: min(620px, calc(100% - 2.4rem));
    margin: 0.15rem 0 0.25rem 2.4rem;
    padding: 0.3rem 0.55rem;
    border: none;
    border-left: 3px solid #8aaee0;
    background: rgba(138,174,224,0.08);
    border-radius: 0 6px 6px 0;
    color: #606060;
    font-family: inherit;
    font-size: calc(var(--chat-font-size) - 0.04rem);
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.chat-reply-chip:hover {
    background: rgba(138,174,224,0.16);
    border-left-color: #5d8bcc;
}
.chat-reply-chip-label {
    display: inline;
    color: #3f5f8d;
    font-weight: 700;
    margin-right: 0.35rem;
}
.chat-reply-chip-label::after {
    content: ':';
    color: #999;
    margin-left: 0.05rem;
}
.chat-reply-chip-text {
    display: inline;
    color: #707070;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-reply-button {
    flex: 0 0 auto;
    min-width: 34px;
    padding: 0.08rem 0.35rem;
    border: 1px solid #cfcfcf;
    background: linear-gradient(180deg,#ffffff 0%,#e6e6e6 100%);
    border-radius: 4px;
    color: #666;
    font-family: inherit;
    font-size: 0.82rem;
    line-height: 1.2;
    opacity: 0.62;
}
.chat-reply-button:hover {
    color: #333;
    border-color: #bdbdbd;
    cursor: pointer;
    opacity: 1;
}
.chat-line:hover .chat-reply-button,
.chat-line.is-replying-to .chat-reply-button {
    opacity: 1;
}
.chat-line strong {
    color: #555555;
    font-weight: 700;
}
.chat-line a {
    color: var(--vp-link);
    text-decoration: none;
    word-break: break-all;
}
.chat-line a:hover {
    text-decoration: underline;
}
.chat-mention-self {
    color: #e39b11;
    font-weight: 700;
}
.chat-composer {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0.45rem 0.75rem 0.55rem;
    background: #e3e3e3;
    border-top: 1px solid #bdbdbd;
    box-shadow: inset 0 1px 0 #f8f8f8;
    box-sizing: border-box;
    flex-shrink: 0;
}
.chat-composer .input-group {
    width: 100%;
    gap: 0.45rem;
    align-items: stretch;
}
.chat-composer .input-group-text {
    min-width: 58px;
    justify-content: center;
    background: linear-gradient(180deg,#ffffff 0%,#e7e7e7 100%);
    border: 1px solid #bdbdbd;
    border-radius: 3px;
    color: #707070;
    font-weight: 700;
}
.chat-composer #input_msg {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 42px;
    padding: 0.55rem 0.7rem;
    border: 1px solid #a9a9a9;
    border-radius: 2px;
    background: #ffffff;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}
.chat-composer .btn-primary {
    min-width: 106px;
    background: linear-gradient(180deg,#ffffff 0%,#dfdfdf 100%);
    border-color: #bdbdbd;
    color: #666666;
}
.chat-composer .btn-primary:hover {
    background: linear-gradient(180deg,#ffffff 0%,#d6d6d6 100%);
    color: #464646;
}
.app-subnav {
    position: relative;
    padding: 0;
    flex: 0 0 var(--subnav-w);
    width: var(--subnav-w);
    min-width: var(--subnav-w);
    max-width: var(--subnav-w);
    box-sizing: border-box;
    overflow: hidden;
}
.chat-sidebar-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    background: #efefef;
}
.chat-sidebar-header {
    padding: 0.75rem 0.85rem;
    background: linear-gradient(180deg,#f4f4f4 0%,#e1e1e1 100%);
    border-bottom: 1px solid #c7c7c7;
    color: #676767;
    font-weight: 700;
}
.chat-sidebar-search-wrap {
    padding: 0.55rem 0.7rem;
    background: #ececec;
    border-bottom: 1px solid #d6d6d6;
}
.chat-sidebar-search {
    min-height: 38px;
    border: 1px solid #bdbdbd;
    background: #ffffff;
    color: #555555;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.chat-sidebar-search:focus {
    border-color: #8aaee0;
    box-shadow: 0 0 0 0.15rem rgba(13,110,253,0.12);
}
.chat-sidebar-link[hidden] {
    display: none !important;
}
.chat-load-more {
    text-align: center;
    padding: 0.6rem 0.8rem;
    color: #888;
    font-size: 0.88rem;
    cursor: pointer;
    user-select: none;
}

/* --- Breadcrumb --- */
.chat-legacy-breadcrumb {
    display: flex;
    align-items: stretch;
    gap: 0;
    min-width: 0;
    height: 43px;
    padding: 0;
    overflow: visible;
}
.chat-legacy-crumb {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    min-height: 43px;
    height: 43px;
    margin: 0 0 0 -12px;
    padding: 0 24px 0 27px;
    border: 1px solid #d0d0d0;
    border-top: 0;
    border-bottom-color: #c4c4c4;
    border-radius: 0;
    background: linear-gradient(180deg, #fafafa 0%, #ececec 100%);
    color: #3178c6;
    clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%);
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
}
.chat-legacy-crumb:first-child {
    margin-left: 0;
}
.chat-legacy-crumb.is-home {
    min-width: 61px;
    padding: 0 21px 0 14px;
    color: #4a9bdd;
    font-size: 24px;
    font-weight: 700;
}
.chat-legacy-crumb.is-current {
    min-width: 160px;
    background: #ffffff;
    color: #111111;
    font-weight: 700;
}

/* --- Reply preview --- */
.chat-reply-preview {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.65rem;
    padding: 0.35rem 0.5rem;
    background: rgba(235,245,255,0.9);
    border: 1px solid #b8c8e0;
    border-left: 3px solid #8aaee0;
    margin-bottom: 0.3rem;
    box-sizing: border-box;
    flex-shrink: 0;
    cursor: pointer;
}
.chat-reply-preview[hidden] {
    display: none;
}
.chat-reply-preview-meta {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.25rem 0.45rem;
    background: rgba(255,255,255,0.7);
    border-left: 3px solid #8aaee0;
    color: #555;
    line-height: 1.2;
    cursor: pointer;
}
.chat-reply-preview-meta strong,
.chat-reply-preview-meta small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-reply-preview-meta strong {
    font-size: 0.85rem;
    color: #3f5f8d;
}
.chat-reply-preview-meta small {
    font-size: 0.75rem;
}

/* --- Image preview --- */
.chat-image-preview {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.65rem;
    padding: 0.35rem 0.5rem;
    background: rgba(255,248,235,0.9);
    border: 1px solid #dcc8a8;
    border-left: 3px solid #e8a040;
    margin-bottom: 0.3rem;
    box-sizing: border-box;
    flex-shrink: 0;
}
.chat-image-preview[hidden] {
    display: none;
}
.chat-image-preview-thumb {
    width: 42px;
    min-width: 42px;
    height: 42px;
    object-fit: cover;
    border: 1px solid #c8b898;
    background: #fff;
    cursor: pointer;
}
.chat-image-preview-meta {
    flex: 1 1 auto;
    min-width: 0;
    color: #555;
    line-height: 1.2;
}
.chat-image-preview-meta strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
    color: #8a5a1a;
    margin-bottom: 0.05rem;
}
.chat-image-preview-meta small {
    display: block;
    font-size: 0.75rem;
    color: #8a6a3a;
}

/* --- Inline images in messages --- */
.chat-inline-image {
    display: block;
    max-width: min(420px, 100%);
    max-height: 320px;
    margin-top: 4px;
    border: 1px solid #c8c8c8;
    background: #ffffff;
    object-fit: contain;
}
.chat-inline-image-link {
    display: block;
    position: relative;
    max-width: min(420px, 100%);
    text-decoration: none;
}
.chat-inline-image-link:hover .chat-inline-image-action {
    opacity: 1;
}
.chat-inline-image-action {
    position: absolute;
    bottom: 6px;
    right: 6px;
    display: inline-block;
    padding: 0.15rem 0.4rem;
    background: rgba(0,0,0,0.58);
    color: #fff;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}
.chat-load-more:hover {
    color: #555;
    background: rgba(0,0,0,0.03);
}
.chat-history-end {
    text-align: center;
    padding: 0.6rem 0.8rem;
    color: #aaa;
    font-size: 0.82rem;
    user-select: none;
}
.chat-sidebar-content {
    flex: 0.9;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}
.chat-sidebar-content .list-group {
    background: #f2f2f2;
}
#chat_sidebar,
#chat_sidebar_offcanvas {
    background: #f2f2f2;
}
.chat-sidebar-link {
    display: block;
}
.chat-user-role-icon {
    vertical-align: middle;
    margin-right: 0.2rem;
}
#chat_sidebar .list-group-item,
#chat_sidebar_offcanvas .list-group-item {
    padding: 0.34rem 0.7rem;
    font-size: 1rem;
    line-height: 1.15;
    border-left: 4px solid transparent;
    border-right: 0;
    border-radius: 0;
    background: #f6f6f6;
    color: #575757;
}
#chat_sidebar .list-group-item:hover,
#chat_sidebar_offcanvas .list-group-item:hover {
    background: #fbfbfb;
    color: #363636;
}
#chat_sidebar .list-group-item.active,
#chat_sidebar_offcanvas .list-group-item.active {
    background: #ffffff;
    border-left-color: var(--vp-link);
    color: var(--vp-link);
    box-shadow: inset 0 1px 0 #ffffff, inset 0 -1px 0 #dddddd;
}
#chat_sidebar .list-group-item .badge,
#chat_sidebar_offcanvas .list-group-item .badge {
    font-size: 0.62rem;
    padding: 0.16rem 0.34rem;
}
#chat_sidebar .list-group-item small,
#chat_sidebar_offcanvas .list-group-item small {
    font-size: 0.8rem;
}
.chat-user-nick {
    font-weight: 700;
}
@media (max-width: 991.98px) {
    .chat-legacy-header { padding: 0.25rem 0.55rem 0; }
    .chat-legacy-crumb { min-height: 34px; padding: 0.42rem 0.8rem 0.38rem; }
    .chat-composer { padding: 0.45rem 0.5rem 0.5rem; }
    .chat-composer .input-group { gap: 0.35rem; }
    .chat-composer .btn-primary { min-width: 84px; }
    #messages { padding-left: 0.65rem; padding-right: 0.65rem; }
}
.chat-hide-events-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0 0.3rem;
    padding: 0.15rem 0.3rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    font-size: 0.78rem;
    color: #444;
    background: transparent;
}
.chat-hide-events-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}
.chat-hide-events-text {
    font-size: 0.78rem;
    color: #444;
    vertical-align: middle;
}
.chat-emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0.75rem;
    right: 0.75rem;
    z-index: 1050;
    max-height: 260px;
    display: flex;
    flex-direction: column;
    background: #f8f8f8;
    border: 1px solid #bdbdbd;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
    overflow: hidden;
    margin-bottom: 0;
}
.chat-emoji-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.7rem;
    background: linear-gradient(180deg,#f4f4f4 0%,#e1e1e1 100%);
    border-bottom: 1px solid #c7c7c7;
    color: #676767;
    font-weight: 700;
    flex-shrink: 0;
}
.chat-emoji-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.6rem;
    overflow-y: auto;
    flex: 1 1 auto;
    align-content: flex-start;
}
.chat-emoji-picker-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 2px;
    background: #ffffff;
    border: 1px solid #d6d6d6;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
}
.chat-emoji-picker-item:hover {
    background: #e8f0fe;
    border-color: #8aaee0;
    transform: scale(1.12);
    z-index: 1;
}
.chat-emoji-picker-item img {
    display: block;
    width: 22px;
    height: 22px;
    object-fit: contain;
    pointer-events: none;
}
.chat-emoji-picker-footer {
    flex-shrink: 0;
    padding: 0.3rem 0.7rem;
    background: #ececec;
    border-top: 1px solid #d6d6d6;
    color: #888;
    text-align: center;
}

.chat-fontsize-controls {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin-left: auto;
}

.chat-fontsize-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #bdbdbd;
    background: linear-gradient(180deg,#ffffff 0%,#e6e6e6 100%);
    border-radius: 4px;
    color: #666;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}

.chat-fontsize-btn:hover {
    background: linear-gradient(180deg,#f6f6f6 0%,#d6d6d6 100%);
    border-color: #aaa;
    color: #333;
}

/* --- Search input in header --- */
#chat_search_input_wrap {
    margin-right: 0.4rem;
}
#chat_search_input_wrap .chat-search-input {
    max-width: 340px;
}
#chat_search_input_wrap[hidden] {
    display: none !important;
}

.chat-fontsize-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 28px;
    padding: 0 0.3rem;
    color: #777;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: monospace;
    line-height: 1;
    text-align: center;
}

.chat-legacy-mobile-button {
    font-weight: 700;
    font-size: 0.88rem;
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .chat-composer .input-group-text {
        min-width: 44px;
        font-size: 0.78rem;
    }
    .chat-composer .btn-primary {
        min-width: 64px;
        font-size: 0.82rem;
        padding: 0.35rem 0.5rem;
    }
    .chat-composer #input_msg {
        min-height: 36px;
        font-size: 0.88rem;
    }
    #button_emoji, #button_attach_image {
        min-width: 32px;
        padding: 0.2rem 0.3rem;
        font-size: 1rem;
    }
}

@media (max-width: 375px) {
    .chat-composer .input-group-text {
        min-width: 36px;
        font-size: 0.72rem;
    }
    .chat-composer .btn-primary {
        min-width: 54px;
        font-size: 0.75rem;
        padding: 0.25rem 0.35rem;
    }
    .chat-composer #input_msg {
        min-height: 32px;
        font-size: 0.82rem;
    }
    #button_emoji, #button_attach_image {
        min-width: 28px;
        padding: 0.15rem 0.2rem;
        font-size: 0.9rem;
    }
    #messages {
        padding-left: 0.4rem;
        padding-right: 0.4rem;
        font-size: calc(var(--chat-font-size) - 0.05rem);
    }
}

/* --- Typing indicator: inside the composer form --- */
#chat_typing_indicator {
    display: none;
    box-sizing: border-box;
    padding: 0.1rem 0 0.2rem;
    font-size: 0.82rem;
    font-style: italic;
    color: #555;
    line-height: 1.3;
    pointer-events: none;
    text-align: left;
    background: transparent;
    border: none;
}
#chat_typing_indicator.is-active {
    display: block;
}
#chat_typing_indicator::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 0.35rem;
    background: #8aaee0;
    border-radius: 50%;
    animation: chat-typing-pulse 1.2s ease-in-out infinite;
    vertical-align: middle;
}
@keyframes chat-typing-pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* --- Image viewer dialog --- */
.chat-image-viewer {
    border: none;
    padding: 0;
    background: rgba(0,0,0,0.92);
    color: #fff;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    overflow: auto;
}
.chat-image-viewer::backdrop {
    background: rgba(0,0,0,0.88);
}
.chat-image-viewer-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}
.chat-image-viewer-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: rgba(0,0,0,0.55);
    z-index: 10;
}
.chat-image-viewer-img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 5rem);
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: zoom-in;
    transition: transform 0.15s ease;
}
.chat-image-viewer-img-full {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}
.chat-image-viewer-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem 0.85rem;
    background: rgba(0,0,0,0.55);
    z-index: 10;
}
.chat-image-viewer-footer .btn-outline-light {
    color: #ccc;
    border-color: #888;
}
.chat-image-viewer-footer .btn-outline-light:hover {
    color: #fff;
    border-color: #bbb;
}

/* --- Inline file attachments in messages --- */
.chat-inline-file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: min(420px, 100%);
    margin-top: 4px;
    padding: 0.4rem 0.6rem;
    background: #f5f5f5;
    border: 1px solid #d0d0d0;
    border-left: 4px solid #e74c3c;
    border-radius: 6px;
    text-decoration: none;
    color: #444;
    font-size: calc(var(--chat-font-size) - 0.02rem);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.chat-inline-file-link:hover {
    background: #ffffff;
    border-color: #c0392b;
    text-decoration: none;
    color: #222;
}
.chat-inline-file-icon {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
}
.chat-inline-file-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: #555;
}
.chat-inline-file-action {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #888;
    font-weight: 600;
    white-space: nowrap;
}
.chat-inline-file-link:hover .chat-inline-file-action {
    color: #c0392b;
}
.chat-line.has-file .chat-line-content {
    display: block;
    margin-top: 0.12rem;
}

/* --- Message search bar --- */
.chat-search-bar {
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #f0f0f0;
    border-top: 1px solid #d0d0d0;
    padding: 0.5rem 0.75rem;
    gap: 0.4rem;
    max-height: 40vh;
    overflow-y: auto;
    overflow-x: hidden;
}
.chat-search-bar[hidden] {
    display: none !important;
}
.chat-search-input-wrap {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    gap: 0.4rem;
}
.chat-search-icon {
    flex-shrink: 0;
    font-size: 1rem;
    opacity: 0.6;
}
.chat-search-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.4rem 0.55rem;
    border: 1px solid #bdbdbd;
    border-radius: 6px;
    background: #ffffff;
    color: #444;
    font-size: 0.88rem;
    outline: none;
}
.chat-search-input:focus {
    border-color: #8aaee0;
    box-shadow: 0 0 0 0.15rem rgba(13,110,253,0.12);
}
.chat-search-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #c8c8c8;
    border-radius: 50%;
    background: #ffffff;
    color: #888;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-search-close:hover {
    background: #f0f0f0;
    color: #555;
}
.chat-search-status {
    font-size: 0.75rem;
    color: #777;
    padding: 0.1rem 0;
    text-align: left;
}
.chat-search-status[hidden] {
    display: none;
}
.chat-search-results {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.chat-search-results[hidden] {
    display: none;
}
.chat-search-result {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #c8c8d0;
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 0.8rem;
    line-height: 1.35;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    gap: 0;
}
.chat-search-result:hover {
    background: #f5f9ff;
    border-color: #b8c8e0;
    border-left-color: #8aaee0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.chat-search-result-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.chat-search-result-role-icon {
    vertical-align: middle;
    flex-shrink: 0;
}
.chat-search-result-nick {
    color: #3f5f8d;
    font-weight: 700;
    font-size: 0.8rem;
    white-space: nowrap;
}
.chat-search-result-time {
    color: #999;
    font-size: 0.72rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.chat-search-result-body {
    flex: 1 1 auto;
    min-width: 0;
    color: #555;
    font-size: 0.8rem;
    line-height: 1.35;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    word-break: break-word;
}
.chat-search-result-body .chat-search-highlight {
    background: #f9e2af;
    color: #1e1e2e;
    padding: 0.05rem 0.15rem;
    border-radius: 3px;
    font-weight: 700;
}
.chat-search-more {
    display: block;
    text-align: center;
    padding: 0.4rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    color: #666;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
}
.chat-search-more:hover {
    background: #f0f0f0;
    color: #444;
}
.chat-search-more[hidden] {
    display: none;
}

/* --- Search toggle button in header --- */
.chat-search-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid #bdbdbd;
    background: linear-gradient(180deg,#ffffff 0%,#e6e6e6 100%);
    border-radius: 4px;
    color: #666;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    user-select: none;
    margin-left: 0.5rem;
}
.chat-search-toggle-btn:hover {
    background: linear-gradient(180deg,#f6f6f6 0%,#d6d6d6 100%);
    border-color: #aaa;
    color: #333;
}

/* --- Group Sidebar Section --- */
.chat-sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.7rem;
    background: linear-gradient(180deg,#f8f8f8 0%,#e8e8e8 100%);
    border-bottom: 1px solid #d6d6d6;
    border-top: 1px solid #d6d6d6;
    color: #666;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.chat-create-group-btn {
    font-size: 0.92rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    line-height: 1.2;
}

/* --- Group Modal --- */
.chat-group-modal {
    border: none;
    padding: 0;
    background: transparent;
    max-width: 420px;
    width: 92%;
    border-radius: 12px;
    overflow: visible;
}
.chat-group-modal::backdrop {
    background: rgba(0,0,0,0.45);
}
.chat-group-modal-panel {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    overflow: hidden;
}
.chat-group-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background: linear-gradient(180deg,#f8f8f8 0%,#e8e8e8 100%);
    border-bottom: 1px solid #d6d6d6;
    color: #555;
    font-size: 1rem;
}
.chat-group-modal-header strong {
    font-size: 1.05rem;
}
.chat-group-modal-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.chat-group-modal-body label {
    font-weight: 600;
    color: #555;
    font-size: 0.88rem;
    margin-bottom: -0.3rem;
}
.chat-group-modal-body input {
    min-height: 38px;
}
.chat-group-modal-body small {
    margin-top: -0.3rem;
}
.chat-group-modal-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    padding: 0.6rem 0 0;
}
.chat-group-error {
    padding: 0.5rem 1rem;
    background: #fce4e4;
    color: #b52b2b;
    font-size: 0.85rem;
    border-top: 1px solid #f0c0c0;
}
.chat-group-error[hidden] {
    display: none;
}

/* --- Group Bar (in chat header) --- */
.chat-group-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.7rem;
    background: rgba(138,174,224,0.1);
    border-bottom: 1px solid #d0d8e8;
    flex-shrink: 0;
}

/* --- Group Members Modal --- */
.chat-group-members-list {
    padding: 1rem;
    max-height: 360px;
    overflow-y: auto;
}
.chat-group-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid #e8e8e8;
}
.chat-group-member-row:last-child {
    border-bottom: none;
}
#chat_group_members_actions {
    padding: 0.6rem 1rem 1rem;
}

#chat_group_delete_btn {
    margin-left: auto;
}


/* --- Group User Search --- */
.chat-group-user-search-container {
    position: relative;
}
.chat-group-user-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1070;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 0 0 0.375rem 0.375rem;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 6px 18px rgba(0,0,0,0.14);
}
.chat-group-user-results[hidden] {
    display: none;
}
.chat-group-user-result-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
    transition: background-color 0.12s;
}
.chat-group-user-result-item:last-child {
    border-bottom: none;
}
.chat-group-user-result-item:hover,
.chat-group-user-result-item.active {
    background-color: #e9ecef;
}
.chat-group-user-result-item .nick {
    font-weight: 600;
}
.chat-group-user-result-item .id-hint {
    color: #999;
    font-size: 0.78rem;
    margin-left: 0.5rem;
}
.chat-group-user-result-no-results,
.chat-group-user-result-loading {
    padding: 0.75rem;
    color: #6c757d;
    text-align: center;
    font-size: 0.85rem;
}
.chat-group-selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 0;
}
.chat-group-selected-users:empty {
    display: none;
}
.chat-group-user-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.45rem;
    background: #d1e7dd;
    border: 1px solid #a3cfbb;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #0f5132;
}
.chat-group-user-tag .remove-tag {
    cursor: pointer;
    font-weight: 700;
    color: #842029;
    padding: 0 0.15rem;
    font-size: 0.9rem;
    line-height: 1;
}
.chat-group-user-tag .remove-tag:hover {
    color: #b02a37;
}