/* Высота диалога как в Telegram: вписывается в экран, не растягивает страницу */
.main-container-messages {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: calc(100dvh - var(--office-header-h, 56px) - 2.75rem);
    display: flex;
    flex-wrap: nowrap;
    overflow: hidden;
}

.right-menu-content.is-visible .main-container-messages {
    flex: 1;
    min-height: 0;
}

.menu-contacts__list .chat-item {
    -webkit-touch-callout: none;
}

.menu-contacts {
    position: relative;
    flex: 0 0 240px;
    min-width: 200px;
    max-width: 280px;
    min-height: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--office-border, #1f2937);
    overflow: hidden;
    padding: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.menu-contacts__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.menu-contacts__scroll::-webkit-scrollbar {
    width: 0;
    display: none;
}

.chat-context-menu {
    position: fixed;
    z-index: 10050;
    min-width: 200px;
    padding: 4px 0;
    border-radius: 10px;
    background: #1a2332;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    pointer-events: auto;
    -webkit-user-select: none;
    user-select: none;
}

.chat-context-menu.hidden {
    pointer-events: none;
}

.chat-context-menu__item.hidden {
    display: none;
}

.chat-context-menu__item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: none;
    background: transparent;
    color: var(--office-text, #f1f5f9);
    font-size: 0.84rem;
    text-align: left;
    cursor: pointer;
}

.chat-context-menu__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--office-muted, #94a3b8);
}

.chat-context-menu__icon--read {
    color: #7dd3fc;
}

.chat-context-menu__icon--mute {
    color: #fbbf24;
}

.chat-context-menu__icon--danger,
.chat-context-menu__item--danger .chat-context-menu__icon {
    color: #f87171;
}

.chat-icon {
    display: block;
    width: 1.125rem;
    height: 1.125rem;
}

.chat-context-menu__label {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.chat-context-menu__item:hover {
    background: rgba(59, 130, 246, 0.15);
}

.chat-context-menu__item:hover .chat-context-menu__icon {
    color: #bfdbfe;
}

.chat-context-menu__item--danger {
    color: #fca5a5;
}

.chat-context-menu__item--danger:hover {
    background: rgba(239, 68, 68, 0.18);
}

.chat-context-menu__item--danger:hover .chat-context-menu__icon {
    color: #fecaca;
}

.chat-item--muted .chat-name {
    opacity: 0.92;
}

.chat-item__mute {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 0.35rem;
    vertical-align: middle;
    width: 1rem;
    height: 1rem;
    color: #fbbf24;
    opacity: 0.95;
}

.chat-item__mute .chat-icon {
    width: 1rem;
    height: 1rem;
}

.chat-item__mute:hover {
    color: #fcd34d;
}

.msg-media-tile--file {
    cursor: pointer;
}

/* —— Reply / pin / selection —— */

.chat-pinned-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    background: rgba(59, 130, 246, 0.12);
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--office-text, #f1f5f9);
}

.chat-pinned-bar__icon {
    flex-shrink: 0;
    color: #fbbf24;
}

.chat-pinned-bar__text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-pinned-bar__close {
    border: none;
    background: transparent;
    color: var(--office-muted, #94a3b8);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.25rem;
}

/* Нижняя зона: ответ + вложения + поле ввода (как в Telegram) */

.chat-compose-dock {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #243044;
    background: linear-gradient(180deg, #131c2e 0%, #0f1724 100%);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
}

.chat-reply-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 8px 12px 8px 10px;
    background: rgba(15, 23, 36, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
}

.chat-reply-bar.hidden {
    display: none;
}

.chat-reply-bar__accent {
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--office-accent, #3b82f6);
}

.chat-reply-bar__content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    padding-left: 8px;
}

.chat-reply-bar__title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--office-accent, #3b82f6);
    line-height: 1.2;
}

.chat-reply-bar__preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--office-muted, #94a3b8);
    min-width: 0;
}

.chat-reply-bar__preview-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.chat-reply-bar__thumb {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-reply-bar__close {
    border: none;
    background: transparent;
    color: var(--office-muted, #94a3b8);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.15rem;
    flex-shrink: 0;
}

.chat-reply-bar__close:hover {
    color: var(--office-text, #f1f5f9);
}

/* Цитата ответа внутри пузыря (Telegram) */

.msg--has-reply .msg-bubble {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 3px 3px 5px;
    overflow: hidden;
}

.msg--has-reply.msg--has-text:not(.msg--has-media) .msg-bubble {
    padding: 5px 5px 3px;
}

.msg--has-reply.msg--has-media:not(.msg--has-text) .msg-bubble {
    padding: 5px 5px 3px;
    background: var(--office-surface-2, #1a2332);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.msg--out.msg--has-reply.msg--has-media:not(.msg--has-text) .msg-bubble {
    background: linear-gradient(145deg, #3b82f6, #2563eb);
    border: none;
}

.msg--has-reply .msg-body {
    padding: 4px 7px 2px;
}

.msg--in.msg--has-reply .msg-body {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 1px;
}

.msg--out.msg--has-reply .msg-body {
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    margin-top: 1px;
}

.msg--has-reply.msg--compact .msg-body {
    padding-top: 3px;
}

.msg--has-reply .msg-text {
    line-height: 1.38;
}

.msg-reply-quote {
    display: flex;
    width: 100%;
    max-width: 100%;
    margin: 0 0 6px;
    padding: 4px 10px 4px 8px;
    border: none;
    border-left: 3px solid;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
    border-radius: 10px;
    transition: background 0.15s ease;
}

.msg--in .msg-reply-quote {
    border-left-color: var(--accent, #4f8cff);
    background: rgba(79, 140, 255, 0.08);
}

.msg--in .msg-reply-quote:hover {
    background: rgba(79, 140, 255, 0.14);
}

.msg--out .msg-reply-quote {
    border-left-color: rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.12);
}

.msg--out .msg-reply-quote:hover {
    background: rgba(255, 255, 255, 0.2);
}

.msg-reply-quote__body {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-align: left;
}

.msg-reply-quote--with-thumb .msg-reply-quote__body {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0 6px;
}

.msg-reply-quote__author {
    display: block;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.msg--out .msg-reply-quote__author {
    color: rgba(255, 255, 255, 0.9);
}

.msg--in .msg-reply-quote__author {
    color: var(--accent, #4f8cff);
}

.msg-reply-quote__text {
    display: block;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.msg--out .msg-reply-quote__text {
    color: rgba(255, 255, 255, 0.65);
}

.msg--in .msg-reply-quote__text {
    color: var(--text-secondary, #666);
}

.msg-reply-quote--with-thumb .msg-reply-quote__text {
    flex: 1 1 auto;
    max-width: calc(100% - 38px);
    text-align: left;
}

.msg-reply-quote__thumb {
    width: 32px;
    height: 32px;
    border-radius: 5px;
    object-fit: cover;
    flex-shrink: 0;
    order: 2;
}

.msg--has-reply.msg--has-media:not(.msg--has-text) .msg-reply-quote {
    margin-bottom: 0;
}

.msg--has-reply.msg--has-media.msg--has-text .msg-media-shell {
    margin: 0 2px 2px;
}

.chat-selection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(180deg, #152238 0%, #0f1724 100%);
    border-top: 1px solid rgba(59, 130, 246, 0.25);
}

.chat-selection-bar__count {
    font-size: 0.82rem;
    font-weight: 600;
    color: #93c5fd;
}

.chat-selection-bar__actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.chat-selection-bar__btn {
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.15);
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
}

.chat-selection-bar__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.chat-selection-bar__btn:hover {
    background: rgba(59, 130, 246, 0.28);
}

.chat-selection-bar__btn--danger {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.15);
    color: #fecaca;
}

.chat-selection-bar__btn--danger:hover {
    background: rgba(239, 68, 68, 0.28);
}

.chat-selection-bar__btn--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--office-muted, #94a3b8);
}

.chat-body--select-mode .msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    cursor: default;
    pointer-events: auto;
    padding: 4px 0;
}

.chat-body--select-mode .msg--in {
    justify-content: flex-start;
}

.chat-body--select-mode .msg--out {
    justify-content: flex-end;
}

.chat-body--select-mode .msg-bubble {
    cursor: pointer;
    pointer-events: auto;
}

.chat-body--select-mode .msg--selected .msg-bubble {
    outline: 2px solid rgba(59, 130, 246, 0.55);
    outline-offset: 2px;
}

.msg-select-check {
    display: none;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin: 4px 0 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
}

.chat-body--select-mode .msg-select-check {
    display: block;
}

.msg-select-check__box {
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(148, 163, 184, 0.55);
    background: rgba(15, 23, 36, 0.65);
    box-sizing: border-box;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.msg-select-check:hover .msg-select-check__box {
    border-color: rgba(96, 165, 250, 0.75);
}

.msg--selected .msg-select-check__box {
    border-color: #3b82f6;
    background: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.2 6.4 11 12.5 5' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 13px 13px;
}

.chat-window--select-mode .chat-topbar__title {
    color: #93c5fd;
}

.msg--pinned-highlight {
    animation: msg-pin-flash 1.2s ease;
}

@keyframes msg-pin-flash {
    0%,
    100% {
        outline-color: transparent;
    }
    30% {
        outline: 2px solid #fbbf24;
        outline-offset: 3px;
    }
}

.chat-context-menu__item:disabled,
.chat-context-menu__item.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.menu-contacts::-webkit-scrollbar {
    width: 0;
    display: none;
}

.menu-contacts__toolbar {
    position: relative;
    z-index: 30;
    display: flex;
    flex-shrink: 0;
    gap: 0.4rem;
    padding: 0.5rem 0.5rem 0.45rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    background: var(--office-surface, #111827);
    overflow: visible;
}

.menu-contacts__toolbar.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.menu-contacts__toolbar-btn {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: var(--office-surface-2, #1a2332);
    color: #cbd5e1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    isolation: isolate;
}

.menu-contacts__toolbar-btn:hover {
    background: rgba(59, 130, 246, 0.16);
    color: #f1f5f9;
}

.menu-contacts__toolbar-btn:focus-visible {
    outline: 2px solid var(--office-accent, #3b82f6);
    outline-offset: 2px;
}

.menu-contacts__toolbar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.menu-contacts__toolbar-icon .chat-icon,
.menu-contacts__toolbar-icon .chat-icon--toolbar {
    display: block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.menu-contacts__toolbar-btn::after {
    content: attr(title);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.22);
    color: #f1f5f9;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.25;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    z-index: 10100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.menu-contacts__toolbar-btn:hover::after,
.menu-contacts__toolbar-btn:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-2px);
}

.menu-contacts__toolbar-btn--solo {
    flex: 1 1 auto;
}

.menu-contacts__toolbar-btn[aria-pressed="true"] {
    background: rgba(59, 130, 246, 0.22);
    color: #f1f5f9;
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.menu-contacts__toolbar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--office-accent, #3b82f6);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}

.friend-requests-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: var(--office-surface, #111827);
}

.friend-requests-panel.hidden {
    display: none !important;
}

.friend-requests-panel__tabs {
    display: flex;
    gap: 0.35rem;
    padding: 0.45rem 0.5rem 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    flex-shrink: 0;
}

.friend-requests-panel__tab {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    padding: 0.45rem 0.5rem;
    border: none;
    border-radius: 8px 8px 0 0;
    background: transparent;
    color: #94a3b8;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.friend-requests-panel__tab.is-active {
    color: #f1f5f9;
    background: var(--office-surface-2, #1a2332);
}

.friend-requests-panel__tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    margin-left: 4px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--office-accent, #3b82f6);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    vertical-align: middle;
}

.friend-requests-panel__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem 0.5rem 0.5rem;
}

.friend-requests-panel__pane.hidden {
    display: none !important;
}

.friend-requests-panel__label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.72rem;
    color: #94a3b8;
}

.friend-requests-panel__input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.65rem;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    background: var(--office-surface-2, #1a2332);
    color: #f1f5f9;
    font-size: 0.85rem;
}

.friend-requests-panel__input:focus {
    outline: 2px solid rgba(59, 130, 246, 0.45);
    outline-offset: 1px;
}

.friend-requests-panel__submit {
    width: 100%;
    margin-top: 0.55rem;
    padding: 0.55rem 0.75rem;
    border: none;
    border-radius: 10px;
    background: var(--office-accent, #3b82f6);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.friend-requests-panel__submit:hover:not(:disabled) {
    opacity: 0.92;
}

.friend-requests-panel__submit:disabled {
    opacity: 0.55;
    cursor: wait;
}

.friend-requests-panel__status {
    margin: 0.55rem 0 0;
    font-size: 0.78rem;
    line-height: 1.35;
}

.friend-requests-panel__status--success {
    color: #4ade80;
}

.friend-requests-panel__status--error {
    color: #f87171;
}

.friend-requests-panel__status--warning {
    color: #fbbf24;
}

.friend-requests-panel__status--info {
    color: #94a3b8;
}

.friend-requests-panel__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.friend-requests-panel__empty {
    margin: 0.5rem 0;
    text-align: center;
    color: #94a3b8;
    font-size: 0.82rem;
}

.fr-item {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem;
    border-radius: 12px;
    background: var(--office-surface-2, #1a2332);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.fr-item--leaving {
    opacity: 0;
    transform: translateX(8px);
    pointer-events: none;
}

.fr-item__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--office-accent, #3b82f6);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.fr-item__name {
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #f1f5f9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fr-item__actions {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.fr-btn {
    padding: 0.3rem 0.55rem;
    border: none;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.fr-btn--accept {
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
}

.fr-btn--accept:hover {
    background: rgba(34, 197, 94, 0.28);
}

.fr-btn--decline {
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
}

.fr-btn--decline:hover {
    background: rgba(148, 163, 184, 0.2);
}

.user-find-modal {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.user-find-modal.hidden {
    display: none;
}

.user-find-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.user-find-modal__panel {
    position: relative;
    width: min(440px, 100%);
    max-height: min(80vh, 520px);
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: var(--office-surface, #111827);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.user-find-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.user-find-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #e2e8f0;
}

.user-find-modal__close {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.user-find-modal__body {
    padding: 14px 16px 16px;
    overflow: auto;
}

.user-find-modal__label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: #94a3b8;
}

.user-find-modal__input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: #0f172a;
    color: #e2e8f0;
    font-size: 0.9rem;
}

.user-find-modal__hint {
    margin: 8px 0 0;
    font-size: 0.8rem;
    color: #f87171;
}

.user-find-modal__results {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-find-modal__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--office-surface-2, #1a2332);
}

.user-find-modal__item-info {
    min-width: 0;
}

.user-find-modal__item-name {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.9rem;
}

.user-find-modal__item-meta {
    font-size: 0.75rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-find-modal__item-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: var(--office-accent, #3b82f6);
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
}

.menu-contacts__pinned {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-item {
    display: flex;
    gap: 0.65rem;
    padding: 0.6rem 0.65rem;
    border-radius: var(--office-radius-sm, 8px);
    cursor: pointer;
    transition: background 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.menu-contacts__list .chat-item {
    -webkit-touch-callout: none;
}

.chat-item:hover,
.chat-item.is-active {
    background: var(--office-surface-2, #1a2332);
}

.chat-item--support .chat-avatar--brand,
.chat-avatar.office-avatar--chat.chat-avatar--brand {
    display: inline-grid;
    place-items: center;
    background: var(--office-accent, #3b82f6);
    border-color: transparent;
    color: #fff;
}

.chat-item .office-avatar--chat.chat-avatar {
    flex-shrink: 0;
}

.office-avatar--chat,
.chat-topbar__avatar.office-avatar--chat {
    width: 40px;
    height: 40px;
    border-width: 0;
}

.chat-avatar.office-avatar--chat .office-avatar__img,
.chat-topbar__avatar .office-avatar__img {
    border-radius: 50%;
}

.chat-content {
    flex: 1;
    min-width: 0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.chat-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--office-text, #f1f5f9);
}

.chat-time {
    font-size: 0.72rem;
    color: var(--office-muted, #94a3b8);
}

.chat-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.chat-last {
    font-size: 0.8rem;
    color: var(--office-muted, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-unread {
    min-width: 1.1rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--office-danger, #ef4444);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
}

.chat-unread.hidden {
    display: none;
}

.menu-contacts__list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.chat-item.hidden,
.menu-contacts .hidden {
    display: none !important;
}

.msg-meta {
    font-size: 0.72rem;
    color: var(--office-muted, #94a3b8);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.msg-role {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

.msg-role--manager {
    background: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

.msg-role--editor {
    background: rgba(168, 85, 247, 0.25);
    color: #d8b4fe;
}

.msg-text {
    white-space: pre-wrap;
}

.msg-footer {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    min-height: 14px;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: max-content;
}

.msg-time {
    font-size: 0.68rem;
    opacity: 0.72;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
}

.msg--out .msg-time {
    color: rgba(255, 255, 255, 0.85);
}

.msg-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 2px;
    color: rgba(255, 255, 255, 0.72);
    flex-shrink: 0;
    line-height: 0;
}

.msg-status--read {
    color: #7dd3fc;
}

.msg-status__icon {
    display: block;
    vertical-align: middle;
}

.msg-status__icon--read {
    width: 16px;
    height: 9px;
}

.msg-file {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: inherit;
    text-decoration: none;
    font-size: 0.8rem;
}


.chat {
    display: flex;
    width: 100%;
    flex: 1;
    min-height: 0;
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
}

.chat-empty {
    display: flex;
    flex: 1;
    text-align: center;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.chat-empty__title {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--office-text, #f1f5f9);
}

.chat-empty__text {
    margin: 0;
    font-size: 0.9rem;
    color: var(--office-muted, #94a3b8);
    max-width: 36ch;
}

.chat-window {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    background: var(--office-bg, #0b1220);
}

.chat-scroll-bottom {
    position: absolute;
    right: 14px;
    bottom: 92px;
    z-index: 6;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    background: rgba(26, 35, 50, 0.94);
    color: #e2e8f0;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.chat-scroll-bottom:hover {
    background: rgba(37, 99, 235, 0.92);
    border-color: rgba(147, 197, 253, 0.35);
    transform: translateY(-1px);
}

.chat-scroll-bottom.hidden {
    display: none;
}

.chat-scroll-bottom__icon {
    display: block;
    width: 12px;
    height: 12px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translate(-2px, -2px);
}

.chat-window--select-mode .chat-scroll-bottom {
    bottom: 132px;
}

.chat-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--office-border, #1f2937);
    background: var(--office-surface, #111827);
    flex-shrink: 0;
}

.chat-topbar__info {
    flex: 1;
    min-width: 0;
}

.chat-topbar__menu-btn {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0 0 0 auto;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--office-muted, #94a3b8);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.chat-topbar__menu-btn:hover,
.chat-topbar__menu-btn[aria-expanded='true'] {
    background: rgba(148, 163, 184, 0.12);
    color: var(--office-text, #f1f5f9);
}

.chat-topbar__menu-btn.hidden {
    display: none;
}

.chat-topbar__menu-icon {
    font-size: 1.35rem;
    line-height: 1;
    letter-spacing: 0.05em;
    user-select: none;
}

.chat-topbar__avatar {
    flex-shrink: 0;
}

.chat-topbar__avatar.office-avatar--chat {
    border: none;
}

.chat-topbar__avatar--brand {
    background: var(--office-accent, #3b82f6);
    color: #fff;
}

.chat-topbar__title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--office-text, #f1f5f9);
}

.chat-topbar__status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 0.1rem;
    min-height: 1rem;
}

.chat-topbar__presence {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chat-topbar__presence--online {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.chat-topbar__presence--offline {
    background: #64748b;
}

.chat-topbar__presence--typing {
    background: var(--office-accent, #3b82f6);
    animation: presence-typing-pulse 1.2s ease-in-out infinite;
}

@keyframes presence-typing-pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.55;
        transform: scale(0.85);
    }
}

.chat-topbar__subtitle {
    font-size: 0.75rem;
    color: var(--office-muted, #94a3b8);
}

.chat-topbar__subtitle--typing {
    color: var(--office-accent, #3b82f6);
}

.hidden {
    display: none;
}

.chat-messages {
    height: 100%;
}







/* actual scroll area — прокрутка есть, полоса скрыта (как в Telegram) */
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px 14px 8px;
    scroll-behavior: smooth;
    min-height: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background-color: var(--office-bg, #0b1220);
    background-image:
        radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.04) 0%, transparent 45%),
        radial-gradient(circle at 80% 70%, rgba(99, 102, 241, 0.03) 0%, transparent 40%);
}

/* Короткая лента — сообщения у низа, без пустоты сверху */
.chat-body__stack {
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding-bottom: 4px;
}

.chat-body--loading,
.chat-body--hint {
    justify-content: center;
    align-items: center;
}

.chat-body__loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1.5rem;
    color: var(--office-muted, #94a3b8);
    text-align: center;
}

.chat-body__loader-spinner {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(148, 163, 184, 0.25);
    border-top-color: var(--office-accent, #3b82f6);
    border-radius: 50%;
    animation: office-spin 0.65s linear infinite;
}

.chat-body__loader-text {
    font-size: 0.85rem;
    line-height: 1.4;
}

.chat-date-divider {
    display: flex;
    justify-content: center;
    margin: 12px 0 10px;
    position: sticky;
    top: 6px;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.chat-date-divider.is-active {
    z-index: 4;
}

.chat-date-divider.is-hidden {
    opacity: 0;
    visibility: hidden;
}

.chat-date-divider span {
    display: inline-block;
    min-width: 5.5rem;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    color: var(--office-muted, #94a3b8);
    background: rgba(15, 23, 36, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.chat-body::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* COMPOSE HINT (no chat yet) */

.chat-compose-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: min(320px, 50vh);
    padding: 2rem 1.5rem;
    color: var(--office-muted, #94a3b8);
}

.chat-compose-hint--inline {
    min-height: 120px;
}

.chat-compose-hint--welcome {
    min-height: min(200px, 36vh);
}

.chat-compose-hint__icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.85;
}

.chat-compose-hint__title {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--office-text, #f1f5f9);
}

.chat-compose-hint__text {
    margin: 0;
    max-width: 32ch;
    font-size: 0.88rem;
    line-height: 1.45;
}

/* MESSAGE ROW + BUBBLE */

.msg {
    display: flex;
    width: 100%;
    max-width: 100%;
    margin-bottom: 8px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    box-sizing: border-box;
}

.msg-bubble {
    width: fit-content;
    max-width: min(78%, 420px);
    min-width: 52px;
    padding: 6px 10px 5px;
    border-radius: 12px;
    background: var(--office-surface-2, #1a2332);
    border: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

.msg--compact .msg-bubble {
    max-width: min(88%, 280px);
}

.msg--has-media .msg-bubble {
    max-width: min(92%, 400px);
    padding: 4px 4px 5px;
}

.msg--has-media.msg--has-text .msg-bubble {
    max-width: min(88%, 400px);
    padding: 6px 8px 5px;
}

.msg--media-only .msg-bubble {
    padding: 0;
    background: transparent;
    border: none;
    max-width: min(92%, 400px);
}

.msg--out.msg--media-only .msg-bubble {
    background: transparent;
}

.msg--media-only .msg-media {
    margin-bottom: 0;
}

.msg-media-shell {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.msg-media-shell:has(.msg-media--group),
.msg-media-shell:has(.msg-media--single) {
    width: min(320px, 100%);
}

.msg-media-shell:has(.msg-media--single .msg-media-tile--video) {
    width: min(400px, 100%);
}

.msg-media-shell .msg-media {
    margin-bottom: 0;
}

.msg-media-caption {
    position: absolute;
    right: 6px;
    bottom: 6px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.msg-media-caption .msg-time {
    opacity: 1;
    color: #fff;
}

.msg-media-caption .msg-status {
    color: rgba(255, 255, 255, 0.9);
}

.msg-media-caption .msg-status--read {
    color: #7dd3fc;
}

.msg--in {
    justify-content: flex-start;
}

.msg--out {
    justify-content: flex-end;
}

.msg--in .msg-bubble {
    border-bottom-left-radius: 4px;
}

.msg--out .msg-bubble {
    background: linear-gradient(145deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    border-bottom-right-radius: 4px;
}

.msg-body {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 2px 6px;
}

.msg--has-text .msg-text {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.msg--has-text .msg-footer {
    margin-left: auto;
}

.msg--compact .msg-body {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: baseline;
    max-width: 100%;
    justify-content: flex-start;
}

.msg--compact .msg-text {
    flex: 0 1 auto;
}

.msg.user {
    justify-content: flex-end;
}

.msg.user .msg-bubble {
    background: linear-gradient(145deg, #3b82f6, #2563eb);
    color: #fff;
}

/* text block spacing */
.msg-text:not(:last-child) {
    margin-bottom: 4px;
}

/* MEDIA INSIDE MESSAGE (Telegram-style) */

@keyframes msg-media-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.chat-body__stack .msg:not(.msg--has-media) {
    content-visibility: auto;
    contain-intrinsic-size: auto 72px;
}

.msg-media {
    position: relative;
    margin-bottom: 0;
    max-width: 320px;
}

/* --- Одиночное фото / видео --- */

.msg-media--single {
    max-width: 320px;
    border-radius: 12px;
    overflow: hidden;
}

.msg-media--single .msg-media-tile {
    border-radius: 12px;
}

.msg-media--single .msg-media-tile--photo {
    display: block;
    width: auto;
    max-width: 320px;
    max-height: 320px;
    min-width: 120px;
    min-height: 120px;
    background: #00000045;
}

.msg-media--single .msg-media-tile--photo .msg-media-photo {
    position: relative;
    display: block;
    width: auto;
    height: auto;
    max-width: 320px;
    max-height: 320px;
    object-fit: contain;
}

.msg-media--single:has(.msg-media-tile--video) {
    width: 100%;
    max-width: 400px;
}

.msg-media--single .msg-media-tile--video {
    display: block;
    width: 100%;
    max-width: 400px;
    height: auto;
    max-height: 400px;
    aspect-ratio: var(--media-aspect, 16 / 9);
    min-height: 200px;
    background: #1a1a1a;
}

.msg-media--single .msg-media-tile--video[data-lazy-media]:not(.is-loaded) {
    width: 360px;
    min-width: 280px;
    height: 260px;
    aspect-ratio: auto;
}

.msg-media--single .msg-media-tile--video .msg-media-video {
    object-fit: cover;
    z-index: 0;
}

/* --- Медиагруппа --- */

.msg-media--group {
    display: grid;
    gap: 2px;
    width: 320px;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #1a1a1a;
}

.msg-media--group .msg-media-tile--photo,
.msg-media--group .msg-media-tile--video {
    position: relative;
    min-height: 0;
    min-width: 0;
    height: 100%;
    background: #1a1a1a;
}

.msg-media--group .msg-media-photo,
.msg-media--group .msg-media-video {
    object-fit: cover;
}

/* 2 фото */
.msg-media--group.msg-media--count-2 {
    grid-template-columns: 1fr 1fr;
    height: 200px;
}

/* 3 фото: слева крупное, справа два */
.msg-media--group.msg-media--count-3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 200px;
}

.msg-media--group.msg-media--count-3 .msg-media-tile:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / 3;
}

.msg-media--group.msg-media--count-3 .msg-media-tile:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

.msg-media--group.msg-media--count-3 .msg-media-tile:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

/* 4 фото: 2×2 */
.msg-media--group.msg-media--count-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 200px;
}

/* 5 фото: 2 сверху, 3 снизу */
.msg-media--group.msg-media--count-5 {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: 100px 100px;
}

.msg-media--group.msg-media--count-5 .msg-media-tile:nth-child(1) {
    grid-column: 1 / 4;
    grid-row: 1;
}

.msg-media--group.msg-media--count-5 .msg-media-tile:nth-child(2) {
    grid-column: 4 / 7;
    grid-row: 1;
}

.msg-media--group.msg-media--count-5 .msg-media-tile:nth-child(3) {
    grid-column: 1 / 3;
    grid-row: 2;
}

.msg-media--group.msg-media--count-5 .msg-media-tile:nth-child(4) {
    grid-column: 3 / 5;
    grid-row: 2;
}

.msg-media--group.msg-media--count-5 .msg-media-tile:nth-child(5) {
    grid-column: 5 / 7;
    grid-row: 2;
}

/* 6 фото: 3×2 */
.msg-media--group.msg-media--count-6 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 100px 100px;
}

/* 7–10: равномерная сетка 2 колонки */
.msg-media--group.msg-media--count-7,
.msg-media--group.msg-media--count-8,
.msg-media--group.msg-media--count-9,
.msg-media--group.msg-media--count-10 {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 100px;
}

.msg-media__more {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.msg-media--single .msg-media-tile--photo[data-lazy-media]:not(.is-loaded) {
    width: 240px;
    height: 180px;
}

.msg-media-tile {
    position: relative;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 0;
    overflow: hidden;
    color: inherit;
    transition: filter 0.15s ease;
}

.msg-media-tile:hover {
    filter: brightness(1.05);
}

.msg-media-tile__skeleton {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 0%,
        rgba(255, 255, 255, 0.1) 45%,
        rgba(255, 255, 255, 0.03) 100%
    );
    background-size: 200% 100%;
    animation: msg-media-shimmer 1.35s ease-in-out infinite;
    pointer-events: none;
}

.msg-media-tile[data-lazy-media]:not(.is-loaded) .msg-media-tile__skeleton {
    display: block;
}

.msg-media-tile.is-loaded .msg-media-tile__skeleton {
    display: none;
}

.msg-media-tile.is-error {
    background: #1a1a1a;
    cursor: pointer;
}

.msg-media-tile.is-error .msg-media-tile__play,
.msg-media-tile.is-error .msg-media-tile__duration {
    display: none;
}

.msg-media-tile__error {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 3;
    place-content: center;
    padding: 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    color: rgba(255, 255, 255, 0.88);
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

.msg-media-tile.is-error .msg-media-tile__error {
    display: grid;
}

.msg-media-photo,
.msg-media-video {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 1;
    transition: opacity 0.28s ease;
}

.msg-media-tile[data-lazy-media]:not(.is-loaded) .msg-media-photo,
.msg-media-tile[data-lazy-media]:not(.is-loaded) .msg-media-video {
    opacity: 0;
}

.msg-media-tile--video {
    background: #1a1a1a;
}

.msg-media-tile__play {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: 2px solid rgba(255, 255, 255, 0.88);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    opacity: 1;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.msg-media-tile--video.is-playing .msg-media-tile__play {
    opacity: 0;
    transform: scale(0.92);
}

.msg-media-tile__play::after {
    content: '';
    position: absolute;
    top: 12px;
    left: 15px;
    border: 7px solid transparent;
    border-left: 11px solid #fff;
}

.msg-media-tile__duration {
    position: absolute;
    right: 6px;
    bottom: 6px;
    z-index: 2;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
    color: #fff;
    background: rgba(0, 0, 0, 0.62);
    pointer-events: none;
    backdrop-filter: blur(3px);
}

.msg-media-tile__duration:empty {
    display: none;
}

.msg-media-tile--file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    min-width: 180px;
    max-width: 100%;
}

.msg-media-tile__name,
.msg-media-tile__label {
    max-width: 240px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.msg-media-tile__icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    display: grid;
    place-items: center;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.88);
    position: relative;
    overflow: hidden;
}

.msg-media-tile__icon .file-tile-icon__svg {
    display: block;
    flex-shrink: 0;
    opacity: 0.95;
}

.msg-media-tile__icon--spreadsheet,
.msg-media-tile__icon--pdf,
.msg-media-tile__icon--doc,
.msg-media-tile__icon--json,
.msg-media-tile__icon--archive,
.msg-media-tile__icon--presentation,
.msg-media-tile__icon--text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 3px 2px;
    color: #fff;
}

.msg-media-tile__icon-label {
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1;
    text-transform: uppercase;
}

.msg-media-tile__icon--spreadsheet {
    background: #217346;
}

.msg-media-tile__icon--pdf {
    background: #d93831;
}

.msg-media-tile__icon--doc {
    background: #2b579a;
}

.msg-media-tile__icon--json {
    background: #d97706;
}

.msg-media-tile__icon--archive {
    background: #7c3aed;
}

.msg-media-tile__icon--presentation {
    background: #ea580c;
}

.msg-media-tile__icon--text {
    background: #64748b;
}

.msg-media-tile__meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg-media-tile__size {
    font-size: 0.68rem;
    opacity: 0.75;
}

/* COMPOSE BAR (above input, Telegram-style) */

.chat-compose-bar {
    flex-shrink: 0;
    z-index: 5;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: transparent;
    padding: 10px 12px 12px;
    box-shadow: none;
    min-height: 0;
}

.chat-compose-dock--reply .chat-compose-bar:not(.hidden) {
    border-top: none;
}

.chat-compose-bar.hidden {
    display: none;
}

.chat-compose-bar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-compose-bar__size {
    font-size: 0.72rem;
    color: var(--office-muted, #94a3b8);
}

.chat-compose-bar__size--over {
    color: #f87171;
}

.chat-compose-bar__clear {
    border: none;
    background: transparent;
    color: var(--office-accent, #3b82f6);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 4px;
}

.chat-compose-bar__clear:hover {
    text-decoration: underline;
}

.chat-compose-bar__items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px;
    scrollbar-width: thin;
    scrollbar-color: #3b4a63 transparent;
}

.chat-compose-bar__items::-webkit-scrollbar {
    width: 6px;
}

.chat-compose-bar__items::-webkit-scrollbar-thumb {
    background: #3b4a63;
    border-radius: 8px;
}

.compose-tile {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    min-height: 100px;
    border-radius: 12px;
    overflow: hidden;
    background: #1a2740;
    border: 1px solid #334155;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.compose-tile:hover {
    border-color: rgba(59, 130, 246, 0.55);
}

.compose-tile--loading {
    opacity: 0.92;
}

.compose-tile__inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    pointer-events: none;
}

.compose-tile__img,
.compose-tile__video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.compose-tile__play {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: 2px solid #fff;
    pointer-events: none;
}

.compose-tile__play::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 11px;
    border: 5px solid transparent;
    border-left: 8px solid #fff;
}

.compose-tile__icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.88);
    margin-bottom: 4px;
    min-width: 44px;
    box-sizing: border-box;
}

.compose-tile__icon .file-tile-icon__svg {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.compose-tile__icon-label {
    font-size: 0.46rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1;
    text-transform: uppercase;
}

.compose-tile__icon--spreadsheet {
    background: #217346;
    color: #fff;
}

.compose-tile__icon--pdf {
    background: #d93831;
    color: #fff;
}

.compose-tile__icon--doc {
    background: #2b579a;
    color: #fff;
}

.compose-tile__icon--json {
    background: #d97706;
    color: #fff;
}

.compose-tile__icon--archive {
    background: #7c3aed;
    color: #fff;
}

.compose-tile__icon--presentation {
    background: #ea580c;
    color: #fff;
}

.compose-tile__icon--text {
    background: #64748b;
    color: #fff;
}

.compose-tile__meta {
    width: 100%;
    text-align: center;
    min-width: 0;
    padding: 8px 10px;
    box-sizing: border-box;
}

.compose-tile__name {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.62rem;
    line-height: 1.25;
    color: #e2e8f0;
    word-break: break-word;
    hyphens: auto;
}

.compose-tile__size {
    display: block;
    font-size: 0.58rem;
    color: #94a3b8;
}

.compose-tile__spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(11, 18, 32, 0.72);
    z-index: 2;
}

.compose-tile__upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.compose-tile__upload-ring {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-top-color: var(--office-accent, #3b82f6);
    border-radius: 50%;
    animation: preview-spin 0.7s linear infinite;
}

.compose-tile__progress-value {
    display: block;
    min-width: 38px;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #f8fafc;
    font-size: 0.68rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-align: center;
}

.compose-tile__spinner::after {
    content: none;
}

@keyframes preview-spin {
    to {
        transform: rotate(360deg);
    }
}

.compose-tile__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
}

.compose-tile__remove:hover {
    background: #ef4444;
}

/* INPUT AREA  */

.chat-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 12px;
    background: #0f1724;
    border-top: 1px solid #1c2636;
}

.chat-input textarea {
    flex: 1;
    min-height: 44px;
    max-height: 280px;
    padding: 11px 14px;
    padding-right: 10px;
    border-radius: 20px;
    border: 1px solid transparent;
    outline: none;
    background: #162033;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.45;
    resize: none;
    overflow-y: hidden;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

.chat-input textarea.is-scrollable {
    overflow-y: auto;
    padding-right: 6px;
}

.chat-input textarea::-webkit-scrollbar {
    width: 5px;
}

.chat-input textarea::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 2px;
}

.chat-input textarea::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    border: 1px solid transparent;
    background-clip: padding-box;
}

.chat-input textarea::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.55);
    background-clip: padding-box;
}

.chat-input textarea:focus {
    border-color: rgba(59, 130, 246, 0.45);
}

.chat-input textarea:disabled {
    opacity: 0.55;
}

/* BUTTONS (ATTACH / SEND) */

.attach-btn,
.send-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: #162033;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.attach-btn:hover:not(:disabled),
.send-btn:hover:not(:disabled) {
    background: #1e2a3c;
}

.send-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.send-btn--active {
    background: var(--office-accent, #3b82f6);
}

.send-btn--active:hover:not(:disabled) {
    background: #2563eb;
}

.send-btn--sending {
    opacity: 0.6;
    pointer-events: none;
}

.attach-btn img,
.send-btn img {
    width: 18px;
    height: 18px;
}

/* MEDIA LIGHTBOX */

body.media-lightbox-open {
    overflow: hidden;
}

.media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.media-lightbox.hidden {
    display: none;
}

.media-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(4px);
}

.media-lightbox__panel {
    position: relative;
    z-index: 1;
    width: min(960px, 100%);
    max-height: min(92vh, 900px);
    display: flex;
    flex-direction: column;
    background: #111827;
    border-radius: 16px;
    border: 1px solid #334155;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.media-lightbox__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}

.media-lightbox__title {
    font-size: 0.9rem;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.media-lightbox__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.media-lightbox__download {
    font-size: 0.8rem;
    color: #93c5fd;
    text-decoration: none;
}

.media-lightbox__download:hover {
    text-decoration: underline;
}

.media-lightbox__close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: #1e293b;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.media-lightbox__close:hover {
    background: #334155;
}

.media-lightbox__body {
    position: relative;
    flex: 1;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0b1220;
}

.media-lightbox__stage {
    flex: 1;
    width: 100%;
    min-height: 240px;
    max-height: calc(92vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
}

.media-lightbox__img {
    max-width: 100%;
    max-height: calc(92vh - 140px);
    object-fit: contain;
    border-radius: 8px;
}

.media-lightbox__video {
    max-width: 100%;
    max-height: calc(92vh - 140px);
    border-radius: 8px;
    background: #000;
}

.media-lightbox__iframe {
    width: 100%;
    height: min(70vh, 640px);
    border: none;
    border-radius: 8px;
    background: #fff;
}

.media-lightbox__file {
    text-align: center;
    color: #e2e8f0;
    padding: 24px;
}

.media-lightbox__file-hint {
    color: #94a3b8;
    font-size: 0.85rem;
}

.media-lightbox__file-link {
    display: inline-block;
    margin-top: 12px;
    color: #93c5fd;
}

.media-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(15, 23, 36, 0.85);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    border: 1px solid #334155;
}

.media-lightbox__nav:hover {
    background: rgba(59, 130, 246, 0.35);
}

.media-lightbox__nav--prev {
    left: 8px;
}

.media-lightbox__nav--next {
    right: 8px;
}

.media-lightbox__footer {
    padding: 8px 16px 12px;
    text-align: center;
    font-size: 0.78rem;
    color: #94a3b8;
    border-top: 1px solid #1e293b;
}