/**
 * pages/chat.css — вынесено 1:1 из style.css (C.3.8).
 * Pure .chat-* (+ потомки). Overrides pages-* не трогались.
 * friends-popup / mini-profile / @media / @keyframes оставлены в style.css.
 */

.chat-vlist-active {
    position: relative;
    overflow-y: auto;
    display: block;
}

.chat-vlist-spacer {
    position: relative;
    width: 100%;
}

.chat-vlist-window {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    will-change: transform;
}

.chat-vlist-window > .chat-msg {
    flex-shrink: 0;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    min-height: auto;
}

.chat-ws-status {
    font-size: 0.75rem;
    margin-left: auto;
    margin-right: var(--space-3);
}

.chat-ws-status.chat-ws-ok {
    color: #51cf66;
}

.chat-ws-status.chat-ws-bad {
    color: #ff8787;
}

.chat-placeholder {
    color: var(--va-text-muted, #8f98a0);
    text-align: center;
    margin: auto;
}

.chat-history-loader {
    text-align: center;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.chat-window {
    display: flex;
    flex-direction: column;
    background: #2a2e3d;
    border-radius: 12px;
    min-height: 420px;
    overflow: hidden;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid #1b1e28;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.chat-msg {
    max-width: min(70%, 480px);
    width: -webkit-max-content;
    width: max-content;
    min-width: 120px;
    padding: 6px 10px;
    border-radius: 12px;
    background: #2b2d31;
    color: #f2f3f5;
    overflow-wrap: anywhere;
    word-break: break-word;
    box-sizing: border-box;
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.chat-msg.has-labels,
.chat-msg.has-quote,
.chat-msg.has-reactions {
    gap: 4px;
}

.chat-msg .chat-msg-body {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
    max-width: 100%;
    width: 100%;
    color: inherit;
    font-size: 0.95rem;
    line-height: 1.35;
    min-height: 0;
    display: block;
    background: transparent;
    padding: 0;
    margin: 0;
}

.chat-msg.mine,
.chat-msg.own {
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
    background: #5865f2;
    color: #fff;
}

.chat-msg.theirs,
.chat-msg:not(.mine):not(.own) {
    align-self: flex-start;
    margin-right: auto;
    margin-left: 0;
}

.chat-msg .chat-author {
    font-size: 0.75rem;
    color: #adb5bd;
    display: block;
    margin-bottom: var(--space-1);
}

.chat-input-row {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3);
    border-top: 1px solid #1b1e28;
    flex-wrap: wrap;
    align-items: center;
}

.chat-input-row input {
    flex: 1;
    min-width: 120px;
}

.chat-input-row .btn {
    flex-shrink: 0;
}

.chat-gif-modal {
    width: 720px;
    max-width: calc(100vw - 24px);
    height: 640px;
    max-height: calc(100vh - 40px);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-picker-modal.chat-gif-modal {
    max-width: none;
    max-height: none;
    overflow: hidden;
}

.chat-gif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--va-border, #343b48);
}

.chat-gif-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.chat-gif-tabs {
    display: flex;
    gap: var(--space-1);
    padding: 8px 12px 0;
    border-bottom: 1px solid var(--va-border, #343b48);
    overflow-x: auto;
}

.chat-gif-tab {
    flex: 1 0 auto;
    min-width: 0;
    padding: 8px 10px;
    border: none;
    border-radius: 8px 8px 0 0;
    background: transparent;
    color: var(--va-text-muted, #9aa4b2);
    font-size: 0.82rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.chat-gif-tab:hover {
    color: var(--va-text, #e8eaed);
    background: rgba(255, 255, 255, 0.04);
}

.chat-gif-tab.is-active {
    color: var(--va-accent, #66c0f4);
    border-bottom-color: var(--va-accent, #66c0f4);
    font-weight: 600;
}

.chat-gif-search-row {
    display: flex;
    gap: var(--space-2);
    padding: 12px 16px 0;
}

.chat-gif-search-row .search-input {
    flex: 1;
}

.chat-gif-hint {
    font-size: 0.75rem;
    margin: 8px 16px 0;
}

.chat-gif-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px 12px;
}

.chat-gif-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    height: 0;
    overflow-y: auto;
    margin: 12px 16px 16px;
    padding-right: var(--space-1);
}

.chat-gif-card {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    aspect-ratio: 1;
}

.chat-gif-fav {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.chat-gif-card:hover .chat-gif-fav,
.chat-gif-fav.is-fav {
    opacity: 1;
}

.chat-gif-fav.is-fav {
    color: #f5c518;
    background: rgba(0, 0, 0, 0.7);
}

.chat-gif-fav:hover {
    transform: scale(1.08);
}

.chat-channel-post-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(100%, 320px);
    max-width: min(100%, 320px);
    min-height: 0;
    text-align: left;
    padding: 0;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #17212b;
    cursor: pointer;
    color: inherit;
    box-sizing: border-box;
    overflow: hidden;
}

.chat-channel-post-card--tg {
    width: min(100%, 300px);
    max-width: min(100%, 300px);
}

.chat-msg .chat-channel-post-card,
.chat-msg .repost-embed {
    width: min(100%, 300px) !important;
    max-width: min(100%, 300px) !important;
    --repost-card-width: 300px;
}

.chat-channel-post-ch-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 4px;
}

.chat-channel-post-ava {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #1e2c3a;
}

.chat-channel-post-ava--empty {
    display: inline-block;
}

.chat-channel-post-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 1px;
}

.chat-channel-post-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #6ec9ff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-channel-post-sub {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-channel-post-text {
    display: block;
    padding: 0 12px;
    font-size: 0.88rem;
    line-height: 1.4;
}

.chat-channel-post-card .repost-embed__media,
.chat-channel-post-card .post-media-item {
    margin: 0;
    border-radius: 0;
    width: 100%;
    aspect-ratio: 1;
    max-height: 220px;
    overflow: hidden;
}

.chat-channel-post-card .repost-embed__media img,
.chat-channel-post-card .repost-embed__media video,
.chat-channel-post-card .post-media-item img,
.chat-channel-post-card .post-media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-channel-post-link {
    display: block;
    padding: 8px 12px 10px;
    font-size: 0.78rem;
}

.chat-channel-post-media {
    width: 100%;
    aspect-ratio: 1;
    max-height: 220px;
    object-fit: cover;
    border-radius: 0;
    display: block;
}

.chat-channel-post-card:hover {
    border-color: rgba(110, 201, 255, 0.35);
    background: #1a2530;
}

.chat-channel-post-author-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Чат */
.chat-tabs-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
    border-bottom: 1px solid var(--va-border, #2a475e);
}

.chat-tab-chip {
    background: var(--va-bg-card, #16202d);
    border: 1px solid var(--va-border, #2a475e);
    color: var(--va-text, #c7d5e0);
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 12px;
}

.chat-tab-chip.active {
    border-color: var(--va-accent, #66c0f4);
    color: #fff;
}

.chat-emoji-panel {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: var(--space-2);
    background: var(--va-bg-card, #16202d);
    border: 1px solid var(--va-border, #2a475e);
    border-radius: var(--radius-sm);
    margin-top: var(--space-1);
}

.chat-emoji-panel.hidden {
    display: none !important;
}

.chat-emoji-panel--rich {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0;
    width: min(420px, 96vw);
    height: min(420px, 70vh);
    margin-top: 8px;
    border-radius: 14px;
    overflow: hidden;
    background: #1e1f22;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    z-index: 80;
    position: relative;
    box-sizing: border-box;
}

.chat-emoji-main {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.chat-emoji-scroll {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px 12px 20px;
    scroll-behavior: smooth;
    scroll-padding-top: 36px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
    align-content: start;
    position: relative;
    z-index: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.chat-emoji-item {
    background: transparent;
    border: none;
    font-size: clamp(1.15rem, 2.2vw, 1.45rem);
    cursor: pointer;
    padding: 4px;
    border-radius: 10px;
    line-height: 1;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-emoji-nav {
    width: 52px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    background: #121317;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    overflow-y: auto;
}

.chat-emoji-nav-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    font-size: 1.25rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    opacity: 0.72;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.chat-emoji-nav-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    opacity: 1;
}

.chat-emoji-nav-btn.is-active {
    background: rgba(88, 101, 242, 0.28);
    opacity: 1;
    box-shadow: inset 0 0 0 1px rgba(88, 101, 242, 0.45);
}

.chat-emoji-section {
    margin-bottom: 16px;
}

.chat-emoji-section:first-child {
    padding-top: 2px;
}

.chat-emoji-section:last-child {
    margin-bottom: 4px;
}

.chat-emoji-cat-title {
    position: relative;
    z-index: 1;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--va-text-muted, #9aa4b2);
    margin: 0 0 12px;
    padding: 4px 0 6px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
}

.chat-emoji-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.08);
}

.chat-context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--va-bg, #1b2838);
    border: 1px solid var(--va-accent, #66c0f4);
    border-radius: var(--radius-sm);
    min-width: 140px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.chat-context-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--va-text, #c7d5e0);
    cursor: pointer;
}

.chat-context-menu button:hover {
    background: var(--va-border, #2a475e);
}

.chat-sticker-img, .chat-gif-img, .chat-image-img {
    display: block;
    max-width: min(280px, 100%);
    max-height: 280px;
    width: auto;
    height: auto;
    border-radius: var(--radius-md);
    vertical-align: top;
}

/* Только эмодзи (1–5): ~половина максимального стикера (280px → ~140px) */
.chat-big-emoji-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.12em;
    line-height: 1;
    margin: 2px 0;
}
.chat-big-emoji {
    display: inline-block;
    line-height: 1;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
    font-size: 140px;
}
.chat-big-emoji-row--n2 .chat-big-emoji { font-size: 120px; }
.chat-big-emoji-row--n3 .chat-big-emoji { font-size: 104px; }
.chat-big-emoji-row--n4 .chat-big-emoji { font-size: 92px; }
.chat-big-emoji-row--n5 .chat-big-emoji { font-size: 80px; }
@media (max-width: 640px) {
    .chat-big-emoji-row--n1 .chat-big-emoji { font-size: 96px; }
    .chat-big-emoji-row--n2 .chat-big-emoji { font-size: 84px; }
    .chat-big-emoji-row--n3 .chat-big-emoji { font-size: 72px; }
    .chat-big-emoji-row--n4 .chat-big-emoji { font-size: 64px; }
    .chat-big-emoji-row--n5 .chat-big-emoji { font-size: 56px; }
}

.chat-video {
    display: block;
    max-width: min(320px, 100%);
    max-height: 280px;
    border-radius: var(--radius-md);
    background: #000;
}

.chat-attachment-link {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
}

.chat-msg .chat-msg-body > img.chat-gif-img,
.chat-msg .chat-msg-body > img.chat-image-img,
.chat-msg .chat-msg-body > img.chat-sticker-img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-md);
}

.chat-picker-modal {
    background: var(--va-bg, #1b2838);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    max-width: 420px;
    max-height: 70vh;
    overflow: auto;
}

.chat-picker-body {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 12px 0;
}

.chat-sticker-pick, .chat-gif-pick {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.chat-sticker-pick img, .chat-gif-pick img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
}

.chat-gif-card .chat-gif-pick {
    display: block;
    width: 100%;
    height: 100%;
}

.chat-gif-card .chat-gif-pick img {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.chat-msg {
    position: relative;
}

.chat-msg-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 4px;
    min-width: 0;
    width: 100%;
    line-height: 1.2;
}

.chat-msg.mine .chat-msg-header,
.chat-msg.own .chat-msg-header {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.chat-msg-header .chat-author-row {
    margin-bottom: 0;
    flex: 0 1 auto;
    min-width: 0;
    align-items: center;
}

.chat-msg-time {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
    font-size: 0.72rem;
    line-height: 1;
    color: rgba(242, 243, 245, 0.55);
    white-space: nowrap;
    align-self: center;
}

.chat-msg.mine .chat-msg-time,
.chat-msg.own .chat-msg-time {
    margin: 0;
    color: rgba(255, 255, 255, 0.62);
}

.chat-msg-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0 2px;
}

.chat-msg-label {
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    color: #8b9bab;
    opacity: 0.95;
}

.chat-msg-label--reply { color: #7eb6d9; }
.chat-msg-label--fwd { color: #9bb0c4; }
.chat-msg-label--edited { color: #a0a8b4; font-style: italic; }

.chat-msg.mine .chat-msg-labels,
.chat-msg.own .chat-msg-labels {
    justify-content: flex-end;
}

.chat-reactions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    margin-top: 0;
    min-height: 0;
    position: relative;
}

.chat-reactions-row.is-filled {
    margin-top: 2px;
}

.chat-msg .chat-add-reaction {
    position: absolute;
    right: 2px;
    bottom: 2px;
    opacity: 0;
    border: none;
    background: rgba(0, 0, 0, 0.35);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
    z-index: 2;
    pointer-events: none;
}

.chat-msg.mine .chat-add-reaction,
.chat-msg.own .chat-add-reaction {
    right: auto;
    left: 2px;
}

.chat-msg:hover .chat-add-reaction {
    opacity: 1;
    pointer-events: auto;
}

.chat-reactions-row.is-filled .chat-add-reaction {
    position: static;
    pointer-events: auto;
}

.chat-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: 0;
}

.chat-reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(79, 84, 92, 0.45);
    color: #dbdee1;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.4;
}

.chat-reaction-chip:hover {
    background: rgba(79, 84, 92, 0.75);
    border-color: rgba(255, 255, 255, 0.2);
}

.chat-reaction-chip.mine {
    background: rgba(88, 101, 242, 0.35);
    border-color: rgba(88, 101, 242, 0.65);
}

.chat-reaction-count {
    font-size: 12px;
    font-weight: 600;
    color: #b5bac1;
}

.chat-window-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: var(--z-overlay-top);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
}

.chat-window-overlay.hidden {
    display: none;
}

.chat-window-panel {
    width: min(520px, 100%);
    max-height: 85vh;
    background: var(--va-bg, #1b2838);
    border: 1px solid var(--va-border, #2a475e);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.chat-window-head {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 12px 16px;
    border-bottom: 1px solid var(--va-border, #2a475e);
}

.chat-win-messages {
    flex: 1;
    min-height: 280px;
    max-height: 50vh;
    overflow-y: auto;
    padding: var(--space-3);
}

.chat-picker-overlay {
    z-index: 10200;
}

.chat-inline-picker {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 72px;
    z-index: 20;
    background: var(--va-bg, #1b2838);
    border: 1px solid var(--va-accent, #66c0f4);
    border-radius: 12px;
    padding: var(--space-3);
    max-height: 240px;
    overflow: auto;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
}

.chat-inline-picker-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.chat-invite-card {
    background: #1e1f22;
    border: 1px solid var(--va-accent, #5865f2);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    max-width: 320px;
}

.chat-invite-card.chat-invite-pending {
    min-height: 48px;
    align-items: center;
}

.chat-invite-card.chat-invite-member {
    border-color: #3d4f5f;
}

.chat-invite-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
    background: #0f1f2d;
}

.chat-invite-icon-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.chat-channel-invite-card.chat-channel-invite-preview {
    flex-direction: column;
    align-items: stretch;
    max-width: 360px;
}

.chat-channel-invite-preview-head {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
}

.chat-channel-invite-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #0f1f2d;
}

.chat-channel-invite-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.chat-channel-invite-desc {
    font-size: 0.85rem;
    color: var(--va-text-muted, #b5bac1);
    line-height: 1.35;
}

.chat-channel-invite-subs {
    white-space: nowrap;
    font-size: 0.82rem;
}

.chat-forward-invite-preview {
    padding: 10px;
    border: 1px solid rgba(88, 101, 242, 0.35);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.2);
}

.chat-invite-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.chat-invite-name {
    font-weight: 600;
    word-break: break-word;
}

.chat-invite-member-note {
    color: #8b98a5;
    font-size: 0.85rem;
    font-style: italic;
}

.chat-invite-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.chat-author-row,
.chat-msg-header,
.chat-author-row .user-framed-avatar,
.chat-author-row .user-framed-avatar--framed {
    overflow: visible;
}

.chat-author-row .user-framed-avatar--framed {
    /* чуть больше места под оверлей рамки в компактном чате */
    --frame-overlay-ratio: 118%;
    --frame-avatar-ratio: 86%;
}

.chat-reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    margin: 0 12px 6px;
    min-height: 56px;
    background: rgba(102, 192, 244, 0.14);
    border-left: 3px solid var(--va-accent, #66c0f4);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-reply-preview {
    font-size: 0.88rem;
    color: var(--va-text-muted, #8f98a0);
    border-left: none;
    padding-left: 0;
    margin: 2px 0 0;
}

.chat-msg-hidden {
    display: none !important;
}

.chat-msg-deleted {
    color: #8b98a5;
    font-style: italic;
}

.chat-msg-deleted-row .chat-add-reaction,
.chat-msg-deleted-row .chat-quote-block {
    display: none !important;
}

.chat-quote-block {
    display: flex;
    gap: var(--space-2);
    align-items: flex-start;
    margin: 4px 0 6px;
    padding: 6px 8px;
    border-left: 3px solid var(--va-accent, #66c0f4);
    background: rgba(0, 0, 0, 0.22);
    border-radius: 6px;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
    cursor: pointer;
    -webkit-user-select: none;
            user-select: none;
}

.chat-msg.mine .chat-quote-block,
.chat-msg.own .chat-quote-block {
    background: rgba(0, 0, 0, 0.18);
    border-left-color: rgba(255, 255, 255, 0.65);
}

.chat-quote-block:hover {
    background: rgba(102, 192, 244, 0.14);
}

.chat-msg-jump-highlight {
    outline: 2px solid var(--va-accent, #66c0f4);
    outline-offset: 2px;
    animation: chat-msg-jump-pulse 1.4s ease;
}

.chat-quote-text {
    min-width: 0;
    flex: 1;
    font-size: 0.85rem;
    overflow: hidden;
}

.chat-quote-text strong {
    display: block;
    color: var(--va-accent, #66c0f4);
    margin-bottom: 2px;
}

.chat-quote-preview {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chat-quote-preview .voice-player,
.chat-quote-block .voice-player {
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0;
    overflow: hidden;
}

.chat-quote-preview .voice-wave-block,
.chat-quote-block .voice-wave-block {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.chat-quote-preview .voice-seek-host,
.chat-quote-block .voice-seek-host {
    max-width: 100%;
    overflow: hidden;
}

.chat-quote-voice-label {
    display: block;
    font-size: 0.85rem;
    color: var(--va-text-muted, #8f98a0);
}

.chat-reply-bar-inner {
    display: flex;
    gap: 10px;
    align-items: center;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.chat-reply-bar-text {
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.chat-reply-bar-text strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.92rem;
}

.chat-reply-preview {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    color: var(--va-text-muted, #8f98a0);
    font-size: 0.88rem;
    line-height: 1.35;
    max-height: 2.7em;
}

.chat-reply-preview .notif-preview-media {
    max-width: 96px;
    max-height: 64px;
    margin-top: 2px;
    border-radius: 6px;
}

.chat-forward-overlay {
    z-index: var(--z-toast);
}

.chat-forward-modal {
    width: min(520px, 96vw);
    max-height: 90vh;
    overflow: auto;
    background: var(--va-bg, #1b2838);
    border: 1px solid var(--va-border, #2a475e);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.chat-forward-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
}

.chat-forward-head h2 {
    margin: 0;
    font-size: 1.1rem;
}

.chat-forward-list {
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--va-border, #2a475e);
    border-radius: 6px;
}

.chat-forward-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(42, 71, 94, 0.6);
    color: var(--va-text, #c7d5e0);
    cursor: pointer;
}

.chat-forward-item:hover,
.chat-forward-item.active {
    background: rgba(102, 192, 244, 0.12);
}

.chat-forward-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--va-border, #2a475e);
    flex-shrink: 0;
    overflow: hidden;
}

.chat-forward-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-forward-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    background: var(--va-accent, #5865f2);
}

.chat-forward-letter-group {
    background: #3ba55c;
}

.chat-forward-letter-dm {
    background: var(--va-border, #2a475e);
    font-size: 1rem;
}

.chat-forward-meta {
    flex: 1;
    min-width: 0;
}

.chat-forward-meta strong {
    display: block;
}

.chat-forward-meta small {
    color: var(--va-text-muted, #8f98a0);
}

.chat-forward-preview {
    border-top: 1px solid var(--va-border, #2a475e);
    padding-top: 10px;
}

.chat-forward-preview-label {
    font-size: 0.8rem;
    color: var(--va-text-muted, #8f98a0);
    margin-bottom: 6px;
}

.chat-forward-comment {
    resize: vertical;
    min-height: 56px;
}

.chat-forward-foot {
    display: flex;
    justify-content: flex-end;
}

.chat-author-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--space-1);
}

.chat-msg-header .chat-author-row {
    margin-bottom: 0;
}

.chat-author-meta {
    display: flex;
    align-items: center;
    min-width: 0;
    line-height: 1.15;
}

.chat-author-name {
    font-size: 0.82rem;
    font-weight: 650;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.chat-author-name.btn-link {
    background: none;
    border: none;
    color: var(--va-accent, #66c0f4);
    padding: 0;
    cursor: pointer;
    font-weight: 650;
    text-align: left;
    font-size: inherit;
    line-height: inherit;
}

.chat-msg.mine .chat-author-name.btn-link,
.chat-msg.own .chat-author-name.btn-link {
    color: rgba(255, 255, 255, 0.95);
}

.chat-author-name.btn-link:hover {
    text-decoration: underline;
}

.chat-msg.mine .chat-author-row {
    flex-direction: row-reverse;
}

.chat-msg.mine .chat-author-meta {
    text-align: right;
}

.chat-head-mute-badge {
    font-size: 0.95rem;
    margin-left: 6px;
}

/* Rich chat list (Telegram / VK) */
.chat-list-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
}

.chat-list-avatar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.chat-list-avatar .group-avatar-wrap,
.chat-list-avatar .friend-avatar-wrap {
    width: 48px;
    height: 48px;
}

.chat-list-row .friend-item-avatar,
.chat-list-row .group-avatar-letter {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    max-width: 48px;
    max-height: 48px;
    border-radius: 50%;
    object-fit: cover;
    aspect-ratio: 1;
    flex-shrink: 0;
}

.chat-list-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}

.chat-list-top,
.chat-list-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-width: 0;
}

.chat-list-name {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-time {
    flex-shrink: 0;
    font-size: 0.72rem;
    opacity: 0.65;
}

.chat-list-preview {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    opacity: 0.72;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-unread {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #3390ec;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-date-header {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 0.78rem;
    color: var(--va-text-muted);
    padding: 10px 8px;
    position: relative;
    z-index: 1;
    text-decoration: none !important;
}

/* Линии по бокам убраны — давали эффект «перечёркнутой» даты */
.chat-date-header::before,
.chat-date-header::after {
    display: none !important;
}

.community-page #community-messages .chat-date-header,
.community-page #community-messages .chat-day-sep {
    align-self: center;
    width: -webkit-max-content;
    width: max-content;
    margin: 8px auto;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(23, 33, 43, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #c7d5e0;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.72rem;
    font-weight: 650;
    text-decoration: none !important;
}

.chat-channel-post-comment {
    display: block;
    margin-top: 6px;
    padding: 8px 10px;
    border-left: 3px solid var(--va-accent, #66c0f4);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 0 8px 8px 0;
}

.chat-channel-post-comment-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.chat-channel-post-comment-text {
    display: block;
    font-size: 0.88rem;
    white-space: pre-wrap;
}

.chat-channel-post-quote {
    display: block;
    margin-top: 6px;
    padding: 8px 10px;
    border-left: 3px solid var(--va-accent, #66c0f4);
    background: rgba(102, 192, 244, 0.08);
    border-radius: 0 8px 8px 0;
}

.chat-channel-post-quote-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.chat-channel-post-quote-text {
    display: block;
    font-size: 0.88rem;
    white-space: pre-wrap;
    font-style: italic;
}

.chat-forward-letter-channel {
    background: rgba(102, 192, 244, 0.2);
    color: var(--va-accent, #66c0f4);
}

.chat-msg:not(.mine):not(.own) .voice-play-btn {
    background: var(--va-accent, #66c0f4);
    color: #0b1622;
}

.chat-msg:not(.mine):not(.own) .voice-progress-playhead {
    background: var(--va-accent, #66c0f4);
}

.chat-msg:not(.mine):not(.own) .voice-time-compact {
    color: var(--va-accent, #66c0f4);
}

.chat-msg:not(.mine):not(.own) .voice-transcript-compact {
    border-color: var(--va-border, #2a475e);
    background: rgba(255, 255, 255, 0.04);
    color: var(--va-accent, #66c0f4);
}

.chat-msg.mine .voice-player,
.chat-msg.own .voice-player {
    background: transparent;
}

.chat-hashtag,
a.chat-hashtag {
    color: var(--va-accent, #66c0f4);
    text-decoration: none;
    font-weight: 600;
}
.chat-hashtag:hover { text-decoration: underline; }
.hashtag-picker.mention-picker { z-index: 9200; }
.md-grid-in-chat.md-grid--empty {
    min-height: 0;
    padding: 8px 12px;
    background: transparent;
    border: 0;
}
.md-grid-in-chat.md-grid--empty .md-cell { display: none; }

.chat-msg-receipt {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 0.72rem;
    letter-spacing: -0.06em;
    line-height: 1;
    color: var(--va-text-muted, #8f98a0);
    opacity: 0.9;
    white-space: nowrap;
    -webkit-user-select: none;
            user-select: none;
    align-self: center;
}
.chat-msg-receipt.is-sent,
.chat-msg-receipt.is-delivered {
    color: rgba(255, 255, 255, 0.55);
    opacity: 0.95;
}
.chat-msg-receipt.is-read {
    color: var(--va-accent, #66c0f4);
    opacity: 1;
}
