.chat-header {
    position: sticky;
    top: 0;
    height: 40px;
    z-index: 1000;
    background: white;
    padding: 10px 0px;
    font-size: 20px;
    color: #333;
    margin:0;
    display: flex;
    flex-direction: column; /* имя сверху, кнопка снизу */
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #eee;
}

.chat-username {
    text-align: center;
    font-weight: 600;
}

.zagolovok {
    font-size: 18px;
    display: flex;
    align-items: center;      /* по вертикали */
    justify-content: center;  /* по горизонтали */
    gap: 6px;
}

.back-to-product {
    display: inline-block;
    font-size: 14px;
    padding: 4px 10px;
    top: 50px;
    text-decoration: none;
    color: #2b8a3e;
    border: 1px solid #2b8a3e;
    border-radius: 4px;
    background: transparent;
    transition: background-color 0.3s, color 0.3s;
}

.back-to-product:hover {
    background-color: #2b8a3e;
    color: white;
}


.back-to-product {
    position: absolute;
    left: 15px;
    font-size: 14px;
    padding: 4px 10px;
    text-decoration: none;
    color: #2b8a3e;
    border: 1px solid #2b8a3e;
    border-radius: 4px;
    background: transparent;
    transition: background-color 0.3s, color 0.3s;
}

.back-to-product:hover {
    background-color: #2b8a3e;
    color: white;
}

.chat-username {
    /* чтобы имя было по центру */
    flex: 1;
    text-align: center;
}
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 15vw 0 15vw;
  padding-bottom: 70px;
}

#chat-box{
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: visible;
  height: auto;
  padding-bottom: 0;
}

.message-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 10px 15px;
    padding-top: 1px;
    border-radius: 15px;
    margin: 10px 0;
    position: relative;
    clear: both;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.my-message {
    background: #dcf8c6;
    margin-left: auto;
    margin-right: 5px;
    text-align: left;

}

.other-message {
    background: #ebebeb;
    margin-right: auto;
    margin-left: 5px;
    text-align: left;
}

.message-content p {
    margin: 0;
    font-size: 14px;
}

.meta {
    font-size: 14px;
    color: #667;
    margin-top: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-bubble .delete-btn {

    transition: opacity 0.1s ease;
    background: none;
    border: none;
    color: grey;
    font-size: 14px;
    cursor: pointer;
    margin-left: 10px;
}

.message-bubble:hover .delete-btn {
    opacity: 1;
    display: inline-block;
}

#chat-form {
    position: fixed;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: #fff;
    border-top: 1px solid #ddd;
    z-index: 1000;
    bottom: 0;
    margin-right: 0vw;
    margin-left: 0vw;
}
#content {
    flex: 1;
    padding: 10px;
    border-radius: 20px;
    border: 1px solid #ccc;
    padding-left: 40px;
    padding-right: 80px;
    font-size: 14px;
}

.message-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-right: 0;
}

.avatar-img {
    width: 35px;
    height: 35px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid #ccc;
}

.message-meta {
    display: flex;
    flex-direction: column;
    min-width: 100px;
    flex: 1;
}

.sender {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 3px;
    color: black;
    display:block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-text {
    margin: 0;
    font-size: 14px;
    color: black;
}

.time {
    font-size: 12px;
    color: #777;
    text-align: right;
    margin-top: 5px;
    margin-left: 10px;
}
.message-bubble {
    padding: 8px 25px 6px 15px;
}
.avatar-link,
.sender-link {
    text-decoration: none;
    color: inherit;
    min-width: 0;
    flex: 1 1 auto;
}

.avatar-link {
    flex: 0 0 auto;
}
.sender-link:hover {
    text-decoration: underline;
    color: #2b8a3e;
}

.emoji-picker {
    z-index: 999999 !important;
}

.emoji {
    cursor: pointer;
}
.delete-global-btn {
    margin-bottom: 5px;
}
#send-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #007bff;
    user-select: none;
}

#send-btn:active {
    transform: translateY(-50%) scale(0.85);
}

#preview-container {
    position: sticky;
    bottom: 60px;
    width: auto;
    padding: 10px;
    background: white;
    z-index: 10000;
    margin-left: 15vw;
    margin-right: 15vw;
}

.preview-wrapper {
    position: relative;
    display: inline-block;
    margin: 5px;
}

.preview-img,
.preview-video {
    max-width: 150px;
    border-radius: 10px;
}

.preview-remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}


.message-bubble .chat-image {
    max-width: 500px;
    max-height: 500px;
    border-radius: 8px;
    margin-top: 5px;
    display: block;
}

/* Стили для видео */
.message-bubble .chat-video {
    max-width: 500px;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

/* Стили для файлов */
.message-bubble .chat-file {
    display: inline-block;
    padding: 6px 12px;
    margin-top: 5px;
    background-color: #f0f0f0;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
    font-size: 12px;
}

.message-bubble .chat-file:hover {
    background-color: #dcdcdc;
}

.emoji-btn {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    user-select: none;
    font-size: 20px;
}

.attach-btn{
    position: absolute;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    right: 55px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    user-select: none;
    font-size: 18px;
}

.attach-btn:hover{
    background-color: rgba(0,0,0,0.06);
    border-radius: 12px;
}

/* “нажатие” */
.attach-btn:active{
    transform: translateY(-50%) scale(0.95);
    background-color: rgba(0,0,0,0.12);
}

/* чтобы иконка тоже реагировала чуть-чуть */
.attach-btn:hover i{
    filter: brightness(0.7);
}

/* когда фокус с клавиатуры (Tab) */
.attach-btn:focus-within{
    outline: 2px solid rgba(43,138,62,0.35);
    outline-offset: 2px;
}

.sender-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
    gap: 10px;
    margin-bottom: 4px;
}

.time-inline {
    font-size: 12px;
    color: #777;
    white-space: nowrap;  /* чтобы время не переносилось */
}

.message-meta {
    display: flex;
    flex-direction: column;
}

.message-meta .chat-media {
    margin-top: 5px;
    max-width: 500px;
    max-height: 500px;
    border-radius: 8px;
}




.time-inline {
    font-size: 12px;
    color: #777;
    white-space: nowrap;
    flex: 0 0 auto;
}



#messageOptionsModal {
    display: none;
    position: absolute !important;
    z-index: 3000;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    padding: 0px 0;
    min-width: 50px;
    font-family: 'Arial', sans-serif;
    border-radius: 8px;
}

/* Контейнер кнопок */
#messageOptionsModal .modal-content-chat {
    display: flex;
    flex-direction: column;
    border-radius: 8px;
}

/* Кнопки */
#messageOptionsModal .modal-action {
    padding: 10px 20px;
    border: none;
    background: #f5f5f5;
    color: #333;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    border-radius: 8px;
}

/* Hover эффект */
#messageOptionsModal .modal-action:hover {
    background: #007bff;
    color: #fff;
    border-radius: 5px;
}

/* Красная кнопка удалить */
#messageOptionsModal .modal-action#deleteBtn {
    color: #d9534f;
}

#messageOptionsModal .modal-action#deleteBtn:hover {
    background: #d9534f;
    color: #fff;
}

/* Добавим мягкую тень при наведении на весь модал */
#messageOptionsModal.show {
    display: block;
    animation: fadeIn 0.2s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-100px); }
    to { opacity: 1; transform: translateY(0); }
}


.message-bubble .meta {
    position: absolute;
    top: 30px;
    right: 20px;
}


#edit-preview,
#reply-preview {
    margin-bottom: 110px;
    z-index: 3000;
    border-left:3px solid #007bff;
    display:none;
    background:#f1f1f1;
    padding:5px 10px;
    width: 100%;
    border-radius:4px;
    position: absolute;
}
.emoji-picker {
    display:none;
    position: fixed;
    bottom: 50px;
    right: 20px;
    background: white;
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 5px;
    max-width: 200px;
    max-height: 150px;
    overflow-y: auto;
}

.chat-date-separator {
    text-align: center;
    margin: 10px 0;
    font-size: 13px;
    color: #888;
}

.scroll-to-bottom {
    position: fixed;
    right: 20px;
    bottom: 70px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: grey;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
    transition:
        opacity 0.25s ease,
        transform 0.25s cubic-bezier(.34,1.56,.64,1);
    z-index: 1000;
}

/* показать кнопку */
.scroll-to-bottom.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* прыжок при новом сообщении */
.scroll-to-bottom.bounce {
    animation: bounce 0.45s ease;
}

.msg-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: red;
    color: white;
    font-size: 11px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
}

@keyframes bounce {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.15); }
    60%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.content-chat-input:disabled {
    background-color: #f1f1f1;
    cursor: not-allowed;
}

/* медиа в сообщении */
.chat-media-grid {
  position: relative;
  display: grid;
  gap: 6px;
}

/* чтобы оверлей мог позиционироваться */
.chat-media.is-processing {
  filter: blur(1px);
  opacity: 0.75;
}

/* общий контейнер-обёртка для медиа (если будешь оборачивать) */
.media-wrap {
  position: relative;
  display: inline-block;
}

/* оверлей */
.media-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  pointer-events: none;
}

/* спиннер */
.chat-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.35);
  border-top-color: rgba(255,255,255,0.95);
  border-radius: 50%;
  animation: chatspin 0.9s linear infinite;
}
#edit-content,
.reply-content {
    display:block;
    color:#555;
    font-size:14px;
}
@keyframes chatspin { to { transform: rotate(360deg); } }

.media-status {
  position: absolute;
  bottom: 6px;
  left: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.95);
  background: rgba(0,0,0,0.35);
  padding: 3px 6px;
  border-radius: 8px;
  pointer-events: none;
}

.cancel-reply {
    position:absolute;
    right:5px;
    top:5px;
    border:none;
    background:none;
    cursor:pointer;
    font-size: 25px;
}

.chat-topbar{
    position: sticky;
    top: 0;
    z-index: 1200;
    display:flex;
    align-items:center;
    gap:10px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid rgba(0,0,0,.06);
    margin-right: 15vw;
    margin-left: 15vw;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.chat-back-btn, .chat-more-btn{
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    border-radius: 10px;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    font-size: 16px;
}

.chat-back-btn:active, .chat-more-btn:active{
    background: rgba(0,0,0,.06);
}

.chat-title{
    flex:1;
    min-width: 0;
    text-decoration:none;
    color: inherit;
    display:flex;
    flex-direction:column;
    line-height: 1.1;
    align-items: center;
}

.chat-name-1{
    font-weight: 700;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-subtitle{
    font-size: 12px;
    opacity: .65;
    margin-top: 2px;
    white-space: nowrap;
    overflow:hidden;
    text-overflow: ellipsis;
}
@media (min-width: 768px) {
.chat-topbar{ padding-left: 12px; }
}

/* === chat POPOVER (⋯) === */
.chat-popover{
  position: fixed;
  z-index: 2500;
  min-width: 220px;
  background: #fff;
  border-radius: 12px;
  box-shadow:
    0 8px 24px rgba(0,0,0,.18),
    0 1px 3px rgba(0,0,0,.12);
  padding: 6px;
  opacity: 0;
  transform: translate3d(8px, -8px, 0) scale(0.85);
  transform-origin: top right;
  pointer-events: none;

  /* Анимация */
  transition: transform 180ms ease, opacity 180ms ease;
  will-change: transform, opacity;
}

.chat-popover.is-open{
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  pointer-events: auto;
}



.chat-popover__item{
  width: 100%;
  background: none;
  border: 0;
  padding: 10px 12px;
  text-align: left;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.chat-popover__item:hover{
  background: rgba(0,0,0,.05);
}

.chat-popover__item:active{
  background: rgba(0,0,0,.08);
}

.chat-popover__divider{
  height: 1px;
  background: rgba(0,0,0,.08);
  margin: 6px 4px;
}

.chat-popover__danger{
  color: #d32f2f;
}

/* мобильная корректировка */
@media (max-width: 768px){
  .chat-popover{
    min-width: 200px;
  }
}

/* === Selectbar поверх topbar === */
.chat-selectbar{
  position: absolute;
  inset: 0;
  background: #fff;
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 12px;
}

.chat-topbar{
  position: sticky;
  top: 0;
  z-index: 1200;
}

/* кнопки и заголовок */
.chat-selectbar__btn{
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;

}
.chat-selectbar__btn:active{ background: rgba(0,0,0,.06); }

.chat-selectbar__title{
  flex: 1;
  font-weight: 700;
  font-size: 15px;
}

.chat-selectbar__actions{
  display:flex;
  gap: 6px;
}

.chat-selectbar__icon{
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  cursor:pointer;
  font-size: 18px;
  align-items: center;
  justify-content: center; chat-select-check
}
.chat-selectbar__icon:active{ background: rgba(0,0,0,.06); }

.chat-select-bottom{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2200;
  padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.06);
  display:flex;
  justify-content:flex-start;
  gap: 10px;
}

.chat-select-bottom__reply{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}

.chat-select-bottom__reply:active{
  background: rgba(0,0,0,.04);
}

.chat-select-bottom__reply:disabled{
  opacity: .45;
  cursor: default;
}

body.chat-select-mode .message-bubble,
body.chat-select-mode .message-bubble *{
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* Safari/Chrome iOS */
}

/* 2) Пока пользователь держит палец (до срабатывания long-press) — тоже не выделяем */
.message-bubble.chat-pressing,
.message-bubble.chat-pressing *{
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 3) (опционально) именно для ссылок в сообщениях */
.message-bubble a{
  -webkit-touch-callout: none;
}

body.chat-select-mode a.avatar-link,
body.chat-select-mode a.sender-link,
.message-bubble.chat-pressing a.avatar-link,
.message-bubble.chat-pressing a.sender-link{
  pointer-events: none;              /* ссылка не активна */
  -webkit-touch-callout: none;       /* iOS callout */
  -webkit-user-select: none;
  user-select: none;
}

.chat-msg-row{
  width: 100%;
  position: relative;
  display: flex;
  align-items: flex-end;
  box-sizing: border-box;
}

.chat-msg-row::before{
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(42, 136, 255, 0.14);
  border-radius: 10px;
  inset: 3px 0;
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}

/* Когда сообщение выбрано — фон плавно появляется */
.chat-msg-row.is-selected::before{
  opacity: 1;
}

/* Чуть разные оттенки (опционально) */
.chat-msg-row.is-mine.is-selected::before{
  background: rgba(42, 136, 255, 0.18);
}

.chat-msg-row.is-theirs.is-selected::before{
  background: rgba(42, 136, 255, 0.12);
}

/* чтобы контент был поверх фона */
.chat-check-slot,
.chat-bubble-slot{
  position: relative;
  z-index: 1;
}

/* поддержка prefers-reduced-motion */
@media (prefers-reduced-motion: reduce){
  .chat-msg-row::before{
    transition: none;
  }
}

/* слот для чекбокса фиксированной ширины слева */
.chat-check-slot{
  width: 0;
  overflow: hidden;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding-bottom: 18px;
  transition: width 180ms ease;
  will-change: width;
}

/* слот для bubble занимает остаток */
.chat-bubble-slot{
  flex: 1;
  display: flex;
}

body.chat-select-mode .chat-check-slot{
  width: 34px;
}

body.chat-select-mode .message-bubble{
  cursor: pointer;
}

/* кружок слева у сообщения */
.chat-select-check{
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.25);
  opacity: 0;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  background: #fff;
  user-select: none;
  transform: scale(0.7);
  transition: opacity 160ms ease, transform 180ms ease;
  will-change: opacity, transform;
}

.chat-select-check::after{
  content: "✓";
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transform: scale(.9);
}

.message-bubble.is-selected .chat-select-check{
  border-color: #3390ec;
  background: rgba(51,144,236,.12);
}

.message-bubble.is-selected .chat-select-check::after{
  opacity: 1;
}

body.chat-select-mode .chat-select-check{
  opacity: 1;
  transform: scale(1);
}
/* не мешать контенту: выстроим header сообщения в линию */
body.chat-select-mode .message-header{
  display: flex;
  align-items: flex-start;
}

/* чтобы avatar/meta остались как были */
body.chat-select-mode .avatar-link{ margin-right: 0; }


/* выравнивание bubble: свои вправо, чужие влево */
.chat-msg-row.is-mine .chat-bubble-slot{ justify-content: flex-end; }
.chat-msg-row.is-theirs .chat-bubble-slot{ justify-content: flex-start; }


/* выбранный кружок */
.chat-msg-row.is-selected .chat-select-check{
  border-color: #2a88ff;
  background: #2a88ff;
  box-shadow: inset 0 0 0 3px #fff;
}

.chat-container, #chat-box {
  overflow-x: hidden;
}

/* визуально подсвечиваем строку, когда свайп засчитан */
.chat-msg-row.chat-swiping {
  transform: translateX(0);
  opacity: 0.98;
}

.message-bubble.flash { background-color: #FFF3C4; }

html.chat-booting #chat-container {  
  opacity: 0;
}

#chat-container { .chat-container
  transition: opacity .12s ease;
}

.chat-empty-state {
  margin: auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px 120px;
  color: #777;
}

.chat-empty-state__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #9aa0a6;
  margin-bottom: 14px;
}

.chat-empty-state__title {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-bottom: 6px;
}

.chat-empty-state__text {
  font-size: 14px;
  color: #888;
  max-width: 320px;
  line-height: 1.4;
}

.chat-block-banner {
  margin: 12px 15vw 8px 15vw;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff3cd;
  border: 1px solid #ffe08a;
  color: #7a5a00;
  font-size: 14px;
  line-height: 1.4;
}

.attach-btn.is-disabled,
#send-btn:disabled,
#emoji-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

#content:disabled {
  background: #f5f5f5;
  color: #777;
}

#chat-form {
    position: fixed;
    left: 15vw;
    right: 15vw;
    bottom: 0;
    display: flex;
    align-items: center;
    padding: 15px;
    background: #fff;
    border-top: 1px solid #ddd;
    z-index: 1000;
    box-sizing: border-box;
    width: auto;
}

.chat-unread-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0;
  padding: 0 10px;
}

.chat-unread-separator::before,
.chat-unread-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(0, 123, 255, 0.18);
}

.chat-unread-separator span {
  font-size: 13px;
  font-weight: 600;
  color: #2b7cff;
  background: rgba(43, 124, 255, 0.08);
  border: 1px solid rgba(43, 124, 255, 0.16);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .chat-block-banner {
    margin: 8px 10px;
  }
}



@media (max-width: 768px) {
    .chat-header {
        top: 0px;
        font-size: 18px;
    }

    .message-bubble{
        max-width: 90%;
    }
    .message-bubble .meta {
        right: 10px;
    }

    .chat-container {
        margin-right: 0vw;
        margin-left: 0vw;
        height: calc(100vh - 110px);
    }

    .message-bubble:hover .delete-btn {
        opacity: 1;

    }


    .scroll-to-bottom {
        position: fixed;
        right: 20px;
        bottom: 130px;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: grey;
        color: white;
        border: none;
        font-size: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transform: translateY(20px) scale(0.9);
        pointer-events: none;
        transition:
            opacity 0.25s ease,
            transform 0.25s cubic-bezier(.34,1.56,.64,1);
        z-index: 1000;
    }


    #chat-form {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 15px;
        background: #fff;
        border-top: 1px solid #ddd;
        position: fixed;
        bottom: 50px;
        margin: 0;
        left: 0;
        right: 0;
    }
    .message-bubble .chat-image {
        max-width: 250px;
        max-height: 200px;
    }

    /* Стили для видео */
    .message-bubble .chat-video {
        max-width: 300px;
        max-height: 300px;
    }

    .message-bubble .chat-video {
        max-width: 360px;
    }

    #preview-container {
        bottom: 110px;
        width: 100%;
        margin-left: 0vw;
        margin-right: 0vw;
    }
    .emoji-picker {
        bottom: 100px;
    }
    .chat-name-1{ font-size: 16px; }
    .chat-topbar{
        margin-right: 0vw;
        margin-left: 0vw;
        border-bottom-left-radius: 0px;
        border-bottom-right-radius: 0px;
    }
    .chat-select-bottom{
      bottom: 50px;
    }
}

.time-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.read-state {
  font-size: 12px;
  line-height: 1;
  opacity: .7;
  user-select: none;
}

.read-state.is-read {
  opacity: 1;
  color: #4ea2ff;
}

.read-state {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  line-height: 1;
  opacity: .7;
  user-select: none;
}

.read-state.is-read {
  opacity: 1;
  color: rgb(99, 230, 190);
}

.read-state .check-icon {
  display: inline-block;
}

.read-state.is-double .check-icon + .check-icon {
  margin-left: -5px; /* делает галочки ближе */
}

.time-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.read-state {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  user-select: none;
  opacity: .8;
}

.read-state .check-icon {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
}

.read-state .check-icon--second {
  margin-left: -4px;
}

.read-state.state-pending .check-icon {
  display: none;
}

.read-state.state-pending::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 1.6px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: chatTickSpin .8s linear infinite;
}

.read-state.state-sent .check-icon--second {
  display: none;
}

.read-state.state-delivered {
  opacity: .9;
  color: #7f8c8d;
}

.read-state.state-read {
  opacity: 1;
  color: rgb(99, 230, 190);
}

@keyframes chatTickSpin {
  to { transform: rotate(360deg); }
}

.chat-subtitle {
    font-size: 12px;
    opacity: .75;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-subtitle.is-online {
    color: #16a34a;
    opacity: 1;
}

.chat-subtitle.is-offline {
    color: #6b7280;
    opacity: .9;
}