/* Beta: tails + keep ALL bubble corners rounded (no sharp bottom corner) */

:root {
  --xam-tail-w: 15px;
  --xam-tail-h: 16px;
  /* SVG spine ≈ 9.6px from outer edge → overlap into bubble */
  --xam-tail-overlap: 9.6px;
  --xam-tail-own-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2215%22%20height%3D%2216%22%20viewBox%3D%220%200%2015%2016%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M9.60963%2C6C9.60963%2C8%209.30942%2C13%2014.1094%2C15C12.1095%2C15.5%207.2096%2C15.8%203.6096%2C13C0.00956869%2C11.8%20-0.223723%2C4.83333%200.109635%2C1.5L9.60963%2C0V6Z%22%20fill%3D%22white%22%2F%3E%3C%2Fsvg%3E");
  --xam-tail-peer-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2215%22%20height%3D%2216%22%20viewBox%3D%220%200%2015%2016%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M5.39037%2C6C5.39037%2C8%205.69058%2C13%200.890625%2C15C2.89053%2C15.5%207.7904%2C15.8%2011.3904%2C13C14.9904%2C11.8%2015.2237%2C4.83333%2014.8904%2C1.5L5.39037%2C0V6Z%22%20fill%3D%22white%22%2F%3E%3C%2Fsvg%3E");
}

/* Важно: НЕ обнуляем радиус — угол остаётся круглым (как ✓ на макете) */
.messages-container .message.own.message-bubble-single:not(.emoji-only):not(.system-message):not(.message--media-card):not(.message--sticker) .message-content,
.messages-container .message.own.message-bubble-last:not(.emoji-only):not(.system-message):not(.message--media-card):not(.message--sticker) .message-content,
.messages-container .message:not(.system-message):not(.emoji-only).message-bubble-last.own .message-content,
.messages-container .message:not(.system-message):not(.emoji-only).message-bubble-single.own .message-content,
.messages-container .message.message--media-card.own.message-bubble-single .message-media-card-shell,
.messages-container .message.message--media-card.own.message-bubble-last .message-media-card-shell {
  border-bottom-right-radius: var(--xam-message-radius, 18px) !important;
  overflow: visible !important;
}

.messages-container .message:not(.own).message-bubble-single:not(.emoji-only):not(.system-message):not(.message--media-card):not(.message--sticker) .message-content,
.messages-container .message:not(.own).message-bubble-last:not(.emoji-only):not(.system-message):not(.message--media-card):not(.message--sticker) .message-content,
.messages-container .message:not(.system-message):not(.emoji-only).message-bubble-last:not(.own) .message-content,
.messages-container .message:not(.system-message):not(.emoji-only).message-bubble-single:not(.own) .message-content,
.messages-container .message.message--media-card:not(.own).message-bubble-single .message-media-card-shell,
.messages-container .message.message--media-card:not(.own).message-bubble-last .message-media-card-shell {
  border-bottom-left-radius: var(--xam-message-radius, 18px) !important;
  overflow: visible !important;
}

/* Own tail */
.messages-container .message.own.message-bubble-single:not(.emoji-only):not(.system-message):not(.message--media-card):not(.message--sticker) .message-content::after,
.messages-container .message.own.message-bubble-last:not(.emoji-only):not(.system-message):not(.message--media-card):not(.message--sticker) .message-content::after,
.messages-container .message.message--media-card.own.message-bubble-single .message-media-card-shell::after,
.messages-container .message.message--media-card.own.message-bubble-last .message-media-card-shell::after {
  content: '' !important;
  display: block !important;
  position: absolute !important;
  width: var(--xam-tail-w) !important;
  height: var(--xam-tail-h) !important;
  left: calc(100% - var(--xam-tail-overlap)) !important;
  right: auto !important;
  bottom: 0 !important;
  box-sizing: border-box !important;
  pointer-events: none !important;
  z-index: 3 !important;
  background-color: var(--msg-own-bg, #8774E1) !important;
  background-image: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  opacity: 1 !important;
  transform: none !important;
  -webkit-mask-image: var(--xam-tail-own-mask) !important;
  mask-image: var(--xam-tail-own-mask) !important;
  -webkit-mask-size: 100% 100% !important;
  mask-size: 100% 100% !important;
  -webkit-mask-repeat: no-repeat !important;
  mask-repeat: no-repeat !important;
  -webkit-mask-position: left bottom !important;
  mask-position: left bottom !important;
}

/* Peer tail */
.messages-container .message:not(.own).message-bubble-single:not(.emoji-only):not(.system-message):not(.message--media-card):not(.message--sticker) .message-content::before,
.messages-container .message:not(.own).message-bubble-last:not(.emoji-only):not(.system-message):not(.message--media-card):not(.message--sticker) .message-content::before {
  content: '' !important;
  display: block !important;
  position: absolute !important;
  width: var(--xam-tail-w) !important;
  height: var(--xam-tail-h) !important;
  right: calc(100% - var(--xam-tail-overlap)) !important;
  left: auto !important;
  bottom: 0 !important;
  box-sizing: border-box !important;
  pointer-events: none !important;
  z-index: 3 !important;
  background-color: var(--msg-peer-bg, #212121) !important;
  background-image: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  opacity: 1 !important;
  transform: none !important;
  -webkit-mask-image: var(--xam-tail-peer-mask) !important;
  mask-image: var(--xam-tail-peer-mask) !important;
  -webkit-mask-size: 100% 100% !important;
  mask-size: 100% 100% !important;
  -webkit-mask-repeat: no-repeat !important;
  mask-repeat: no-repeat !important;
  -webkit-mask-position: right bottom !important;
  mask-position: right bottom !important;
}

.messages-container .message.message--media-card:not(.own).message-bubble-single .message-media-card-shell::after,
.messages-container .message.message--media-card:not(.own).message-bubble-last .message-media-card-shell::after {
  content: '' !important;
  display: block !important;
  position: absolute !important;
  width: var(--xam-tail-w) !important;
  height: var(--xam-tail-h) !important;
  right: calc(100% - var(--xam-tail-overlap)) !important;
  left: auto !important;
  bottom: 0 !important;
  pointer-events: none !important;
  z-index: 3 !important;
  background-color: var(--msg-peer-bg, #212121) !important;
  -webkit-mask-image: var(--xam-tail-peer-mask) !important;
  mask-image: var(--xam-tail-peer-mask) !important;
  -webkit-mask-size: 100% 100% !important;
  mask-size: 100% 100% !important;
  -webkit-mask-repeat: no-repeat !important;
  mask-repeat: no-repeat !important;
  -webkit-mask-position: right bottom !important;
  mask-position: right bottom !important;
}

.message.message-tail-hidden .message-content::after,
.message.message-tail-hidden .message-content::before,
.message.message-tail-hidden .message-media-card-shell::after {
  content: none !important;
  display: none !important;
}

@media (max-width: 768px) {
  :root {
    --xam-tail-w: 14px;
    --xam-tail-h: 15px;
    --xam-tail-overlap: 9px;
  }
}
