/* Composer, format toolbar, rich editor, attachments and media preview. */
/* Format toolbar slides up out of the composer when the input is focused. */
.composer-format-slot {
  display: grid;
  grid-template-rows: 0fr;
  flex: none;
  width: 100%;
  min-width: 0;
  opacity: 0;
  pointer-events: none;
  transition:
    grid-template-rows .34s cubic-bezier(.22, .61, .36, 1),
    opacity .26s ease;
}
.composer-format-slot.hidden { display: none !important; }
html.composer-focused .composer-format-slot:not(.hidden),
html.composer-format-hold .composer-format-slot:not(.hidden) {
  grid-template-rows: 1fr;
  opacity: 1;
  pointer-events: auto;
}
.composer-format-slot-inner {
  min-height: 0;
  overflow: hidden;
}
.composer-format {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
  padding: 0 2px 6px;
  margin: 0 0 2px;
  border-bottom: 1px solid rgba(180, 186, 198, 0.45);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  transform: translateY(10px);
  opacity: 0;
  transition:
    transform .34s cubic-bezier(.22, .61, .36, 1),
    opacity .26s ease;
}
.composer-format::-webkit-scrollbar { display: none; }
html.composer-focused .composer-format-slot:not(.hidden) .composer-format,
html.composer-format-hold .composer-format-slot:not(.hidden) .composer-format {
  transform: translateY(0);
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .composer-format-slot,
  .composer-format {
    transition: none !important;
  }
}
.composer-fmt-sep {
  flex: none;
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: rgba(160, 166, 180, 0.55);
}
.composer-fmt-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #5c6270;
  width: 30px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.composer-fmt-btn svg { display: block; width: 17px; height: 17px; }
.composer-fmt-glyph {
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
.composer-fmt-glyph.is-bold { font-weight: 800; }
.composer-fmt-glyph.is-italic { font-style: italic; font-weight: 700; }
.composer-fmt-glyph.is-underline { text-decoration: underline; text-underline-offset: 2px; }
.composer-fmt-glyph.is-strike { text-decoration: line-through; }
@media (hover: hover) {
  .composer-fmt-btn:hover:not(:disabled) {
    color: var(--accent);
    background: rgba(255, 255, 255, 0.45);
  }
}
.composer-fmt-btn:active:not(:disabled) { color: var(--accent); }
.composer-fmt-btn.is-active:not(:disabled) {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.6);
}
.composer-fmt-btn:disabled { opacity: .4; cursor: default; }
.composer-shell:has(.composer.is-recording) .composer-format-slot { display: none !important; }
/* The attach bar (phone): the paperclip slides it out in the format bar's place. */
html:not(.composer-attach-open) .composer-attach-slot {
  grid-template-rows: 0fr !important; opacity: 0 !important; pointer-events: none !important;
}
html:not(.composer-attach-open) .composer-attach-slot .composer-format { transform: translateY(10px) !important; opacity: 0 !important; }
html.composer-attach-open .composer-attach-slot {
  grid-template-rows: 1fr; opacity: 1; pointer-events: auto;
}
html.composer-attach-open .composer-attach-slot .composer-format { transform: translateY(0); opacity: 1; }
html.composer-attach-open #composer-format-slot {
  grid-template-rows: 0fr !important; opacity: 0 !important; pointer-events: none !important;
}
.composer-attach-bar { justify-content: space-around; gap: 4px; padding-bottom: 6px; }
/* The label under the icon: three always fit, whatever the text size. */
.composer-attach-src {
  appearance: none; border: 0; background: transparent; color: #4b5160;
  flex: 1 1 0; min-width: 0; padding: 4px 2px; border-radius: 12px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: inherit; font-size: 12px; font-weight: 600; line-height: 1.2; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.composer-attach-src svg { width: 24px; height: 24px; flex: none; }
.composer-attach-src span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-attach-src:active { color: var(--accent); background: rgba(255, 255, 255, 0.55); }
.attach-btn.is-active { color: var(--accent); }
.composer {
  display: flex; align-items: flex-end; gap: 6px; border: none; border-radius: 0; padding: 0; background: transparent;
  min-width: 0; width: 100%;
}
.msg-body .md-bold { font-weight: 700; }
.msg-body .md-italic { font-style: italic; }
.msg-body .md-underline { text-decoration: underline; text-underline-offset: 2px; }
.msg-body .md-strike { text-decoration: line-through; }
.msg-body .md-h {
  display: block;
  font-size: 1.15em;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 2px;
}
.msg-body .md-quote {
  display: block;
  margin: 2px 0;
  padding: 2px 0 2px 8px;
  border-left: 3px solid var(--accent);
  color: inherit;
  opacity: .92;
}
.msg-body .md-li {
  display: block;
  padding-left: 0.2em;
}
.msg-body .md-pre {
  display: block;
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .06);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.attach-btn, .emoji-btn, .media-btn, .send {
  width: var(--chrome-icon-btn); height: var(--chrome-icon-btn); border: none; border-radius: 4px; background: transparent;
  color: #8b8e98; display: grid; place-items: center; flex: none; padding: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .attach-btn:hover:not(:disabled), .emoji-btn:hover:not(:disabled),
  .media-btn:hover:not(:disabled):not(.is-armed):not(.is-recording),
  .send:hover:not(:disabled) {
    color: var(--accent);
    background: transparent;
  }
}
.attach-btn:active:not(:disabled), .emoji-btn:active:not(:disabled),
.media-btn:active:not(:disabled):not(.is-armed):not(.is-recording),
.send:active:not(:disabled) {
  color: var(--accent);
  background: transparent;
}
.attach-btn:disabled, .emoji-btn:disabled, .media-btn:disabled { opacity: .45; cursor: default; }
.attach-btn svg, .emoji-btn svg, .media-btn svg, .send svg {
  width: var(--chrome-icon-svg); height: var(--chrome-icon-svg); display: block;
}
.composer-tools { position: relative; display: flex; align-items: flex-end; gap: 4px; flex: none; z-index: 4; overflow: visible; }
.emoji-picker {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 20;
  width: min(320px, calc(100vw - 32px)); max-height: min(300px, 45vh);
  display: flex; flex-direction: column; overflow: hidden;
  padding: 0; background: #fff; border: 1px solid #e4e7ec; border-radius: 12px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, .16);
}
.emoji-picker.hidden { display: none !important; }
.emoji-picker-tabs {
  display: flex; gap: 2px; flex: none; padding: 6px 6px 4px;
  border-bottom: 1px solid #eef0f4; overflow-x: auto;
  scrollbar-width: none;
}
.emoji-picker-tabs::-webkit-scrollbar { display: none; }
.emoji-picker-tab {
  flex: none; width: 32px; height: 32px; border: none; border-radius: 8px;
  background: transparent; color: #5c6270; font-size: 16px; line-height: 1;
  cursor: pointer; padding: 0; display: grid; place-items: center;
}
.emoji-picker-tab-img { width: 22px; height: 22px; object-fit: contain; image-rendering: auto; }
.emoji-picker-tab:hover { background: #f3f5f8; }
.emoji-picker-tab.active { background: var(--accent-soft); color: var(--accent); }
.emoji-picker-body {
  flex: 1; min-height: 0; overflow: auto; padding: 6px 8px 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  align-content: start;
}
.emoji-picker-body.is-icq {
  grid-template-columns: repeat(6, 1fr);
}
.emoji-picker-title {
  grid-column: 1 / -1; font-size: 12px; font-weight: 600; color: #8b8e98;
  padding: 4px 2px 6px; letter-spacing: .02em;
}
.emoji-picker-empty {
  grid-column: 1 / -1; color: #8b8e98; font-size: 13px; padding: 18px 8px; text-align: center;
}
.emoji-picker-item {
  width: 100%; aspect-ratio: 1; border: none; border-radius: 8px; background: transparent;
  font-size: 28px; line-height: 1; cursor: pointer; padding: 0;
  display: grid; place-items: center;
  -webkit-text-size-adjust: 100%;
}
.emoji-picker-item.is-icq { padding: 4px; }
.emoji-picker-item.is-icq img.icq-smiley { width: 32px; height: 32px; }
.emoji-picker-item.is-text {
  aspect-ratio: auto; min-height: 36px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600; color: #3f4350; padding: 6px 4px;
}
.emoji-picker-item:hover, .emoji-picker-item:focus-visible,
.emoji-picker-tab:focus-visible { background: var(--accent-soft); outline: none; }
.icq-smiley {
  width: 28px; height: 28px; vertical-align: -6px; display: inline-block;
  object-fit: contain; margin: 0 1px;
}
.icq-smiley.large {
  width: 48px; height: 48px; vertical-align: bottom; margin: 0 2px;
}
.msg.emoji-only .msg-body.icq-only {
  font-size: inherit; letter-spacing: 0; line-height: 1;
  display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-end;
}
.msg.emoji-only.emoji-1 .msg-body.icq-only .icq-smiley.large { width: 60px; height: 60px; }
.msg.emoji-only.emoji-2 .msg-body.icq-only .icq-smiley.large { width: 48px; height: 48px; }
.msg.emoji-only.emoji-3 .msg-body.icq-only .icq-smiley.large { width: 40px; height: 40px; }
.composer-fields {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 6px;
  align-self: stretch;
}
/* Picked files: a single strip across the composer (like Telegram's), swiped
   sideways — however many there are, it stays one row. */
.attach-preview {
  display: flex; align-items: flex-start; min-width: 0; width: 100%;
  margin: 0 0 6px;
}
.attach-preview.hidden { display: none !important; }
.attach-preview-list {
  display: flex; flex-wrap: nowrap; gap: 8px; width: 100%; min-width: 0;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  /* room for the × that sits over each thumbnail's corner */
  padding: 8px 8px 2px 2px;
  scroll-snap-type: x proximity;
}
.attach-preview-list::-webkit-scrollbar { display: none; }
.attach-preview-item { scroll-snap-align: start; }
.attach-preview-item { flex: none; max-width: 80%; }
.attach-preview-item.is-image { flex: none; }
.attach-preview-file {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; width: 100%;
  background: #f3f5f8; border-radius: 6px; font-size: 13px; color: #3f4350;
  max-width: 280px;
}
.attach-preview-ico { flex: none; }
.attach-preview-name {
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-preview-thumb-wrap {
  position: relative; flex: none; width: 72px; height: 72px;
  border-radius: 10px; overflow: visible;
}
.attach-preview-thumb {
  display: block; width: 72px; height: 72px; object-fit: cover;
  border-radius: 10px; background: #e8eaee; border: 1px solid rgba(0,0,0,.06);
}
.attach-preview-clear {
  appearance: none; border: 0; background: transparent; color: #8b8e98;
  font-size: 18px; line-height: 1; padding: 0 2px; cursor: pointer; flex: none;
}
.attach-preview-clear:hover { color: #d24b4e; }
.attach-preview-clear-thumb {
  position: absolute; top: -6px; right: -6px; z-index: 1;
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  background: #9aa0a8; color: #fff; font-size: 14px; line-height: 20px;
  text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.attach-preview-clear-thumb:hover { background: #d24b4e; color: #fff; }
/* A video in the composer: its first frame, with a play mark. */
.attach-preview-thumb-wrap.is-video .attach-preview-thumb { background: #1b2236; }
.attach-preview-play {
  position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; transform: translate(-50%, -50%);
  border-radius: 50%; background: rgba(10, 14, 30, .55); pointer-events: none;
}
.attach-preview-play::after {
  content: ""; position: absolute; left: 10px; top: 7px;
  border-style: solid; border-width: 6px 0 6px 9px; border-color: transparent transparent transparent #fff;
}
.composer textarea,
.composer .composer-rich {
  flex: 1 1 auto; width: 100%; min-width: 0; max-width: 100%;
  border: none; resize: none; font-size: calc(15px * var(--text-scale, 1)); line-height: 1.4;
  padding: 6px 4px; outline: none; background: transparent;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  overflow-x: hidden; overflow-y: hidden;
  min-height: calc(1.4em + 12px);
  height: calc(1.4em + 12px);
  max-height: min(calc(1.4em * 8 + 12px), var(--composer-max-h, 9999px));
  box-sizing: border-box;
  text-align: left;
  /* Grow with content where supported; JS mirror covers iOS Safari. */
  field-sizing: content;
  -webkit-overflow-scrolling: auto;
}
/* Rich composer (composer-rich.js): a contenteditable stand-in for the textarea.
   Each line is a .cl element; block styles mirror .msg-body .md-* so the draft looks
   like the sent message. */
.composer .composer-rich {
  position: relative;
  display: block;
  cursor: text;
  /* Same ink as the textarea it replaces (form controls do not inherit color). */
  color: fieldtext;
  caret-color: fieldtext;
  -webkit-user-select: text;
  user-select: text;
  tab-size: 4;
}
.composer .composer-rich.is-disabled { cursor: default; }
.composer .composer-rich.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  left: 4px; right: 4px; top: 6px;
  color: #757575;
  pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.composer-rich .cl { min-height: 1.4em; }
.composer-rich b, .composer-rich strong { font-weight: 700; }
.composer-rich i, .composer-rich em { font-style: italic; }
.composer-rich u { text-decoration: underline; text-underline-offset: 2px; }
.composer-rich s, .composer-rich strike, .composer-rich del { text-decoration: line-through; }
.composer-rich u s, .composer-rich s u, .composer-rich u strike, .composer-rich strike u {
  text-decoration: underline line-through;
}
.composer-rich a { color: var(--accent); text-decoration: underline; cursor: text; }
.composer-rich 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;
}
.composer-rich .cl[data-b="h"] { font-size: 1.15em; font-weight: 700; line-height: 1.3; min-height: 1.3em; }
.composer-rich .cl[data-b="q"] {
  padding-left: 8px;
  border-left: 3px solid var(--accent);
  opacity: .92;
}
.composer-rich .cl[data-b="ul"],
.composer-rich .cl[data-b="ol"] { padding-left: 0.2em; }
.composer-rich .cl[data-b="ul"]::before { content: "\2022\00a0"; }
.composer-rich .cl[data-b="ol"]::before { content: attr(data-n) ".\00a0"; }
.composer-rich .cl[data-b="code"] {
  padding: 0 10px;
  background: rgba(0, 0, 0, .06);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
}
.composer-rich .cl[data-b="code"]:not(.cl[data-b="code"] + .cl) {
  margin-top: 4px; padding-top: 6px; border-radius: 8px 8px 0 0;
}
.composer-rich .cl[data-b="code"]:not(:has(+ .cl[data-b="code"])) {
  margin-bottom: 4px; padding-bottom: 6px; border-radius: 0 0 8px 8px;
}
.composer-rich .cl[data-b="code"]:not(.cl[data-b="code"] + .cl):not(:has(+ .cl[data-b="code"])) {
  border-radius: 8px;
}
.send {
  position: relative;
  color: var(--accent);
  overflow: visible;
}
.send-chevrons { display: block; overflow: visible; width: 26px; height: 26px; }
.send-chev-1 { opacity: 1; }
.send-chev-2 { opacity: .9; }
.send-chev-3 { opacity: .72; }
.send:disabled { cursor: default; }
.send:disabled .send-chev-1 { opacity: .88; }
.send:disabled .send-chev-2 { opacity: .72; }
.send:disabled .send-chev-3 { opacity: .55; }
html.is-reconnecting .send .send-chevrons { visibility: hidden; }

.reconnect-indicator {
  position: fixed;
  z-index: 10050;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  pointer-events: none;
  margin: 0;
  padding: 0;
  /* Keep bubble visible above the indicator (not clipped by ancestors). */
  overflow: visible;
}
.reconnect-indicator.hidden { display: none !important; }
.reconnect-indicator .send-satellite {
  display: block;
  width: 26px;
  height: 26px;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  animation: send-sat-blink 1.05s ease-in-out infinite;
}
@keyframes send-sat-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.28; }
}
.send-reconnect-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  width: 72px;
  height: 22px;
  padding: 0;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.96);
  border: none;
  border-radius: 999px;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
}
.send-reconnect-marquee {
  display: block;
  height: 100%;
  width: max-content;
  max-width: none;
  white-space: nowrap;
  will-change: transform;
  /* One full pass: enter from the right, exit left — then JS picks the next phrase. */
  transform: translateX(72px);
  animation: none;
}
.send-reconnect-marquee.is-running {
  animation-name: send-reconnect-marquee;
  animation-timing-function: linear;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}
.send-reconnect-text {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #1a1d26;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
@keyframes send-reconnect-marquee {
  from { transform: translateX(72px); }
  to { transform: translateX(calc(-100%)); }
}
.media-btn {
  touch-action: none; user-select: none; -webkit-user-select: none;
  position: relative;
}
/* Invisible expanded hit area — especially important on iOS near the home indicator. */
.media-btn::before {
  content: "";
  position: absolute;
  top: -10px;
  right: -8px;
  bottom: -12px;
  left: -8px;
}
.media-btn.hidden, .send.hidden { display: none !important; }
.media-btn.is-armed, .media-btn.is-recording {
  color: #e25555; background: rgba(226, 85, 85, .1);
}
.media-btn-icon { display: grid; place-items: center; }
.media-btn-icon.hidden { display: none !important; }
.composer.is-recording .composer-fields,
.composer.is-recording .attach-btn,
.composer.is-recording .composer-tools { display: none !important; }
.voice-record-bar {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 2px;
}
.voice-record-bar.hidden { display: none !important; }
.voice-record-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #e25555; flex: none;
  animation: voice-pulse 1.1s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.85); }
}
.voice-record-time {
  font-size: 15px; font-variant-numeric: tabular-nums; color: #1f2430; font-weight: 600; flex: none;
}
.voice-record-hint { flex: 1; font-size: 13px; color: #8b8e98; }
.msg-file {
  display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; padding: 8px 10px;
  background: rgba(0,0,0,.05); border-radius: 8px; text-decoration: none; color: inherit; max-width: 100%;
}
.msg.mine .msg-file { background: rgba(255,255,255,.4); }
.msg-file:hover { background: rgba(0,0,0,.08); }
.msg-file-ico { flex: none; color: var(--accent); font-size: 16px; }
.msg-file-name {
  flex: 1; min-width: 0; font-size: calc(14px * var(--text-scale, 1)); color: var(--accent); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-file-size { flex: none; font-size: calc(12px * var(--text-scale, 1)); color: #8b8e98; }
.msg-image {
  /* No % here: a % max-width is left out when the bubble works out its width,
     so a wide photo would make the bubble wider than the picture. */
  display: block; max-width: min(320px, var(--msg-media-max, 72vw)); max-height: 280px; border-radius: 8px;
  margin: 2px 0; object-fit: contain; background: rgba(0,0,0,.04);
  box-shadow: 0 0 0 1px rgba(16, 24, 40, .12);
}
.msg.image-only .msg-bubble {
  position: relative;
  padding: 0;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}
.msg.mine.image-only .msg-bubble {
  background: transparent;
  box-shadow: none;
}
.msg.image-only .msg-body {
  display: flex; flex-wrap: wrap; gap: 2px;
  margin: 0;
}
.msg.image-only .msg-image {
  margin: 0;
  border-radius: 12px;
  max-width: 100%;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, .14);
}
.msg.image-only.image-many .msg-image {
  max-width: calc(50% - 1px);
  max-height: 180px;
  object-fit: cover;
  flex: 1 1 calc(50% - 1px);
  border-radius: 8px;
}
.msg.image-only.image-many .msg-image:first-child { border-top-left-radius: 12px; }
.msg.image-only.image-many .msg-image:nth-child(2) { border-top-right-radius: 12px; }
.msg.image-only .msg-receipt {
  --receipt-muted: rgba(255, 255, 255, .4);
  --receipt-blue: #fff;
}
.msg.image-only .msg-receipt.is-sent .msg-receipt-chev { color: var(--receipt-muted); }
.msg.image-only .msg-receipt.is-delivered .msg-receipt-chev:first-child { color: var(--receipt-blue); }
.msg.image-only .msg-receipt.is-delivered .msg-receipt-chev:last-child { color: var(--receipt-muted); }
.msg.image-only .msg-receipt.is-read .msg-receipt-chev { color: var(--receipt-blue); }
.msg.image-only.mentions-me .msg-bubble { box-shadow: none; }
.image-viewer {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 16px;
}
.image-viewer.hidden { display: none !important; }
.image-viewer-backdrop {
  position: absolute; inset: 0; background: rgba(10, 14, 22, .82);
}
.image-viewer-stage {
  position: relative; z-index: 1; flex: 1; min-height: 0; width: 100%;
  display: grid; place-items: center; pointer-events: none;
}
.image-viewer-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  pointer-events: none;
}
.image-viewer-download {
  position: absolute; top: 0; right: 0; z-index: 2;
  transform: translateY(calc(-100% - 8px));
  display: inline-flex; align-items: center; gap: 8px;
  appearance: none; border: 0; background: transparent;
  color: #fff; font: inherit; font-size: 15px; font-weight: 600;
  padding: 0; cursor: pointer; text-shadow: 0 1px 2px rgba(0,0,0,.35);
  pointer-events: auto; white-space: nowrap;
}
.image-viewer-download:hover { opacity: .88; }
.image-viewer-download svg { display: block; flex: none; }
.image-viewer-attach-actions {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  pointer-events: auto;
}
.image-viewer-attach-actions.hidden { display: none !important; }
.image-viewer-attach-btn {
  appearance: none; border: 0; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; padding: 0;
  background: rgba(26, 29, 38, .72); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
  backdrop-filter: blur(6px);
}
.image-viewer-attach-btn:hover { background: rgba(26, 29, 38, .9); }
.image-viewer-attach-btn svg { display: block; }
.image-viewer.is-attach .image-viewer-download { display: none !important; }
.image-viewer.is-attach .image-viewer-frame { pointer-events: auto; }
/* The limits are in screen units, not %: a % against the shrink-wrapped frame
   let a wide picture stretch the frame past the picture (the picture then sat
   at its left, «Сохранить» far to the right). */
.image-viewer-img {
  display: block;
  max-width: min(calc(100vw - 32px), 960px); max-height: calc(100vh - 72px);
  object-fit: contain; border-radius: 8px; background: #111;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  pointer-events: auto;
}
.image-viewer-nav {
  display: none; position: absolute; top: 50%; z-index: 4; transform: translateY(-50%);
  appearance: none; border: 0; cursor: pointer; padding: 0;
  width: 44px; height: 44px; border-radius: 50%; place-items: center;
  background: rgba(26, 29, 38, .62); color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.3); backdrop-filter: blur(6px);
  pointer-events: auto;
}
.image-viewer-nav.is-prev { left: 8px; }
.image-viewer-nav.is-next { right: 8px; }
.image-viewer.has-nav .image-viewer-nav { display: grid; }
.image-viewer-nav:disabled { opacity: .3; cursor: default; }
.image-viewer-nav:not(:disabled):hover { background: rgba(26, 29, 38, .85); }
.image-viewer-counter {
  display: none; position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 4; padding: 4px 12px; border-radius: 999px;
  background: rgba(26, 29, 38, .62); color: #fff; font-size: 14px; font-weight: 600;
  pointer-events: none; font-variant-numeric: tabular-nums;
}
.image-viewer.has-nav .image-viewer-counter { display: block; }
/* The image takes all touches: one finger swipes or drags, two pinch-zoom (18-image-tools.js). */
.image-viewer-img { touch-action: none; transform-origin: center center; will-change: transform; }
.image-viewer.is-zoomed .image-viewer-img { cursor: grab; border-radius: 0; box-shadow: none; }
.image-viewer.is-zoomed .image-viewer-nav,
.image-viewer.is-zoomed .image-viewer-counter { opacity: 0; pointer-events: none; }
/* The caption under an image being sent: our composer's look (glass shell, the
   chevrons), the text centred in it. */
.image-viewer-caption {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 5;
  width: min(100%, 560px); box-sizing: border-box;
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 14px; min-height: 52px;
  border-radius: 16px; background: rgba(226, 238, 250, .94); color: #1a1d26;
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .28); backdrop-filter: blur(12px); pointer-events: auto;
}
.image-viewer-caption.hidden { display: none !important; }
.image-viewer-caption textarea {
  flex: 1; min-width: 0; border: 0 !important; outline: 0 !important; resize: none;
  background: transparent !important; box-shadow: none !important; border-radius: 0;
  font: inherit; font-size: 16px; line-height: 22px; color: inherit;
  padding: 7px 0; min-height: 22px; max-height: 120px; box-sizing: content-box; align-self: center;
}
.image-viewer-caption textarea::placeholder { color: #7a8394; line-height: 22px; }
.image-viewer-caption-send {
  appearance: none; border: 0; cursor: pointer; flex: none; padding: 0;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: transparent; color: var(--accent, #3b82f6); overflow: visible;
}
.image-viewer.is-attach .image-viewer-stage { padding-bottom: 64px; box-sizing: border-box; }
.image-viewer.is-compact .image-viewer-img {
  max-width: min(86vw, 520px);
  max-height: min(70vh, 640px);
}
.image-editor {
  position: fixed; inset: 0; z-index: 85; display: flex; flex-direction: column;
  align-items: stretch; justify-content: stretch;
  background: #0c1018;
}
.image-editor.hidden { display: none !important; }
.image-editor-backdrop {
  position: absolute; inset: 0; background: #0c1018; z-index: 0;
}
.image-editor-stage {
  position: relative; z-index: 1; flex: 1; min-height: 0;
  display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(20px, var(--sab));
  overflow: hidden; touch-action: none;
}
.image-editor-work {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 20px;
  width: fit-content;
  max-width: 100%; max-height: 100%;
  min-width: 0;
}
.image-editor-frame {
  position: relative;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  line-height: 0;
}
.image-editor-canvas {
  display: block;
  max-width: min(100vw - 32px, 960px);
  max-height: calc(100vh - 160px);
  width: auto; height: auto;
  border-radius: 8px; background: #111;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  touch-action: none; cursor: default;
}
.image-editor.is-draw .image-editor-canvas { cursor: crosshair; }
.image-editor-crop {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
}
.image-editor-crop:not(.hidden) { pointer-events: auto; }
.image-editor-crop-shade {
  position: absolute; background: rgba(0,0,0,.45); pointer-events: none;
}
.image-editor-crop-box {
  position: absolute; box-sizing: border-box;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
  cursor: move; touch-action: none;
}
.image-editor-crop-handle {
  position: absolute; width: 14px; height: 14px; border-radius: 3px;
  background: #fff; border: 1px solid rgba(0,0,0,.2);
  transform: translate(-50%, -50%); touch-action: none;
}
.image-editor-crop-handle[data-handle="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.image-editor-crop-handle[data-handle="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.image-editor-crop-handle[data-handle="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.image-editor-crop-handle[data-handle="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.image-editor-crop-handle[data-handle="n"] { left: 50%; top: 0; cursor: ns-resize; }
.image-editor-crop-handle[data-handle="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.image-editor-crop-handle[data-handle="w"] { left: 0; top: 50%; cursor: ew-resize; }
.image-editor-crop-handle[data-handle="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.image-editor-crop-handle.is-edge {
  width: 22px; height: 6px; border-radius: 3px;
}
.image-editor-crop-handle.is-edge[data-handle="w"],
.image-editor-crop-handle.is-edge[data-handle="e"] {
  width: 6px; height: 22px;
}
.image-editor-dock {
  position: relative; z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: max-content;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0;
  flex: none;
}
.image-editor-bar-btn {
  appearance: none; border: 0; background: transparent; color: #fff;
  font: inherit; font-size: 18px; font-weight: 650; letter-spacing: .01em;
  padding: 12px 4px; cursor: pointer;
  white-space: nowrap; flex: none; line-height: 1.2;
}
.image-editor-bar-btn.is-primary { color: var(--accent, #3b82f6); }
.image-editor-tools-cluster {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; flex: none;
}
.image-editor-toolbar {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 12px; border-radius: 999px;
  background: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.28);
}
.image-editor-tool {
  appearance: none; border: 0; background: transparent; color: #1a1d26;
  width: 52px; height: 48px; border-radius: 999px; cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.image-editor-tool:hover { background: #f2f4f7; }
.image-editor-tool.is-active {
  background: color-mix(in srgb, var(--accent, #3b82f6) 16%, #fff);
  color: var(--accent, #3b82f6);
}
.image-editor-tool svg { display: block; width: 26px; height: 26px; }
.image-editor-palette {
  display: inline-flex; flex-direction: row; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 999px;
  background: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.28);
}
.image-editor-palette.hidden { display: none !important; }
.image-editor-palette-row {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.image-editor-palette-row.hidden { display: none !important; }
.image-editor-history-btn {
  appearance: none; border: 0; cursor: pointer; padding: 0;
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: #fff; color: #1a1d26; box-shadow: 0 8px 28px rgba(0,0,0,.28);
}
.image-editor-history-btn:disabled { opacity: .45; cursor: default; }
.image-editor-history-btn:not(:disabled):active { background: #f2f4f7; }
.image-editor-color {
  appearance: none; border: 1px solid #d8dbe3; width: 30px; height: 30px;
  border-radius: 8px; cursor: pointer; padding: 2px; box-sizing: border-box;
  background:
    linear-gradient(var(--editor-swatch, #1a1d26), var(--editor-swatch, #1a1d26)) content-box,
    #fff;
}
.image-editor-color.is-active {
  border-color: #1a1d26;
  box-shadow: 0 0 0 2px color-mix(in srgb, #1a1d26 28%, transparent);
}
.image-editor-color.is-light {
  border-color: #c5c8ce;
}
.msg-voice {
  display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; min-width: 180px; max-width: 280px;
}
.msg-voice-play {
  width: 36px; height: 36px; border: none; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.msg.mine .msg-voice-play { background: rgba(0,0,0,.55); }
.msg-voice-play svg { width: 18px; height: 18px; display: block; }
.msg-voice-wave {
  flex: 1; display: flex; align-items: center; gap: 2px; height: 28px; min-width: 0;
}
.msg-voice-bar {
  width: 3px; border-radius: 2px; background: rgba(0,0,0,.22); flex: none;
  transition: background .15s ease;
}
.msg.mine .msg-voice-bar { background: rgba(0,0,0,.28); }
.msg-voice-bar.on { background: var(--accent); }
.msg.mine .msg-voice-bar.on { background: rgba(0,0,0,.65); }
.msg-voice-time {
  flex: none; font-size: calc(12px * var(--text-scale, 1)); color: #8b8e98; font-variant-numeric: tabular-nums; min-width: 2.4em;
}
.msg-video-note {
  position: relative; width: 200px; height: 200px; margin: 4px 0 2px;
  border-radius: 50%; overflow: hidden; cursor: pointer; background: #111;
  box-shadow: 0 0 0 2px rgba(0,0,0,.06);
}
.msg-video-note video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform: scaleX(-1);
}
.msg-video-note-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,.28); color: #fff; pointer-events: none;
  transition: opacity .15s ease;
}
.msg-video-note.is-playing .msg-video-note-play { opacity: 0; }
.msg-video-note.is-broken .msg-video-note-play {
  opacity: 1;
  background: rgba(0,0,0,.45);
  font-size: 28px;
  font-weight: 700;
}
.msg-video-note-play svg { width: 42px; height: 42px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
.msg-video-note-dur {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.55);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.circle-record {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  pointer-events: none;
}
.circle-record.hidden { display: none !important; }
.circle-record-backdrop {
  position: absolute; inset: 0; background: rgba(12, 16, 24, .72); backdrop-filter: blur(6px);
}
.circle-record-panel {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 18px;
  width: min(100%, 360px);
}
.circle-record-stage {
  position: relative; width: min(72vw, 280px); height: min(72vw, 280px);
}
.circle-record-video {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  background: #1a1f2a; transform: scaleX(-1); display: block;
}
.circle-record-ring {
  position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid #e25555; pointer-events: none;
  animation: voice-pulse 1.1s ease-in-out infinite;
}
.circle-record-meta {
  display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff;
}
.circle-record-time {
  font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.circle-record-hint { font-size: 13px; color: rgba(255,255,255,.72); }
.media-preview {
  position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 24px;
}
.media-preview.hidden { display: none !important; }
.media-preview-backdrop {
  position: absolute; inset: 0; background: rgba(12, 16, 24, .72); backdrop-filter: blur(6px);
}
.media-preview-panel {
  position: relative; z-index: 1; width: min(100%, 360px);
  background: #fff; border-radius: 16px; padding: 20px 18px 16px;
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
/* Circle preview: no white card — just the circle over the dimmed backdrop. */
.media-preview.is-circle .media-preview-panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 12px 8px;
}
.media-preview-body {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.media-preview-voice {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.media-preview-voice audio { width: 100%; }
.media-preview-label {
  font-size: 14px; font-weight: 600; color: #1f2430; text-align: center;
}
.media-preview.is-circle .media-preview-label {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
}
.media-preview-circle {
  width: min(70vw, 240px); height: min(70vw, 240px); border-radius: 50%; overflow: hidden;
  background: #111; box-shadow: 0 0 0 2px rgba(255, 255, 255, .22);
}
.media-preview-circle video {
  width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1);
}
.media-preview-actions {
  display: flex; gap: 10px; width: 100%;
}
.media-preview-actions .btn { flex: 1; }
/* Circle actions: muted gray default, white + blue accent on hover/press. */
.media-preview.is-circle .media-preview-actions .btn,
.media-preview.is-circle .media-preview-actions .btn.primary {
  background: #95a0ba;
  color: #fff;
  border: 1px solid transparent;
  box-shadow: none;
}
.media-preview.is-circle .media-preview-actions .btn:hover,
.media-preview.is-circle .media-preview-actions .btn:focus-visible,
.media-preview.is-circle .media-preview-actions .btn:active,
.media-preview.is-circle .media-preview-actions .btn.primary:hover,
.media-preview.is-circle .media-preview-actions .btn.primary:focus-visible,
.media-preview.is-circle .media-preview-actions .btn.primary:active {
  background: #fff;
  color: var(--accent, #1c58d9);
  border-color: #d0d5e0;
}
.composer-hint { display: none !important; }

.rhs {
  width: 280px;
  background: var(--glass-panel-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border-left: var(--glass-border);
  display: flex; flex-direction: column; min-height: 0;
}
.rhs.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; left: auto; width: 380px; max-width: 100%;
  background: var(--glass-panel-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  color: var(--text-strong); z-index: 25;
  box-shadow: -12px 0 32px rgba(0,0,0,.08);
}


/* —— Phones: the image viewer and editor fit the screen. —— */
html.capacitor-android .image-viewer,
html.capacitor-android .image-editor-stage {
  padding-top: calc(max(16px, var(--sat)) + 34px);
}
@media (max-width: 640px) {
  .image-viewer { padding: calc(max(12px, env(safe-area-inset-top, 0px)) + 30px) 10px max(12px, var(--sab)); }
  .image-viewer-caption { width: 100%; }
  .image-editor-stage { padding-left: 10px; padding-right: 10px; }
  .image-editor-work { gap: 12px; width: 100%; }
  .image-editor-canvas, .image-editor-frame { max-height: calc(100vh - 230px); }
  .image-editor-canvas { max-width: calc(100vw - 20px); }
  /* Cancel and Done on one line under the tools, the tools across the width. */
  .image-editor-dock {
    width: 100%; flex-wrap: wrap; justify-content: space-between; gap: 10px 8px;
  }
  .image-editor-tools-cluster { order: -1; flex: 1 1 100%; gap: 8px; min-width: 0; }
  .image-editor-bar-btn { font-size: 16px; padding: 8px 6px; }
  .image-editor-toolbar { padding: 4px 8px; gap: 2px; }
  .image-editor-tool { width: 44px; height: 40px; }
  .image-editor-tool svg { width: 22px; height: 22px; }
  .image-editor-palette-row { gap: 6px; max-width: 100%; }
  .image-editor-palette { gap: 6px; padding: 6px 8px; min-width: 0; flex-wrap: wrap; justify-content: center; }
  .image-editor-color { width: 26px; height: 26px; border-radius: 7px; }
  .image-editor-history-btn { width: 36px; height: 36px; }
  .image-editor-history-btn svg { width: 18px; height: 18px; }
}

/* «@» in the composer: the chat's members to pick from, above the input. */
.mention-picker {
  position: fixed; z-index: 70; max-height: 50vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 6px;
  border-radius: 14px; background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid rgba(216, 216, 220, 0.8); box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
}
.mention-picker.hidden { display: none; }
.mention-pick {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px;
  border: 0; border-radius: 10px; background: transparent; color: #1f2430;
  font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.mention-pick.is-active, .mention-pick:hover { background: var(--accent-soft); }
.mention-pick-avatar { width: 30px; height: 30px; min-width: 30px; border-radius: 50%; font-size: 12px; }
.mention-pick-text { min-width: 0; display: flex; flex-direction: column; }
.mention-pick-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-pick-login { font-size: 13px; color: #6b7080; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The emoji under the pointer plays (30-anim-emoji.js): over its cell, a little
   bigger; the glyph hides while the animation is on. */
.emoji-picker-item { position: relative; }
.emoji-picker-glyph { display: block; transition: opacity .1s ease; }
.emoji-picker-item.is-animating .emoji-picker-glyph { opacity: 0; }
.emoji-pick-play {
  position: absolute; inset: -12%; pointer-events: none; opacity: 0; transition: opacity .1s ease;
}
.emoji-pick-play.is-on { opacity: 1; }
.emoji-pick-play svg, .emoji-pick-pop svg { display: block; width: 100% !important; height: 100% !important; }
/* Touch: the one under the finger, big, above it. */
.emoji-pick-pop {
  position: fixed; z-index: 10050; pointer-events: none;
  border-radius: 22px; padding: 6px; box-sizing: border-box;
  background: var(--glass-tools-bg, rgba(255, 255, 255, .92));
  -webkit-backdrop-filter: blur(var(--glass-blur, 16px)); backdrop-filter: blur(var(--glass-blur, 16px));
  box-shadow: 0 12px 30px rgba(20, 32, 51, .2);
  opacity: 0; transform: translateY(8px) scale(.8); transform-origin: 50% 100%;
  transition: opacity .14s ease, transform .18s cubic-bezier(.2, .8, .3, 1.2);
}
.emoji-pick-pop.is-on { opacity: 1; transform: none; }

/* The row is a size container: media may take the message's 78 % less the
   bubble's padding — in cqw, which (unlike %) counts in the bubble's width. */
.msg { container-type: inline-size; --msg-media-max: calc(78cqw - 20px); }
/* Media + caption: the caption doesn't widen the bubble, it wraps to the media. */
.msg-body.has-media > .msg-caption { width: 0; min-width: 100%; }
/* «Аа»: a voice message / video note as text (32-stt.js). */
.msg-stt-btn {
  flex: none; display: inline-flex; align-items: center; height: auto; min-width: 0;
  padding: 2px 7px; border: 0; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: calc(11px * var(--text-scale, 1)); line-height: 1; letter-spacing: .2px;
  color: #fff;
  /* The same dark pill as the time next to it. */
  background: color-mix(in srgb, color-mix(in srgb, var(--pill-color, #1a1d26) 28%, #1a1d26) calc(var(--pill-opacity, 0.55) * 100%), transparent);
  transition: filter .15s ease, background .15s ease;
}
.msg-stt-btn:hover { filter: brightness(1.25); }
.msg-stt-btn.is-open { background: color-mix(in srgb, var(--accent, #2f6fd6) 80%, transparent); }
.msg-stt-btn.is-busy { animation: msg-stt-busy 1s ease-in-out infinite; }
@keyframes msg-stt-busy { 50% { opacity: .45; } }
.msg-meta-end { display: inline-flex; align-items: center; gap: 4px; margin-right: auto; }
.msg.mine .msg-meta-end { margin-left: auto; margin-right: 0; }
.msg-meta-end > .msg-foot { margin: 0; }
.msg-stt-row { display: flex; margin-top: 4px; }
.msg-stt-text {
  margin-top: 6px; padding: 8px 10px; border-radius: 10px;
  background: rgba(20, 32, 51, .05); border-left: 3px solid color-mix(in srgb, var(--accent, #2f6fd6) 55%, transparent);
  font-size: calc(14px * var(--text-scale, 1)); line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-stt-text.hidden { display: none; }
.msg-stt-text.is-waiting, .msg-stt-text.is-empty { opacity: .65; font-style: italic; }
/* —— Emoji packs (34-emoji-packs.js) —— */
img.pack-emoji { cursor: pointer; }
.emoji-picker-item.is-pack img.pack-emoji { cursor: inherit; width: 32px; height: 32px; }
.emoji-picker-tab.is-pack .emoji-picker-tab-img { object-fit: contain; }
.pack-emoji-missing { color: #8b8e98; font-size: .9em; }
/* A click on a pack picture in a message: the pack and «Добавить себе». */
.emoji-pack-pop {
  position: fixed; z-index: 1300; width: min(300px, calc(100vw - 16px)); box-sizing: border-box;
  padding: 12px; border-radius: 14px; background: #fff; border: 1px solid #e6e8ee;
  box-shadow: 0 12px 36px rgba(16, 24, 40, .18); display: flex; flex-direction: column; gap: 10px;
  animation: emoji-pack-pop-in .16s cubic-bezier(.2, .8, .3, 1);
}
@keyframes emoji-pack-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.97); } }
.emoji-pack-pop-loading { padding: 8px; text-align: center; color: #6b7080; }
.emoji-pack-pop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.emoji-pack-pop-head strong { font-size: calc(14px * var(--text-scale, 1)); color: #1a1d26; overflow-wrap: anywhere; }
.emoji-pack-pop-head span { flex: none; font-size: calc(12px * var(--text-scale, 1)); color: #6b7080; }
.emoji-pack-pop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px;
  max-height: 180px; overflow: auto;
}
.emoji-pack-pop-grid img.pack-emoji { width: 36px; height: 36px; margin: 0; cursor: default; }
.emoji-pack-pop .btn { width: 100%; }
.emoji-pack-pop .btn.emoji-pack-have { color: #22a35a; border-color: #cdeedb; background: #f2fbf6; opacity: 1; }
/* Настройки → Сообщения → «Смайлики и эмоции». */
.emoji-pack-panel { display: flex; flex-direction: column; gap: 10px; border-radius: 12px; transition: background .12s ease; }
.emoji-pack-panel.is-drop { background: color-mix(in srgb, var(--accent, #2f5bd8) 7%, transparent); outline: 2px dashed color-mix(in srgb, var(--accent, #2f5bd8) 45%, transparent); }
.emoji-pack-upload-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.emoji-pack-upload-row .emoji-pack-title { flex: 1 1 200px; min-width: 0; }
.emoji-pack-hint { margin: 0; font-size: calc(12px * var(--text-scale, 1)); color: #6b7080; line-height: 1.4; }
.emoji-pack-list { display: flex; flex-direction: column; gap: 8px; }
.emoji-pack-empty { padding: 10px 2px; font-size: calc(13px * var(--text-scale, 1)); color: #6b7080; }
.emoji-pack-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid #e8eaef; border-radius: 12px; background: #fff;
}
.emoji-pack-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.emoji-pack-row-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.emoji-pack-row-text strong { font-size: calc(14px * var(--text-scale, 1)); color: #1a1d26; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emoji-pack-row-text span { flex: none; font-size: calc(12px * var(--text-scale, 1)); color: #6b7080; }
.emoji-pack-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.emoji-pack-strip img.pack-emoji { width: 28px; height: 28px; margin: 0; cursor: default; }
.emoji-pack-more { font-size: calc(12px * var(--text-scale, 1)); color: #6b7080; padding-left: 2px; }
.emoji-pack-remove {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: #8b8e98; cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.emoji-pack-remove:hover, .emoji-pack-remove:focus-visible { background: #fdecec; color: #d64545; outline: none; }
/* Stickers: bigger in the picker, alone in a message without a bubble. */
.emoji-picker-body.is-stickers { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.emoji-picker-item.is-sticker { min-width: 0; }
.emoji-picker-item.is-sticker img.pack-emoji.sticker { width: 100%; height: 100%; max-width: 84px; max-height: 84px; object-fit: contain; margin: 0; }
.emoji-picker-item.is-sticker { padding: 4px; transition: transform .12s ease, background .12s ease; }
.emoji-picker-item.is-sticker:hover { transform: scale(1.06); }
img.pack-emoji.sticker { width: 72px; height: 72px; vertical-align: middle; }
.msg.sticker-only.emoji-only .msg-body.icq-only img.pack-emoji.sticker.large { width: 168px; height: 168px; margin: 0; }
.emoji-pack-pop-grid.is-sticker { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); max-height: 220px; }
.emoji-pack-pop-grid.is-sticker img.pack-emoji { width: 60px; height: 60px; }
.emoji-pack-row.is-sticker .emoji-pack-strip img.pack-emoji { width: 44px; height: 44px; }
@media (max-width: 760px) {
  .msg.sticker-only.emoji-only .msg-body.icq-only img.pack-emoji.sticker.large { width: 140px; height: 140px; }
}
.emoji-pack-subhead {
  margin: 6px 2px 0; font-size: calc(12px * var(--text-scale, 1)); font-weight: 600;
  letter-spacing: .02em; text-transform: uppercase; color: #8b8e98;
}
.emoji-pack-row.is-builtin { background: #fafbfc; }
.emoji-pack-row.is-builtin img.icq-smiley { width: 28px; height: 28px; margin: 0; }
.emoji-pack-glyphs span { font-size: 24px; line-height: 28px; width: 30px; text-align: center; }
.emoji-pack-add { flex: none; padding: 6px 14px; min-height: 0; font-size: calc(13px * var(--text-scale, 1)); }
/* Chosen files waiting for «Добавить». */
.emoji-pack-stage { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.emoji-pack-stage-tile {
  position: relative; width: 72px; height: 72px; border-radius: 10px; border: 1px solid #e3e6ec;
  background: repeating-conic-gradient(#f1f3f6 0 25%, #fff 0 50%) 0 / 12px 12px;
  display: grid; place-items: center; overflow: hidden;
  animation: emoji-pack-pop-in .16s cubic-bezier(.2, .8, .3, 1);
}
.emoji-pack-stage-tile img { max-width: 100%; max-height: 100%; object-fit: contain; }
.emoji-pack-stage-zip { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; color: #4a4f5c; }
.emoji-pack-stage-zip b { font-size: 13px; }
.emoji-pack-stage-zip span { max-width: 64px; font-size: 10px; color: #6b7080; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emoji-pack-stage-remove {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(26, 29, 38, .62); color: #fff; cursor: pointer;
}
.emoji-pack-stage-remove svg { width: 12px; height: 12px; }
.emoji-pack-stage-remove:hover { background: #d64545; }
.emoji-pack-stage-more {
  width: 72px; height: 72px; padding: 0; display: grid; place-items: center; border-radius: 10px;
  border: 1.5px dashed #c5cbd6; background: transparent; color: var(--accent, #2f5bd8); cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.emoji-pack-stage-more:hover { background: color-mix(in srgb, var(--accent, #2f5bd8) 7%, transparent); border-color: var(--accent, #2f5bd8); }
.emoji-pack-stage-note { flex-basis: 100%; margin: 0; font-size: calc(12px * var(--text-scale, 1)); color: #6b7080; }
/* Voice message: the wave seeks (tap or drag), so it takes the finger. */
.msg-voice-wave { cursor: pointer; touch-action: none; padding: 6px 0; margin: -6px 0; }
.msg-voice-wave:hover .msg-voice-bar:not(.on) { background: rgba(0, 0, 0, .3); }
