/* =========================================================================
   Файл: /_assets/_css/modules/message.css (Часть 1 из 4)
   Описание: Стили мессенджера LAFRUM на CSS-токенах темы (100dvh, фото-коллажи, голос, кружки)
   ========================================================================= */

html:has(body.in-direct-chat),
body.in-direct-chat {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    scrollbar-gutter: stable;
    overscroll-behavior: none;
    scroll-behavior: auto !important;
}

body.in-direct-chat .app-footer,
body.in-direct-chat .mobile-tabbar {
    display: none !important;
}

@media (max-width: 959px) {
    body.in-direct-chat {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
    body.in-direct-chat .topbar {
        display: none !important;
    }
    body.in-direct-chat .app-shell {
        height: 100dvh;
        max-height: 100dvh;
        padding: 0 !important;
        overflow: hidden;
    }
    body.in-direct-chat .app-main {
        height: 100dvh;
        max-height: 100dvh;
        min-height: 0;
    }
    body.in-direct-chat .dm-shell {
        height: 100%;
        border: none;
        border-radius: 0;
    }
}

@media (min-width: 960px) {
    body.in-direct-chat {
        padding-bottom: 24px !important;
    }
    body.in-direct-chat .app-shell {
        height: calc(100dvh - 84px);
        max-height: calc(100dvh - 84px);
        padding: 20px 24px 0 calc(272px + 24px) !important;
        overflow: hidden;
    }

    body.in-direct-chat .app-main {
        height: 100%;
        max-height: 100%;
        min-height: 0;
    }
    body.in-direct-chat .dm-shell {
        border: 1px solid var(--border-color);
        border-radius: 20px;
        box-shadow: var(--card-shadow);
    }
}

body.in-direct-chat .app-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-bottom: 0 !important;
    overflow: hidden;
}

body.in-direct-chat #spa-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 !important;
    max-width: none !important;
    overflow: hidden;
}

.dm-shell {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    height: calc(100dvh - 96px);
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 18px);
    overflow: hidden;
}

body.in-direct-chat .dm-shell {
    height: 100%;
}

/* --- ЛЕВАЯ ПАНЕЛЬ: СПИСОК ДИАЛОГОВ --- */
.dm-sidebar {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 2;
}

@media (min-width: 860px) {
    .dm-sidebar {
        width: 340px;
    }
}

@media (max-width: 859px) {
    .dm-shell.has-active-chat .dm-sidebar {
        display: none;
    }
    .dm-shell:not(.has-active-chat) .dm-chat-area {
        display: none;
    }
}

.dm-sidebar-head {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.dm-total-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--accent-grad, var(--accent));
    color: #fff;
    font-size: 0.75rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dm-sidebar-top-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (min-width: 960px) {
    .dm-menu-btn {
        display: none !important;
    }
}

.dm-search-box {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dm-search-box .ico {
    position: absolute;
    left: 11px;
    color: var(--text-secondary);
    pointer-events: none;
}

.dm-search-box input {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 38px;
    padding: 0 12px 0 34px;
    border-radius: 11px;
    border: 1px solid var(--border-color);
    background: var(--bg-input, var(--bg-card));
    color: var(--text-primary);
    font-size: 0.86rem;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.dm-search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.dm-filter-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.dm-tab-btn {
    height: 32px;
    border-radius: 9px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.16s ease;
}

.dm-tab-btn.is-active {
    background: color-mix(in srgb, var(--accent) 18%, var(--bg-card));
    border-color: var(--accent);
    color: var(--text-primary);
}
.dm-dialogs-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    transition: opacity 0.14s ease;
}

.dm-dialogs-list.is-loading {
    opacity: 0.6;
}

.dm-empty-dialogs {
    margin: auto;
    text-align: center;
    padding: 28px 18px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.dm-empty-dialogs p {
    margin: 0;
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dm-empty-dialogs span {
    font-size: 0.8rem;
    line-height: 1.35;
}

.dm-dialog-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.dm-dialog-item:hover {
    background: var(--bg-card-hover, color-mix(in srgb, var(--bg-card) 85%, var(--accent)));
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border-color));
}

.dm-dialog-item.is-pinned {
    border-color: color-mix(in srgb, var(--accent) 38%, var(--border-color));
}

.dm-dialog-item.is-active {
    background: color-mix(in srgb, var(--accent) 16%, var(--bg-card));
    border-color: var(--accent);
}

.dm-dlg-avatar { position: relative; flex-shrink: 0; }
.dm-online-dot {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--success, #10b981);
    border: 2px solid var(--bg-surface);
}

.dm-dlg-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.dm-dlg-top, .dm-dlg-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.dm-dlg-nick { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }

.dm-streak-pill {
    font-size: 0.72rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--warning, #f59e0b) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--warning, #f59e0b) 42%, transparent);
    color: var(--warning, #f59e0b);
    flex-shrink: 0;
}

.dm-dlg-meta { display: flex; align-items: center; gap: 4px; flex-shrink: 0; color: var(--text-secondary); font-size: 0.74rem; }
.dm-dlg-ticks { display: inline-flex; align-items: center; line-height: 1; }
.dm-dlg-ticks.is-sent { color: var(--text-secondary); }
.dm-dlg-ticks.is-read { color: var(--accent); }
.dm-pin-ic { color: var(--accent); }

.dm-dlg-preview { font-size: 0.81rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-dlg-preview i { font-style: normal; color: var(--accent); font-weight: 600; }
.dm-dlg-typing { font-size: 0.8rem; color: var(--accent); font-weight: 600; }
.dm-dlg-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.73rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* --- ПРАВАЯ ПАНЕЛЬ: АКТИВНЫЙ ДИАЛОГ --- */
.dm-chat-area {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-main, var(--bg-surface));
    overflow: hidden;
}

.dm-placeholder { position: relative; z-index: 1; margin: auto; padding: 24px; }
.dm-placeholder-card {
    max-width: 360px;
    padding: 28px 24px;
    border-radius: 22px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.dm-placeholder-card h2 { margin: 0; font-size: 1.08rem; color: var(--text-primary); }
.dm-placeholder-card p { margin: 0; font-size: 0.84rem; line-height: 1.45; }

.dm-chat-header {
    position: relative;
    z-index: 10;
    flex: 0 0 56px;
    height: 56px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

.dm-header-left, .dm-peer-link { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }

.dm-back-btn, .dm-hdr-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
    transition: border-color 0.16s ease, background 0.16s ease;
}

@media (min-width: 860px) { .dm-back-btn:not(.dm-menu-btn) { display: none; } }

.dm-hdr-btn:hover, .dm-hdr-btn.is-active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 18%, var(--bg-card));
    color: var(--accent);
}
.dm-header-actions { display: flex; align-items: center; gap: 6px; }
.dm-peer-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dm-peer-name-row { display: flex; align-items: center; gap: 6px; font-size: 0.94rem; font-weight: 800; color: var(--text-primary); }
.dm-peer-status { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* --- ЛЕНТА СООБЩЕНИЙ И ПУЗЫРИ --- */
.dm-feed {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: auto !important;
    overflow-anchor: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dm-feed.is-prepending { overflow-anchor: none; }
@media (min-width: 768px) { .dm-feed { padding: 16px 22px 20px; } }

.dm-text-body { font-size: 0.93rem; }
.dm-photo-attach + .dm-text-body,
.dm-photo-grid + .dm-text-body,
.dm-gift-card + .dm-text-body,
.dm-media-removed + .dm-text-body { margin-top: 8px; }

.dm-inline-link { color: var(--accent); text-decoration: underline; word-break: break-all; }

.dm-media-removed {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 9px;
    background: var(--bg-surface);
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-style: italic;
    user-select: none;
}

.dm-history-sentinel { width: 100%; height: 1px; flex-shrink: 0; pointer-events: none; }
.dm-history-loader { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px; font-size: 0.78rem; color: var(--text-secondary); flex-shrink: 0; }
.dm-history-loader[hidden] { display: none !important; }
.dm-mini-spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: dmSpin 0.75s linear infinite; }
@keyframes dmSpin { to { transform: rotate(360deg); } }

.dm-feed > .dm-msg-row:first-of-type { margin-top: auto; }
.dm-msg-row { display: flex; width: 100%; flex-shrink: 0; }

.dm-msg-row.is-mine { justify-content: flex-end; }
.dm-msg-row.is-peer { justify-content: flex-start; }

.dm-bubble-wrap { position: relative; max-width: 82%; display: flex; flex-direction: column; gap: 4px; }
@media (min-width: 768px) { .dm-bubble-wrap { max-width: 66%; } }
.dm-msg-row.is-mine .dm-bubble-wrap { align-items: flex-end; }

.dm-bubble {
    position: relative;
    padding: 9px 13px 7px;
    border-radius: 17px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    line-height: 1.42;
    word-break: break-word;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.dm-msg-row.is-mine .dm-bubble {
    background: color-mix(in srgb, var(--accent) 18%, var(--bg-card));
    border-color: color-mix(in srgb, var(--accent) 42%, var(--border-color));
    border-bottom-right-radius: 5px;
}

.dm-msg-row.is-peer .dm-bubble { border-bottom-left-radius: 5px; }
.dm-bubble.is-frameless { background: transparent !important; border: none !important; box-shadow: none !important; padding: 2px; }

.dm-msg-tools { display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity 0.16s; }
.dm-bubble-wrap:hover .dm-msg-tools, .dm-msg-row.is-tools-open .dm-msg-tools { opacity: 1; }
@media (hover: none) { .dm-msg-tools { opacity: 0.85; } }

.dm-tool-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.dm-tool-btn:hover { color: var(--accent); border-color: var(--accent); }

.dm-fwd-tag { display: flex; align-items: center; gap: 5px; font-size: 0.74rem; color: var(--accent); margin-bottom: 4px; font-weight: 600; }
.dm-reply-quote { margin-bottom: 6px; padding: 5px 9px; border-left: 3px solid var(--accent); border-radius: 6px; background: color-mix(in srgb, var(--bg-surface) 75%, transparent); display: flex; flex-direction: column; cursor: pointer; }
.dm-reply-author { font-size: 0.74rem; font-weight: 800; color: var(--accent); }
.dm-reply-snippet { font-size: 0.78rem; color: var(--text-secondary); }

/* --- КОЛЛАЖ ФОТОГРАФИЙ (ДО 5 ШТ.) --- */
.dm-photo-attach { position: relative; border-radius: 12px; overflow: hidden; cursor: zoom-in; }
.dm-photo-attach img { max-width: 100%; max-height: 310px; border-radius: 12px; display: block; object-fit: cover; }

.dm-photo-grid { display: grid; gap: 3px; border-radius: 12px; overflow: hidden; max-width: 340px; }
.dm-photo-grid .dm-grid-cell { position: relative; overflow: hidden; background: var(--bg-surface); cursor: zoom-in; }
.dm-photo-grid .dm-grid-cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s ease; }
.dm-photo-grid .dm-grid-cell:hover img { transform: scale(1.03); }

.dm-photo-grid.is-count-2 { grid-template-columns: repeat(2, 1fr); }
.dm-photo-grid.is-count-2 .dm-grid-cell { aspect-ratio: 1 / 1; }
.dm-photo-grid.is-count-3 { grid-template-columns: repeat(2, 1fr); }
.dm-photo-grid.is-count-3 .dm-grid-cell:first-child { grid-column: span 2; aspect-ratio: 16 / 10; }
.dm-photo-grid.is-count-3 .dm-grid-cell:not(:first-child) { aspect-ratio: 1 / 1; }
.dm-photo-grid.is-count-4 { grid-template-columns: repeat(2, 1fr); }
.dm-photo-grid.is-count-4 .dm-grid-cell { aspect-ratio: 1 / 1; }
.dm-photo-grid.is-count-5 { grid-template-columns: repeat(6, 1fr); }
.dm-photo-grid.is-count-5 .dm-grid-cell:nth-child(1),
.dm-photo-grid.is-count-5 .dm-grid-cell:nth-child(2) { grid-column: span 3; aspect-ratio: 4 / 3; }
.dm-photo-grid.is-count-5 .dm-grid-cell:nth-child(3),
.dm-photo-grid.is-count-5 .dm-grid-cell:nth-child(4),
.dm-photo-grid.is-count-5 .dm-grid-cell:nth-child(5) { grid-column: span 2; aspect-ratio: 1 / 1; }

.dm-sticker-emoji { font-size: 3.4rem; line-height: 1.1; user-select: none; }
.dm-sticker-img img { max-width: 125px; max-height: 125px; border-radius: 10px; display: block; }

.dm-gift-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, var(--bg-surface)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border-color)); }
.dm-gift-card img { width: 48px; height: 48px; object-fit: contain; }
.dm-gift-info { display: flex; flex-direction: column; gap: 2px; }
.dm-gift-lbl { font-size: 0.72rem; color: var(--text-secondary); text-transform: uppercase; font-weight: 700; }

/* --- ГОЛОСОВЫЕ И ВИДЕО-КРУЖКИ (VIP) --- */
.dm-voice-player { display: flex; align-items: center; gap: 10px; min-width: 195px; padding: 3px 2px; }
.dm-voice-play-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--accent-grad, var(--accent)); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.dm-voice-player.is-playing .ic-play { display: none !important; }
.dm-voice-player .ic-pause { display: none; }
.dm-voice-player.is-playing .ic-pause { display: inline-block !important; }
.dm-voice-track-wrap { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.dm-voice-bars { height: 22px; display: flex; align-items: center; gap: 2px; cursor: pointer; touch-action: manipulation; }
.dm-voice-bars span { flex: 1; background: color-mix(in srgb, var(--text-secondary) 40%, transparent); border-radius: 2px; transition: background 0.1s ease, transform 0.12s ease; }
.dm-voice-bars span.is-filled { background: var(--accent); }
.dm-voice-bars span.is-head { transform: scaleY(1.16); }
.dm-voice-dur { font-size: 0.72rem; color: var(--text-secondary); font-weight: 700; font-variant-numeric: tabular-nums; }

.dm-circle-player { position: relative; width: 200px; height: 200px; border-radius: 50%; overflow: hidden; cursor: pointer; background: var(--bg-surface); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.dm-circle-player video { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.dm-circle-play-overlay { position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%; background: rgba(9, 13, 28, 0.68); backdrop-filter: blur(6px); border: 1.5px solid rgba(255, 255, 255, 0.32); color: #fff; display: flex; align-items: center; justify-content: center; padding-left: 3px; pointer-events: none; transition: opacity 0.18s ease, transform 0.18s ease; }
.dm-circle-player.is-playing .dm-circle-play-overlay { opacity: 0; transform: scale(0.82); }
.dm-circle-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.dm-circle-ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.22); stroke-width: 3; }
.dm-circle-ring-fg { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-dasharray: 302; stroke-dashoffset: 302; will-change: stroke-dashoffset; }
.dm-circle-badge { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); padding: 2px 8px; border-radius: 999px; background: rgba(9, 13, 28, 0.78); color: #fff; font-size: 0.72rem; font-weight: 700; pointer-events: none; }
/* Оверлей загрузки тяжёлых медиафайлов (кружки / фото / голосовые) */
.dm-msg-row.is-optimistic .dm-bubble { opacity: 0.92; }
.dm-upload-overlay { position: absolute; inset: 0; border-radius: inherit; background: rgba(9, 13, 28, 0.66); backdrop-filter: blur(4px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #fff; font-size: 0.74rem; font-weight: 800; z-index: 4; pointer-events: none; }
.dm-upload-ring { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(56, 189, 248, 0.25); border-top-color: var(--accent); animation: dmSpin 0.8s linear infinite; }
.dm-voice-uploading { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-secondary); padding: 4px 2px; }

/* --- НИЖНИЙ ИНДИКАТОР «••• ПЕЧАТАЕТ / ДУМАЕТ» --- */
.dm-typing-footer {
    position: relative;
    z-index: 5;
    padding: 4px 16px 3px;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-surface);
}
.dm-typing-footer[hidden] { display: none !important; }

.dm-thinking-ic { display: none !important; }
.dm-dlg-typing.is-thinking { color: var(--accent); }

.dm-typing-dots { display: inline-flex; align-items: center; gap: 3px; }
.dm-typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-secondary); animation: dmDotBounce 1.2s infinite ease-in-out; }
.dm-typing-dots i:nth-child(2) { animation-delay: 0.18s; }
.dm-typing-dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes dmDotBounce {
    0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1.2); background: var(--accent); }
}

/* --- ПОЛОСА ПРЕДПРОСМОТРА ПРИКРЕПЛЁННЫХ ФОТО (ДО 5 ШТ.) --- */
.dm-photo-staging {
    position: relative;
    z-index: 6;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px 6px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
    overflow-y: hidden;
}
.dm-photo-staging[hidden] { display: none !important; }

.dm-stage-thumb { position: relative; width: 62px; height: 62px; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: var(--bg-card); border: 1.5px solid var(--border-color); }
.dm-stage-thumb.is-error { border-color: var(--danger, #ef4444); }
.dm-stage-thumb.is-ready { border-color: var(--success, #10b981); }
.dm-stage-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.dm-stage-status { position: absolute; inset: 0; background: rgba(9, 13, 28, 0.65); backdrop-filter: blur(2px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #fff; font-size: 0.68rem; font-weight: 800; pointer-events: none; }
.dm-stage-status.is-error { background: color-mix(in srgb, var(--danger, #ef4444) 82%, #000); color: #fff; font-size: 0.65rem; }
.dm-stage-mini-ring { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: dmSpin 0.75s linear infinite; }
.dm-stage-done-badge { position: absolute; bottom: 4px; left: 4px; width: 17px; height: 17px; border-radius: 50%; background: var(--success, #10b981); color: #fff; display: flex; align-items: center; justify-content: center; pointer-events: none; }

.dm-stage-del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.28); background: rgba(9, 13, 28, 0.88); color: #fff; font-size: 0.95rem; font-weight: 700; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 3; }
/* --- ПИКЕР СМАЙЛОВ И СТИКЕРОВ (ВНУТРИ LafrumUI POPOVER / SHEET) --- */
.dm-mp-wrap { width: 320px; max-width: 100%; display: flex; flex-direction: column; }
.app-overlay.mode-sheet .dm-mp-wrap { width: 100%; }
.dm-mp-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border-color); }
.dm-mp-tab { padding: 8px; border: none; background: transparent; color: var(--text-secondary); font-size: 0.84rem; font-weight: 700; cursor: pointer; }
.dm-mp-tab.is-active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.dm-mp-subtabs { display: flex; gap: 4px; padding: 6px 8px; overflow-x: auto; border-bottom: 1px solid var(--border-color); }
.dm-mp-subtab { padding: 4px 9px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-secondary); font-size: 0.76rem; white-space: nowrap; cursor: pointer; }
.dm-mp-subtab.is-active { background: color-mix(in srgb, var(--accent) 18%, var(--bg-card)); border-color: var(--accent); color: var(--text-primary); }
.dm-mp-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; padding: 8px; max-height: 210px; overflow-y: auto; }
.dm-mp-grid.is-stickers { grid-template-columns: repeat(4, 1fr); }
.dm-mp-item { display: flex; align-items: center; justify-content: center; padding: 6px; border: none; border-radius: 10px; background: var(--bg-card); font-size: 1.45rem; cursor: pointer; }
.dm-mp-item:hover { background: color-mix(in srgb, var(--accent) 18%, var(--bg-card)); }
.dm-mp-item img { width: 42px; height: 42px; object-fit: contain; }

/* --- КАПСУЛА ВВОДА И ОВЕРЛЕЙ ЗАПИСИ --- */
.dm-composer { position: relative; z-index: 8; flex: 0 0 auto; padding: 8px 10px 10px; background: var(--bg-surface); border-top: 1px solid var(--border-color); }
.dm-capsule { display: flex; align-items: flex-end; gap: 4px; width: 100%; padding: 4px 6px; border-radius: 22px; background: var(--bg-input, var(--bg-card)); border: 1px solid var(--border-color); }
.dm-capsule:focus-within { border-color: var(--accent); }
.dm-capsule textarea { flex: 1; min-width: 0; min-height: 34px; max-height: 100px; padding: 7px 4px; border: none; background: transparent; color: var(--text-primary); font-size: 0.93rem; line-height: 1.35; resize: none; outline: none; font-family: inherit; }

.dm-cap-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; align-self: flex-end; }
.dm-cap-icon { position: relative; width: 34px; height: 34px; border-radius: 50%; border: none; background: transparent; color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.dm-cap-icon:hover { color: var(--text-primary); background: color-mix(in srgb, var(--text-secondary) 14%, transparent); }

.dm-cap-icon.is-vip-locked::after { content: ''; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--warning, #f59e0b); }
.dm-burn-pill-val { position: absolute; bottom: 0; right: 0; padding: 1px 4px; border-radius: 6px; background: var(--warning, #f59e0b); color: #fff; font-size: 9px; line-height: 1; font-weight: 800; pointer-events: none; }
.dm-media-rec-btns { display: flex; align-items: center; gap: 6px; }

.dm-media-rec-btns[hidden] { display: none !important; }
.dm-send-btn { width: 36px; height: 34px; border-radius: 50%; border: none; background: var(--accent-grad, var(--accent)); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.dm-send-btn[hidden] { display: none !important; }

.dm-rec-overlay { position: relative; z-index: 9; flex: 0 0 auto; width: 100%; padding: 10px 12px; background: var(--bg-surface); border-top: 1px solid var(--accent); display: flex; flex-direction: column; align-items: center; gap: 10px; box-sizing: border-box; }
.dm-rec-overlay[hidden] { display: none !important; }
.dm-rec-circle-preview { width: 165px; height: 165px; border-radius: 50%; overflow: hidden; border: 3px solid var(--accent); }
.dm-rec-circle-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.dm-rec-bar { width: 100%; display: flex; align-items: center; gap: 8px; }
.dm-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger, #ef4444); flex-shrink: 0; animation: dmRecBlink 1s infinite; }

@keyframes dmRecBlink { 50% { opacity: 0.25; } }
.dm-rec-timer { font-weight: 800; color: var(--text-primary); font-size: 0.9rem; }
.dm-rec-hint { flex: 1; font-size: 0.78rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* --- МЕТА, РЕАКЦИИ, VIP FX, КОНТЕКСТНОЕ МЕНЮ И ЛАЙТБОКС --- */
.dm-meta-row { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 3px; font-size: 0.7rem; color: var(--text-secondary); }
.dm-ticks.is-read { color: var(--accent); }
.dm-burn-badge { display: inline-flex; align-items: center; gap: 2px; color: var(--warning, #f59e0b); font-weight: 700; }
.dm-reactions-row { display: flex; flex-wrap: wrap; gap: 4px; }
.dm-react-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-primary); font-size: 0.78rem; cursor: pointer; }
.dm-react-pill.is-mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--bg-surface)); }
.dm-react-pill.is-vip-fx { border-color: color-mix(in srgb, var(--warning, #f59e0b) 65%, transparent); }

.dm-vip-fx-stage { position: fixed; width: 0; height: 0; pointer-events: none; z-index: 9999; }
.dm-fx-hero { position: absolute; left: 0; top: 0; font-size: 2.5rem; line-height: 1; animation: dmFxHeroPop 1.15s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards; }
.dm-fx-particle { position: absolute; left: 0; top: 0; font-size: 1.25rem; line-height: 1; opacity: 0; animation: dmFxParticleFly 1.15s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes dmFxHeroPop {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.25) rotate(-12deg); }
    22%  { opacity: 1; transform: translate(-50%, -85%) scale(1.35) rotate(6deg); }
    65%  { opacity: 1; transform: translate(-50%, -115%) scale(1.1) rotate(0deg); }
    100% { opacity: 0; transform: translate(-50%, -145%) scale(0.85); }
}
@keyframes dmFxParticleFly {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
    18%  { opacity: 1; }
    80%  { opacity: 0.92; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--sc)) rotate(var(--rot)); }
}

.dm-fx-glow-hearts    { box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.65), 0 0 24px rgba(236, 72, 153, 0.45) !important; }
.dm-fx-glow-crown     { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.72), 0 0 24px rgba(245, 158, 11, 0.45) !important; }
.dm-fx-glow-lightning { box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.78), 0 0 26px rgba(56, 189, 248, 0.55) !important; }
.dm-fx-glow-fireworks { box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.75), 0 0 26px rgba(236, 72, 153, 0.45) !important; }
.dm-fx-glow-crystal   { box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.75), 0 0 24px rgba(56, 189, 248, 0.48) !important; }

.dm-scroll-down-btn { position: absolute; right: 14px; bottom: 68px; z-index: 7; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-primary); display: none; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); }
.dm-scroll-down-btn.is-visible { display: inline-flex; }
.dm-new-cnt { position: absolute; top: -6px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.dm-new-cnt[hidden] { display: none !important; }

.dm-composer-banner { position: relative; z-index: 7; padding: 6px 14px; background: var(--bg-surface); border-top: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dm-composer-banner[hidden] { display: none !important; }
.dm-banner-info { display: flex; flex-direction: column; min-width: 0; font-size: 0.8rem; }
.dm-banner-info strong { color: var(--accent); }
.dm-banner-info span { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-banner-close { background: none; border: none; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }

.dm-react-row { display: flex; gap: 4px; }
.dm-pick-react { width: 34px; height: 34px; border-radius: 9px; border: none; background: var(--bg-card); font-size: 1.15rem; cursor: pointer; }
.dm-pick-react:hover { background: color-mix(in srgb, var(--accent) 20%, var(--bg-card)); }
.dm-react-vip-divider { margin: 6px 0 4px; font-size: 0.68rem; font-weight: 800; color: var(--warning, #f59e0b); text-transform: uppercase; }

.dm-blocked-bar { padding: 12px; background: var(--bg-surface); border-top: 1px solid color-mix(in srgb, var(--danger, #ef4444) 35%, transparent); color: var(--danger, #ef4444); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.85rem; }

.dm-fwd-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.dm-fwd-target { justify-content: flex-start; text-align: left; width: 100%; }

.dm-lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(5, 8, 18, 0.94); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 16px; user-select: none; touch-action: pan-y; }
.dm-lightbox[hidden] { display: none !important; }
.dm-lb-close { position: fixed; top: 14px; right: 18px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(15, 23, 42, 0.8); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; z-index: 25; }
.dm-lb-topbar { position: fixed; top: 0; left: 0; right: 0; height: 56px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; z-index: 20; pointer-events: none; }
.dm-lb-counter { padding: 5px 12px; border-radius: 999px; background: rgba(15, 23, 42, 0.78); border: 1px solid rgba(255, 255, 255, 0.14); color: #fff; font-size: 0.84rem; font-weight: 700; }
.dm-lb-stage { position: relative; flex: 1 1 auto; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 58px 16px 76px; overflow: hidden; }
.dm-lb-stage img { max-width: 100%; max-height: 100%; border-radius: 10px; transition: opacity 0.18s ease, transform 0.22s ease; object-fit: contain; }
.dm-lb-stage img.is-switching { opacity: 0.35; transform: scale(0.97); }
.dm-lb-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(15, 23, 42, 0.72); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 22; }
.dm-lb-nav.is-prev { left: 14px; }
.dm-lb-nav.is-next { right: 14px; }
.dm-lb-thumbs { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 14px; background: rgba(15, 23, 42, 0.8); border: 1px solid rgba(255, 255, 255, 0.14); z-index: 22; max-width: calc(100vw - 24px); overflow-x: auto; }
.dm-lb-thumb-btn { width: 44px; height: 44px; padding: 0; border-radius: 8px; overflow: hidden; border: 2px solid transparent; opacity: 0.55; cursor: pointer; flex-shrink: 0; background: #0f172a; }
.dm-lb-thumb-btn.is-active { opacity: 1; border-color: var(--accent); transform: scale(1.06); }
.dm-lb-thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Точная привязка границ чата к сетке профиля и шапки (1280px / 272px / 24px) */
@media (min-width: 960px) {
    body.in-direct-chat .dm-shell {
        position: fixed !important;
        top: 80px !important;
        bottom: 24px !important;
        left: calc(max(0px, (100% - 1280px) / 2) + 272px + 24px) !important;
        right: calc(max(0px, (100% - 1280px) / 2) + 24px) !important;
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        margin: 0 !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 20px !important;
        box-shadow: var(--card-shadow) !important;
        z-index: 10;
    }
}
