/* ═══ CHAT (DM с друзьями) ═══════════════════════════════════════════ */

/* Floating action button — внизу справа */
#dm-fab {
  position: fixed;
  bottom: 76px;
  right: 18px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--gold);
  color: #000;
  border: none;
  font-size: 22px;
  cursor: pointer;
  z-index: 9100;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
#dm-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 28px rgba(201,168,76,.4);
}
.dm-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #d33;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
  border: 2px solid var(--bg);
}

/* ── Главный оверлей чата ──────────────────────────────────
   box-shadow ТОЛЬКО на .open. Закрытая панель (right:-100%) с тенью
   -12px 40px рисовала её внутрь viewport — выглядело как тёмная
   вертикальная полоса справа на каждой странице. */
#dm-panel {
  position: fixed;
  top: 0;
  right: -100%;
  width: 720px;
  max-width: 96vw;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 9200;
  transition: right 0.25s ease;
}
#dm-panel.open {
  right: 0;
  box-shadow: -12px 0 40px rgba(0,0,0,.5);
}

/* ── Полностраничный режим /messages (докнутая панель) ── */
.messages-page-root {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  height: calc(100vh - 220px);
  min-height: 480px;
}
#dm-panel.dm-docked {
  position: static;
  right: auto;
  width: 100%;
  max-width: none;
  height: 100%;
  border-left: none;
  transition: none;
  z-index: auto;
}
#dm-panel.dm-docked .dm-head { display: none; }        /* заголовок страницы уже есть */
#dm-panel.dm-docked .dm-threads { width: 320px; }       /* шире список на большом экране */
@media (max-width: 720px){
  .messages-page-root { height: calc(100vh - 180px); border-radius: 10px; }
  #dm-panel.dm-docked .dm-threads { width: 100%; }       /* мобиле: список на всю, тред поверх */
}

.dm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* env(safe-area-inset-top) — отступ под iPhone notch/Dynamic Island.
     Без него аватар и имя налезали на статус-бар. */
  padding: max(16px, calc(env(safe-area-inset-top) + 12px)) 20px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.dm-x {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 14px;
}
.dm-x:hover { border-color: var(--gold); color: var(--gold); }

.dm-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.dm-threads {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--bg);
}
.dm-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  position: relative;   /* якорь для плашки «новые сообщения» */
}

/* Плашка «↓ новые сообщения» — всплывает над формой ввода когда юзер
   читает историю и прилетело новое. */
.dm-new-pill {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translate(-50%, 12px);
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 40;
}
.dm-new-pill.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.dm-thread-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border2);
  transition: background 0.15s;
}
.dm-thread-row:hover { background: var(--bg3); }
.dm-thread-row.on { background: rgba(201,168,76,.08); border-left: 3px solid var(--gold); padding-left: 11px; }

.dm-badge {
  background: var(--gold);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 7px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.dm-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

/* ── Активный диалог ─────────────────────────────────────── */
.dm-thread-head {
  display: flex;
  align-items: center;
  gap: 10px;
  /* env(safe-area-inset-top) — отступ под notch/Dynamic Island.
     Раньше аватар и имя налезали на iOS статус-бар (часы, батарея). */
  padding: max(12px, calc(env(safe-area-inset-top) + 10px)) 14px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  /* sticky чтобы шапка оставалась видимой при скролле длинного диалога */
  position: sticky;
  top: 0;
  z-index: 5;
}
.dm-back {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 24px;
  cursor: pointer;
  padding: 0 6px;
  display: none;
}

.dm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dm-msg {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  margin-top: 10px;          /* отступ между группами */
}
.dm-msg.grp-cont { margin-top: 2px; }   /* сообщения внутри группы — плотнее */
.dm-msg.mine { align-self: flex-end; align-items: flex-end; }
.dm-msg.theirs {
  align-self: flex-start;
  flex-direction: row;        /* аватар слева + колонка сообщения */
  align-items: flex-end;
  gap: 8px;
  max-width: 82%;
}
.dm-msg-col { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }

/* ── Аватар собеседника (theirs) ── */
.dm-msg-av {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  align-self: flex-end;
}
.dm-msg-av-ph {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3);
  color: var(--gold);
  font-weight: 700; font-size: 13px;
}
.dm-msg-av-hidden { background: transparent; }   /* спейсер для сгруппированных */

.dm-msg-bubble {
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.dm-msg.mine .dm-msg-bubble {
  background: var(--gold);
  color: #000;
}
.dm-msg.theirs .dm-msg-bubble {
  background: var(--bg3);
  color: var(--text);
}
/* Хвостик — острый угол только у первого пузыря в группе */
.dm-msg.mine.grp-first .dm-msg-bubble  { border-bottom-right-radius: 5px; }
.dm-msg.theirs.grp-first .dm-msg-bubble { border-bottom-left-radius: 5px; }

.dm-msg-time {
  font-size: 10px;
  color: var(--dim);
  margin-top: 3px;
  padding: 0 4px;
}
/* Время внутри группы показываем только по наведению — чище выглядит */
.dm-msg.grp-cont .dm-msg-time { opacity: 0; height: 0; margin: 0; overflow: hidden; transition: opacity .15s; }
.dm-msg.grp-cont:hover .dm-msg-time { opacity: .7; height: auto; margin-top: 2px; }

/* ── Разделитель по датам (Сегодня / Вчера / 3 июля) ── */
.dm-day-sep {
  align-self: center;
  margin: 14px 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
}
.dm-day-sep span {
  font-size: 11px;
  letter-spacing: .5px;
  color: var(--muted);
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 3px 12px;
  border-radius: 999px;
}

/* ── Форма ввода ─────────────────────────────────────────── */
.dm-form {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.dm-form input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  border-radius: 20px;
  transition: border-color 0.15s;
}
.dm-form input:focus { border-color: var(--gold); }
.dm-send {
  background: var(--gold);
  color: #000;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
/* Иконки Lucide в кнопках формы ввода */
.dm-form button svg { width: 18px; height: 18px; }
.dm-emoji-btn svg, .dm-attach svg, .dm-mic svg { width: 17px; height: 17px; }
.dm-send:hover { background: var(--gold2); }
.dm-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Film card в сообщении ─────────────────────────────── */
.dm-film-card {
  display: flex;
  gap: 10px;
  background: rgba(0,0,0,.3);
  padding: 8px;
  border-radius: 8px;
  margin-top: 6px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.08);
  transition: border-color .15s;
}
.dm-film-card:hover { border-color: var(--gold); }
.dm-msg.mine .dm-film-card { background: rgba(0,0,0,.18); border-color: rgba(0,0,0,.25); }
.dm-msg.mine .dm-film-card:hover { border-color: rgba(0,0,0,.5); }
.dm-film-card-poster {
  width: 50px; height: 75px;
  background: #111;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.dm-film-card-poster img { width:100%; height:100%; object-fit:cover; display:block; }
.dm-film-card-info { flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.dm-film-card-tag { font-size:9px; color:var(--gold); letter-spacing:1.5px; }
.dm-msg.mine .dm-film-card-tag { color:#000; opacity:.7; }
.dm-film-card-title { font-size:13px; font-weight:600; line-height:1.3; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dm-film-card-meta { font-size:11px; color:var(--muted); }
.dm-msg.mine .dm-film-card-meta { color:rgba(0,0,0,.5); }
.dm-film-card-btn {
  margin-top:4px;
  background: var(--gold); color:#000;
  border: none; padding: 4px 10px; font-size:10px;
  cursor: pointer; letter-spacing:1px; align-self:flex-start;
  font-family: inherit; font-weight:600;
}
.dm-msg.mine .dm-film-card-btn { background:#000; color:var(--gold); }

/* ── Реакции ────────────────────────────────────────────── */
.dm-msg-wrap { display:flex; align-items:center; gap:4px; }
.dm-msg.mine .dm-msg-wrap { flex-direction:row-reverse; }
.dm-rx-btn {
  opacity: 0.45;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity .15s, background .15s, color .15s;
  flex-shrink: 0;
}
.dm-msg-wrap:hover .dm-rx-btn { opacity: 1; }
.dm-rx-btn:hover { opacity: 1; background: var(--gold); color: #000; border-color: var(--gold); }
.dm-rx-picker {
  background: var(--bg2);
  border: 1px solid var(--gold);
  padding: 4px;
  display: flex;
  gap: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.dm-rx-picker button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  padding: 4px 6px;
  transition: transform .12s;
}
.dm-rx-picker button:hover { transform: scale(1.3); }
.dm-msg-rx {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
  padding: 0 4px;
}
.dm-msg.mine .dm-msg-rx { justify-content: flex-end; }
.dm-rx-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
}
.dm-rx-chip:hover { background: rgba(201,168,76,.15); border-color: var(--gold); }
.dm-rx-chip.mine { background: rgba(201,168,76,.18); border-color: var(--gold); }

/* ── Reply: чип над инпутом и превью внутри сообщения ──── */
.dm-reply-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--gold);
}
.dm-reply-btn {
  opacity: 0.45;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  transition: opacity .15s, color .15s;
  flex-shrink: 0;
}
.dm-msg-wrap:hover .dm-reply-btn { opacity: 1; }
.dm-reply-btn:hover { opacity: 1; color: var(--gold); border-color: var(--gold); }
.dm-reply-preview {
  background: rgba(201,168,76,.08);
  border-left: 3px solid var(--gold);
  padding: 4px 10px;
  margin-bottom: 4px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  max-width: 75%;
  align-self: flex-start;
}
.dm-msg.mine .dm-reply-preview { align-self: flex-end; }
.dm-reply-preview.faded { color: var(--dim); font-style: italic; }
.dm-reply-author { color: var(--gold); font-weight: 600; margin-right: 4px; }
.dm-reply-text { color: var(--muted); }
.dm-reply-preview:hover { background: rgba(201,168,76,.16); }
.dm-msg-flash { animation: dmFlash 1.2s ease; }
@keyframes dmFlash {
  0%, 100% { background: transparent; }
  30% { background: rgba(201,168,76,.18); }
}

/* ── Typing-индикатор ───────────────────────────────────── */
.dm-typing {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 18px;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
}
.dm-typing-dots { display: inline-flex; gap: 3px; }
.dm-typing-dots i {
  width: 4px; height: 4px;
  background: var(--muted);
  border-radius: 50%;
  display: inline-block;
  animation: dmDotBounce 1.4s infinite;
}
.dm-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.dm-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dmDotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* ── Поиск по чату ──────────────────────────────────────── */
.dm-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.dm-search-bar input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 6px 12px;
  font-size: 12px;
  outline: none;
}
.dm-search-bar input:focus { border-color: var(--gold); }
.dm-match .dm-msg-bubble { box-shadow: 0 0 0 2px var(--gold); }

/* ── Голосовые сообщения ─────────────────────────────────── */
.dm-mic {
  background: var(--bg3);
  color: var(--muted);
  border: 1px solid var(--border2);
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dm-mic:hover { background: var(--gold); color: #000; border-color: var(--gold); }

/* Кнопки прикрепления и эмодзи */
.dm-attach, .dm-emoji-btn {
  background: var(--bg3);
  color: var(--muted);
  border: 1px solid var(--border2);
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dm-attach:hover, .dm-emoji-btn:hover { background: var(--gold); color: #000; border-color: var(--gold); }

/* Эмодзи-пикер (над формой ввода) */
.dm-emoji-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 10px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  max-height: 180px;
  overflow-y: auto;
}
.dm-emoji-picker button {
  background: none; border: none; cursor: pointer;
  font-size: 22px; padding: 4px; border-radius: 8px;
  line-height: 1;
}
.dm-emoji-picker button:hover { background: var(--bg3); }

/* ── Свайп-ответ (мобиле): иконка ↩ проявляется при протягивании ── */
.dm-msg.dm-swipe-armed::after {
  content: '↩';
  position: absolute;
  left: -34px; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  background: var(--gold); color: #000;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}

/* ── Мультивыбор сообщений ── */
.dm-selecting .dm-msg { cursor: pointer; }
.dm-selecting .dm-msg-wrap button,
.dm-selecting .dm-rx-btn,
.dm-selecting .dm-reply-btn,
.dm-selecting .dm-menu-btn { display: none !important; }  /* прячем действия в режиме выбора */
.dm-msg.dm-selected .dm-msg-bubble {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.dm-msg.dm-selected::before {
  content: '✓';
  position: absolute;
  top: 50%; transform: translateY(-50%);
  left: -6px;
  width: 20px; height: 20px;
  background: var(--gold); color: #000;
  border-radius: 50%;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.dm-msg { position: relative; }
.dm-select-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: 60;
}
.dm-sel-x, .dm-sel-act {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text);
  width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; font-size: 15px; flex-shrink: 0;
}
.dm-sel-act:hover { background: var(--gold); color: #000; }
.dm-sel-act.danger:hover { background: #d33; color: #fff; border-color: #d33; }
.dm-sel-count { font-size: 14px; font-weight: 600; }

/* ── Онлайн-статус ── */
.dm-head-status {
  display: block;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.2;
  min-height: 13px;
}
.dm-head-status.online { color: #4cc96b; }

/* Точка онлайн на аватаре в списке чатов */
.dm-ava-wrap { position: relative; flex-shrink: 0; }
.dm-online-dot {
  position: absolute;
  right: 0; bottom: 0;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #4cc96b;
  border: 2px solid var(--bg2);
  display: none;
}
.dm-thread-row.is-online .dm-online-dot { display: block; }

/* ── Кликабельные ссылки в тексте ── */
.dm-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.dm-msg.theirs .dm-link { color: var(--gold); }

/* ── Превью-карточка ссылки ── */
.dm-link-card {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  max-width: 280px;
  background: var(--bg3);
}
.dm-link-card:empty { display: none; }
.dm-msg.mine .dm-link-card { background: rgba(0,0,0,.14); border-color: rgba(0,0,0,.2); }
.dm-link-img img { width: 100%; max-height: 150px; object-fit: cover; display: block; }
.dm-link-body { padding: 8px 10px; }
.dm-link-site { font-size: 10px; letter-spacing: .5px; color: var(--gold); text-transform: uppercase; margin-bottom: 2px; }
.dm-msg.mine .dm-link-site { color: rgba(0,0,0,.6); }
.dm-link-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.dm-link-desc { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.35; max-height: 44px; overflow: hidden; }
.dm-msg.mine .dm-link-desc { color: rgba(0,0,0,.55); }

/* Метка «Пересланное» в пузыре */
.dm-fwd-label {
  font-size: 11px;
  color: var(--gold);
  opacity: .85;
  margin-bottom: 3px;
  font-style: italic;
}
.dm-msg.mine .dm-fwd-label { color: rgba(0,0,0,.6); }

/* ── Медиа в пузыре: фото ── */
.dm-img {
  width: auto;
  height: auto;
  max-width: min(220px, 60vw);
  max-height: 240px;
  border-radius: 12px;
  cursor: pointer;
  display: block;
  object-fit: cover;
  background: var(--bg3);
  min-width: 70px;
  min-height: 50px;
}
.dm-img:hover { opacity: .92; }
.dm-vid {
  max-width: min(260px, 68vw);
  max-height: 300px;
  border-radius: 12px;
  display: block;
  background: #000;
}
.dm-media-err::after { content: '⚠ не загрузилось'; color: var(--muted); font-size: 11px; }

/* ── Файл-карточка ── */
.dm-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  max-width: 260px;
}
.dm-file-ico { font-size: 26px; flex-shrink: 0; }
.dm-file-info { min-width: 0; }
.dm-file-name {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dm-msg.mine .dm-file-name { color: #000; }
.dm-file-dl { font-size: 11px; color: var(--gold); text-decoration: none; }
.dm-msg.mine .dm-file-dl { color: #000; text-decoration: underline; }
.dm-file-dl[aria-disabled="true"] { opacity: .5; pointer-events: none; }

/* ── Полноэкранный просмотр фото ── */
.dm-img-viewer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.94);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.dm-img-viewer img {
  max-width: 96vw; max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.dm-img-viewer-bar {
  position: absolute; top: 16px; right: 18px;
  display: flex; align-items: center; gap: 10px;
  cursor: default;
}
.dm-img-viewer-btn {
  background: rgba(255,255,255,.12);
  color: #fff; border: none;
  height: 40px; padding: 0 16px; border-radius: 20px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: background .15s;
}
.dm-img-viewer-btn:hover { background: rgba(255,255,255,.24); }
.dm-img-viewer-close {
  width: 40px; padding: 0; border-radius: 50%;
  font-size: 18px; justify-content: center;
}

.dm-voice-overlay {
  display: none;
  position: fixed;
  left: 14px; right: 14px;
  bottom: 78px;  /* над формой ввода чата */
  max-width: 460px;
  margin: 0 auto;
  background: rgba(8,8,16,.96);
  border: 1px solid #d33;
  padding: 10px 16px;
  align-items: center;
  gap: 14px;
  z-index: 10600;
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.dm-voice-cancel, .dm-voice-stop {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.dm-voice-cancel {
  background: rgba(255,255,255,.08);
  color: var(--muted);
}
.dm-voice-cancel:hover { background: #d33; color: #fff; }
.dm-voice-stop {
  background: var(--gold);
  color: #000;
}
.dm-voice-stop:hover { background: var(--gold2); }
.dm-voice-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #d33;
  animation: dmVoicePulse 1s infinite;
}
.dm-voice-time {
  flex: 1;
  color: #fff;
  font-family: 'Inter', monospace;
  font-size: 14px;
  letter-spacing: 1.5px;
}
@keyframes dmVoicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.3); }
}

/* Карточка голосового в чате */
.dm-voice-msg {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 8px;
  background: rgba(0,0,0,.18);
  border-radius: 18px;
  cursor: pointer;
  user-select: none;
  min-width: 160px;
  margin-top: 2px;
}
.dm-msg.theirs .dm-voice-msg { background: rgba(255,255,255,.08); }
.dm-voice-msg:hover { background: rgba(0,0,0,.28); }
.dm-msg.theirs .dm-voice-msg:hover { background: rgba(255,255,255,.14); }
.dm-voice-play {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: #000;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.dm-msg.mine .dm-voice-play { background: #000; color: var(--gold); }
.dm-voice-wave { font-size: 14px; opacity: 0.7; }
.dm-voice-dur {
  font-size: 11px;
  color: var(--muted);
  font-family: 'Inter', monospace;
  letter-spacing: 1px;
}
.dm-msg.mine .dm-voice-dur { color: rgba(0,0,0,.55); }
.dm-voice-msg.playing { background: rgba(201,168,76,.22); }

/* ── Локация-карточка в сообщении (на базе film-card) ───── */
.dm-loc-card .dm-film-card-poster {
  background: rgba(201,168,76,.12);
  color: var(--gold);
}

/* ── Меню действий на сообщении (⋮) ────────────────────── */
.dm-menu-btn {
  opacity: 0.45;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  transition: opacity .15s, color .15s;
  flex-shrink: 0;
}
.dm-msg-wrap:hover .dm-menu-btn { opacity: 1; }
.dm-menu-btn:hover { opacity: 1; color: var(--gold); border-color: var(--gold); }

/* ── На тач-устройствах action-иконки рядом с каждым сообщением создавали
   визуальный мусор: react (+), reply (↩), kebab (⋮) видны постоянно при
   opacity:0.45, потому что hover на touch не срабатывает. Скрываем react
   и reply — оставляем только kebab, который при тапе открывает меню со
   ВСЕМИ действиями (Ответить, Реакция, Удалить). */
@media (pointer: coarse), (max-width: 640px){
  .dm-rx-btn, .dm-reply-btn { display: none !important; }
  .dm-menu-btn {
    opacity: 0.6 !important;
    width: 26px !important;
    height: 26px !important;
    font-size: 16px !important;
  }
}

.dm-msg-menu {
  background: var(--bg2);
  border: 1px solid var(--gold);
  padding: 4px;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.dm-msg-menu button {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
}
.dm-mi {
  width: 16px; height: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  opacity: .85;
}
.dm-mi svg { width: 16px; height: 16px; }
.dm-msg-menu button:hover { background: var(--bg3); color: var(--gold); }
.dm-msg-menu button:hover .dm-mi { color: var(--gold); opacity: 1; }
.dm-msg-menu button.danger .dm-mi { color: #e44; }
.dm-msg-menu button.danger { color: #e44; }
.dm-msg-menu button.danger:hover { background: rgba(228,68,68,.12); color: #f66; }

/* ── Edit-режим ───────────────────────────────────────── */
.dm-edit-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 50px;
  outline: none;
}
.dm-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.dm-edit-actions button {
  background: var(--gold);
  color: #000;
  border: none;
  padding: 4px 10px;
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  font-family: inherit;
}
.dm-edit-actions button:last-child {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border2);
}

/* ── Pin ──────────────────────────────────────────────── */
.dm-pin-mark {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.7;
}
.dm-msg.pinned .dm-msg-bubble {
  border: 1px solid rgba(201,168,76,.5);
  box-shadow: 0 0 0 1px rgba(201,168,76,.18);
}
.dm-pinned-bar {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 6px 14px;
  max-height: 100px;
  overflow-y: auto;
}
.dm-pinned-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
}
.dm-pinned-item:hover { background: rgba(201,168,76,.08); }
.dm-pinned-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

/* ── Мобила ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  /* Тот же фикс что и #cart-panel — right:-100% + width:100vw оставляли
     1-10px панели в viewport (с border-left). Используем transform. */
  #dm-panel {
    width: 100vw;
    max-width: 100vw;
    right: 0 !important;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }
  #dm-panel.open { transform: translateX(0); }
  .dm-threads {
    width: 100%;
    /* border-right на 100% ширины ставил тонкую вертикальную полоску
       у правого края viewport — убираем на мобиле, список и так
       занимает весь экран. */
    border-right: none !important;
  }
  .dm-thread { display: none; position: absolute; inset: 0; background: var(--bg); }
  .dm-thread.open { display: flex; }
  .dm-back { display: inline-block; }
  /* Когда открыт активный диалог, скрываем список потока */
  #dm-panel:has(.dm-thread.open) .dm-threads { display: none; }
  /* На мобиле .dm-rx-btn и .dm-reply-btn скрыты, .dm-menu-btn полупрозрачный
     — см. правило выше @media (pointer:coarse). Здесь НЕ выставляем opacity:1
     иначе старое правило перебивает свежий display:none. */
}
