@font-face {
    font-family: DC;
    src: url('../Fonts/Dana-Regular.ttf');
}

:root {
    /* iOS Glass Variables */
    --glass-bg: rgba(25, 25, 28, 0.65);
    /* Telegram iOS dark panel */
    --glass-border: rgba(255, 255, 255, 0.06);
    /* Ultra-thin Apple-style border */
    --glass-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);

    /* Text Variables */
    --text-primary: #f5f5f7;
    /* Apple UI White */
    --text-muted: rgba(235, 235, 245, 0.55);

    /* Gold Theme Variables */
    --accent-color: #D4AF37;
    /* Premium Gold */
    --accent-rgb: 212, 175, 55;

    /* Telegram iOS Bubble Colors */
    --sent-bg: linear-gradient(135deg, #D4AF37, #B58D22);
    /* Gold gradient for sent */
    --received-bg: rgba(40, 40, 43, 0.85);
    /* Dark frosted received bubble */

    font-family: DC;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: DC;
}

.hidden {
    display: none !important;
}

/* --- PREMIUM GLASSMORPHISM INPUTS --- */
.glass-input {
    width: 100%;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    padding: 12px 16px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
}

.glass-input:focus,
#messageInput:focus {
    background: rgba(0, 0, 0, 0.4);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
    /* Soft gold glowing ring */
}

.glass-btn {
    background: rgba(212, 175, 55, 0.15);
    /* Translucent gold */
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 175, 55, 0.3);
    /* Distinct gold border */
    color: var(--accent-color);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}


.glass-btn:hover {
    background: rgba(255, 77, 77, 0.6);
    /* Dark icon for contrast */
    transform: scale(1.05);
}

.glass-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 59, 130, 246), 0.2);
    /* Soft glowing ring */
}

/* Username Feedback Colors */
.text-success {
    color: #10b981;
}

.text-danger {
    color: #ef4444;
}

body {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Deep carbon black with subtle gold ambient glows */
    background: radial-gradient(circle at top left, rgba(212, 175, 55, 0.15) 0%, transparent 40%),
        radial-gradient(circle at bottom right, rgba(212, 175, 55, 0.08) 0%, transparent 40%),
        #0a0a0c;
    color: var(--text-primary);
    overflow: hidden;
}

/* Optional: Make the glowing orbs breathe slowly */
@keyframes goldBreathe {
    0% {
        background-position: 0% 0%;
    }

    50% {
        background-position: 100% 100%;
    }

    100% {
        background-position: 0% 0%;
    }
}

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.glass {
    background: var(--glass-bg);
    /* The secret to iOS glass: Heavy blur + increased saturation! */
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
}


.border-bottom {
    border-bottom: 1px solid var(--glass-border);
}

.border-top {
    border-top: 1px solid var(--glass-border);
}

.app-container {
    display: flex;
    gap: 20px;
    width: 95%;
    max-width: 1300px;
    height: 85dvh;
    position: relative;
    overflow: hidden;
}

.app-title-container {
    display: flex;
    align-items: center;
}

.app-title-container .app-title {
    width: 130px;
    height: auto;
    user-select: none;
    pointer-events: none;
}

.app-title-container .hidden {
    display: none;
}

.chat-dock {
    width: 300px;
    display: flex;
    flex-direction: column;
    padding: 20px 15px;
    position: relative;
    overflow: hidden;
}

.chat-dock #contactList {
    overflow-y: auto;
    height: 100%;
    padding-bottom: 70px;
}

.chat-dock #contactList::-webkit-scrollbar {
    width: 5px;
}

/* 2. Hide the track completely so the thumb looks like it's floating */
.chat-dock #contactList::-webkit-scrollbar-track {
    background: transparent;
}

/* 3. The actual draggable thumb (Sleek Glass Pill) */
.chat-dock #contactList::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

/* 4. Brighten up slightly when hovered or clicked for UX */
.chat-dock #contactList::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}


#infoMembersList::-webkit-scrollbar {
    width: 5px;
}

/* 2. Hide the track completely so the thumb looks like it's floating */
#infoMembersList::-webkit-scrollbar-track {
    background: transparent;
}

/* 3. The actual draggable thumb (Sleek Glass Pill) */
#infoMembersList::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

/* 4. Brighten up slightly when hovered or clicked for UX */
#infoMembersList::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.dock-header {
    padding-bottom: 20px;
    margin-bottom: 15px;
    text-align: left;
    font-weight: 700;
}

.chat-nodes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.node {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: background 0.3s ease;
    height: 75px;
}

.node .preview {
    display: flex;
    align-items: center;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    /* Ensures the text is allowed to wrap to the second line */

    /* Clean spacing so the bottoms of letters don't get cut off */
    line-height: 1.4;
    margin-top: 4px;
}

/* LTR Fix: Border shifted to the left */
.node:hover,
.node.active {
    background: rgba(255, 255, 255, 0.15);
    border-left: 3px solid var(--accent-color);
}

.avatar,
.profile-avatar,
.msg-avatar,
.profile-avatar-large {
    /* Replaces the teal/blue with a high-end dark/gold gradient */
    background: linear-gradient(135deg, #2a2a2d, #1a1a1c);
    border: 1px solid rgba(212, 175, 55, 0.3);
    /* Subtle gold ring */
    color: var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    border-radius: 50%;
    width: 45px;
    height: 45px;
}

.node:hover,
.node.active {
    background: rgba(255, 255, 255, 0.08);
    /* Softer highlight */
    border-left: 3px solid var(--accent-color);
    /* Gold active indicator */
}

.avatar-container {
    position: relative;
    display: inline-flex;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background-color: #6b7280;
    /* Default offline gray */
    border: 2px solid rgba(20, 40, 60, 0.8);
    /* Creates a nice cutout effect against the avatar */
    transition: background-color 0.3s ease;
    z-index: 2;
}

.status-dot.online {
    background-color: #10b981;
    /* Bright vibrant green */
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.5);
    /* Slight glow */
}

.status-dot.hidden {
    display: none;
    /* Used to hide the dot completely for Group Chats */
}

.node-info {
    display: flex;
    flex-direction: column;
}

.name {
    font-size: 1rem;
    font-weight: 500;
}

.preview {
    font-size: 0.8rem;
    /* color: var(--text-muted); */
    margin-top: 3px;
    unicode-bidi: plaintext;
    text-align: start;
    display: flex;
    align-items: center;
    word-break: break-word;
}

.chat-arena {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: width 0.3s ease;
}

.arena-header {
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.3s ease;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
}

.arena-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 5;
}

.header-text {
    display: flex;
    flex-direction: column;
}

.header-text h3 {
    font-size: 1.1rem;
}

.status {
    font-size: 0.8rem;
    color: var(--accent-color);
}

.info-icon {
    color: var(--text-muted);
}

.messages-container {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.msg-wrapper {
    display: flex !important;
    align-items: flex-start;
    /* Received messages stay left */
    overflow: visible !important;
    /* Let the swipe happen without clipping */
    flex-direction: column;
    width: 100%;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.msg-wrapper.sent {
    align-items: flex-end;
    /* Sent messages stay right */
}

/* Ensure the bubble itself doesn't shrink weirdly */
.msg-content {
    max-width: 80%;
    min-width: 60px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* LTR Standard alignment */
.msg-wrapper.sent {
    align-self: flex-end;
}

.msg-wrapper.received {
    align-self: flex-start;
}

.msg-wrapper.system {
    align-self: center;
    max-width: 80%;
}

.msg-bubble {
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    /* white-space: pre-wrap; */
    /* iOS blurring on the bubbles themselves */
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    min-width: 100px;
    max-width: 68%;
    cursor: grab;
}

.msg-bubble:active {
    cursor: grabbing;
}

.msg-content-text {
    white-space: pre-wrap;
    /* Put it here! Now ONLY the user's message gets spaces preserved! */
    word-break: break-word;
    /* Good to have so long links don't break the bubble */
}

.sent .msg-bubble {
    background: var(--sent-bg);
    color: #111;
    /* Dark text on gold looks ultra-premium and highly readable */
    border: none;
    /* Remove glass border for the solid gold bubble */
    border-bottom-right-radius: 4px;
    /* box-shadow: 0 4px 10px rgba(212, 175, 55, 0.2); */
}


.sent .check-icon {
    stroke: #111;
    /* Dark ticks on gold background */
}

.received .msg-bubble {
    background: var(--received-bg);
    border-bottom-left-radius: 4px;
}

/* LTR Fix: Bubble corners */
.sent .msg-bubble {
    background: var(--sent-bg);
    border-bottom-right-radius: 4px;
}

.received .msg-bubble {
    background: var(--received-bg);
    border-bottom-left-radius: 4px;
}

.system .msg-bubble {
    background: rgba(0, 0, 0, 0.25);
    font-size: 0.8rem;
    color: var(--text-muted);
    border-radius: 12px;
    padding: 8px 16px;
    text-align: center;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    align-self: flex-end;
    margin-top: 4px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
}
.msg-views {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: rgba(255, 255, 255, 0.7);
    /* white, slightly muted */
    font-size: 0.7rem;
    margin: 0px 6px 2px 0px;
}

.msg-views svg {
    flex-shrink: 0;
    stroke: currentColor;
    margin-bottom: 2px;
}

.views-count {
    line-height: 1;
}

.check-container {
    display: flex;
    align-items: center;
}

.check-icon {
    width: 14px;
    height: 14px;
}

.sent .check-icon {
    stroke: var(--accent-color);
}

.input-area {
    padding: 20px 30px;
    display: flex;
    gap: 15px;
    align-items: center;
}


.glass-btn {
    background: rgba(0, 166, 147, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}


/* LTR Fix: Panel slides from the right side */
.profile-panel {
    width: 320px;
    position: absolute;
    right: -350px;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

.profile-panel.open {
    right: 0;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-content {
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.profile-avatar-large {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #00a693, #26619c);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.glass-light {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: 100%;
    margin-top: 20px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
}

.accent-icon {
    color: var(--accent-color);
}

.info-text {
    display: flex;
    flex-direction: column;
}

.info-text .label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.info-text .value {
    font-size: 0.9rem;
    margin-top: 2px;
}


/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 450px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(0);
    transition: transform 0.3s ease;
    position: relative;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}


.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-content #infoCloseBtn {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: transparent;
    outline: 0px;
    border: 0px;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.3);
}

.modal-content #infoCloseBtn span {
    background-color: white;
    width: 40%;
    height: 2px;
    content: "";
    border-radius: 10px;
}

.modal-content #infoCloseBtn span:first-child {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
}

.modal-content #infoCloseBtn span:nth-child(2) {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
}


.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.modal-tabs {
    display: flex;
    gap: 15px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    padding-bottom: 5px;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-color);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.modal-body.hidden {
    display: none;
}

.modal-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 15px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: background 0.3s ease;
}

.modal-input:focus {
    background: rgba(0, 0, 0, 0.4);
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
}

/* Scrollbar for search results */
.search-results-list::-webkit-scrollbar {
    width: 4px;
}

.search-results-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.user-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-result-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-result-item .avatar {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.user-tag {
    background: rgba(0, 166, 147, 0.4);
    border: 1px solid var(--glass-border);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.user-tag button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
}

.full-width {
    width: 100%;
    border-radius: 12px;
}


/* Context Menu Buttons */
.ctx-btn {
    background: transparent;
    border: none;
    color: white;
    text-align: left;
    padding: 10px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.ctx-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Selected Message State */
.msg-wrapper {
    transition: transform 0.2s ease, opacity 0.2s ease;
    /* Makes them feel clickable during select mode */
}

.msg-wrapper.selected {
    position: relative;
    transform: scale(0.98);
    opacity: 0.8;
}

.msg-wrapper.selected::before {
    content: 'âœ“';
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-color);
    color: #000;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
}

.msg-wrapper.received.selected::before {
    left: auto;
    right: -25px;
}


.msg-content-text {
    /* This tells the browser to isolate the text direction independently of the parent */
    unicode-bidi: plaintext;
    /* Aligns left for English, right for Persian automatically */
    text-align: start;
    display: inline-block;
    word-break: break-word;
    width: 100%;
}

/* Unread Message Badge */
.unread-badge {
    background: #ef4444;
    /* Vibrant Red */
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 6px;
    box-shadow: 0 2px 5px rgba(239, 68, 68, 0.4);
    margin-left: auto;
    /* Pushes it to the far right of the flex container */
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Ensure the node info stretches so the badge gets pushed right */
.node-info {
    flex: 1;
    overflow: hidden;
    /* Prevents long text from breaking layout */
}


/* Group Chat Message Avatars & Names */
.msg-wrapper.received.group-msg {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: flex-end;
    /* Aligns avatar to the bottom of the bubble */
    max-width: 100%;
    /* Give it a bit more room since we added an avatar */
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00a693, #26619c);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    font-weight: bold;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.msg-sender-name {
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: bold;
    margin-bottom: 4px;
    margin-left: 2px;
    display: flex;
    align-items: center;
}

/* --- MESSAGE CLUSTERING STYLES --- */

/* Reduce gap between consecutive messages */
.msg-wrapper.is-consecutive {
    margin-top: -12px;
    /* Pulls the new message up tight against the old one */
}

/* Hide the avatar on previous messages, but keep the empty space so bubbles align */
.msg-avatar.hidden-avatar {
    visibility: hidden;
}

/* Telegram-style connected bubble corners for Sent messages */
.msg-wrapper.sent.is-consecutive .msg-bubble {
    border-top-right-radius: 4px;
}

.msg-wrapper.sent:not(.is-last-in-group) .msg-bubble {
    border-bottom-right-radius: 4px;
}

/* Telegram-style connected bubble corners for Received messages */
.msg-wrapper.received.is-consecutive .msg-bubble {
    border-top-left-radius: 4px;
}

.msg-wrapper.received:not(.is-last-in-group) .msg-bubble {
    border-bottom-left-radius: 4px;
}

/* --- SWIPE & REPLY STYLES --- */

/* The wrapper needs to handle transform smoothly on release */
.msg-wrapper {
    transition: opacity 0.2s ease;
    /* Removed transform here to prevent lag while dragging */
    will-change: transform;
}

.msg-wrapper.spring-back {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* The quoted reply block inside the bubble */
.msg-reply-block {
    background: rgba(0, 0, 0, 0.15);
    border-left: 3px solid var(--accent-color);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
}

.msg-wrapper.sent .msg-reply-block {
    border-left-color: #fff;
    /* White line for your own sent bubbles */
    background: rgba(255, 255, 255, 0.15);
}

.reply-sender-name {
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 2px;
    font-size: 0.75rem;
}

.msg-wrapper.sent .reply-sender-name {
    color: #fff;
}

.reply-content-preview {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.msg-wrapper.sent .reply-content-preview {
    color: rgba(255, 255, 255, 0.8);
}

/* --- BULLETPROOF SWIPE & HIGHLIGHT --- */
.msg-wrapper {
    touch-action: pan-y;
    /* Tells browser: "Allow vertical scroll, let JS handle horizontal swipe" */
    will-change: transform;
}

/* The Flash Animation when jumping to a message */
@keyframes highlightFlash {
    0% {
        background-color: rgba(59, 130, 246, 0.6);
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    }

    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

.highlight-active .msg-bubble {
    animation: highlightFlash 2s ease-out;
}

/* --- REPLY BLOCK COLORS --- */
.msg-reply-block {
    background: rgba(0, 0, 0, 0.15);
    border-left: 3px solid var(--accent-color);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
}

/* If the reply is to YOUR message (Blue) */
.msg-reply-block.reply-to-me {
    border-left-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.msg-reply-block.reply-to-me .reply-sender-name {
    color: #3b82f6;
}

/* If the reply is to THEIR message (Green) */
.msg-reply-block.reply-to-other {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.msg-reply-block.reply-to-other .reply-sender-name {
    color: #10b981;
}

/* Invert for your own sent bubbles so it stays visible on the accent background */
.msg-wrapper.sent .msg-reply-block {
    border-left-color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
}

.msg-wrapper.sent .msg-reply-block .reply-sender-name {
    color: #ffffff;
}



/* --- USER PROFILE BAR (DISCORD STYLE) --- */
.user-profile-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    /* Stretch across the whole aside */
    box-sizing: border-box;
    /* Ensures the 100% width doesn't spill over due to padding */
    z-index: 50;
    /* Keeps it layered above the scrolling contacts */

    display: flex;
    align-items: center;
    padding: 12px 15px;
    gap: 12px;

    /* Optional: Add a glass blur so contacts look cool scrolling under it */
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--glass-border);

    border-radius: 24px 24px 0px 0px;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.profile-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    /* Takes up remaining space */
    overflow: hidden;
    /* Prevents long names from breaking layout */
}

.profile-name {
    font-size: 0.9rem;
    font-weight: bold;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
}

.profile-id {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Settings Button Hover */
.settings-modal-glass {
    background: rgba(20, 25, 35, 0.65);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.settings-sidebar {
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-tab-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted, #a0a0b0);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.settings-tab-btn.active {
    background: rgba(var(--accent-color-rgb, 59, 130, 246), 0.2);
    color: var(--accent-color, #60a5fa);
}

.settings-tab-content {
    display: none;
    animation: fadeIn 0.3s ease forwards;
}

.settings-tab-content.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.device-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background 0.2s;
}

.device-card:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* 📜 Sleek Telegram Scrollbar */
.settings-tab-content::-webkit-scrollbar {
    width: 6px;
}

.settings-tab-content::-webkit-scrollbar-track {
    background: transparent;
    /* Invisible track */
    margin: 10px 0;
    /* Keeps it away from the absolute edges */
}

.settings-tab-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.settings-tab-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Make sure uploaded images fit perfectly in the circle */
.profile-avatar img,
.msg-avatar img,
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Prevents stretching */
    border-radius: 50%;
}

/* Avatar Hover State */
#avatarHoverOverlay:hover {
    opacity: 1 !important;
}


.msg-wrapper.channel-broadcast.sent {
    justify-content: flex-start !important;
    /* Fixes flex-row layouts */
    align-self: flex-start !important;
    /* Fixes flex-column layouts */
    flex-direction: row !important;
    /* Resets row-reverse if used */
    margin-left: 0 !important;
    /* Kills auto-margins pushing it right */
    margin-right: auto !important;
    /* Forces margin push to the left */
}

/* 2. Change the bubble color to standard gray and flip the tail */
.msg-wrapper.channel-broadcast.sent .msg-bubble {
    /* Change this to match your exact 'received' message color */
    background: rgba(255, 255, 255, 0.1) !important;
    color: var(--text-color) !important;

    /* Flip the bubble tail from the right side to the left side */
    border-bottom-right-radius: 12px !important;
    border-bottom-left-radius: 2px !important;

    border-top-right-radius: 16px !important;
    /* Adjust 16px to whatever your normal bubble roundness is */
    border-bottom-right-radius: 16px !important;
}

/* 3. Hide the read-receipt checkmarks for broadcasts */
.msg-wrapper.channel-broadcast.sent .check-container {
    display: none !important;
}


/* 3. If it's a consecutive message (there is a message ABOVE it), flatten the top-left */
.msg-wrapper.channel-broadcast.sent.is-consecutive .msg-bubble {
    border-top-left-radius: 2px !important;
}

/* 4. If it's NOT the last message (there is a message BELOW it), flatten the bottom-left */
.msg-wrapper.channel-broadcast.sent:not(.is-last-in-group) .msg-bubble {
    border-bottom-left-radius: 2px !important;
}


.node-info .name,
.header-user-info h3,
#infoTitle {
    display: inline-flex !important;
    align-items: center !important;
    /* Centering vertically */
    white-space: nowrap;
}

.verified-badge {
    flex-shrink: 0;
    display: block;
    /* Prevents inline-block baseline shifts */
    margin-bottom: 1px;
    /* Optical adjustment to line up with text cap-height */
}


.version {
    position: fixed;
    left: 5px;
    bottom: 5px;
    font-size: 13px;
}

.context-menu {
    position: absolute;
    z-index: 1000;
    padding: 5px;
    min-width: 150px;

    background: var(--glass-bg);
    /* The secret to iOS glass: Heavy blur + increased saturation! */
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
}

/* The Bubble that holds everything */
.telegram-input-wrapper {
    display: flex;
    align-items: flex-end;
    /* This forces the buttons to stay at the bottom! */
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.08);
    /* Dark mode input background */
    border-radius: 24px;
    padding: 6px 10px;
    gap: 8px;
    transition: background 0.3s ease;
}

#voiceVisualizer {
    width: calc(100% + 40px);
    /* extend beyond padding */
    height: calc(100% + 40px);
    top: -100px;
    left: -20px;
    border-radius: inherit;
    /* match the container’s corners */
}

/* The actual typing area */
#messageInput {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    flex-grow: 1;
    border: none;
    color: var(--text-color, #ffffff);
    font-size: 1rem;
    line-height: 1.4;
    padding: 8px 0;
    resize: none;
    /* Disables the manual drag handle */
    min-height: 38px;
    /* Height of exactly one line */
    max-height: 150px;
    /* Stops expanding after ~6 lines */
    overflow-y: auto;
    /* Adds scrollbar only if it hits max-height */
    font-family: inherit;
    /* Hides the ugly default scrollbar */
    scrollbar-width: none;
}

#messageInput::-webkit-scrollbar {
    display: none;
}

/* The Buttons */
.telegram-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted, #aaa);
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
    margin-bottom: 0px;
    /* Keeps them perfectly aligned with the bottom text line */
}

.telegram-icon-btn svg {
    width: 20px;
    height: 20px;
}

.telegram-icon-btn:hover {
    color: var(--accent-color, #3b82f6);
    background: rgba(255, 255, 255, 0.1);
}

.telegram-icon-btn.send-btn {
    color: var(--accent-color, #3b82f6);
    /* Telegram makes the send button colored */
}

/* Ensure the main arena can hold absolute elements safely */
.chat-arena {
    position: relative;
    overflow: hidden;
}

/* 1. The Header Glass */
.arena-header {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    /* Use your app's background color here, but with ~0.65 opacity */
    background: rgba(15, 15, 20, 0.65) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    /* Safari support */
}

/* 2. The Footer Glass */
.chat-bottom-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: rgba(15, 15, 20, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* Strip backgrounds from the inner divs so the main glass effect shows through! */
#messageInputArea,
#channelSubscriberBanner {
    background: transparent !important;
}

#messageInputArea {
    position: relative;
    overflow: visible;
}

/* 3. The Full-Height Messages Container */
.messages-container {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1;
    /* Stays BEHIND the header and footer */

    /* We use padding so the first/last messages don't get permanently stuck under the glass */
    padding-top: 80px;
    /* Make this match your header's height */

    /* The bottom padding uses a CSS variable so JS can dynamically update it when the textarea grows! */
    padding-bottom: var(--chat-bottom-padding, 80px);
}

.hidden-desktop {
    display: none;
}


.coffebede {
    width: 80%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    margin: 5px 0px 15px 0px;
}

.coffebede img {
    width: 100%;
    height: auto;
    user-select: none;
    pointer-events: none;
}


/* The Floating Button */
#scroll-bottom-btn {
    position: absolute;
    /* Or 'fixed' depending on your layout */
    bottom: 80px;
    /* Adjust this so it sits right above your text input! */
    right: 20px;
    width: 45px;
    height: 45px;
    background-color: var(--glass-bg, #2b2d31);
    /* Use your app's theme colors */
    color: var(--text-color, #ffffff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, opacity 0.2s ease;
    z-index: 100;
    transition: 0.2s ease;
}

/* Hide/Show Animations */
.scroll-btn-hidden {
    opacity: 0;
    transform: scale(0) translateY(20px);
    pointer-events: none;
}

.scroll-btn-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* The Red Counter Badge */
#unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #ff3b30;
    /* Telegram Red */
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-sizing: border-box;
}

.badge-hidden {
    display: none !important;
}



/* ðŸ’€ Skeleton Loading Animation */
.skeleton-wrapper {
    display: flex;
    margin-bottom: 15px;
    width: 100%;
    padding: 0 15px;
}

.skeleton-wrapper.sent {
    justify-content: flex-end;
}

.skeleton-wrapper.received {
    justify-content: flex-start;
}

.skeleton-bubble {
    border-radius: 18px;
    /* Uses your dark mode colors, adjust if needed! */
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite linear;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}


/* --------------------------------------------------------- */
/* 🍞 THE GLOBAL TOAST CONTAINER                             */
/* --------------------------------------------------------- */
/* 🍞 THE TOAST CONTAINER */
#toast-container {
    position: fixed;
    /*right: 20px;*/
    bottom: 20px;
    /* Default desktop position */
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* 🚨 HIGHER THAN EVERYTHING ELSE */
    z-index: 2147483647;
    pointer-events: none;
    /* Allows clicks to pass through empty space */
}

/* 📱 MOBILE TOP ALIGNMENT */
@media (max-width: 768px) {
    #toast-container {
        top: 20px;
        bottom: auto;
        left: 20px;
        right: 20px;
        align-items: center;
    }

    /* Adjust entry animation for top-down feel */
    .toast-snack {
        animation: toastInTop 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    }
}

.toast-snack {
    pointer-events: all;
    background: rgba(30, 35, 45, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    min-width: 250px;
}

@keyframes toastInTop {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Smooth exit animation */
.toast-snack.removing {
    animation: toastLeave 0.4s cubic-bezier(0.5, 0, 0.25, 1) forwards;
}

/* --------------------------------------------------------- */
/* 🎨 THE COLOR THEMES                                       */
/* --------------------------------------------------------- */
/* Success: Glowing Teal/Green */
.toast-success {
    border-left: 4px solid #2ecc71;
}

.toast-success .toast-icon {
    color: #2ecc71;
    text-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

/* Error: Glowing Crimson */
.toast-error {
    border-left: 4px solid #e74c3c;
}

.toast-error .toast-icon {
    color: #e74c3c;
    text-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

/* Warning: Glowing Gold/Orange */
.toast-warning {
    border-left: 4px solid #f39c12;
}

.toast-warning .toast-icon {
    color: #f39c12;
    text-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    /* 🚨 This prevents the text from squishing the icon! */
    flex-shrink: 0;

    /* Optional: Lock in the size so it's always a perfect square */
    width: 24px;
    height: 24px;
}

/* Ensure the SVG itself behaves perfectly inside the wrapper */
.toast-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Normal bottom spacing for login page, settings, etc. */
.toast-container {
    bottom: 30px;
}

/* 🚨 Push the container up ONLY if it contains a chat-page toast! */
.toast-container:has([data-page="chat"]) {
    bottom: 90px;
    /* Adjust this to clear your input box! */
}


/* --------------------------------------------------------- */
/* 💬 iOS GLASS TOOLTIPS                                     */
/* --------------------------------------------------------- */
.hint-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    /* Changes mouse to a question mark on desktop */
    /* Prevents mobile tap highlights */
    -webkit-tap-highlight-color: transparent;
}

/* The invisible starting state for the pop-up */
.hint-wrapper::before,
.hint-wrapper::after {
    position: absolute;
    left: 50%;
    /* Start slightly pushed down and shrunken */
    transform: translateX(-50%) translateY(8px) scale(0.9);
    opacity: 0;
    pointer-events: none;
    /* Let clicks pass through it */
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    /* iOS Spring! */
}

/* 🧼 THE GLASS BUBBLE */
.hint-wrapper::after {
    content: attr(data-hint);
    /* Magically reads the text from your HTML! */
    bottom: calc(100% + 8px);
    /* Hover above the badge */

    background: rgba(25, 25, 28, 0.85);
    /* Deep dark glass */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.08);

    color: #f5f5f7;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* 🔻 THE TINY TRIANGLE POINTER */
.hint-wrapper::before {
    content: '';
    bottom: calc(100% + 2px);
    border-width: 5px;
    border-style: solid;
    /* Match the glass background color */
    border-color: rgba(25, 25, 28, 0.85) transparent transparent transparent;
}

/* 🎬 THE TRIGGER: Hover (Desktop) or Active (Mobile Tap) */
.hint-wrapper:hover::before,
.hint-wrapper:hover::after,
.hint-wrapper.show-hint::before,
.hint-wrapper.show-hint::after {
    opacity: 1;
    /* Snap into final position */
    transform: translateX(-50%) translateY(0) scale(1);
}


/* The dark overlay sitting on top of the blurred image */
.download-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    transition: opacity 0.2s;
    z-index: 10;
}

/* The dark circular background behind the icon */
.download-button-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    backdrop-filter: blur(5px);
    cursor: pointer;
}

/* The SVG Ring Canvas */
.circular-progress-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    /* Start the line at 12 o'clock! */
}

/* The invisible background track */
.progress-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 2.5;
}

/* The white loading ring! */
.progress-fill {
    fill: none;
    stroke: white;
    stroke-width: 2.5;
    stroke-linecap: round;
    /* 125.6 is the circumference of a circle with r=20 (2 * pi * 20) */
    stroke-dasharray: 125.6;
    stroke-dashoffset: 125.6;
    /* Starts empty */
    transition: stroke-dashoffset 0.1s linear;
}

/* The actual download arrow */
.download-icon {
    position: relative;
    z-index: 2;
    /* Keep it above the rings */
}

/* The black background that covers the whole app */
.media-viewer {
    position: fixed;
    inset: 0;
    /* Stretches to all 4 corners */
    z-index: 99999;
    /* Stay above EVERYTHING */
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.2s ease-in-out;
}

/* When the 'hidden' class is applied, it fades out and becomes unclickable */
.media-viewer.hidden {
    opacity: 0;
    pointer-events: none;
}

/* The gradient bar at the top so the close button is always visible */
.viewer-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    z-index: 100000;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
}

.viewer-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.8);
}

/* Centers the media perfectly in the middle of the screen */
.viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Forces the media to fit the screen without stretching! */
.viewer-content img,
.viewer-content video {
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* -------------------------------------------
   TELEGRAM PHOTO GRID SYSTEM
------------------------------------------- */
.msg-attachments-grid {
    display: grid;
    gap: 2px;
    /* That iconic ultra-thin Telegram gap */
    border-radius: 12px;
    overflow: hidden;
    /* Clips the outer edges perfectly rounded */
    background: transparent;
}

/* 1 Item: Let it size itself naturally */
.msg-attachments-grid.layout-1 {
    display: block;
}

/* 2 Items: Face to Face (Side by Side) */
.msg-attachments-grid.layout-2 {
    grid-template-columns: 1fr 1fr;
    height: 160px;
    /* Forces a nice wide rectangle */
}

/* 3 Items: Left side full, Right side stacked! */
.msg-attachments-grid.layout-3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 220px;
}

/* The Magic: Make the 1st image span top to bottom! */
.msg-attachments-grid.layout-3 .media-container:nth-child(1) {
    grid-row: span 2;
}

/* 4 Items: Perfect 2x2 Square */
.msg-attachments-grid.layout-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 300px;
}

/* 5+ Items: 3-column grid (Instagram style) */
.msg-attachments-grid.layout-plus {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 100px;
}

/* 🚨 CRITICAL OVERRIDE: 
   If there is more than 1 item, ignore inline styles and force them into the grid cells! */
.msg-attachments-grid:not(.layout-1) .media-container {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: auto !important;
    border-radius: 0px !important;
    /* Let the parent handle the curves */
    max-width: none !important;
}

/* ========== SYSTEM MESSAGES ========== */

/* Centered container for all non-chat-bubble messages */
.system-message {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.system-message__content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-width: 90%;
  text-align: center;
  word-break: break-word;
}

.system-message__icon {
  font-size: 1rem;
  /* You can use an SVG or emoji */
}

/* Subtle gold highlight for "joined" type (optional) */
.system-message__content--accent {
  color: var(--accent-color);
  border-color: rgba(var(--accent-rgb), 0.2);
}

/* ========== DATE DIVIDERS ========== */
.date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
  gap: 8px;
}

/* The line on both sides */
.date-divider::before,
.date-divider::after {
  content: '';
  height: 1px;
  flex: 1;
  background: linear-gradient(
    to var(--direction, right),
    transparent 0%,
    var(--glass-border) 50%,
    transparent 100%
  );
}

.date-divider::before {
  --direction: right;
}

.date-divider::after {
  --direction: left;
}

.date-divider__text {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  white-space: nowrap;
  user-select: none;
}


/* --------------------------------------------------------- */
/* 🎬 THE KEYFRAMES                                          */
/* --------------------------------------------------------- */
@keyframes toastEnter {
    0% {
        opacity: 0;
        transform: translateY(100%) scale(0.9);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastLeave {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(20px) scale(0.85);
    }
}

@media (max-width: 800px) {
    .hidden-desktop {
        display: flex;
        /* Show the back button only on mobile */
    }

    .arena-header {
        border-radius: 0;
        padding: 15px 10px;
    }

    .app-container {
        width: 100%;
        height: 100dvh;
        /* Take up the entire phone screen */
        border-radius: 0;
        border: none;
        margin: 0;
        position: fixed;
        top: 0px;
    }

    .chat-dock {
        width: 100%;
        border-radius: 0;
        /* Premium iOS Parallax effect: We will slide this slightly left when chat opens */
        transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
        padding: 0px;
    }

    .chat-arena {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 20;
        /* Layer it ON TOP of the contact list */

        /* The Magic: Hide it completely off-screen to the right */
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);

        /* Make sure the glass is solid enough so you don't see the contacts through it */
        background: rgba(20, 20, 22, 0.95);
        backdrop-filter: blur(25px) saturate(180%);
        -webkit-backdrop-filter: blur(25px) saturate(180%);
        border-radius: 0;
    }

    /* The JS toggle classes for sliding */
    .chat-arena.open-mobile {
        transform: translateX(0);
        /* Slide the chat IN */
    }

    .chat-dock.shifted {
        transform: translateX(-30%);
        /* Slide the contacts slightly LEFT (Parallax) */
    }

    /* Small mobile tweaks for better typing experience */
    .input-area {
        padding: 12px 15px;
    }

    .msg-wrapper {
        max-width: 100%;
        /* Make bubbles a bit wider on small screens */
    }

    .coffebede {
        width: 300px;
        height: 50px;
    }

    .messages-container {
        padding: 10px;
        padding-top: 80px;
        padding-bottom: var(--chat-bottom-padding, 80px);
    }

    .msg-bubble {
        font-size: 0.85rem;
        max-width: 90%
    }

    .msg-wrapper.received.group-msg .msg-bubble {
        max-width: 80%;
    }

    .chat-dock #contactList {

        padding: 20px 5px 60px 0px;
    }

    .dock-header {
        padding: 20px 15px;
    }
}

@media screen and (max-width: 433px) {
    .coffebede {
        width: 200px;
        height: 30px;
    }
}