/* Единый вид диалогов (как на планировании авантюры): пузыри слева/справа, реакции, меню. */

.thread-chat-list {
  max-height: min(55vh, 520px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 12px;
  min-height: 120px;
}
.thread-chat-list .miravi-smiley,
.thread-chat-list .miravi-smiley-animated {
  vertical-align: -0.22em;
  width: 1.75em !important;
  height: 1.75em !important;
  min-width: 1.75em !important;
  min-height: 1.75em !important;
  max-width: 1.75em !important;
  max-height: 1.75em !important;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: inline-block;
}
.thread-chat-row {
  display: flex;
  width: 100%;
  flex-shrink: 0;
  overflow: visible;
}
.thread-chat-row--mine { justify-content: flex-end; }
.thread-chat-row--theirs { justify-content: flex-start; }
.thread-chat-item {
  width: fit-content;
  max-width: min(68%, 320px);
  min-width: 0;
  flex: 0 1 auto;
  border-radius: 16px;
  padding: 8px 12px 10px;
  cursor: pointer;
  margin-bottom: 6px;
  box-sizing: border-box;
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #fff;
}
.thread-chat-row--mine .thread-chat-item {
  background: #dbeafe;
  border-color: rgba(59, 130, 246, 0.32);
  margin-left: auto;
}
.thread-chat-row--theirs .thread-chat-item {
  margin-right: auto;
}
.thread-chat-row--theirs .thread-chat-item::after {
  content: "";
  position: absolute;
  left: 12px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-top: none;
  border-left: none;
  border-radius: 0 0 2px 0;
  transform: rotate(45deg);
}
.thread-chat-row--mine .thread-chat-item::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  background: #dbeafe;
  border: 1px solid rgba(59, 130, 246, 0.32);
  border-top: none;
  border-right: none;
  border-radius: 0 0 0 2px;
  transform: rotate(45deg);
}
.thread-chat-bubble-text { margin-top: 4px; word-break: break-word; }
.thread-chat-bubble-text img { max-width: 100%; height: auto; border-radius: 8px; }
.thread-chat-quote {
  margin-top: 6px;
  padding: 6px 8px;
  border-left: 3px solid rgba(59, 130, 246, 0.55);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.06);
  font-size: 12px;
  line-height: 1.35;
  max-width: 100%;
}
.thread-chat-quote--framed {
  border: 1px solid rgba(59, 130, 246, 0.38);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(248, 250, 252, 0.95);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}
.thread-chat-row--mine .thread-chat-quote {
  border-left-color: rgba(37, 99, 235, 0.75);
  background: rgba(255, 255, 255, 0.45);
}
.thread-chat-row--mine .thread-chat-quote--framed {
  border-color: rgba(37, 99, 235, 0.42);
  background: rgba(255, 255, 255, 0.72);
}
.thread-chat-quote-author {
  font-weight: 800;
  color: #1e40af;
  margin-bottom: 2px;
}
.thread-chat-quote-text {
  color: #475569;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.thread-chat-quote-text .miravi-smiley,
.thread-chat-quote-text .miravi-smiley-animated {
  width: 1.35em !important;
  height: 1.35em !important;
  min-width: 1.35em !important;
  min-height: 1.35em !important;
  max-width: 1.35em !important;
  max-height: 1.35em !important;
}
.messages-reply-bar {
  display: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--border, #e2e8f0);
  background: #f8fafc;
}
.messages-reply-bar.is-visible { display: flex; }
.messages-reply-bar-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
}
.messages-reply-bar-preview {
  font-size: 13px;
  line-height: 1.35;
  color: #334155;
  max-height: 4.2em;
  overflow: hidden;
}
.messages-reply-bar-cancel {
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.messages-reply-bar-cancel:hover { color: #0f172a; }
/* Личные сообщения: пузыри на 2/3 ширины, слева / справа */
#messages-thread-list.thread-chat-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#messages-thread-list .thread-chat-row {
  display: flex;
  width: 100%;
  flex-shrink: 0;
}
#messages-thread-list .thread-chat-row--mine {
  justify-content: flex-end;
}
#messages-thread-list .thread-chat-row--theirs {
  justify-content: flex-start;
}
#messages-thread-list .dm-chat-bubble-col {
  display: flex;
  flex-direction: column;
  max-width: 66.67%;
  width: max-content;
  min-width: 0;
  flex: 0 1 auto;
}
#messages-thread-list .thread-chat-row--mine .dm-chat-bubble-col {
  align-items: flex-end;
}
#messages-thread-list .thread-chat-row--theirs .dm-chat-bubble-col {
  align-items: flex-start;
}
#messages-thread-list .dm-chat-bubble-col > .thread-chat-item {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.dm-msg-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.dm-msg-quick-btn {
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: #fff;
  color: #1e293b;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.2;
}
.dm-msg-quick-btn:hover {
  background: #f8fafc;
}
.thread-chat-row--mine .dm-msg-quick-btn {
  background: rgba(255, 255, 255, 0.88);
}
.thread-chat-item.is-editing {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 2px;
}
.thread-chat-edit-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid rgba(59, 130, 246, 0.28);
  font-size: 13px;
}
.thread-chat-edit-bar.is-visible { display: flex; }
.thread-chat-edit-bar-label { font-weight: 700; color: #1e40af; }
.thread-chat-item.is-active .thread-chat-menu-wrap { display: block; }
.thread-chat-reaction-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.thread-chat-reaction-badge {
  border: 1px solid #dbe2ea;
  border-radius: 999px;
  background: #fff;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
}
.thread-chat-menu-wrap { display: none; margin-top: 8px; }
.thread-chat-menu {
  position: relative;
  width: fit-content;
  max-width: min(92vw, 220px);
  border: 1px solid #dbe2ea;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
  overflow: visible;
}
.thread-chat-menu-reactions {
  position: relative;
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  flex-wrap: wrap;
}
.thread-chat-quick-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #dbe2ea;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.thread-chat-quick-btn:hover { background: #eef2ff; }
.thread-chat-reaction-gallery {
  display: none;
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 30;
  background: #fff;
  border: 1px solid #dbe2ea;
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.14);
}
.thread-chat-reaction-gallery button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.thread-chat-reaction-gallery button:hover { background: #f1f5f9; }
.thread-chat-menu-list { display: grid; }
.thread-chat-menu-item {
  border: 0;
  border-top: 1px solid #f1f5f9;
  background: #fff;
  text-align: left;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.thread-chat-menu-item:first-child { border-top: 0; }
.thread-chat-menu-item:hover { background: #f8fafc; }
.thread-chat-menu-item.is-danger { color: #b91c1c; }
.thread-chat-menu-item.is-danger:hover { background: #fef2f2; }
.thread-chat-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.thread-chat-action-btn {
  border: 1px solid var(--border, #e2e8f0);
  background: #fff;
  color: #0f172a;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.thread-chat-action-btn:hover { background: #f8fafc; }
.thread-chat-editor {
  min-height: 46px;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
.thread-chat-editor:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
}
.thread-chat-editor:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}
.thread-chat-smiley-wrap { position: relative; }
.thread-chat-smiley-panel {
  display: none;
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 40;
  width: min(520px, 92vw);
  max-height: min(340px, 48vh);
  overflow: auto;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  padding: 10px;
}
.thread-chat-smiley-panel .section-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 6px;
}
.thread-chat-smiley-panel .grid { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.thread-chat-smiley-panel .kolobki-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border, #e2e8f0);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  cursor: pointer;
}
.thread-chat-smiley-panel .kolobki-btn img { width: 32px; height: 32px; object-fit: contain; display: block; }
