/* ==================== DIRECT MESSAGES ==================== */
.message-icon {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.22rem;
    transition: transform var(--transition-normal), color var(--transition-normal), filter var(--transition-normal);
}

.message-icon:hover {
    transform: translateY(-1px) scale(1.08);
    color: #38bdf8;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.6));
}

.message-icon[hidden],
.message-count[hidden],
.dropdown-unread-badge[hidden] {
    display: none;
}

.message-count,
.dropdown-unread-badge {
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.message-count {
    position: absolute;
    top: -2px;
    right: -2px;
    border: 2px solid var(--bg-primary);
    box-shadow: 0 7px 16px -8px rgba(239, 68, 68, 0.95);
}

.dropdown-unread-badge {
    margin-left: auto;
}

#messagesModal .messages-modal-content {
    max-width: min(1480px, calc(100vw - 72px));
    width: min(1480px, calc(100vw - 72px));
    height: min(800px, 88vh);
    overflow: hidden;
    overflow-y: hidden;
    border: 1px solid rgba(125, 92, 255, 0.36);
    border-radius: 26px;
    background:
        linear-gradient(135deg, rgba(14, 18, 38, 0.98), rgba(25, 20, 45, 0.98) 48%, rgba(16, 32, 54, 0.98)),
        var(--bg-card);
    box-shadow:
        0 34px 90px rgba(0, 0, 0, 0.58),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 0 52px rgba(56, 189, 248, 0.10);
}

.messages-shell {
    position: relative;
    display: grid;
    grid-template-columns: minmax(420px, 0.9fr) minmax(760px, 1.4fr);
    height: 100%;
    min-height: 560px;
    isolation: isolate;
}

.messages-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background:
        radial-gradient(circle at 10% 8%, rgba(56, 189, 248, 0.18), transparent 28%),
        radial-gradient(circle at 86% 10%, rgba(168, 85, 247, 0.20), transparent 30%),
        radial-gradient(circle at 68% 88%, rgba(16, 185, 129, 0.10), transparent 28%);
}

.messages-sidebar {
    position: relative;
    border-right: 1px solid rgba(125, 92, 255, 0.25);
    background:
        linear-gradient(180deg, rgba(6, 22, 42, 0.92), rgba(9, 13, 30, 0.96)),
        rgba(15, 23, 42, 0.76);
    padding: 26px 20px 18px;
    display: grid;
    grid-template-rows: auto auto auto 1fr;
    gap: 16px;
    min-width: 0;
    overflow: hidden;
}

.messages-sidebar::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(56, 189, 248, 0.08), transparent 42%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 16px);
    opacity: 0.8;
}

.messages-head {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-right: 36px;
}

.messages-head span {
    display: block;
    color: #38bdf8;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.messages-head h2 {
    margin: 2px 0 0;
    font-family: 'Cinzel', serif;
    font-size: 1.85rem;
    letter-spacing: 0.02em;
    text-shadow: 0 0 22px rgba(56, 189, 248, 0.28);
}

.messages-refresh {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(167, 139, 250, 0.22);
    background: rgba(255,255,255,0.055);
    color: var(--text-secondary);
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.20);
    transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.messages-refresh:hover {
    transform: translateY(-2px);
    color: #fff;
    border-color: rgba(56,189,248,0.55);
    background: rgba(56, 189, 248, 0.12);
}

.messages-block-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(239, 68, 68, 0.30);
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.10);
    color: #fecaca;
    padding: 7px 10px;
    font-size: 0.76rem;
    cursor: pointer;
}

.messages-block-btn.is-blocked {
    border-color: rgba(16, 185, 129, 0.30);
    background: rgba(16, 185, 129, 0.10);
    color: #bbf7d0;
}

.messages-delete-thread-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.10);
    color: #fecaca;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.messages-delete-thread-btn:hover {
    background: rgba(239, 68, 68, 0.28);
    color: #fff;
    transform: scale(1.08);
}

.messages-search {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(56, 189, 248, 0.16);
    border-radius: 14px;
    padding: 11px 12px;
    background: rgba(8, 10, 20, 0.72);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.20) inset;
}

.messages-search i {
    color: var(--text-muted);
}

.messages-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
}

.messages-search-results,
.messages-thread-list {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.messages-thread-list {
    align-content: start;
    overflow-y: auto;
    padding-right: 4px;
    position: relative;
    z-index: 1;
}

.messages-user-result,
.messages-thread {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 38px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.08);
    background:
        linear-gradient(135deg, rgba(255,255,255,0.055), rgba(255,255,255,0.018)),
        rgba(11, 18, 34, 0.64);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
    transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.messages-thread-end {
    display: flex;
    align-items: center;
    gap: 5px;
}

.messages-thread-del {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.messages-thread:hover .messages-thread-del {
    opacity: 1;
}
.messages-thread-del:hover {
    background: rgba(239,68,68,0.2);
    color: #f87171;
}

.messages-user-result:hover,
.messages-thread:hover,
.messages-thread.active {
    border-color: rgba(56,189,248,0.55);
    background:
        linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(124, 58, 237, 0.12)),
        rgba(8, 24, 44, 0.88);
    box-shadow:
        0 18px 36px rgba(0, 0, 0, 0.24),
        0 0 28px rgba(56, 189, 248, 0.10);
}

.messages-thread:hover {
    transform: translateY(-2px);
}

.messages-thread.active {
    transform: translateY(-1px);
}

.messages-thread span,
.messages-user-result span {
    min-width: 0;
}

.messages-thread strong,
.messages-user-result strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

.messages-thread small,
.messages-user-result small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.74rem;
}

.messages-thread b {
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ef4444;
    color: #fff;
    font-size: 0.68rem;
}

.messages-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    font-weight: 800;
    font-size: 0.78rem;
    flex-shrink: 0;
    border: 2px solid rgba(167, 139, 250, 0.45);
    box-shadow:
        0 0 0 4px rgba(124, 58, 237, 0.12),
        0 0 20px rgba(168, 85, 247, 0.22);
}

.messages-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.messages-chat {
    position: relative;
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 82% 12%, rgba(124,58,237,0.20), transparent 34%),
        radial-gradient(circle at 35% 70%, rgba(56,189,248,0.08), transparent 36%),
        linear-gradient(180deg, rgba(26, 23, 45, 0.86), rgba(16, 18, 36, 0.96)),
        var(--bg-card);
    overflow: hidden;
}

.messages-chat::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, transparent 0, #000 12%, #000 88%, transparent 100%);
    opacity: 0.5;
}

.messages-chat-head {
    position: relative;
    z-index: 1;
    min-height: 74px;
    padding: 16px 92px 16px 18px;
    border-bottom: 1px solid rgba(167, 139, 250, 0.18);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(22, 18, 42, 0.62);
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.12);
}

.messages-chat-head strong {
    display: block;
}

.messages-chat-head span {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

.messages-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: 48px;
    flex-shrink: 0;
}

.messages-list {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    overscroll-behavior: contain;
    overflow-y: auto;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-row {
    display: flex;
    justify-content: flex-start;
}

.message-row.own {
    justify-content: flex-end;
}

.message-bubble {
    position: relative;
    max-width: min(72%, 520px);
    padding: 12px 14px;
    border-radius: 18px 18px 18px 6px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background:
        linear-gradient(145deg, rgba(255,255,255,0.09), rgba(255,255,255,0.035)),
        rgba(27, 28, 48, 0.82);
    box-shadow:
        0 16px 34px rgba(0, 0, 0, 0.20),
        0 1px 0 rgba(255,255,255,0.05) inset;
}

.message-bubble::before {
    content: "";
    position: absolute;
    left: -7px;
    bottom: 9px;
    width: 12px;
    height: 12px;
    border-left: 1px solid rgba(255,255,255,0.10);
    border-bottom: 1px solid rgba(255,255,255,0.10);
    background: rgba(34, 35, 58, 0.92);
    transform: rotate(45deg);
}

.message-row.own .message-bubble {
    border-radius: 18px 18px 6px 18px;
    border-color: rgba(56,189,248,0.48);
    background:
        linear-gradient(135deg, rgba(55, 91, 246, 0.92), rgba(8, 148, 180, 0.76)),
        rgba(6,182,212,0.46);
    box-shadow:
        0 18px 36px rgba(37, 99, 235, 0.18),
        0 0 26px rgba(56, 189, 248, 0.10);
}

.message-row.own .message-bubble::before {
    left: auto;
    right: -7px;
    border-left: 0;
    border-bottom: 0;
    border-right: 1px solid rgba(56,189,248,0.48);
    border-top: 1px solid rgba(56,189,248,0.48);
    background: rgba(13, 130, 190, 0.92);
}

.message-bubble p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 5px;
}

.message-bubble time {
    display: block;
    color: rgba(255,255,255,0.54);
    font-size: 0.64rem;
    text-align: right;
    cursor: default;
}

@keyframes msgSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg-enter {
    animation: msgSlideIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.message-report-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.62);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    opacity: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.message-bubble:hover .message-report-btn,
.message-report-btn:focus-visible {
    opacity: 1;
}

.message-report-btn:hover {
    color: #fde68a;
    border-color: rgba(245, 158, 11, 0.46);
}

.messages-compose {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    padding: 10px 16px 12px;
    border-top: 1px solid rgba(167, 139, 250, 0.16);
    background: rgba(10, 13, 28, 0.78);
    backdrop-filter: blur(16px);
}

.messages-compose[hidden] {
    display: none;
}

/* ── Quick reply chips (hidden by default, slide up on focus) ── */
.messages-quick-replies {
    display: flex;
    gap: 6px;
    overflow: hidden;        /* Hidden in both axes while collapsed — prevents width blowout */
    scrollbar-width: none;
    max-height: 0;
    opacity: 0;
    padding: 0;
    transition: max-height 0.22s ease, opacity 0.18s ease, padding 0.22s ease;
    pointer-events: none;
}

.messages-compose:focus-within .messages-quick-replies {
    max-height: 44px;
    overflow-x: auto;        /* Allow horizontal scroll only when visible */
    overflow-y: hidden;
    opacity: 1;
    padding: 2px 0 6px;
    pointer-events: auto;
}

.messages-quick-replies::-webkit-scrollbar {
    display: none;
}

.msg-quick-reply {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(167, 139, 250, 0.28);
    background: rgba(255, 255, 255, 0.042);
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.msg-quick-reply:hover {
    background: rgba(124, 58, 237, 0.22);
    border-color: rgba(167, 139, 250, 0.6);
    color: #e9d5ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.22);
}

.msg-quick-reply:active {
    transform: translateY(0);
}

/* ── Inline chat search bar ── */
.messages-chat-search-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-bottom: 1px solid rgba(167, 139, 250, 0.18);
    background: rgba(16, 14, 34, 0.82);
    backdrop-filter: blur(12px);
    animation: searchSlideDown 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.messages-chat-search-bar[hidden] {
    display: none;
}

@keyframes searchSlideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.messages-chat-search-bar > i {
    color: rgba(56, 189, 248, 0.7);
    font-size: 0.82rem;
    flex-shrink: 0;
}

.messages-chat-search-bar input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.88rem;
}

.messages-chat-search-bar input::placeholder {
    color: var(--text-muted);
}

.messages-search-count {
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(56, 189, 248, 0.75);
    white-space: nowrap;
    flex-shrink: 0;
}

.messages-search-close {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.messages-search-close:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

/* Message highlighted by search */
.msg-match .message-bubble {
    border-color: rgba(56, 189, 248, 0.55) !important;
    box-shadow:
        0 0 0 2px rgba(56, 189, 248, 0.12),
        0 16px 34px rgba(0, 0, 0, 0.20) !important;
}

.msg-no-match {
    display: none !important;
}

/* Search toggle button in chat head */
.messages-search-toggle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(56, 189, 248, 0.28);
    background: rgba(56, 189, 248, 0.08);
    color: #7dd3fc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}

.messages-search-toggle:hover,
.messages-search-toggle.active {
    background: rgba(56, 189, 248, 0.20);
    border-color: rgba(56, 189, 248, 0.6);
    color: #38bdf8;
    transform: scale(1.06);
}

/* Broom in thread list */
.messages-thread-clear {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.messages-thread:hover .messages-thread-clear {
    opacity: 1;
}

.messages-thread-clear:hover {
    background: rgba(56, 189, 248, 0.18);
    color: #7dd3fc;
}

/* ── Compose row ── */
.messages-compose-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    min-width: 0;
}

.messages-textarea-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.messages-compose textarea {
    width: 100%;
    max-height: 120px;
    min-height: 44px;
    resize: none;
    border: 1px solid rgba(167, 139, 250, 0.22);
    border-radius: 14px;
    background: rgba(8, 10, 18, 0.78);
    color: var(--text-primary);
    padding: 11px 44px 11px 13px;
    outline: none;
    overflow-y: auto;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22) inset;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.messages-compose textarea:focus {
    border-color: rgba(56, 189, 248, 0.52);
    box-shadow:
        0 12px 26px rgba(0, 0, 0, 0.22) inset,
        0 0 0 3px rgba(56, 189, 248, 0.10);
}

/* ── Char counter ── */
.messages-char-counter {
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-size: 0.62rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.58);
    pointer-events: none;
    transition: color 0.2s;
    line-height: 1;
}

.messages-char-counter.warn {
    color: #fbbf24;
}

.messages-char-counter.danger {
    color: #f87171;
}

/* ── Send button ── */
.messages-send-btn {
    width: 46px;
    height: 46px;
    padding: 0 !important;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #2563eb 55%, #06b6d4);
    box-shadow:
        0 14px 30px rgba(37, 99, 235, 0.30),
        0 0 22px rgba(124, 58, 237, 0.18);
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
}

.messages-send-btn:hover {
    transform: scale(1.08);
    box-shadow:
        0 18px 36px rgba(37, 99, 235, 0.42),
        0 0 30px rgba(56, 189, 248, 0.28);
}

.messages-send-btn:active {
    transform: scale(0.94);
}

/* ── Scroll to bottom button ── */
.messages-scroll-bottom {
    position: sticky;
    bottom: 14px;
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(56, 189, 248, 0.45);
    background: rgba(14, 20, 40, 0.92);
    backdrop-filter: blur(14px);
    color: #38bdf8;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.36),
        0 0 20px rgba(56, 189, 248, 0.18);
    transition: box-shadow 0.2s, transform 0.18s;
    z-index: 10;
    margin-top: auto;
}

.messages-scroll-bottom[hidden] {
    display: none;
}

.messages-scroll-bottom:hover {
    box-shadow:
        0 12px 36px rgba(0, 0, 0, 0.42),
        0 0 28px rgba(56, 189, 248, 0.32);
    transform: translateY(-3px);
}

.messages-scroll-bottom i {
    font-size: 0.72rem;
    animation: scrollBounce 1.4s ease-in-out infinite;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

#messagesNewBadge:not(:empty) {
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: #fff;
    font-size: 0.6rem;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.messages-empty,
.messages-empty-small {
    color: var(--text-muted);
    text-align: center;
    padding: 28px 14px;
    line-height: 1.5;
}

.messages-empty-small {
    padding: 12px;
    font-size: 0.8rem;
    border: 1px dashed var(--border-light);
    border-radius: 12px;
}

.messages-restricted {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 4px;
    width: min(100%, 620px);
    align-self: center;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.30);
    background: rgba(239, 68, 68, 0.10);
    color: #fecaca;
    line-height: 1.45;
    font-size: 0.95rem;
}

.messages-restricted i {
    margin-top: 3px;
}

.messages-restricted p {
    margin: 0;
}

.messages-restricted a {
    color: #fff;
    font-weight: 800;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.dm-guidelines-content {
    max-width: 520px;
    overflow: hidden;
}

.dm-guidelines-body {
    padding: 32px;
    text-align: center;
}

.dm-guidelines-icon {
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    box-shadow: 0 18px 40px -24px rgba(6, 182, 212, 0.95);
    font-size: 1.35rem;
}

.dm-guidelines-body h2 {
    margin: 0 0 10px;
    font-family: 'Cinzel', serif;
}

.dm-guidelines-body p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 14px;
}

.dm-guidelines-body ul {
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
    text-align: left;
}

.dm-guidelines-body li {
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 9px 10px;
    background: rgba(255,255,255,0.035);
    color: var(--text-secondary);
}

.profile-message-actions {
    display: inline-flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

@media (max-width: 780px) {
    #messagesModal .messages-modal-content {
        width: min(100vw - 16px, 620px);
        height: calc(100dvh - max(24px, env(safe-area-inset-top)) - max(14px, env(safe-area-inset-bottom)));
        max-height: calc(100dvh - max(24px, env(safe-area-inset-top)) - max(14px, env(safe-area-inset-bottom)));
        border-radius: 24px;
    }

    .messages-shell {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(172px, 30%) minmax(0, 1fr);
        min-height: 0;
        height: 100%;
    }

    .messages-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border-light);
        padding: 14px 14px 10px;
        gap: 10px;
        min-height: 0;
    }

    .messages-thread-list {
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .messages-chat {
        min-height: 0;
    }

    .messages-chat-head {
        min-height: 58px;
        padding-right: 52px;
    }

    .message-bubble {
        max-width: 86%;
    }

    .messages-block-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
        font-size: 0;
    }

    .messages-block-btn i {
        font-size: 0.82rem;
    }

    .messages-delete-thread-btn {
        width: 32px;
        height: 32px;
    }

    .messages-head-actions {
        margin-right: 44px;
    }
}

@media (max-width: 520px) {
    .message-icon {
        width: 40px;
        height: 40px;
    }

    #messagesModal .messages-modal-content {
        width: 100vw;
        height: calc(100dvh - max(8px, env(safe-area-inset-top)));
        max-height: calc(100dvh - max(8px, env(safe-area-inset-top)));
        border-radius: 22px 22px 0 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
    }

    .messages-shell {
        grid-template-rows: minmax(148px, 27%) minmax(0, 1fr);
    }

    .messages-head {
        padding-right: 44px;
    }

    .messages-head h2 {
        font-size: 1.35rem;
    }

    .messages-search {
        min-height: 42px;
    }

    .messages-thread {
        padding: 10px;
    }

    .messages-chat-head {
        min-height: 52px;
        padding: 10px 52px 10px 12px;
    }

    .messages-list {
        padding: 12px;
    }

    .message-bubble {
        max-width: 92%;
        padding: 10px 12px;
    }

    .messages-quick-replies {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .messages-quick-replies::-webkit-scrollbar {
        display: none;
    }

    .msg-quick-reply {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .messages-compose {
        padding: 10px 12px max(12px, env(safe-area-inset-bottom));
    }

    .messages-compose-row textarea {
        font-size: 16px;
        min-height: 42px;
    }
}

@media (max-width: 380px) {
    .messages-shell {
        grid-template-rows: minmax(132px, 24%) minmax(0, 1fr);
    }

    .messages-sidebar {
        padding: 12px 10px 8px;
    }

    .messages-search {
        display: none;
    }
}
