/* ============================================================
   Discord-like chat / PM (site light theme + brand accent)
   ============================================================ */

.dc-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: none;
    min-height: 0;
    padding: 0 !important;
    overflow: hidden;
}

body.section-chat,
body.section-messages {
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
}

body.section-chat > .topbar,
body.section-messages > .topbar {
    flex-shrink: 0;
}

body.section-chat > .bg-ambient,
body.section-messages > .bg-ambient {
    flex: none;
}

body.section-chat .site-footer,
body.section-messages .site-footer {
    display: none;
}

body.section-chat .layout,
body.section-messages .layout {
    align-items: stretch;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: calc(100dvh - var(--chat-topbar, 64px));
    padding-top: 12px;
    padding-bottom: 12px;
    overflow: hidden;
    box-sizing: border-box;
}

body.section-chat .content,
body.section-messages .content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    align-self: stretch;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

body.section-chat #chatSection.active,
body.section-messages #messagesSection.active {
    flex: 1 1 auto;
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    margin: 0;
}

body.section-chat .dc-shell,
body.section-messages .messages-page.dc-shell {
    flex: 1 1 auto;
    width: 100%;
    margin-bottom: 0 !important;
    min-height: 0 !important;
    overflow: hidden;
}

body.section-chat .sidebar,
body.section-messages .sidebar {
    align-self: stretch;
    height: auto;
    max-height: 100%;
    overflow-y: auto;
}

.dc-channel-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 !important;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(23, 34, 47, 0.04);
    flex-shrink: 0;
    position: relative;
}

.dc-channel-header h2 {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    font-size: 0.62rem;
    text-transform: none;
}

.dc-channel-header h2::after { display: none !important; }

.dc-channel-header h2 i {
    color: var(--muted);
    margin-right: 4px;
}

.dc-members-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-right: 2px;
}

.chat-members-toggle,
.chat-members-close,
.chat-members-backdrop {
    display: none;
}

/* Discord: members LEFT, chat RIGHT */
.dc-layout.chat-with-users-layout {
    display: grid !important;
    grid-template-columns: 248px minmax(0, 1fr) !important;
    gap: 0 !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 0; /* force flex child to take remaining shell height */
    overflow: hidden;
}

.dc-members.chat-users-sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 10px;
    background: var(--panel-2);
    border-right: 1px solid var(--border);
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    order: 0;
}

.dc-main.chat-main-area {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    max-height: 100%;
    overflow: hidden;
    background: var(--panel);
    border-right: none;
    order: 1;
}

.dc-members-title {
    font-family: var(--font-pixel);
    font-size: 0.48rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px 6px;
}

.dc-member-group { margin-bottom: 10px; }

.dc-member-group-title {
    font-family: var(--font-pixel);
    font-size: 0.42rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 8px 4px;
}

.dc-members .chat-users-list {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background: transparent;
    border: none;
    border-radius: 0;
}

.dc-members .chat-user-row {
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 2px;
    transition: background 0.12s ease;
}

.dc-members .chat-user-row:hover {
    background: color-mix(in srgb, var(--ink) 6%, transparent);
}

.dc-members .chat-user-row[data-presence="offline"] .chat-user-name,
.dc-members .chat-user-row[data-presence="offline"] .chat-user-sub,
.dc-members .chat-user-row[data-presence="offline"] .chat-user-avatar {
    opacity: 0.55;
}

.dc-members .chat-user-avatar {
    border-radius: 50%;
    border: none;
}

.dc-members .chat-user-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    padding: 0;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
}

.dc-members .chat-user-main:hover {
    transform: none;
    box-shadow: none;
}

/* Messages scroller — block flow so rows don't flex-shrink/overlap */
.dc-messages.global-chat-messages,
.dc-messages.pm-messages {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto;
    margin: 0 !important;
    padding: 8px 0 16px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    background: var(--panel) !important;
    border: none !important;
    border-radius: 0 !important;
    display: block !important;
    width: 100%;
    box-sizing: border-box;
}

/* Discord message row — force grid over legacy flex */
.dc-messages .dc-msg,
.dc-messages .dc-msg.global-chat-message,
.dc-messages .dc-msg.pm-message {
    display: grid !important;
    grid-template-columns: 56px minmax(0, 1fr) !important;
    gap: 0 12px !important;
    padding: 4px 16px 4px 8px !important;
    margin: 0 0 2px !important;
    max-width: 100% !important;
    width: 100%;
    box-sizing: border-box;
    align-self: auto !important;
    align-items: flex-start;
    position: relative;
    flex: none !important;
    flex-shrink: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible;
    float: none !important;
    transition: background 0.1s ease;
}

.dc-msg:hover {
    background: color-mix(in srgb, var(--ink) 4%, transparent) !important;
}

.dc-messages .dc-msg.pm-message,
.dc-messages .pm-message.dc-msg,
.dc-messages .pm-message {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    align-self: auto !important;
}

.dc-msg + .dc-msg:not(.dc-msg-compact) {
    margin-top: 14px !important;
}

.dc-msg-compact {
    margin-top: 0 !important;
    padding-top: 2px !important;
    padding-bottom: 2px !important;
}

.dc-avatar-col {
    position: relative;
    width: 40px;
    min-height: 22px;
    margin-left: 8px;
    margin-top: 2px;
    flex-shrink: 0;
}

.dc-avatar,
.dc-msg .chat-avatar,
.dc-msg .pm-msg-avatar,
.dc-avatar-wrap .dc-avatar,
.dc-avatar-wrap .chat-avatar,
.dc-avatar-wrap .pm-msg-avatar,
.dc-avatar-wrap .chat-user-avatar {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    border: none !important;
    object-fit: cover;
    display: block;
}

.dc-members .dc-avatar-wrap .chat-user-avatar {
    width: 32px !important;
    height: 32px !important;
}

.dc-body {
    min-width: 0;
    padding: 2px 0;
    display: block !important;
    float: none !important;
    position: relative;
    overflow: visible;
}

.dc-header {
    display: flex !important;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-start !important;
    gap: 6px 8px;
    margin: 0 0 2px !important;
    line-height: 1.25;
    width: auto;
}

.dc-name,
a.dc-name,
button.dc-name {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--ink);
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
    cursor: pointer;
    text-align: left;
    width: auto !important;
    flex: 0 0 auto !important;
    display: inline !important;
}

.dc-name:hover,
a.dc-name:hover,
button.dc-name:hover {
    text-decoration: underline;
    color: var(--link);
    transform: none;
}

.dc-name-own { color: var(--accent-deep); }

.dc-timestamp {
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--dim);
    font-weight: 400;
    margin-left: 0 !important;
    margin-right: 0 !important;
    flex: 0 0 auto !important;
}

.dc-compact-time {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: flex-end;
    font-family: var(--font-body);
    font-size: 0.62rem;
    color: var(--dim);
    white-space: nowrap;
    padding-right: 2px;
    line-height: 1.2;
}

.dc-msg-compact:hover .dc-compact-time {
    display: flex;
}

.dc-content {
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--ink);
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    float: none !important;
    max-width: 100%;
}

.dc-attach {
    margin-top: 6px;
    line-height: 0;
}

.dc-attach img,
.dc-attach .chat-msg-image,
.dc-attach .pm-msg-image {
    display: block;
    max-width: min(400px, 100%);
    max-height: 300px;
    border: none !important;
    border-radius: 8px;
    background: transparent !important;
    box-shadow: none !important;
    object-fit: contain;
}

.dc-attach .chat-msg-image-link {
    display: inline-block;
    line-height: 0;
    border: none;
}

/* Status: plane = sent, eye = read */
.dc-status {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    line-height: 1;
    opacity: 0.85;
    margin-left: 0 !important;
}

.dc-status-sent { color: var(--dim); }
.dc-status-read { color: var(--accent); }
.dc-status i { font-size: 0.68rem; }

/* Kill old bubble look */
.dc-messages .global-chat-bubble,
.dc-messages .pm-bubble,
.dc-msg .global-chat-bubble,
.dc-msg .pm-bubble {
    display: block;
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
    max-width: none;
}

.dc-messages .global-chat-bubble-meta,
.dc-messages .global-chat-meta {
    margin-left: 0 !important;
}

/* ---------- Discord presence (global, any avatar) ---------- */
.dc-avatar-wrap {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    width: fit-content;
    line-height: 0;
    vertical-align: middle;
}

.dc-avatar-mask {
    display: block;
    border-radius: 50%;
    overflow: hidden;
    line-height: 0;
}

.dc-presence {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-sizing: border-box;
    border: 3px solid var(--panel);
    background-clip: padding-box;
    pointer-events: none;
    z-index: 1;
}

.dc-presence-online { background-color: #23a55a; }

.dc-presence-idle {
    background-color: #f0b232;
    background-image: radial-gradient(circle at 30% 30%, var(--panel) 42%, transparent 43%);
}

.dc-presence-dnd {
    background-color: #f23f43;
    background-image: linear-gradient(
        transparent 38%,
        var(--panel) 38%,
        var(--panel) 62%,
        transparent 62%
    );
}

.dc-presence-offline {
    background-color: #80848e;
    background-image: radial-gradient(circle at center, var(--panel) 38%, transparent 39%);
}

.side-group .dc-presence,
.dc-members .dc-presence,
.messages-sidebar .dc-presence,
.dialogs-list .dc-presence,
.pm-user-results .dc-presence {
    border-color: var(--panel-2);
}

.dc-members .dc-presence-idle,
.messages-sidebar .dc-presence-idle,
.dialogs-list .dc-presence-idle,
.pm-user-results .dc-presence-idle {
    background-image: radial-gradient(circle at 30% 30%, var(--panel-2) 42%, transparent 43%);
}

.dc-members .dc-presence-dnd,
.messages-sidebar .dc-presence-dnd,
.dialogs-list .dc-presence-dnd,
.pm-user-results .dc-presence-dnd {
    background-image: linear-gradient(
        transparent 38%,
        var(--panel-2) 38%,
        var(--panel-2) 62%,
        transparent 62%
    );
}

.dc-members .dc-presence-offline,
.messages-sidebar .dc-presence-offline,
.dialogs-list .dc-presence-offline,
.pm-user-results .dc-presence-offline {
    background-image: radial-gradient(circle at center, var(--panel-2) 38%, transparent 39%);
}

.dc-members .dc-presence,
.dialogs-list .dc-presence,
.pm-user-results .dc-presence,
.profile-user-list-item .dc-presence,
.search-result-item .dc-presence,
#userPanel .dc-presence {
    width: 12px;
    height: 12px;
    border-width: 2.5px;
    bottom: -1px;
    right: -1px;
}

.dc-avatar-wrap .post-avatar { width: 44px; height: 44px; display: block; }
.dc-avatar-wrap .comment-avatar { width: 30px; height: 30px; display: block; }
.dc-avatar-wrap .profile-avatar,
.dc-avatar-wrap .profile-page-avatar { width: 110px; height: 110px; display: block; }
.dc-avatar-wrap .search-avatar { width: 44px; height: 44px; display: block; }
.dc-avatar-wrap .dialog-avatar { width: 40px; height: 40px; display: block; object-fit: cover; border-radius: 50%; }
.dc-avatar-wrap .pm-user-avatar { width: 36px; height: 36px; display: block; }
.dc-avatar-wrap .pm-title-avatar-img { width: 32px; height: 32px; display: block; border-radius: 50%; object-fit: cover; }
.dc-avatar-wrap .admin-user-avatar { width: 40px; height: 40px; display: block; }
#userPanel .dc-avatar-wrap img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.profile-page-avatar-wrap .dc-presence,
.profile-header .dc-presence {
    width: 22px;
    height: 22px;
    border-width: 4px;
    bottom: 4px;
    right: 4px;
}

/* Composer — одна полоса как в Discord */
.dc-composer.chat-composer,
.dc-main .chat-composer,
.pm-chat-area .chat-composer,
.forum-comment-composer.chat-composer {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    margin: 0 16px 16px !important;
    padding: 0 8px 0 4px !important;
    min-height: 44px;
    border: none !important;
    border-radius: 8px !important;
    background: var(--panel-3) !important;
    box-shadow: none !important;
    flex-shrink: 0;
    position: relative;
    box-sizing: border-box;
}

.dc-composer .chat-composer-tools,
.pm-chat-area .chat-composer-tools {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    padding-left: 4px;
}

.dc-composer .chat-tool-btn,
.dc-composer label.chat-tool-btn,
.pm-chat-area .chat-tool-btn,
.pm-chat-area label.chat-tool-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    border-radius: 4px !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--muted) !important;
    padding: 0 !important;
    font-size: 1.05rem;
}

.dc-composer .chat-tool-btn:hover,
.dc-composer label.chat-tool-btn:hover,
.pm-chat-area .chat-tool-btn:hover,
.pm-chat-area label.chat-tool-btn:hover {
    background: color-mix(in srgb, var(--ink) 8%, transparent) !important;
    color: var(--ink) !important;
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
}

.dc-composer .chat-composer-main,
.pm-chat-area .chat-composer-main,
.forum-comment-composer .chat-composer-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.dc-composer .chat-composer-main input,
.dc-composer .chat-composer-main textarea,
.pm-chat-area .chat-composer-main input,
.pm-chat-area .chat-composer-main textarea,
.forum-comment-composer .chat-composer-main input {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    width: 100%;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    line-height: 44px !important;
    padding: 0 8px !important;
    margin: 0 !important;
    font-size: 0.95rem !important;
    font-family: var(--font-body) !important;
    color: var(--ink);
    resize: none;
    white-space: nowrap;
    overflow-x: hidden;
}

.dc-composer .chat-composer-main textarea,
.pm-chat-area .chat-composer-main textarea {
    white-space: pre-wrap;
    line-height: 1.35 !important;
    height: auto !important;
    min-height: 44px !important;
    max-height: 120px !important;
    padding: 12px 8px !important;
}

.dc-composer .chat-send-btn,
.pm-chat-area .chat-send-btn,
.forum-comment-composer .chat-send-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    border-radius: 4px !important;
    border: none !important;
    background: transparent !important;
    color: var(--muted) !important;
    box-shadow: none !important;
    padding: 0 !important;
    flex-shrink: 0;
}

.dc-composer .chat-send-btn:hover,
.pm-chat-area .chat-send-btn:hover {
    background: color-mix(in srgb, var(--accent) 16%, transparent) !important;
    color: var(--accent-deep) !important;
    transform: none !important;
    box-shadow: none !important;
}

.dc-main .chat-login-hint {
    margin: 0 16px 16px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--panel-2);
    flex-shrink: 0;
}

.messages-page.dc-shell {
    height: 100%;
    max-height: none;
    min-height: 0;
}

.messages-page.dc-shell .messages-page-header.dc-channel-header {
    flex-shrink: 0;
}

.messages-page.dc-shell .messages-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 0;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 0;
    overflow: hidden;
}

.messages-page.dc-shell .messages-sidebar {
    display: flex;
    flex-direction: column;
    padding: 12px 10px;
    background: var(--panel-2);
    border-right: 1px solid var(--border);
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.messages-page.dc-shell .dialogs-list {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    border: none;
    background: transparent;
    border-radius: 0;
}

.messages-page.dc-shell .dialog-item {
    border: none;
    border-radius: 6px;
    margin-bottom: 2px;
}

.messages-page.dc-shell .dialog-item.active {
    background: color-mix(in srgb, var(--accent) 14%, var(--panel));
    box-shadow: none;
}

.messages-page.dc-shell .pm-chat-area {
    border: none;
    border-radius: 0;
    background: var(--panel);
    min-height: 0;
    min-width: 0;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.messages-page.dc-shell .conversation-header {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: normal;
    text-transform: none;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    min-height: 52px;
}

.messages-page.dc-shell #messagesSection .pm-input-area .chat-send-btn,
.messages-page.dc-shell .pm-input-area .chat-send-btn {
    background: transparent !important;
    border: none !important;
    color: var(--muted) !important;
    box-shadow: none !important;
}

.pm-status { display: none; }
.dc-header .dc-status { display: inline-flex; }

.dc-avatar-wrap .profile-list-avatar,
.dc-avatar-wrap .user-panel-avatar {
    width: 32px;
    height: 32px;
    display: block;
    border-radius: 50%;
    object-fit: cover;
}

.profile-page-hero .dc-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    width: 110px;
    height: 110px;
    display: block;
    line-height: 0;
}

.profile-page-hero .dc-avatar-mask {
    display: block;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--border-strong);
    box-sizing: border-box;
    line-height: 0;
}

.profile-page-hero .dc-avatar-wrap .profile-avatar,
.profile-page-hero .dc-avatar-wrap .profile-page-avatar {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.profile-page-hero .dc-presence {
    width: 22px;
    height: 22px;
    border-width: 4px;
    border-color: var(--panel);
    bottom: 2px;
    right: 2px;
}

.comment {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

@media (max-width: 900px) {
    .dc-shell,
    .messages-page.dc-shell {
        height: calc(100dvh - 112px);
        max-height: none;
        min-height: 360px;
    }

    body.section-chat .layout,
    body.section-messages .layout {
        align-items: flex-start;
    }

    body.section-chat .dc-shell,
    body.section-messages .messages-page.dc-shell {
        height: calc(100dvh - 112px) !important;
        min-height: 360px !important;
    }

    .dc-layout.chat-with-users-layout {
        grid-template-columns: 1fr !important;
        grid-template-rows: minmax(0, 1fr);
        height: 0;
        position: relative;
    }

    .chat-members-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        position: absolute;
        top: 10px;
        right: 12px;
        min-height: 40px;
        padding: 8px 12px;
        border-radius: var(--radius-sm);
        border: 2px solid var(--border);
        background: var(--panel);
        color: var(--ink);
        font-family: var(--font-body);
        font-size: 0.85rem;
        font-weight: 700;
        box-shadow: none;
        cursor: pointer;
        z-index: 2;
    }
    .chat-members-toggle:hover {
        background: var(--panel-2);
        transform: none;
    }
    .chat-members-toggle[aria-expanded="true"] {
        background: var(--accent);
        border-color: var(--accent-deep);
        color: #fff;
    }

    .dc-channel-header {
        padding-right: 120px;
    }

    .chat-members-backdrop {
        display: block;
        position: absolute;
        inset: 0;
        background: rgba(10, 15, 30, 0.45);
        z-index: 20;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    .dc-layout.members-open .chat-members-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .dc-members.chat-users-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, 88vw);
        z-index: 25;
        order: 0;
        max-height: none;
        height: 100%;
        border-right: 1px solid var(--border);
        border-bottom: none;
        padding: 12px 10px;
        background: var(--panel-2);
        box-shadow: 8px 0 28px rgba(0, 0, 0, 0.22);
        transform: translateX(-105%);
        transition: transform 0.28s ease;
        overflow: hidden;
    }
    .dc-layout.members-open .dc-members.chat-users-sidebar {
        transform: translateX(0);
    }

    .chat-members-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        min-width: 40px;
        padding: 0;
        border-radius: var(--radius-sm);
        border: 2px solid var(--border);
        background: var(--panel);
        color: var(--ink);
        box-shadow: none;
        cursor: pointer;
        font-size: 1rem;
    }
    .chat-members-close:hover {
        background: var(--panel-3);
        transform: none;
    }

    .dc-members .chat-users-list {
        max-height: none;
    }

    .dc-main.chat-main-area {
        border-right: none;
        min-height: 0 !important;
        grid-column: 1;
        grid-row: 1;
    }

    .messages-page.dc-shell .messages-layout {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr);
        height: 0;
    }
    .messages-page.dc-shell .messages-layout:not(.chat-open) .pm-chat-area {
        display: none !important;
    }
    .messages-page.dc-shell .messages-layout:not(.chat-open) .messages-sidebar {
        display: flex;
        max-height: none;
        height: 100%;
        min-height: 0;
    }
    .messages-page.dc-shell .messages-layout.chat-open {
        grid-template-rows: minmax(0, 1fr);
    }
}

@media (max-width: 768px) {
    .dc-messages .dc-msg,
    .dc-messages .dc-msg.global-chat-message,
    .dc-messages .dc-msg.pm-message {
        grid-template-columns: 44px minmax(0, 1fr) !important;
        padding-left: 4px !important;
        padding-right: 10px !important;
    }

    .dc-avatar-col {
        width: 32px;
        margin-left: 4px;
    }

    .dc-avatar,
    .dc-msg .chat-avatar,
    .dc-msg .pm-msg-avatar,
    .dc-avatar-wrap .dc-avatar,
    .dc-avatar-wrap .chat-avatar,
    .dc-avatar-wrap .pm-msg-avatar {
        width: 32px !important;
        height: 32px !important;
    }

    .dc-msg .dc-presence {
        width: 11px;
        height: 11px;
        border-width: 2px;
    }

    .messages-layout.chat-open .messages-sidebar { display: none; }
    .messages-layout.chat-open .pm-chat-area {
        display: flex !important;
        min-height: 0;
        height: 100%;
    }

    .dc-members-title,
    .dc-member-group-title {
        font-family: var(--font-body) !important;
        font-size: 0.78rem !important;
        font-weight: 700;
        letter-spacing: 0.02em;
        padding: 6px 8px 4px;
    }

    .dc-members .chat-user-row,
    .chat-user-row {
        padding: 10px 8px;
        gap: 10px;
        align-items: center;
    }

    .dc-members .chat-user-avatar,
    .chat-user-avatar,
    .dc-members .dc-avatar-wrap .chat-user-avatar {
        width: 40px !important;
        height: 40px !important;
    }

    .chat-user-name,
    .chat-user-name-link,
    .dialog-name,
    .dialog-name-link,
    .pm-user-name,
    .pm-user-name-link {
        font-family: var(--font-body) !important;
        font-size: 1rem !important;
        font-weight: 700 !important;
        line-height: 1.3;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        color: var(--ink) !important;
    }

    .chat-user-sub,
    .pm-user-sub,
    .dialog-preview {
        font-family: var(--font-body) !important;
        font-size: 0.85rem !important;
        line-height: 1.35;
        color: var(--muted);
    }

    .chat-user-main,
    .pm-user-item {
        font-family: var(--font-body) !important;
        font-size: 1rem !important;
        gap: 10px;
        min-height: 44px;
    }

    .pm-user-item {
        padding: 12px 10px;
    }

    .pm-user-avatar,
    .dialog-avatar,
    .dc-avatar-wrap .dialog-avatar,
    .dc-avatar-wrap .pm-user-avatar {
        width: 42px !important;
        height: 42px !important;
    }

    .dialog-item {
        padding: 12px 10px;
        gap: 12px;
        min-height: 56px;
    }

    .dialog-preview {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .chat-msg-btn {
        width: 40px;
        height: 40px;
        font-family: var(--font-body) !important;
        font-size: 0.95rem;
    }

    .dc-members .chat-user-row[data-presence="offline"] .chat-user-name,
    .dc-members .chat-user-row[data-presence="offline"] .chat-user-sub,
    .dc-members .chat-user-row[data-presence="offline"] .chat-user-avatar {
        opacity: 0.78;
    }

    .pm-user-results-inline {
        max-height: min(40vh, 280px);
    }

    .messages-page.dc-shell .dialogs-list,
    .dialogs-list {
        max-height: none !important;
        flex: 1 1 auto;
        min-height: 0;
    }

    .chat-users-list {
        max-height: none !important;
    }

    .pm-back-btn {
        display: inline-flex !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dc-msg,
    .dc-members .chat-user-row {
        transition: none;
    }
}
