/* Dialogue (thread) card under the header. */
/* Dialogue: floating card under header (I), capped above composer (II). No dim. */
#dialogue-overlay.dialogue-overlay {
  display: none;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 8;
  box-sizing: border-box;
  margin: 0;
  padding:
    calc(var(--chat-scroll-top, 76px) + 12px)
    12px
    calc(var(--chat-overlay-bottom, 48px) + 8px);
  background: transparent;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
  pointer-events: none;
}
#dialogue-overlay.dialogue-overlay:not(.hidden) {
  display: flex !important;
}
.dialogue-card {
  position: relative;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: 100%;
  margin: 0 auto;
  padding: 8px 18px 14px;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(16, 24, 40, .18);
}
.dialogue-card > .feature-back {
  margin: 0 0 2px 0;
  flex: none;
}
.dialogue-card > h1,
.dialogue-card > .feature-lead {
  flex: none;
  cursor: grab;
  user-select: none;
}
.dialogue-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  border: 1px solid #e8eaef;
  border-color: var(--dialogue-line, #e8eaef);
  border-radius: 12px;
  overflow: hidden;
  background: var(--dialogue-bg, rgba(255, 255, 255, 0.55));
}
.dialogue-root-slot {
  flex: none;
  padding: 10px 12px 8px;
  border-bottom: 1px solid #e8eaef;
  border-bottom-color: var(--dialogue-line, #e8eaef);
  background: var(--dialogue-root-bg, rgba(248, 249, 251, 0.9));
  max-height: 40%;
  overflow: auto;
}
.dialogue-root-slot .msg { margin: 0; }
/* Root message under discussion — distinct from reply bubbles. */
.dialogue-root-slot .msg.is-dialogue-root .msg-bubble,
.dialogue-root-slot .msg.is-dialogue-root.mine .msg-bubble,
.dialogue-root-slot .msg.is-dialogue-root:not(.mine) .msg-bubble {
  background: #efe8dc;
  color: #1a1d26;
  box-shadow: inset 0 0 0 1px rgba(120, 90, 40, 0.14);
}
.dialogue-root-slot .msg.is-dialogue-root.task-only .msg-bubble,
.dialogue-root-slot .msg.is-dialogue-root.poll-only .msg-bubble,
.dialogue-root-slot .msg.is-dialogue-root.image-only .msg-bubble,
.dialogue-root-slot .msg.is-dialogue-root.emoji-only .msg-bubble,
.dialogue-root-slot .msg.is-dialogue-root.video-note-only .msg-bubble {
  background: transparent;
  box-shadow: none;
}
.dialogue-messages {
  flex: 1 1 auto;
  min-height: 80px;
  overflow: auto;
  padding: 10px 12px 12px;
  -webkit-overflow-scrolling: touch;
}
.dialogue-messages .dialogue-empty {
  border: 1px dashed #d0d4dc;
  border-color: var(--dialogue-line, #d0d4dc);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--dialogue-ink, #8b8e98);
  font-size: calc(14px * var(--text-scale, 1));
  background: #fafbfc;
  margin: 4px 0;
}
.channel-card-dialogues-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
}
.channel-card-dialogues-head .channel-card-section-label { margin: 0; }
.channel-card-dialogues-tools {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
}
.channel-dialogues-tool-btn {
  appearance: none; border: 0; background: transparent;
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; padding: 0;
  color: #5c6270; cursor: pointer;
}
.channel-dialogues-tool-btn:hover { background: #f2f4f8; color: #1a1d26; }
.channel-dialogues-chevron svg {
  transition: transform .15s ease;
}
.channel-dialogues-chevron.is-open svg {
  transform: rotate(90deg);
}
.channel-dialogues-search-btn { display: none; }
.channel-dialogues-search-input {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 8px;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: calc(14px * var(--text-scale, 1));
  background: #fff;
  color: #1a1d26;
}
.channel-dialogues-search-input.hidden { display: none !important; }
.channel-card-dialogues {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 16px;
}
.channel-card-dialogues.is-collapsed,
.channel-card-dialogues[hidden] { display: none !important; }
.channel-card-dialogue {
  appearance: none; border: 1px solid #e8eaef; background: #fff;
  border-radius: 12px; padding: 10px 12px; text-align: left;
  cursor: pointer; font: inherit; color: inherit;
  display: flex; flex-direction: column; gap: 4px;
}
.channel-card-dialogue:hover { background: #f7f8fa; }
.channel-card-dialogue-preview {
  font-size: calc(14px * var(--text-scale, 1));
  color: #1a1d26;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.channel-card-dialogue-meta {
  font-size: calc(12px * var(--text-scale, 1));
  color: #8b8e98;
}
.channel-card-dialogues-empty {
  border: 1px dashed #d0d4dc; border-radius: 12px; padding: 16px;
  text-align: center; color: #8b8e98; font-size: calc(13px * var(--text-scale, 1));
}
@media (max-width: 800px) {
  .channel-dialogues-search-btn { display: grid; }
}
.msg-dialogue-badge {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 2px 7px;
  border: 0;
  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
    );
  color: #fff;
  font: inherit;
  font-size: calc(11px * var(--text-scale, 1));
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}
.msg-dialogue-badge:hover,
.msg-dialogue-badge:focus-visible {
  background:
    color-mix(
      in srgb,
      color-mix(in srgb, var(--pill-color, #1a1d26) 28%, #1a1d26)
      calc(min(1, var(--pill-opacity, 0.55) + 0.12) * 100%),
      transparent
    );
  color: #fff;
  outline: none;
}
.msg-dialogue-badge svg {
  width: 12px;
  height: 12px;
  flex: none;
  color: inherit;
}
.intro { padding: 28px 20px 12px; }
.intro h1 {
  font-size: calc(22px * var(--text-scale, 1)); margin: 0 0 8px; color: var(--on-wallpaper-text, #1a1d26);
  text-shadow: 0 1px 0 var(--on-wallpaper-glow, rgba(255,255,255,.7));
}
.intro p {
  margin: 0; max-width: 640px; color: var(--on-wallpaper-muted, #3a4150);
  font-size: calc(14px * var(--text-scale, 1));
  display: inline-block; padding: 6px 10px; border-radius: 8px;
  background: var(--on-wallpaper-chip, rgba(255,255,255,.72));
  box-shadow: 0 1px 1px rgba(16,24,40,.04);
}
.day {
  display: flex; align-items: center; gap: 12px; margin: 12px 20px;
  color: var(--on-wallpaper-muted, #3a4150);
  font-size: calc(12px * var(--text-scale, 1)); font-weight: 700;
}
.day-label {
  padding: 3px 10px; border-radius: 999px;
  background: var(--on-wallpaper-chip, rgba(255,255,255,.78));
  box-shadow: 0 1px 1px rgba(16,24,40,.04);
}
.day::before, .day::after { content: ""; height: 1px; background: var(--on-wallpaper-line, rgba(26,29,38,.18)); flex: 1; }
.msg {
  display: flex; gap: 8px; padding: 8px 16px 4px; position: relative;
  align-items: flex-end; max-width: 100%;
}
.msg.mine { flex-direction: row-reverse; }
.msg:hover { background: transparent; }
.msg.compact { padding-top: 4px; padding-bottom: 4px; }
.msg.mentions-me .msg-bubble { box-shadow: inset 3px 0 0 #f5a623; }
.msg-avatar-slot {
  width: 36px; min-width: 36px; max-width: 36px; flex: 0 0 36px; align-self: flex-end;
  overflow: visible;
  /* Keep avatar against bubble bottom, not the meta row below it. */
  margin-bottom: 26px;
}
.msg.compact .msg-avatar-slot { visibility: hidden; }
.msg-main {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: min(78%, 560px);
  min-width: 64px;
}
.msg.task-only .msg-main {
  max-width: min(92%, 440px);
}
.msg.poll-only .msg-main {
  /* Wide poll card by default; grow later only if content needs it. */
  width: min(92%, 380px);
  max-width: min(92%, 560px);
  min-width: min(92%, 320px);
}
.msg.emoji-only .msg-main {
  max-width: min(90%, 420px);
  min-width: 0;
}
.msg.video-note-only .msg-main {
  max-width: none;
  min-width: 0;
}
.msg.image-only .msg-main {
  max-width: min(78%, 560px);
  min-width: 0;
}
.msg-bubble {
  max-width: 100%; min-width: 0;
  padding: 8px 10px 6px; border-radius: 14px;
  /* «Прозрачность → Пузырь текста» (--glass-text-mix, 100% = solid). */
  background: color-mix(in srgb, #ffffff var(--glass-text-mix, 100%), transparent);
  color: var(--bubble-peer-text, #1a1d26);
  box-shadow: 0 1px 1px rgba(16, 24, 40, .08);
}
.msg.mine .msg-bubble {
  background: color-mix(in srgb, var(--bubble-color, #ffffff) var(--glass-text-mix, 100%), transparent);
  color: var(--bubble-text, #1a1d26);
  border-bottom-right-radius: 4px;
}
.msg:not(.mine) .msg-bubble {
  border-bottom-left-radius: 4px;
  background: color-mix(in srgb, #ffffff var(--glass-text-mix, 100%), transparent);
  color: var(--bubble-peer-text, #1a1d26);
}

/* —— Sending files: the bubble «charges for a jump» while it uploads ——
   --p: 0…1 sent (the frame loop in 20-composer.js eases it). */
.msg-upload-card {
  --p: 0;
  position: relative; overflow: hidden; isolation: isolate;
  max-width: 100%; border-radius: 12px;
}
/* The picture inside is the message's own .msg-image / .msg-video. */
.msg-upload-card .msg-image { margin: 0; }
.msg-upload-card.is-video .msg-video { border-radius: 12px; }
.msg-upload-poster { min-height: 160px; }
.msg-upload-poster:not([src]) { min-height: 260px; background: linear-gradient(160deg, #1b2236, #2c3a6e); }
.msg-upload-card.is-video .msg-video { width: min(320px, 72vw); }
.msg-upload-card.is-file { width: min(260px, 68vw); height: 132px; background: linear-gradient(135deg, #24305a, #3b4fd0); box-shadow: 0 6px 22px rgba(15, 23, 42, .18); }
/* A scrim so the white marks read on any picture. */
.msg-upload-card::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(8, 12, 30, .15), rgba(8, 12, 30, .5));
}
.msg-upload-file {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 2;
  color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-upload-stat, .msg-upload-more {
  position: absolute; z-index: 2; color: #fff; font-size: 13px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: rgba(10, 14, 30, .45);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-variant-numeric: tabular-nums;
}
.msg-upload-stat { top: 10px; left: 10px; }
.msg-upload-stat.hidden { display: none; }
.msg-upload-more { top: 10px; right: 10px; }

/* The »» in its glass circle: tap = cancel. */
.msg-upload-hyper {
  position: absolute; z-index: 3; left: 50%; top: 50%; width: 72px; height: 72px;
  transform: translate(-50%, -50%); padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: #fff;
  background: rgba(12, 18, 40, .42);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
}
.msg-upload-hyper > * { grid-area: 1 / 1; }
/* Progress ring around it. */
.hyper-ring {
  width: 100%; height: 100%; border-radius: 50%;
  background: conic-gradient(#9fc2ff calc(var(--p) * 360deg), rgba(255, 255, 255, .16) 0);
  -webkit-mask: radial-gradient(circle, transparent 31px, #000 32px);
  mask: radial-gradient(circle, transparent 31px, #000 32px);
}
.hyper-chevrons { width: 34px; height: 34px; overflow: visible; filter: drop-shadow(0 0 6px rgba(140, 180, 255, .7)); }
/* The chevrons light up one after another, back to front: charging (the frame
   loop in 20-composer.js sets their glow and the rays' turn). */
.hyper-chev { opacity: .3; stroke: #eef3ff; }
  to { transform: rotate(28deg) scale(1.08); }
}
/* All sent, the server is taking it: fully charged — every chevron lit, humming. */
.msg-upload-card.is-launched .hyper-chev { stroke: #fff; }
.msg-upload-card.is-jumping .hyper-chevrons { animation: hyper-hum .5s ease-in-out infinite; }
.msg-upload-card.is-jumping .hyper-ring { background: #9fc2ff; transition: background .3s ease; }
/* Starts and ends where the charge left it: no jolt when it begins. */
@keyframes hyper-hum {
  0%, 100% { transform: translateX(0); filter: drop-shadow(0 0 6px rgba(140, 180, 255, .7)); }
  50% { transform: translateX(1.5px); filter: drop-shadow(0 0 12px rgba(200, 222, 255, 1)); }
}
/* The jump: the »» shoots off, the rays burst outwards, the circle flashes and goes. */
/* The jump: the chevrons are let go one after another — the front one first —
   and shoot off to the right, out of the circle. */
.hyper-chev { transform-box: fill-box; }
.msg-upload-card.is-launched .hyper-chev-1 { animation: hyper-chev-fly .55s cubic-bezier(.5, 0, .2, 1) forwards; }
.msg-upload-card.is-launched .hyper-chev-2 { animation: hyper-chev-fly .55s cubic-bezier(.5, 0, .2, 1) .09s forwards; }
.msg-upload-card.is-launched .hyper-chev-3 { animation: hyper-chev-fly .55s cubic-bezier(.5, 0, .2, 1) .18s forwards; }
.msg-upload-card.is-launched .hyper-ring { background: #ffffff; animation: hyper-ring-out .7s ease-out forwards; }
.msg-upload-card.is-launched .msg-upload-hyper { animation: hyper-flash .7s ease-out forwards; }
.msg-upload-card.is-launched::after { transition: opacity .6s ease; opacity: 0; }
@keyframes hyper-chev-fly {
  /* from the glow the charge left (no 0% opacity) to full, then away */
  25% { opacity: 1; transform: translateX(-2px) scaleX(.9); }
  100% { opacity: 0; transform: translateX(42px) scaleX(1.6); }
}
@keyframes hyper-ring-out {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.7); opacity: 0; }
}
@keyframes hyper-flash {
  0% { background: rgba(12, 18, 40, .42); box-shadow: 0 0 0 0 rgba(190, 215, 255, .0); }
  25% { background: rgba(120, 160, 255, .45); box-shadow: 0 0 40px 12px rgba(190, 215, 255, .55); }
  100% { background: rgba(12, 18, 40, 0); box-shadow: 0 0 60px 30px rgba(190, 215, 255, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .msg-upload-card.is-jumping .hyper-chevrons, .msg-upload-card.is-launched .hyper-chev,
  .msg-upload-card.is-launched .hyper-ring, .msg-upload-card.is-launched .msg-upload-hyper { animation: none; }
  .hyper-chev { opacity: 1; }
}

/* A sent video plays in the chat. */
.msg-video { max-width: min(320px, var(--msg-media-max, 72vw)); border-radius: 16px; overflow: hidden; background: #0f1424; line-height: 0; }
.msg-video-player { display: block; width: 100%; height: auto; max-height: 420px; background: #0f1424; object-fit: cover; }
.msg-video { position: relative; }
/* «Развернуть»: opens the dark viewer (the whole video, centred). */
.msg-video-expand {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: #fff;
  background: rgba(10, 14, 22, .5);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: background .15s ease, opacity .15s ease, transform .1s ease;
}
.msg-video-expand:hover { background: rgba(10, 14, 22, .72); }
.msg-video-expand:active { transform: scale(.94); }
@media (hover: hover) {
  .msg-video .msg-video-expand { opacity: 0; }
  .msg-video:hover .msg-video-expand, .msg-video-expand:focus-visible { opacity: 1; }
}
/* If the browser's own full screen is used anyway (Safari): the whole picture. */
.msg-video-player:fullscreen { object-fit: contain; max-height: none; background: #000; }
.msg-video-player:-webkit-full-screen { object-fit: contain; max-height: none; background: #000; }


/* Waiting its turn (several messages of files): dimmer, not charging yet. */
.msg-upload-card.is-queued .msg-upload-hyper { opacity: .55; }
.msg-upload-card.is-queued::after { background: rgba(8, 12, 30, .45); }
.msg-upload-card.is-album { border-radius: 12px; }

/* —— «Диалог» pinned to the right (36-dialogue-dock.js), computer only —— */
.dialogue-dock-btn {
  position: absolute; top: 8px; right: 12px;
  width: 36px; height: 36px; border-radius: 10px; color: #6b7080;
}
.dialogue-dock-btn:hover { color: var(--accent, #5b5bd6); background: rgba(91, 91, 214, .08); }
body.dialogue-dragging, body.dialogue-dragging * { cursor: grabbing !important; user-select: none !important; }
.dialogue-card.is-dragging {
  transition: none;
  box-shadow: 0 22px 60px rgba(16, 24, 40, .28);
  opacity: .96;
}
/* While dragged over the right edge: where it will stand. */
#dialogue-overlay.dialogue-overlay::after {
  content: ""; position: absolute; pointer-events: none;
  top: calc(var(--chat-scroll-top, 76px) + 12px);
  bottom: calc(var(--chat-overlay-bottom, 48px) + 8px);
  right: 12px; width: var(--dlg-dock-w);
  border: 2px dashed rgba(91, 91, 214, .55); border-radius: 16px;
  background: rgba(91, 91, 214, .07);
  opacity: 0; transform: translateX(16px);
  transition: opacity .18s ease, transform .18s ease;
}
#dialogue-overlay.dialogue-overlay.is-dock-target::after { opacity: 1; transform: none; }
:root { --dlg-dock-w: clamp(340px, 36vw, 480px); }
.app.dialogue-docked #dialogue-overlay.dialogue-overlay {
  /* The column's shadow falls on the chat beside it, not cut at its edge. */
  overflow: visible;
  left: auto !important;
  width: calc(var(--dlg-dock-w) + 12px);
  padding-left: 0;
  justify-content: flex-end;
  align-items: stretch;
}
.app.dialogue-docked #dialogue-overlay.dialogue-overlay::after { display: none; }
.app.dialogue-docked .dialogue-card { width: 100%; height: 100%; margin: 0; }
.app.dialogue-docked .dialogue-card > h1 { font-size: 26px; }
/* The chat makes room for the column and stays readable and clickable. */
.app.dialogue-docked #messages { padding-right: calc(var(--dlg-dock-w) + 24px); }
.dialogue-card.is-dock-landing { animation: dlg-dock-land .24s cubic-bezier(.2, .8, .3, 1); }
@keyframes dlg-dock-land {
  from { opacity: .6; transform: scale(.97); }
  to { opacity: 1; transform: none; }
}
#dialogue-overlay.dialogue-overlay.is-dragging { overflow: visible; }
/* Free window: placed and sized by the user (36-dialogue-dock.js). */
.app:not(.dialogue-docked) .dialogue-card.is-free { position: absolute; margin: 0; }
.dialogue-resize { position: absolute; z-index: 2; touch-action: none; }
.dialogue-resize[hidden] { display: none; }
.dialogue-resize-se {
  right: 3px; bottom: 3px; width: 18px; height: 18px; cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 0 55%, rgba(107, 112, 128, .45) 55% 62%, transparent 62% 72%, rgba(107, 112, 128, .45) 72% 79%, transparent 79%);
  border-bottom-right-radius: 12px;
  opacity: .7; transition: opacity .15s ease;
}
.dialogue-resize-se:hover { opacity: 1; }
.dialogue-resize-w { display: none; left: -4px; top: 16px; bottom: 16px; width: 10px; cursor: ew-resize; }
.dialogue-resize-w::after {
  content: ""; position: absolute; left: 3px; top: 50%; width: 4px; height: 44px; margin-top: -22px;
  border-radius: 2px; background: rgba(107, 112, 128, .35); opacity: 0; transition: opacity .15s ease;
}
.dialogue-resize-w:hover::after { opacity: 1; }
.app.dialogue-docked .dialogue-resize-w:not([hidden]) { display: block; }
.app.dialogue-docked .dialogue-resize-se { display: none; }
body.dialogue-resizing, body.dialogue-resizing * { cursor: nwse-resize !important; user-select: none !important; }
body.dialogue-resizing-x, body.dialogue-resizing-x * { cursor: ew-resize !important; user-select: none !important; }
/* The composer writes into this dialogue: a faint accent edge says so. */
.dialogue-card.is-composer-target { outline: 1.5px solid color-mix(in srgb, var(--accent, #5b5bd6) 35%, transparent); outline-offset: -1px; }

/* «Фон диалогов» (37-dialogue-bg.js): unset = the usual glass. */
/* The window is frosted glass, as the chat window is («Прозрачность → Окно»):
   the chat behind shows through, blurred. */
#dialogue-overlay .dialogue-card {
  background: var(--glass-window-bg, rgba(255, 255, 255, .55));
  -webkit-backdrop-filter: blur(var(--glass-blur, 16px)) saturate(1.2);
  backdrop-filter: blur(var(--glass-blur, 16px)) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, .75);
}
.dialogue-bg-preview {
  width: 72px; height: 54px; flex: none; box-sizing: border-box;
  border-radius: 12px; border: 1px solid #d8dbe3;
  background: rgba(255, 255, 255, .55);
  display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 8px;
  transition: background .2s ease;
}
.dialogue-bg-preview-msg {
  display: block; width: 60%; height: 12px; border-radius: 6px; background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 3px 8px rgba(38, 44, 96, .12);
}
.dialogue-bg-preview-msg.is-mine { align-self: flex-end; background: var(--bubble-color, #eef8fc); }
.dialogue-bg-swatch.is-default {
  background: repeating-linear-gradient(45deg, #f2f3f6 0 4px, #fff 4px 8px) content-box, #fff;
}
.dialogue-bg-swatch.is-custom { display: grid; place-items: center; color: #6b7080; }
