.day-span {
    text-align: center;
    margin: 10px 0;
    color: gray;
    font-size: 14px;
    font-weight: bold;
    opacity: 0.7;
}

/* ОСНОВНОЙ КОНТЕЙНЕР ЧАТА */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    width: 100%;
    position: relative;
}

.chat-header {
    border: none;
    background: var(--bg-panel);
    display: flex;
    align-items: center;
    padding-left: 12px;
    transition: background-color 0.2s ease;
    min-height: 50px;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-header-chat {
    display: flex;
    align-items: center;
    margin-right: auto;
    width: 200px;
    height: 80%;
    border-radius: 10px;
    transition: background-color 0.2s ease, transform 0.1s ease, scale 0.1s ease;
    transform: scale(1);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    margin: 4px;
    z-index: 0;
}

.message {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: min-content;
    margin-bottom: 4px;
    padding: 8px;
    border-radius: 4px;
    position: relative;
}

.message:hover {
    background-color: rgba(79, 84, 92, 0.16);
}

.message-background {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
    border-radius: 8px;
    top: 0;
    right: 0;
    opacity: 0;
    transition: opacity 0.75s ease-out;
}

.message-background.highlighted {
    background-color: var(--highlight-color) !important;
    opacity: 0.4;
}

/* ЗАГРУЗКА СООБЩЕНИЯ */

.message-loading {
    align-items: center;
    margin-left: 8px;
    vertical-align: middle;
    display: none;
}

.message-loading.active {
    display: inline-flex
}

.loading-dots {
    display: flex;
    gap: 3px;
}

.loading-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dot-pulse 1.4s ease-in-out infinite both;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.16s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes dot-pulse {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ЗАГРУЗКА СООБЩЕНИЯ */

.message-header-info {
    grid-area: header-info;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 20px;
    margin-bottom: 2px;
}

.avatar {
    width: 35px;
    height: 35px;
    grid-area: avatar;
    border-radius: 50%;
    font-weight: 600;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.username {
    font-weight: 500;
    margin-right: 8px;
    align-items: flex-start;
    margin-top: -5px;
    font-size: 14px;
}

.timestamp {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: -5px;
}

.message-content {
    font-size: 16px;
    grid-area: content;
    line-height: 1.375;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    margin-top: -5px;
}

.message-header {
    display: grid;
    grid-template-columns: 40px 1fr;
    grid-template-areas:
        "avatar header-info"
        "avatar content";
    gap: 0 4px;
    align-items: normal;
}

.message-form {
    flex-shrink: 0;
    padding: 12px 16px;
    position: relative;
}

.input-container {
    display: flex;
    align-items: center;
    background-color: var(--background-tertiary);
    border-radius: 8px;
    padding: 0 16px;
    min-height: 44px;
}

.input-container.startBorderByZero {
    border-start-end-radius: 0;
    border-start-start-radius: 0;
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-normal);
    padding: 12px 0;
    font-size: 16px;
    outline: none;
    resize: none;
    max-height: 200px;
    height: 44px;
    overflow-y: auto;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--background-accent);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.chat-header .back-btn {
    margin-right: 8px;
    display: none;
}

.input-action-button {
    background-color: transparent;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.input-action-button img {
    filter: brightness(0.8);
}

.input-actions {
    display: flex;
    align-content: baseline;
    gap: 10px;
}

.chat-actions {
    display: flex;
    align-items: center;
    margin-right: 24px;
    gap: 4px;
}

.chat-action {
    background: none;
    border: none;
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    color: #b5bac1;
    transition: all 0.2s ease;
    display: inline;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-action.select {
    background: rgba(78, 80, 88, 0.6);
    color: #dbdee1;
}

.chat-action:hover {
    background-color: rgba(78, 80, 88, 0.6);
    color: #dbdee1;
    transform: translateY(-1px);
}

.chat-action img {
    filter: brightness(0.8);
    transition: filter 0.2s ease;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.chat-action:hover img {
    filter: brightness(1);
}

/* === ОТВЕТ ВНУТРИ СООБЩЕНИЯ (без SVG, как в Discord) === */
.answer-preview {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
    padding-left: 50px;
    position: relative;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

/* Линия: вверх → вправо */
.answer-preview::before {
    content: "";
    position: absolute;
    border-left: 2px solid var(--accent);
    border-top: 2px solid var(--accent);
    height: 12px;
    width: 24px;
    border-top-left-radius: 6px;
    border-color: var(--accent);
    opacity: 0.6;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 0;
    left: 17px;
    bottom: 2px;
}

.answer-preview:hover::before {
    opacity: 0.9;
}

/* Аватар пользователя, на который ответ */
.answer-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 0 0 1px #2b2d31;
    background-color: #2b2d31;
}

.answer-avatar .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Текст ответа */
.answer-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    font-size: 14px;
    line-height: 1.3;
    overflow: hidden;
    gap: 8px;
    /* расстояние между именем и текстом */
}

.answer-username {
    font-weight: 600;
    font-size: 12px;
}

.answer-content {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    flex: 1;
}

.answer-preview:hover .answer-content,
.answer-preview:hover .answer-username {
    color: var(--text-normal);
}


/* ---- PANEL DISPLAY ACTIONS ---- */

/* Панель ответа на сообщение */
.reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--background-secondary);
    border-left: 4px solid var(--accent);
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 8px;
}

.reply-bar:hover {
    cursor: pointer;
}

.reply-info {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-grow: 1;
}

.reply-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.reply-username {
    font-size: 12px;
    color: var(--accent-color);
    font-weight: 600;
}

.reply-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    opacity: 0.7;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.reply-close-btn:hover {
    background: var(--background-modifier-hover);
    opacity: 1;
}

/* Панель редактирования сообщения */
.edit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--background-secondary);
    border-left: 4px solid var(--accent);
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 8px;
}

.edit-bar:hover {
    cursor: pointer;
}

.edit-info {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-grow: 1;
}

.edit-label {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

.edit-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.edit-close-btn:hover {
    background: var(--background-modifier-hover);
    opacity: 1;
}

.reply-bar,
.edit-bar {
    animation: slideFromBottom 0.2s ease-out;
}

.reply-bar.hide,
.edit-bar.hide {
    animation: slideToBottom 0.2s ease-out forwards;
}

.call-start-message {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    margin: 4px 0;
    font-size: 14px;
    color: #fff;
    border-radius: 4px;
    white-space: nowrap;
}

.call-start-username-message {
    font-weight: 500;
    font-size: 14px;
    margin-left: 16px;
}

.call-start-text-message {
    font-size: 14px;
    word-break: break-word;
    overflow-wrap: break-word;
    color: var(--text-muted);
    font-weight: 500;
}

.call-start-time-message {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
    margin-left: 5px;
    line-height: 1.375rem;
    font-weight: 500;
}

.call-start-message:hover {
    background-color: rgba(79, 84, 92, 0.16);
}

.call-start-message .time {
    color: #999;
    font-size: 12px;
}



/* Анимация: появление снизу вверх */
@keyframes slideFromBottom {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Анимация: исчезновение вниз */
@keyframes slideToBottom {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(10px);
    }
}



/* ---- PANEL DISPLAY ACTIONS ---- */

/* ---- PROFILE SIDEBAR ---- */
.profile-sidebar {
    width: 350px;
    height: 100vh;
    background: #2b2d31;
    border-left: 1px solid #1e1f22;
    display: none;
    /* по умолчанию скрыт, показываем через JS */
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 1000;
    transform: translateX(100%);
    opacity: 0;
}

/* Сдвигаем чат при открытом профиле через класс на body */
body.profile-open .chat-container {
    margin-right: 350px;
    width: calc(100% - 350px);
}

/* Показываем при active — display управляется из JS, но оставим правило для ясности */
.profile-sidebar.active {
    /* display: block; <- ставим из JS, чтобы transition отработал */
    transform: translateX(0);
    opacity: 1;
}

.profile-header {
    padding: 16px;
    border-bottom: 1px solid #1e1f22;
    display: flex;
    justify-content: flex-end;
    background: #2b2d31;
}

.close-profile-btn {
    position: absolute;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    color: #b5bac1;
    width: 50px;
    height: 50px;
}

.profile-content {
    flex: 1;
    overflow-y: auto;
    background: #2b2d31;
}

.profile-banner {
    overflow: hidden;
    min-height: 120px;
}

.banner-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-section {
    padding: 0 20px;
    margin-top: -50px;
}

.profile-avatar-container {
    width: 100px;
    height: 100px;
    outline: 10px solid #2b2d31;
    outline-offset: -1px;
    overflow: hidden;
    background: #1e1f22;
    border-radius: 50%;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    padding: 20px;
}

.profile-username {
    margin: 0 0 16px 0;
    font-size: 20px;
    font-weight: 600;
    color: #f2f3f5;
}

.about-section {
    margin-top: 24px;
}

.about-title {
    display: none;
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 700;
    color: #b5bac1;
    text-transform: uppercase;
}

.about-title.active {
    display: block;
}

.about-text {
    margin: 0;
    line-height: 1.5;
    color: #dbdee1;
    white-space: pre-wrap;
    font-size: 14px;
}

.back-btn {
    background: none;
    border: none;
    border-radius: 4px;
    padding: 4px;
    margin-right: 8px;
    cursor: pointer;
    color: #b5bac1;
    transition: all 0.2s ease;
    display: none;
}

.attached-btn {
    background-color: transparent;
    border: none;
    margin-right: 8px;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.attached-btn img {
    filter: brightness(0.8);
}

.attachments-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 16px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #4f545c transparent;
    -webkit-overflow-scrolling: touch;
    display: none;
    background: var(--background-tertiary);
    border-radius: 8px;
    border-end-end-radius: 0px;
    border-end-start-radius: 0px;
}

.file-container {
    position: relative;
    background: var(--background-secondary);
    border-radius: 8px;
    overflow: hidden;
    width: 200px;
    max-width: 200px;
    flex-shrink: 0;
    transition: all 0.2s ease;
    border: 1px solid var(--background-tertiary);
}

.file-container:hover {
    border-color: var(--background-modifier-hover);
}


/* Медиа контейнер (изображение/превью) */
.media-container {
    position: relative;
    cursor: pointer;
}

.media-preview {
    width: 100%;
    min-width: 200px;
    min-height: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 4px 4px 0 0;
}


.filename-container {
    padding: 8px;
    background: var(--background-secondary);
    border-top: 1px solid var(--background-tertiary);
}

.filename {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-normal);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-bar-container {
    position: absolute;
    top: 4px;
    right: 4px;
}

.action-bar {
    display: flex;
    gap: 4px;
    background-color: var(--background-floating);
    border-radius: 4px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.file-container:hover .action-bar-container {
    pointer-events: all;
}

.action-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--text-normal);
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button:hover {
    background: var(--background-modifier-hover);
    color: var(--text-normal);
}

.action-button.dangerous:hover {
    background: var(--status-danger);
    color: white;
}


.action-icon {
    width: 16px;
    height: 16px;
}

.grid-image .cover-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

.grid-image .cover-video:hover .play-button {
    opacity: 0.8;
    transform: scale(1.1);
}

.grid-image .play-button {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    opacity: 0.7;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.play-button .icon-video-controls,
.play-pause-btn .icon-video-controls {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

.fullscreen-btn .icon-video-controls {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
}

.volume-btn .icon-video-controls {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
}

.grid-image .video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 8px 12px;
    display: none;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    gap: 8px;
    z-index: 4;
}

.video-controls.pause {
    display: flex;
}

.video-controls.drag {
    display: flex;
}

.grid-image:hover .video-controls.active {
    display: flex;
}

.grid-image .controls-left {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-family: var(--font-code);
    font-size: 12px;
}

.grid-image .play-pause-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    border-radius: 5px;
    padding: 3px;
    transition: transform 0.2s ease;
    transform: scale(1);
}

.grid-image .play-pause-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

.grid-image .progress-bar {
    flex: 1;
    margin: 0 20px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.grid-image .progress-line {
    position: absolute;
    height: 100%;
    background: #5865f2;
    border-radius: 2px;
    width: 0%;
    will-change: width;
    transition: width 0.1s linear;
}

.grid-image .progress-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    will-change: left, transform;
    transition: left 0.1s linear;
}

.grid-image .progress-handle:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

.grid-image .controls-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

.grid-image .volume-mixer {
    display: flex;
    align-items: center;
    position: relative;
}

.grid-image .volume-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s ease;
    border-radius: 5px;
    transform: scale(1);
}

.grid-image .volume-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

.grid-image .volume-slider {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 80px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
    margin-bottom: 10px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.grid-image .volume-slider.drag {
    opacity: 1;
    visibility: visible;
}

.grid-image .volume-mixer:hover .volume-slider {
    opacity: 1;
    visibility: visible;
}

.grid-image .volume-level {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    border-radius: 2px;
    height: 70%;
    /* примерное значение громкости */
    transition: height 0.1s ease;
}

.grid-image .fullscreen-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s ease;
    border-radius: 5px;
    transform: scale(1);
}

.grid-image .fullscreen-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

/* ИНДИКАТОР УСТАНОВКИ ФАЙЛА */

.file-progress-ring {
    position: absolute;
    top: 50%;
    left: 32px;
    transform: translate(-50%, -50%) rotate(-90deg);
    width: 36px;
    height: 32px;
    pointer-events: none;
}

.file-progress-ring circle {
    fill: none;
    stroke-width: 3;
    r: 14;
    cx: 16;
    cy: 16;
}

.file-progress-ring .bg {
    stroke: rgba(0, 0, 0, 0.1);
}

.file-progress-ring .progress {
    stroke: var(--accent, #0096ff);
    stroke-dasharray: 88;
    stroke-dashoffset: 88;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear;
}

/* ИНДИКАТОР УСТАНОВКИ ФАЙЛА */

/* СЕТКА */

/* Специальные стили для сеток с видео */
.images-grid.video .grid-image {
    aspect-ratio: 1;
    /* Сохраняем квадратную форму для сетки */
}

/* Для одиночного видео можно сохранить оригинальные пропорции */
.images-grid.single.video .grid-image {
    aspect-ratio: auto;
}

.images-grid.single.video .grid-image video {
    max-height: 400px;
    object-fit: contain;
}

/* Улучшаем отображение при наведении на видео в сетке */
.images-grid.video .grid-image:hover .cover-video {
    background: rgba(0, 0, 0, 0.4);
}

/* Полноэкранные стили для контейнера видео */
/* Полноэкранные стили с сохранением aspect ratio */
.grid-image:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    background: black;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 0 !important;
    max-width: none !important;
    max-height: none !important;
}

.grid-image:-moz-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    background: black;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 0 !important;
    max-width: none !important;
    max-height: none !important;
}

.grid-image:-ms-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    background: black;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 0 !important;
    max-width: none !important;
    max-height: none !important;
}

.title-gif-grid-image {
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    margin: 5px;
    min-width: 30px;
    display: flex;
    justify-content: center;
    font-family: var(--font-code);
    font-size: 12px;
}

.grid-image:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    background: black;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 0 !important;
    max-width: none !important;
    max-height: none !important;
}

/* Видео в полноэкранном режиме - адаптируем aspect ratio */
.grid-image:-webkit-full-screen video {
    object-fit: contain !important;
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: var(--video-aspect-ratio, 16/9) !important;
}

.grid-image:-moz-full-screen video {
    object-fit: contain !important;
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: var(--video-aspect-ratio, 16/9) !important;
}

.grid-image:-ms-fullscreen video {
    object-fit: contain !important;
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: var(--video-aspect-ratio, 16/9) !important;
}

.grid-image:fullscreen video {
    object-fit: contain !important;
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: var(--video-aspect-ratio, 16/9) !important;
}

/* Альтернатива для браузеров без поддержки aspect-ratio */
@supports not (aspect-ratio: 1) {
    .grid-image:fullscreen video {
        max-width: 100vw !important;
        max-height: 100vh !important;
        width: auto !important;
        height: auto !important;
    }
}

.images-grid {
    display: grid;
    grid-gap: 4px;
    max-width: 400px;
    border-radius: 8px;
    margin-top: 4px;
    overflow: hidden;
}

/* Контейнер для каждого видео в сетке */
.grid-image.video {
    position: relative;
    background: var(--background-tertiary);
}

/* Видео элемент внутри grid-image */
.grid-image.video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.images-grid img,
.images-grid .grid-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.images-grid.single .grid-image img {
    border-radius: 8px;
}


/* 1 изображение */

.images-grid.single img {
    height: auto;
    max-height: 400px;
}

.images-grid.sticker {
    overflow: visible;
}

.images-grid.sticker img {
    height: auto;
    max-height: 200px;
    max-width: 200px;
}

.grid-image.gif img {
    max-height: 250px;
    max-width: 250px;
}


.images-grid.sticker img:hover {
    transform: scale(1);
}


/* 2 изображения */
.images-grid.double {
    grid-template-columns: 1fr 1fr;
}

.images-grid.double img {
    aspect-ratio: 1;
}

/* 3 изображения - Telegram style */
.images-grid.triple {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* Первое */
.images-grid.triple img:nth-child(1),
.images-grid.triple .video:nth-child(1) {
    grid-column: 1 / 3;
    grid-row: 1;
    aspect-ratio: 16/9;
}

/* Второе */
.images-grid.triple img:nth-child(2),
.images-grid.triple .video:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

/* Третье */
.images-grid.triple img:nth-child(3),
.images-grid.triple .video:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

/* 4 изображения */
.images-grid.quad {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.images-grid.quad img,
.images-grid.quad .video {
    aspect-ratio: 1;
}

/* 5+ изображений - адаптивная сетка */
.images-grid.multiple {
    grid-template-columns: repeat(3, 1fr);
}

.images-grid.multiple img,
.images-grid.multiple .video {
    aspect-ratio: 1;
}

/* Специальные правила для заполнения пустых мест */

/* 5 изображений - последнее занимает 2 колонки */
.images-grid.multiple.count-5 img:nth-child(5),
.images-grid.multiple.count-5 .video:nth-child(5) {
    grid-column: 2 / 4;
}

.images-grid.multiple.count-7 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.images-grid.multiple.count-7 img:nth-child(7),
.images-grid.multiple.count-7 .video:nth-child(7) {
    grid-column: 1 / 4;
    grid-row: 3;
    aspect-ratio: 16/9;
}

/* 8 изображений - нормальная сетка 3-3-2 */
.images-grid.multiple.count-8 img:nth-child(7),
.images-grid.multiple.count-8 .video:nth-child(7) {
    grid-column: 1 / 3;
}

.images-grid.multiple.count-10 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.images-grid.multiple.count-10 img:nth-child(10),
.images-grid.multiple.count-10 .video:nth-child(10) {
    grid-column: 1 / 4;
    grid-row: 3;
    aspect-ratio: 16/9;
}

.images-grid img {
    transition: transform 0.2s ease;
}

.images-grid img:hover {
    transform: scale(1.02);
    z-index: 1;
}

/* СЕТКА */

/* файл */

.files-container {
    max-width: 400px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-link {
    display: flex;
    flex-direction: row;
    /* Элементы в строку */
    align-items: flex-start;
    /* Выравнивание по верхнему краю */
    padding: 8px 12px;
    background-color: var(--background-primary);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-normal);
    font-size: 14px;
    transition: background-color 0.2s ease;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    gap: 12px;
    /* Расстояние между иконкой и текстом */
}

.file-link:hover {
    background-color: var(--background-primary-hover);
}

.file-link img {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.file-link-content {
    display: flex;
    flex-direction: column;
    /* Текст в колонку */
    justify-content: center;
    /* Выравнивание по вертикали */
}

.file-link-text {
    font-weight: 500;
    margin-bottom: 2px;
    /* Отступ между названием и описанием */
}

.file-link-desc {
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.8;
}

.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(1px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drop-overlay.active {
    display: flex;
    opacity: 1;
}

.drop-content {
    background: var(--background-secondary);
    border: 3px dashed var(--brand);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    color: var(--text-normal);
}

.drop-icon {
    margin-bottom: 16px;
}

.drop-icon img {
    width: 150px;
    height: 150px;
}


.drop-text {
    font-size: 18px;
    font-weight: 600;
}

.message-actions {
    position: absolute;
    top: -8px;
    right: 16px;
    background: #2b2d31;
    border-radius: 4px;
    padding: 4px;
    display: none;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.message:hover .message-actions {
    opacity: 1;
    display: flex;
}

.message-action {
    width: 25px;
    height: 25px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #b5bac1;
    transition: all 0.2s ease;
    font-size: 14px;
    padding: 5px;
    transform: scale(1);
}

.message-action:hover {
    transform: scale(1.1);
    background-color: var(--background-secondary);
    color: #dbdee1;
}

.message-action.delete-btn:hover {
    transform: scale(1.1);
    background-color: var(--status-danger);
    color: #dbdee1;
}

/* Участники группы  */

.container-members-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    background: var(--bg-panel);
    min-width: 300px;
}

.members-group-wrap {
    flex: 1 1 100%;
    max-width: 100%;
}

.content-members-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.amount-member-group {
    font-size: 14px;
    color: var(--text-secondary);
    padding-left: 12px;
}

.amount-member-group-text {
    font-weight: 500;
    color: var(--text-muted);
}

.content-info-members {
    display: flex;
    flex-direction: column;
}

.role-members {
    gap: 5px;
    display: flex;
    margin-bottom: 14px;
    font-size: 12px;
    margin-right: 5px;
}

.role-members img {
    filter: brightness(0.5);
}

.item-member-group:hover .role-members img {
    filter: brightness(1);
    /* или любое другое значение */
}


.item-member-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background-color 0.1s ease;
    color: var(--text-muted);
}

.item-member-group span {
    display: inline-block;
    margin-right: auto;
}

.item-member-group:hover {
    background: var(--bg-dark);
    cursor: pointer;
    color: var(--text-primary);
}

.item-member-group img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 50%;
}


/* Участники группы  */




/* МОБИЛЬНАЯ ВЕРСИЯ */
@media (max-width: 768px) {
    .images-grid.sticker img {
        max-height: 150px;
        max-width: 150px;
    }

    .input-actions {
        gap: 2px;
    }

    .input-action-button {
        width: 40px;
        height: 40px;
    }

    * {
        -webkit-tap-highlight-color: transparent;
        /* Убирает серую подсветку на iOS и Android */
        -webkit-touch-callout: none;
        /* Отключает системное меню при долгом тапе */
    }

    .info-header-chat.hover {
        background-color: var(--background-modifier-hover);
        transform: scale(1.01);
    }

    .info-header-chat:active {
        background-color: var(--background-secondary);
        transform: scale(0.99);
    }

    .amount-member-group {
        display: flex;
        justify-content: center;
        padding: 12px;
    }

    .files-container {
        max-width: 300px;
    }

    .play-pause-btn {
        display: none;
    }

    .volume-btn {
        display: none;
    }

    .images-grid {
        gap: 3px;
        max-width: 300px;
    }

    /* СЕТКА */

    .back-btn {
        display: flex;
        width: 35px;
        height: 35px;
    }

    .profile-sidebar {
        width: 100%;
        transform: translateX(100%);
        transition: transform 0.28s ease, opacity 0.28s ease;
    }

    /* На мобильных не сдвигаем контент */
    .chat-container {
        margin-right: 0 !important;
        width: 100% !important;
        transition: width 0.3s ease, margin-right 0.3s ease;
    }

    /* Профиль открыт на мобильном - занимает весь экран */
    .profile-sidebar.active {
        transform: translateX(0);
        opacity: 1;
    }

    /* На мобильных кнопка закрытия слева */
    .profile-header {
        justify-content: flex-start;
    }

    .chat-header .back-btn {
        display: inline-flex;
    }

    .chat-header .avatarConversion {
        margin-left: 6px;
    }

    .chat-container {
        height: 100vh;
    }

    .messages-container {
        padding: 4px;
    }

    .message {
        padding: 6px;
    }

    .avatar {
        margin-right: 8px;
    }

    .message-content {
        font-size: 14px;
    }

    .message-header {
        flex-wrap: wrap;
        gap: 4px;
    }

    .username {
        font-size: 14px;
    }

    .timestamp {
        font-size: 11px;
    }

    .message-form {
        padding: 8px 12px;
        position: sticky;
        bottom: 0;
        border-top: 1px solid var(--background-tertiary);
    }

    .input-container {
        padding: 0 12px;
    }

    .message-input {
        font-size: 14px;
        margin-top: 4px;
    }

    .send-button {
        min-width: 40px;
        min-height: 40px;
    }

    .attached-btn {
        min-width: 40px;
        min-height: 40px;
    }

    .message:hover {
        background-color: transparent;
    }

    .chat-action {
        width: 35px;
        height: 35px;
    }

    .chat-action.select {
        background: none;
        color: #b5bac1;
    }

    .chat-action:hover {
        background-color: transparent;
    }
}

/* ДЕСКТОПНАЯ ВЕРСИЯ */
@media (min-width: 769px) {
    .close-profile-btn {
        display: none;
    }

    /* На десктопе профиль открыт по умолчанию */
    .profile-sidebar {
        transform: translateX(0);
    }

    /* На десктопе chat-container изначально сдвинут */
    .chat-container {
        margin-right: 350px;
        width: calc(100% - 350px);
    }

    /* Когда профиль закрыт на десктопе */
    .profile-sidebar:not(.active) {
        transform: translateX(100%);
    }

    body:not(.profile-open) .chat-container {
        margin-right: 0;
        width: 100%;
    }
}