/*
 * Tidy messages in direct chats and group chats (owner, 2026-11-26), drawn on top of the older layers.
 * The classes come from assets/olone-chat-tidy.js:
 *   tidy-join-prev / tidy-join-next  messages of one person in a row form one column: the name once at the top,
 *                                    the avatar once at the bottom, 2 px between them;
 *   tidy-inline                      the time sits at the end of the last line of text, not on a line of its own;
 *   tidy-overlay                     a photo, video or sticker without text: no frame, the time lies on top of it.
 */

/* ---------- Runs of one person ---------- */
#messages > .bubble.tidy-join-prev {
  margin-top: -8px !important; /* the list keeps 10 px between messages; inside a run it is 2 px */
}

#messages > .bubble--gc-layout.tidy-join-prev .gc-message-header {
  display: none !important;
}

/* The avatar stands by the last message of the run, at its bottom. */
#messages > .bubble--gc-layout.in .gc-message-item {
  align-items: flex-end !important;
}

#messages > .bubble--gc-layout.in.tidy-join-next .gc-message-avatar {
  visibility: hidden !important;
  height: 0 !important;
}

/* Corners on the side of the speaker get smaller inside a run. */
#messages > .bubble--gc-layout.in.tidy-join-prev .gc-message-bubble,
#messages > .bubble.in:not(.bubble--gc-layout).tidy-join-prev {
  border-top-left-radius: 5px !important;
}

#messages > .bubble--gc-layout.in.tidy-join-next .gc-message-bubble,
#messages > .bubble.in:not(.bubble--gc-layout).tidy-join-next {
  border-bottom-left-radius: 5px !important;
}

#messages > .bubble--gc-layout.out.tidy-join-prev .gc-message-bubble,
#messages > .bubble.out:not(.bubble--gc-layout).tidy-join-prev {
  border-top-right-radius: 5px !important;
}

#messages > .bubble--gc-layout.out.tidy-join-next .gc-message-bubble,
#messages > .bubble.out:not(.bubble--gc-layout).tidy-join-next {
  border-bottom-right-radius: 5px !important;
}

/* ---------- The time at the end of the text ---------- */
#messages .tidy-inline {
  position: relative !important;
}

/* An empty place at the end of the last line, as wide as the time: the text never runs under it. */
#messages .tidy-inline > .bubble-body::after {
  content: "";
  display: inline-block;
  width: var(--tidy-sw, 44px);
  height: 1px;
}

#messages .tidy-inline > .msg-stamp,
#messages .tidy-inline > .meta {
  position: absolute !important;
  right: 10px;
  bottom: var(--tidy-sb, 7px);
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
}

#messages .tidy-inline > .msg-stamp *,
#messages .tidy-inline > .meta * {
  pointer-events: auto;
}

/* ---------- A reply: one line, smaller than the answer ---------- */
#messages .bubble-context--reply {
  padding-top: 3px !important;
  padding-bottom: 3px !important;
  margin-bottom: 4px !important;
}

#messages .bubble-context--reply .bubble-context-snippet {
  display: block;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

/* ---------- A photo, video or sticker without text ---------- */
#messages .tidy-overlay {
  position: relative !important;
  padding: 0 !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

#messages .tidy-overlay::before,
#messages .tidy-overlay::after {
  display: none !important;
}

#messages .tidy-overlay .bubble-media-wrap,
#messages .tidy-overlay .bubble-media-tile,
#messages .tidy-overlay .media-album {
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}

#messages .tidy-overlay .bubble-media-tile,
#messages .tidy-overlay .media-album,
#messages .tidy-overlay .bubble-media-img,
#messages .tidy-overlay .bubble-media-video,
#messages .tidy-overlay .bubble-media-video-box {
  border-radius: 14px !important;
  overflow: hidden;
}

#messages .tidy-overlay > .msg-stamp,
#messages .tidy-overlay > .meta {
  position: absolute !important;
  right: var(--tidy-sr, 8px);
  bottom: var(--tidy-sb, 8px);
  z-index: 2;
  width: auto !important;
  margin: 0 !important;
  padding: 2px 7px !important;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5) !important;
  color: #fff !important;
  pointer-events: none;
}

#messages .tidy-overlay > .msg-stamp *,
#messages .tidy-overlay > .meta * {
  color: #fff !important;
}

/* The place for a photo while it is still on its way: the conversation does not jump when it arrives. */
#messages .bubble-media-wrap.tidy-media-pending:empty {
  display: block;
  width: min(280px, 60vw);
  height: 200px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

/* A message without reactions keeps no empty strip under it (it doubled the space inside a run). */
#messages > .bubble > .reaction-row:not(:has(*)) {
  display: none !important;
}

/* One to three large emoji: no bubble (your own ones kept the blue gradient), the time in a pill under them. */
#messages .tidy-bare {
  padding: 0 !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  border-color: transparent !important;
}

#messages .tidy-bare::before,
#messages .tidy-bare::after {
  display: none !important;
}

#messages .tidy-bare > .msg-stamp,
#messages .tidy-bare > .meta {
  width: max-content !important;
  margin-left: auto !important;
  padding: 2px 7px !important;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42) !important;
  color: #fff !important;
}

/* A reaction under a photo or sticker in a direct chat hangs on the picture's lower edge, like on a bubble. */
#messages > .bubble.tidy-overlay > .reaction-row:has(*) {
  position: relative;
  z-index: 3;
  margin-top: -14px !important;
  margin-left: 6px !important;
}

/* The plain crown mark waits invisible (keeping its place) until the person's own badge is known:
   before, the old outline crown flashed by the name for a moment when a chat opened. */
.premium-crown-inline[data-badge-user]:not([data-badge-applied]) {
  visibility: hidden;
}

/* A chat that is opening stays invisible until its last messages are decrypted and their pictures are in
   (at most 0.9 s, assets/olone-chat-tidy.js), then appears at once, already at the bottom. */
#messages {
  transition: opacity 0.12s ease-out;
}

#messages.tidy-opening {
  opacity: 0 !important;
  transition: none !important;
}
