/* Message bubbles, media in messages, replies, mentions. */
/* Card / media messages: keep bubble chrome transparent (must follow base .msg-bubble). */
.msg.task-only .msg-bubble,
.msg.poll-only .msg-bubble,
.msg.image-only .msg-bubble,
.msg.emoji-only .msg-bubble,
.msg.video-note-only .msg-bubble,
.msg.mine.task-only .msg-bubble,
.msg.mine.poll-only .msg-bubble,
.msg.mine.image-only .msg-bubble,
.msg.mine.emoji-only .msg-bubble,
.msg.mine.video-note-only .msg-bubble,
.msg:not(.mine).task-only .msg-bubble,
.msg:not(.mine).poll-only .msg-bubble,
.msg:not(.mine).image-only .msg-bubble,
.msg:not(.mine).emoji-only .msg-bubble,
.msg:not(.mine).video-note-only .msg-bubble {
  background: transparent;
  box-shadow: none;
}
.msg.task-only .msg-bubble,
.msg.poll-only .msg-bubble {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 100%;
  min-width: 0;
  padding: 0;
  position: relative;
  color: #1a1d26;
}
.msg.mine.task-only .msg-bubble,
.msg.mine.poll-only .msg-bubble {
  align-items: flex-end;
}
.msg.task-only:not(.mine) .msg-bubble,
.msg.poll-only:not(.mine) .msg-bubble {
  align-items: flex-start;
}
.msg.task-only .msg-body,
.msg.poll-only .msg-body {
  width: 100%;
}
.msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.msg-meta:not(:has(.msg-reactions)) {
  justify-content: flex-end;
}
.msg:not(.mine) .msg-meta:not(:has(.msg-reactions)) {
  justify-content: flex-start;
}
.msg .msg-reactions {
  flex: 1 1 auto;
  justify-content: flex-start;
}
.msg.mine .msg-meta {
  justify-content: space-between;
}
.msg.mine .msg-meta:not(:has(.msg-reactions)) {
  justify-content: flex-end;
}
.msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin: 0;
  max-width: calc(100% - 72px);
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-start;
}
.msg-reaction {
  appearance: none; border: 1px solid rgba(16, 24, 40, .08);
  background: rgba(255, 255, 255, .92);
  border-radius: 999px;
  padding: 2px 8px 2px 6px;
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; line-height: 1.2;
  box-shadow: 0 1px 1px rgba(16, 24, 40, .04);
}
.msg-reaction:hover { background: #fff; border-color: rgba(16, 24, 40, .16); }
.msg-reaction.is-mine {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-soft);
}
.msg-reaction-emoji {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  line-height: 1;
}
.msg-reaction-emoji img.icq-smiley {
  width: 18px;
  height: 18px;
}
.msg-reaction-count {
  font-size: 12px; font-weight: 400; color: #5c6270; min-width: 0.6em;
}
.msg-reaction.is-mine .msg-reaction-count { color: var(--accent); }
.msg-reaction-add {
  min-width: 26px;
  justify-content: center;
  color: #7a8494;
  font-weight: 700;
}
.emoji-picker.reaction-mode .emoji-picker-tab[data-group="icq"] { display: none; }
.emoji-picker.reaction-mode {
  position: fixed;
  z-index: 95;
  right: auto;
  bottom: auto;
}
.msg.emoji-only .msg-bubble,
.msg.mine.emoji-only .msg-bubble,
.msg:not(.mine).emoji-only .msg-bubble {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  color: inherit;
  min-width: 0; max-width: 100%;
  padding: 0; border-radius: 0;
}
.msg.emoji-only .msg-body {
  font-size: 54px; line-height: 1.05; white-space: pre-wrap;
  letter-spacing: 2px; user-select: text;
  -webkit-text-size-adjust: 100%;
}
.msg.emoji-only.emoji-2 .msg-body { font-size: 44px; }
.msg.emoji-only.emoji-3 .msg-body { font-size: 36px; letter-spacing: 1px; }
/* Animated emoji (Noto Emoji Animation): a square a little over twice the
   emoji's size; the emoji itself shows until the first frame is drawn. */
.msg-body .anim-emoji {
  position: relative; display: inline-block; vertical-align: middle;
  width: 2.2em; height: 2.2em; letter-spacing: 0;
  background: transparent !important;
}
.msg-body .anim-emoji-txt {
  position: absolute; inset: 0; display: grid; place-items: center;
  transition: opacity .12s ease;
}
.msg-body .anim-emoji.is-playing .anim-emoji-txt { opacity: 0; }
.msg-body .anim-emoji-play { position: absolute; inset: 0; pointer-events: none; }
.msg-body .anim-emoji-play svg { display: block; width: 100% !important; height: 100% !important; }
.msg.emoji-only .msg-body.has-anim-emoji { line-height: 1; letter-spacing: 0; }
.msg.emoji-only .msg-receipt {
  --receipt-muted: rgba(255, 255, 255, .4);
  --receipt-blue: #fff;
}
.msg.emoji-only .msg-receipt.is-sent .msg-receipt-chev { color: var(--receipt-muted); }
.msg.emoji-only .msg-receipt.is-delivered .msg-receipt-chev:first-child { color: var(--receipt-blue); }
.msg.emoji-only .msg-receipt.is-delivered .msg-receipt-chev:last-child { color: var(--receipt-muted); }
.msg.emoji-only .msg-receipt.is-read .msg-receipt-chev { color: var(--receipt-blue); }
.msg.emoji-only.mentions-me .msg-bubble { box-shadow: none; }
.msg.video-note-only .msg-bubble {
  background: transparent; box-shadow: none; color: inherit;
  min-width: 0; max-width: 100%;
  padding: 0; border-radius: 0;
}
.msg.video-note-only .msg-body { margin: 0; padding: 0; }
.msg.video-note-only .msg-video-note {
  margin: 0;
  box-shadow: 0 2px 10px rgba(16, 24, 40, .18);
}
.msg.video-note-only .msg-receipt {
  --receipt-muted: rgba(255, 255, 255, .4);
  --receipt-blue: #fff;
}
.msg.video-note-only .msg-receipt.is-sent .msg-receipt-chev { color: var(--receipt-muted); }
.msg.video-note-only .msg-receipt.is-delivered .msg-receipt-chev:first-child { color: var(--receipt-blue); }
.msg.video-note-only .msg-receipt.is-delivered .msg-receipt-chev:last-child { color: var(--receipt-muted); }
.msg.video-note-only .msg-receipt.is-read .msg-receipt-chev { color: var(--receipt-blue); }
.msg.video-note-only.mentions-me .msg-bubble { box-shadow: none; }
.msg.video-note-only .msg-video-note-dur { bottom: 10px; }
.msg-head { display: flex; gap: 8px; align-items: baseline; margin: 0 0 2px; }
.msg.compact .msg-head { display: none; }
.msg.mine .msg-head { justify-content: flex-end; }
.msg-name {
  appearance: none; border: 0; background: transparent; padding: 0; cursor: pointer;
  font-weight: 700; font-size: calc(14px * var(--text-scale, 1)); color: inherit; font-family: inherit;
}
.msg-name:hover { text-decoration: underline; }
.msg-name.is-you {
  cursor: default;
  font-weight: 650;
  opacity: 0.72;
  text-decoration: none;
}
.msg-name.is-you:hover { text-decoration: none; }
#dialogue-overlay .msg.compact .msg-head { display: flex; }
.avatar.is-clickable { cursor: pointer; }
.avatar.is-clickable:hover { box-shadow: 0 0 0 2px var(--accent-soft); }
.msg-body { font-size: calc(15px * var(--text-scale, 1)); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; color: inherit; }
.msg-body.msg-e2e-locked { color: #8b8e98; font-style: italic; }
.msg-foot {
  display: inline-flex; justify-content: center; align-items: center; gap: 4px;
  margin: 0; margin-right: auto; flex: none;
  min-height: 0;
  /* Same dark pill as image / emoji / task messages: white »» = read. */
  padding: 2px 7px;
  border-radius: 10px;
  background:
    color-mix(
      in srgb,
      color-mix(in srgb, var(--pill-color, #1a1d26) 28%, #1a1d26)
      calc(var(--pill-opacity, 0.55) * 100%),
      transparent
    );
  pointer-events: none;
}
.msg.mine .msg-foot {
  margin-left: auto;
  margin-right: 0;
}
.msg-time {
  color: #fff;
  font-size: calc(11px * var(--text-scale, 1));
  line-height: 1;
  font-weight: 600;
}
.msg.mine .msg-time { color: #fff; }
.msg-receipt {
  display: inline-flex; align-items: center; justify-content: center;
  height: 12px; flex: none; margin-left: 3px; gap: 0;
  --receipt-muted: rgba(255, 255, 255, .4);
  --receipt-blue: #fff;
}
.msg-receipt-chev { width: 9px; height: 12px; display: block; margin-left: -3px; }
.msg-receipt-chev:first-child { margin-left: 0; }
.msg-receipt.is-pending { font-size: 11px; line-height: 12px; }
.msg-receipt.is-sent .msg-receipt-chev { color: var(--receipt-muted); }
.msg-receipt.is-delivered .msg-receipt-chev:first-child { color: var(--receipt-blue); }
.msg-receipt.is-delivered .msg-receipt-chev:last-child { color: var(--receipt-muted); }
.msg-receipt.is-read .msg-receipt-chev { color: var(--receipt-blue); }
.msg-meta:empty { display: none; }
.msg-edited {
  color: #fff;
  font-size: calc(11px * var(--text-scale, 1));
  margin-right: 4px;
  font-weight: 500;
}
.msg.mine .msg-edited { color: #fff; }
.msg.image-only .msg-time,
.msg.image-only .msg-edited,
.msg.mine.image-only .msg-time,
.msg.mine.image-only .msg-edited,
.msg.emoji-only .msg-time,
.msg.emoji-only .msg-edited,
.msg.mine.emoji-only .msg-time,
.msg.mine.emoji-only .msg-edited,
.msg.video-note-only .msg-time,
.msg.video-note-only .msg-edited,
.msg.mine.video-note-only .msg-time,
.msg.mine.video-note-only .msg-edited {
  color: #fff;
}
.msg-reply {
  display: flex; gap: 8px; margin: 0 0 4px; padding: 4px 8px;
  border-left: 3px solid var(--accent); background: rgba(0,0,0,.04); border-radius: 4px;
  cursor: pointer; max-width: 100%;
}
.msg.mine .msg-reply { background: rgba(255,255,255,.35); }
.msg-reply-name { color: var(--accent); font-size: calc(12px * var(--text-scale, 1)); font-weight: 700; }
.msg-reply-body { color: #6b7080; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.selecting { cursor: pointer; }
.msg.selected-msg { background: transparent; }
.msg-check {
  width: 22px; height: 22px; min-width: 22px; border-radius: 50%;
  border: 2px solid #d5d8de;
  display: grid; place-items: center; margin: 8px 4px 0; flex: none;
  color: transparent; background: #fff;
  font-size: 13px; font-weight: 700; line-height: 1;
}
.msg.selected-msg .msg-check {
  background: #d7dbe3;
  border-color: #d7dbe3;
  color: var(--accent, #1c58d9);
}
.msg-body code {
  background: rgba(0,0,0,.06); border-radius: 3px; padding: 1px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em;
}
.msg-body a {
  color: var(--accent);
  text-decoration: none;
}
.msg-body a:hover {
  text-decoration: none;
}
.mention { background: var(--mention-bg); color: var(--accent); border-radius: 3px; padding: 0 3px; }
.mention.me { background: #ffe8e8; color: #c43133; font-weight: 700; }
/* People (Noto Emoji pictures) move by CSS: a hop, a wave, a dance… Each
   motion keeps the feet on the ground (transform-origin at the bottom). */
.msg-body .anim-emoji.is-art .anim-emoji-art {
  position: absolute; inset: 6%; width: 88%; height: 88%; opacity: 0;
  transition: opacity .12s ease;
}
.msg-body .anim-emoji.is-art.is-playing .anim-emoji-art { opacity: 1; }
.anim-emoji-art, .emoji-pick-art {
  display: block; transform-origin: 50% 96%; user-select: none; -webkit-user-drag: none;
  animation-duration: 2.4s; animation-iteration-count: infinite; animation-timing-function: ease-in-out;
}
.emoji-pick-art { width: 100%; height: 100%; }
.motion-hop { animation-name: ae-hop; animation-duration: 1.8s; }
.motion-wave { animation-name: ae-wave; animation-duration: 1.6s; }
.motion-dance { animation-name: ae-dance; animation-duration: 1.2s; }
.motion-walk { animation-name: ae-walk; animation-duration: 1.4s; }
.motion-bow { animation-name: ae-bow; animation-duration: 2.6s; }
.motion-shake { animation-name: ae-shake; animation-duration: 1.9s; }
.motion-talk { animation-name: ae-talk; animation-duration: 1.1s; }
@keyframes ae-hop {
  0%, 52%, 100% { transform: translateY(0) scale(1, 1); }
  10% { transform: translateY(0) scale(1.06, .92); }
  26% { transform: translateY(-14%) scale(.96, 1.05) rotate(-3deg); }
  40% { transform: translateY(0) scale(1.05, .94); }
  46% { transform: translateY(-3%) scale(1, 1) rotate(1deg); }
}
@keyframes ae-wave {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-9deg); }
  40% { transform: rotate(7deg); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(3deg); }
}
@keyframes ae-dance {
  0%, 100% { transform: translateX(0) rotate(0) scale(1, 1); }
  25% { transform: translateX(-6%) rotate(-8deg) scale(1.03, .97); }
  50% { transform: translateX(0) rotate(0) translateY(-6%) scale(.98, 1.03); }
  75% { transform: translateX(6%) rotate(8deg) scale(1.03, .97); }
}
@keyframes ae-walk {
  0%, 100% { transform: translate(-4%, 0) rotate(-2deg); }
  25% { transform: translate(0, -5%) rotate(0); }
  50% { transform: translate(4%, 0) rotate(2deg); }
  75% { transform: translate(0, -5%) rotate(0); }
}
@keyframes ae-bow {
  0%, 15%, 100% { transform: scale(1, 1) translateY(0); }
  35%, 55% { transform: scale(1.04, .86) translateY(3%) rotate(2deg); }
  70% { transform: scale(.98, 1.03) translateY(-2%); }
}
@keyframes ae-shake {
  0%, 40%, 100% { transform: rotate(0); }
  48% { transform: rotate(-7deg); }
  56% { transform: rotate(6deg); }
  64% { transform: rotate(-5deg); }
  72% { transform: rotate(4deg); }
  80% { transform: rotate(0) scale(1.04, .96); }
}
@keyframes ae-talk {
  0%, 100% { transform: scale(1, 1); }
  30% { transform: scale(1.05, .95) rotate(-2deg); }
  60% { transform: scale(.97, 1.04) rotate(2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .anim-emoji-art, .emoji-pick-art { animation: none; }
}

/* Swipe a message: right — reply, left — forward (35-msg-swipe.js). */
#messages .msg.is-swiping { transition: none; will-change: transform; }
#messages .msg.is-swipe-back { transition: transform .2s cubic-bezier(.2, .8, .3, 1); }
.msg-swipe-hint {
  position: fixed; z-index: 60; width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(26, 29, 38, .14); color: #3b3f4a; pointer-events: none;
  opacity: 0; transition: background .15s ease, color .15s ease;
}
.msg-swipe-hint.is-ready { background: var(--accent, #2f5bd8); color: #fff; }
.msg-swipe-hint.is-leaving { transition: opacity .18s ease, transform .18s ease; opacity: 0 !important; transform: scale(.5) !important; }

/* Touch screens: a long-press on a bubble opens our own context menu, so the
   WebView's word selection (blue highlight + the «Перевести» system pill, which
   then lingers over the chat) must never start. Copying stays available through
   the menu's «Скопировать». Desktop keeps normal mouse selection. */
@media (hover: none), (pointer: coarse) {
  .msg, .msg.emoji-only .msg-body,
  .msg-menu, .msg-menu-views-flyout {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
}
