/* ==========================================================================
   Kosmo — вложения, свайпы, кружки, звонки, стикеры, опросы, истории,
   папки, поиск, аккаунты, вход по QR
   ========================================================================== */

/* Появление только у новых строк: обновление списка ничего не «перепроигрывает» */
#chat-list > .chat:not(.is-new), #feed > .post:not(.is-new) { animation: none; }

/* ---------- Папки чатов ---------- */
.folders {
  display: flex;
  gap: 6px;
  padding: 0 14px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 680px;
  margin: 0 auto;
}
.folders::-webkit-scrollbar { display: none; }
.folder {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--c-text-2);
  font-size: 14px;
  font-weight: 600;
  transition: background 220ms ease, color 220ms ease, scale 300ms var(--spring-bouncy);
}
.folder:active { scale: 0.94; }
.folder.is-active { background: var(--c-accent); color: #fff; }
.folder-n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: rgba(255, 255, 255, 0.22); font-size: 11px; line-height: 18px; text-align: center; }
html[data-theme="material"] .folder { background: var(--md-sys-color-surface-container-high); border-radius: 10px; }
html[data-theme="material"] .folder.is-active { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.is-secret { color: #34c759; }
.is-secret .room-icon { color: #34c759; }

/* ---------- Шапка чата: «⋯», поиск по чату ---------- */
.chat-more { flex: none; }
.chat-more[hidden] { display: none; }
.chat-search {
  position: sticky;
  top: calc(max(14px, env(safe-area-inset-top)) + 62px);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: -4px 12px 8px;
  padding: 0 4px 0 14px;
  height: 48px;
  border-radius: 999px;
  animation: bar-in 320ms var(--spring) both;
}
html[data-theme="glass"] .chat-search { background: rgba(28, 28, 30, 0.72); }
html[data-theme="material"] .chat-search { background: var(--md-tint-high); }
.chat-search > svg { width: 18px; height: 18px; color: var(--c-text-2); flex: none; }
.chat-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 16px; color: var(--c-text); }
.cs-count { font-size: 13px; color: var(--c-text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chat-search .icon-btn { width: 36px; height: 36px; }
.bubble-row.is-match .bubble { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-accent) 70%, transparent); }

.chat-menu, .send-menu { position: fixed; z-index: 40; width: 250px; }
.send-menu { transform-origin: 100% 100%; }
.menu-sub { padding: 6px 8px 8px; }
.menu-sub > span { display: flex; align-items: center; gap: 12px; padding: 6px 6px 8px; font-size: 16px; }
.menu-sub .segs { width: 100%; }
.menu-sub .seg-btn { flex: 1; padding: 0 6px; }

.sched-bar {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto 8px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  color: var(--c-accent);
  font-size: 14px;
  font-weight: 600;
}
html[data-theme="glass"] .sched-bar { background: rgba(28, 28, 30, 0.7); }
html[data-theme="material"] .sched-bar { background: var(--md-tint-high); }
.sched-bar svg { width: 18px; height: 18px; }

/* ---------- Лента вложений над полем ввода ---------- */
.attach-tray {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 58px);
  width: min(680px, calc(100% - 20px));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 24px;
  overflow-x: auto;
  scrollbar-width: none;
  transform: translateX(-50%);
  animation: tray-in 380ms var(--spring) both;
}
.attach-tray::-webkit-scrollbar { display: none; }
@keyframes tray-in { from { opacity: 0; transform: translate(-50%, 24px) scale(0.96); } }
html[data-theme="glass"] .attach-tray { background: rgba(28, 28, 30, 0.72); }
html[data-theme="material"] .attach-tray { background: var(--md-tint-high); }
.panel-chat:not([data-composer="compose"]) .attach-tray { display: none; }
.tray-item {
  position: relative;
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  animation: pop-in 380ms var(--spring-bouncy) both;
  transition: opacity 180ms ease, scale 180ms ease;
}
.tray-item.is-removing { opacity: 0; scale: 0.6; }
.tray-item img, .tray-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tray-item.is-code { width: 112px; }
.tray-code { display: flex; flex-direction: column; justify-content: center; gap: 2px; height: 100%; padding: 8px 10px; background: color-mix(in srgb, var(--c-accent) 20%, #141416); }
.tray-code svg { width: 18px; height: 18px; color: var(--c-accent); }
.tray-code b { font-size: 12px; }
.tray-code small { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; color: var(--c-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray-remove { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; }
.tray-remove svg { width: 13px; height: 13px; stroke-width: 2.6; }
.tray-badge { position: absolute; left: 4px; bottom: 4px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; }
.tray-badge svg { width: 12px; height: 12px; }
.tray-add { flex: none; width: 44px; height: 72px; display: grid; place-items: center; border: 1.5px dashed var(--c-text-3); border-radius: 16px; background: none; color: var(--c-text-2); }
.tray-add svg { width: 20px; height: 20px; }
.tray-count { flex: none; padding: 0 6px; font-size: 13px; color: var(--c-text-2); white-space: nowrap; }
.panel-chat.has-tray .messages { padding-bottom: 168px; }
.panel-chat.has-tray.is-composing .messages { padding-bottom: 220px; }
.panel-chat.has-tray .compose-bar { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 150px); }
.send-btn .ic-round { opacity: 0; scale: 0.3; }
.send-btn[data-mode="round"] .ic-mic, .send-btn[data-mode="round"] .ic-send { opacity: 0; scale: 0.3; }
.send-btn[data-mode="round"] .ic-round { opacity: 1; scale: 1; }
.send-btn[data-mode="voice"] .ic-round, .send-btn[data-mode="send"] .ic-round { opacity: 0; scale: 0.3; rotate: 90deg; }
.ic-round { background: #34c759; }
.ic-poll { background: #ff9f0a; }
.menu-ic.ic-round, .menu-ic.ic-poll { color: #fff; }

/* ---------- Пузырь: реакции и время в одной строке, без растягивания ---------- */
.b-foot { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 4px 8px; margin-top: 4px; }
.b-foot .reactions { flex: 0 1 auto; margin: 0 auto 0 0; }
.b-foot .b-meta { float: none; margin: 0 -4px -4px auto; }
.kind-photo .b-foot, .kind-video .b-foot, .kind-album .b-foot { margin: 6px 4px 2px; }
.kind-photo .b-foot .b-meta, .kind-video .b-foot .b-meta, .kind-album .b-foot .b-meta { position: static; background: none; color: inherit; padding: 0; opacity: 0.72; }
.bubble.has-reactions .reactions .reaction { height: 26px; padding: 0 8px 0 4px; font-size: 12px; }
.bubble.has-reactions .reactions .reaction .emoji { width: 19px; height: 19px; }
.b-ttl { display: inline-grid; margin-right: 3px; opacity: 0.9; }
.b-ttl svg { width: 12px; height: 12px; }
.b-sender, .b-avatar, .b-fwd button { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; text-align: left; }
.b-sender { color: var(--c-accent); }
.b-avatar { margin-right: 6px; border-radius: 50%; align-self: flex-end; }
.b-fwd { display: flex; align-items: center; gap: 4px; margin: 0 0 4px; font-size: 13px; opacity: 0.85; flex-wrap: wrap; }
.b-fwd svg { width: 14px; height: 14px; }
.b-fwd button, .b-fwd b { font-weight: 600; color: inherit; }
.theirs .b-fwd button, .theirs .b-fwd b { color: var(--c-accent); }
.mention { padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; cursor: pointer; }
.theirs .mention, .post-text .mention, .comment-text .mention { color: var(--c-accent); text-decoration: none; }
.b-link { color: inherit; text-decoration: underline; word-break: break-all; }
.theirs .b-link { color: var(--c-accent); }

/* Свайп по сообщению: влево — ответ, вправо — переслать */
.bubble-row { position: relative; touch-action: pan-y; }
.bubble-row .bubble { will-change: auto; }
.bubble-row.is-swiping .bubble { will-change: transform; transition: none; }
.swipe-ic {
  position: absolute;
  top: 50%;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  margin-top: -17px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--c-text);
  opacity: 0;
  scale: 0.4;
  pointer-events: none;
  transition: opacity 120ms ease, scale 260ms var(--spring-bouncy), background 200ms ease;
}
.swipe-ic svg { width: 18px; height: 18px; }
.swipe-reply { right: 8px; }
.swipe-fwd { left: 8px; }
.bubble-row.is-swiping[data-swipe="reply"] .swipe-reply,
.bubble-row.is-swiping[data-swipe="fwd"] .swipe-fwd { opacity: var(--swipe, 0); scale: calc(0.4 + var(--swipe, 0) * 0.6); }
.bubble-row.is-armed .swipe-ic { background: var(--c-accent); color: #fff; scale: 1.1 !important; }

/* ---------- Альбом ---------- */
.kind-album { padding: 4px; }
.b-album { display: grid; gap: 3px; width: min(300px, 70vw); border-radius: 16px; overflow: hidden; }
.b-album[data-count="2"], .b-album[data-count="4"] { grid-template-columns: 1fr 1fr; }
.b-album[data-count="3"], .b-album[data-count="5"], .b-album[data-count="6"] { grid-template-columns: repeat(6, 1fr); }
.b-album[data-count="3"] .b-album-item:first-child { grid-column: 1 / -1; }
.b-album[data-count="3"] .b-album-item:not(:first-child) { grid-column: span 3; }
.b-album[data-count="5"] .b-album-item:nth-child(-n+2) { grid-column: span 3; }
.b-album[data-count="5"] .b-album-item:nth-child(n+3) { grid-column: span 2; }
.b-album[data-count="6"] .b-album-item { grid-column: span 2; }
.b-album-item { position: relative; display: block; padding: 0; border: 0; background: #000; aspect-ratio: 1; overflow: hidden; cursor: zoom-in; }
.b-album[data-count="3"] .b-album-item:first-child { aspect-ratio: 16 / 10; }
.b-album-item img, .b-album-item video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.b-album-item .b-play-ov { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
.b-album-item .b-play-ov svg { width: 18px; height: 18px; }

/* ---------- Кружки ---------- */
.kind-round, .kind-sticker { background: none !important; padding: 0 !important; box-shadow: none !important; }
.kind-round .b-meta, .kind-sticker .b-meta { float: none; display: inline-flex; margin: 4px 0 0; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); color: #fff; opacity: 1; }
.mine .kind-round, .mine .kind-sticker { display: flex; flex-direction: column; align-items: flex-end; }
.b-round { position: relative; display: block; width: min(220px, 56vw); aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%; overflow: hidden; background: #111; cursor: pointer; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.b-round video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.round-ring { position: absolute; inset: 0; width: 100%; height: 100%; rotate: -90deg; pointer-events: none; }
.round-ring circle { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; opacity: 0; transition: opacity 200ms ease, stroke-dashoffset 250ms linear; }
.b-round.is-playing .round-ring circle { opacity: 0.95; }
.round-dur { position: absolute; left: 50%; bottom: 10px; translate: -50% 0; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.round-sound { position: absolute; right: 12%; top: 12%; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, 0.5); color: #fff; transition: opacity 200ms ease; }
.round-sound svg { width: 14px; height: 14px; }
.b-round.is-playing .round-sound { opacity: 0; }

.round-rec { position: fixed; inset: 0; z-index: 85; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; animation: fade-in 220ms ease both; }
.round-rec.is-closing { animation: fade-out 200ms ease both; }
.round-rec-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.round-rec-stage { position: relative; width: min(300px, 76vw); aspect-ratio: 1; animation: pop-in 480ms var(--spring-bouncy) both; }
.round-rec-circle { position: absolute; inset: 8px; border-radius: 50%; overflow: hidden; background: #111; }
.round-rec-circle video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.round-rec-ring { position: absolute; inset: 0; width: 100%; height: 100%; rotate: -90deg; }
.round-rec-ring circle { fill: none; stroke: var(--c-accent); stroke-width: 2.6; stroke-linecap: round; transition: stroke-dashoffset 100ms linear; }
.round-rec-time { position: relative; display: flex; align-items: center; gap: 8px; color: #fff; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.round-rec-actions { position: relative; display: flex; align-items: center; gap: 28px; }
.round-rec-send { width: 68px; height: 68px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--c-accent); color: #fff; box-shadow: 0 8px 26px color-mix(in srgb, var(--c-accent) 55%, transparent); transition: scale 300ms var(--spring-bouncy); }
.round-rec-send:active { scale: 0.9; }
.round-rec-send svg { width: 28px; height: 28px; stroke-width: 2.4; }

/* ---------- Стикеры ---------- */
.sticker { position: relative; display: inline-grid; place-items: center; }
.sticker .emoji { width: 100%; height: 100%; }
.sticker-big { width: 150px; height: 150px; }
.sticker-big .emoji { filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35)); }
.sticker-text {
  position: absolute;
  left: 50%;
  bottom: -2px;
  translate: -50% 0;
  padding: 3px 10px;
  border-radius: 12px;
  background: #fff;
  color: #111;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  rotate: -4deg;
}
.anim-jelly .emoji { animation: st-jelly 1.6s ease-in-out infinite; }
.anim-pulse .emoji, .anim-beat .emoji { animation: st-beat 1.2s ease-in-out infinite; }
.anim-pop .emoji { animation: st-pop 1.8s var(--spring-bouncy) infinite; }
.anim-shake .emoji { animation: st-shake 1.4s ease-in-out infinite; }
.anim-float .emoji { animation: st-float 2.4s ease-in-out infinite; }
.anim-spin .emoji { animation: st-spin 2.6s ease-in-out infinite; }
.anim-wave .emoji { animation: st-wave 1.6s ease-in-out infinite; transform-origin: 70% 90%; }
.anim-launch .emoji { animation: st-launch 2.2s ease-in-out infinite; }
.anim-orbit .emoji { animation: st-orbit 4s linear infinite; }
.anim-twinkle .emoji { animation: st-twinkle 1.8s ease-in-out infinite; }
.anim-flicker .emoji { animation: st-flicker 1.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes st-jelly { 0%, 100% { transform: scale(1, 1); } 25% { transform: scale(1.12, 0.88); } 50% { transform: scale(0.92, 1.08); } 75% { transform: scale(1.04, 0.96); } }
@keyframes st-beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.15); } 30% { transform: scale(0.98); } 45% { transform: scale(1.1); } }
@keyframes st-pop { 0%, 60%, 100% { transform: scale(1); } 20% { transform: scale(1.22) rotate(-6deg); } 40% { transform: scale(0.94) rotate(4deg); } }
@keyframes st-shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-9deg); } 40% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 80% { transform: rotate(3deg); } }
@keyframes st-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8%); } }
@keyframes st-spin { 0% { transform: rotate(0); } 60%, 100% { transform: rotate(360deg); } }
@keyframes st-wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-16deg); } 50% { transform: rotate(10deg); } 75% { transform: rotate(-8deg); } }
@keyframes st-launch { 0%, 100% { transform: translate(0, 0); } 45% { transform: translate(6%, -12%) rotate(-4deg); } 55% { transform: translate(7%, -14%) rotate(-4deg); } }
@keyframes st-orbit { from { transform: rotate(0) translateX(4%) rotate(0); } to { transform: rotate(360deg) translateX(4%) rotate(-360deg); } }
@keyframes st-twinkle { 0%, 100% { transform: scale(1) rotate(0); filter: brightness(1); } 50% { transform: scale(1.12) rotate(14deg); filter: brightness(1.3); } }
@keyframes st-flicker { 0%, 100% { transform: scale(1, 1); } 33% { transform: scale(0.94, 1.08); } 66% { transform: scale(1.05, 0.95); } }
@media (prefers-reduced-motion: reduce) { .sticker .emoji { animation: none !important; } }

/* выбор: вкладки «Эмодзи / Стикеры» */
.emoji-picker { display: block !important; width: min(360px, calc(100% - 20px)) !important; max-height: 50vh; overflow-y: auto; padding: 8px !important; }
.emoji-picker[hidden] { display: none !important; }
.picker-tabs { position: sticky; top: -8px; z-index: 1; display: flex; gap: 4px; margin: -8px -8px 8px; padding: 8px; background: inherit; border-radius: 26px 26px 0 0; }
.picker-tabs button { flex: 1; height: 34px; border: 0; border-radius: 12px; background: none; color: var(--c-text-2); font-weight: 600; }
.picker-tabs [aria-selected="true"] { background: color-mix(in srgb, var(--c-accent) 22%, transparent); color: var(--c-text); }
.emoji-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sticker-pack h4 { margin: 8px 6px 6px; font-size: 13px; color: var(--c-text-2); font-weight: 600; }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sticker-opt { aspect-ratio: 1; display: grid; place-items: center; padding: 8px; border: 0; border-radius: 16px; background: none; transition: background 150ms ease, scale 300ms var(--spring-bouncy); }
.sticker-opt:hover { background: rgba(255, 255, 255, 0.08); }
.sticker-opt:active { scale: 0.9; }
.sticker-opt .sticker { width: 100%; height: 100%; }
.sticker-opt .sticker-text { font-size: 10px; padding: 1px 6px; bottom: -4px; }

/* ---------- Опросы ---------- */
.kind-poll { min-width: min(300px, 76vw); }
.poll { display: flex; flex-direction: column; gap: 6px; padding: 2px 0; }
.poll-q { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.3; }
.poll-type { font-size: 12px; opacity: 0.7; }
.poll-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.poll-opt { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.08); color: inherit; font-size: 15px; text-align: left; transition: background 150ms ease, scale 250ms var(--spring-bouncy); }
.poll-opt:active { scale: 0.98; }
.mine .poll-opt { background: rgba(255, 255, 255, 0.18); }
.poll-radio { flex: none; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 2px currentColor; opacity: 0.6; transition: box-shadow 150ms ease, opacity 150ms ease; }
.poll-radio.is-box { border-radius: 6px; }
.poll-opt.is-picked .poll-radio { box-shadow: inset 0 0 0 6px currentColor; opacity: 1; }
.poll-res { position: relative; display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 4px 6px; padding: 4px 0; }
.poll-pct { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.poll-label { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.poll-label svg { width: 16px; height: 16px; stroke-width: 2.6; }
.poll-bar { grid-column: 2; height: 5px; border-radius: 3px; background: currentColor; opacity: 0.85; width: var(--w); min-width: 5px; transform-origin: 0 50%; animation: grow 700ms var(--spring) both; }
.poll-res:not(.is-chosen) .poll-bar { opacity: 0.35; }
.poll-res.is-right .poll-bar, .poll-res.is-right .poll-label svg { color: #34c759; }
.poll-res.is-wrong .poll-bar, .poll-res.is-wrong .poll-label svg { color: #ff453a; }
.poll-expl { display: flex; gap: 8px; margin: 4px 0 0; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); font-size: 13px; line-height: 1.4; }
.poll-expl svg { flex: none; width: 18px; height: 18px; }
.poll-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; opacity: 0.75; }
.poll-voters { margin-left: auto; }
.poll-submit { margin-left: auto; height: 32px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--c-accent); color: #fff; font-weight: 700; }
.mine .poll-submit { background: #fff; color: var(--c-accent); }
.poll-submit:disabled { opacity: 0.4; }

/* ---------- Приглашение и звонок в чате ---------- */
.kind-invite, .kind-call { min-width: min(260px, 70vw); }
.b-invite { display: flex; flex-direction: column; gap: 8px; }
.b-invite-head { display: flex; align-items: center; gap: 10px; }
.avatar-sm { width: 44px; height: 44px; font-size: 16px; }
.b-invite-head span { display: flex; flex-direction: column; line-height: 1.25; }
.b-invite-head small { font-size: 12px; opacity: 0.7; }
.b-invite-text { margin: 0; font-size: 14px; opacity: 0.9; }
.b-invite-btn { height: 38px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.16); color: inherit; font-weight: 600; transition: scale 250ms var(--spring-bouncy); }
.theirs .b-invite-btn { background: color-mix(in srgb, var(--c-accent) 22%, transparent); color: var(--c-accent); }
.b-invite-btn:active { scale: 0.97; }
.b-invite.is-gone { flex-direction: row; align-items: center; opacity: 0.7; font-size: 14px; }
.b-invite.is-gone svg { width: 18px; height: 18px; }
.b-call { display: flex; align-items: center; gap: 10px; }
.b-call-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }
.b-call-icon svg { width: 18px; height: 18px; }
.b-call.is-missed .b-call-icon { color: #ff6961; }
.b-call-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.b-call-text small { font-size: 12px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.b-call-back { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: inherit; }
.b-call-back svg { width: 20px; height: 20px; }

/* ---------- Экран звонка ---------- */
.call-screen {
  position: fixed;
  inset: 0;
  z-index: 88;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(70px, env(safe-area-inset-top)) 20px max(40px, env(safe-area-inset-bottom));
  color: #fff;
  background: #050507;
  animation: call-in 420ms var(--spring) both;
  overflow: hidden;
}
@keyframes call-in { from { opacity: 0; transform: translateY(6%) scale(0.98); } }
.call-screen.is-ending { animation: fade-out 600ms ease 300ms both; }
.call-bg { position: absolute; inset: 0; background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--c-accent) 55%, #000), #050507 70%); }
.call-remote, .call-local { position: absolute; object-fit: cover; background: #000; opacity: 0; transition: opacity 300ms ease; }
.call-remote { inset: 0; width: 100%; height: 100%; }
.call-screen.has-remote-video .call-remote { opacity: 1; z-index: 1; }
.call-local { right: 16px; top: max(16px, env(safe-area-inset-top)); width: 110px; height: 150px; border-radius: 18px; z-index: 3; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); transform: scaleX(-1); }
.call-screen.is-video .call-local { opacity: 1; }
.call-info { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.call-screen.has-remote-video .call-info { opacity: 0; }
.call-avatar { position: relative; display: grid; place-items: center; margin-bottom: 14px; }
.avatar-call { width: 128px; height: 128px; font-size: 44px; position: relative; z-index: 1; }
.call-wave { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); animation: call-wave 2s ease-out infinite; }
.call-wave.w2 { animation-delay: 1s; }
.call-screen.is-active .call-wave { display: none; }
@keyframes call-wave { from { transform: scale(1); opacity: 0.9; } to { transform: scale(1.8); opacity: 0; } }
.call-info h2 { margin: 0; font-size: 28px; font-weight: 700; }
.call-status { margin: 0; color: rgba(255, 255, 255, 0.75); font-size: 16px; font-variant-numeric: tabular-nums; }
.call-actions { position: relative; z-index: 2; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.call-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: none; color: #fff; font-size: 12px; }
.call-btn svg { width: 64px; height: 64px; padding: 19px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); transition: background 200ms ease, scale 300ms var(--spring-bouncy); }
.call-btn:active svg { scale: 0.9; }
.call-btn.is-off svg, .call-btn.is-on svg { background: #fff; color: #000; }
.call-btn.is-end svg { background: #ff3b30; color: #fff; }
.call-btn.is-accept svg { background: #34c759; color: #fff; animation: accept-bob 1.2s ease-in-out infinite; }
@keyframes accept-bob { 50% { transform: translateY(-6px); } }

/* ---------- Модальные окна (опрос, время, отложенные, привязка) ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: end center; padding: 12px; }
.modal-wrap.is-closing { animation: fade-out 180ms ease both; }
.modal-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); animation: fade-in 200ms ease both; }
.modal {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  border-radius: 30px;
  background: var(--c-sheet-bg);
  animation: modal-in 420ms var(--spring) both;
}
@media (min-width: 600px) { .modal-wrap { place-items: center; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(40px) scale(0.97); } }
html[data-theme="material"] .modal { border-radius: 28px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-field { display: flex; flex-direction: column; gap: 6px; }
.modal-field > span, .modal-label { font-size: 13px; font-weight: 600; color: var(--c-text-2); padding-left: 4px; }
.modal-field textarea, .modal-field input, .poll-edit-row input {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  outline: 0;
  border-radius: 16px;
  background: var(--c-field-bg);
  color: var(--c-text);
  font: inherit;
  font-size: 16px;
  resize: none;
  color-scheme: dark;
}
.poll-edit-opts { display: flex; flex-direction: column; gap: 6px; }
.poll-edit-row { display: flex; align-items: center; gap: 6px; animation: chat-in 300ms var(--spring) both; }
.poll-edit-row .icon-btn { flex: none; width: 36px; height: 36px; color: var(--c-text-2); }
.poll-mark { flex: none; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--c-text-3); background: none; color: transparent; }
.poll-mark svg { width: 16px; height: 16px; stroke-width: 3; }
.is-correct .poll-mark { background: #34c759; box-shadow: none; color: #fff; }
.poll-add { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin: 0; padding: 4px; }
.poll-add svg { width: 18px; height: 18px; }
.modal-switches { display: flex; flex-direction: column; }
.tp-quick { display: flex; flex-direction: column; gap: 4px; }
.tp-opt { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px; border: 0; border-radius: 16px; background: rgba(255, 255, 255, 0.06); color: var(--c-text); font-size: 15px; text-align: left; }
.tp-opt svg { width: 20px; height: 20px; color: var(--c-accent); }
.tp-opt small { color: var(--c-text-2); font-size: 12px; }
.sched-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sched-item { display: flex; align-items: center; gap: 6px; padding: 8px 6px 8px 12px; border-radius: 16px; background: rgba(255, 255, 255, 0.06); }
.sched-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.sched-text b { color: var(--c-accent); font-size: 12px; }
.sched-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-item .icon-btn { width: 38px; height: 38px; }
.sched-item .danger { color: var(--c-error); }

/* напоминание в чате Kosmo */
.msg-reminder .msg-title { display: flex; align-items: center; gap: 8px; }
.msg-reminder .msg-title svg { width: 20px; height: 20px; color: var(--c-accent); }

/* ---------- Истории ---------- */
.stories { display: flex; gap: 12px; max-width: 680px; margin: 0 auto; padding: 4px 16px 12px; overflow-x: auto; scrollbar-width: none; }
.stories::-webkit-scrollbar { display: none; }
.stories:empty { display: none; }
.story { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 70px; padding: 0; border: 0; background: none; color: var(--c-text); animation: pop-in 420ms var(--spring-bouncy) both; }
.story-ring { position: relative; display: grid; place-items: center; width: 66px; height: 66px; border-radius: 50%; padding: 3px; background: rgba(255, 255, 255, 0.18); }
.story-ring.is-unseen { background: conic-gradient(from 200deg, var(--c-accent), #ff6ec4, #ffb347, var(--c-accent)); }
.story-ring .avatar { width: 100%; height: 100%; box-shadow: 0 0 0 3px var(--page-bg); }
.story-ring.is-add { background: none; padding: 0; }
.story-plus { position: absolute; right: -1px; bottom: -1px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--c-accent); color: #fff; box-shadow: 0 0 0 3px var(--page-bg); }
.story-plus svg { width: 14px; height: 14px; stroke-width: 3; }
.story-name { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--c-text-2); }
.avatar-story { font-size: 22px; }

.story-viewer { position: fixed; inset: 0; z-index: 82; background: #000; color: #fff; touch-action: none; user-select: none; animation: story-in 360ms var(--spring) both; transition: transform 250ms ease; }
@keyframes story-in { from { opacity: 0; transform: scale(0.9); } }
.story-viewer.is-closing { animation: fade-out 220ms ease both; }
.sv-media { position: absolute; inset: 0; display: grid; place-items: center; }
.sv-media img, .sv-media video { width: 100%; height: 100%; object-fit: contain; }
.sv-top { position: absolute; left: 0; right: 0; top: 0; z-index: 2; padding: max(10px, env(safe-area-inset-top)) 10px 18px; background: linear-gradient(rgba(0, 0, 0, 0.55), transparent); }
.sv-bars { display: flex; gap: 4px; }
.sv-bar { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.35); overflow: hidden; }
.sv-bar i { display: block; height: 100%; background: #fff; transform: scaleX(0); transform-origin: 0 50%; }
.sv-bar.is-done i { transform: scaleX(1); }
.sv-head { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.sv-who { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.sv-who small { color: rgba(255, 255, 255, 0.7); font-size: 13px; }
.sv-tap { position: absolute; top: 90px; bottom: 90px; z-index: 1; width: 35%; border: 0; background: none; }
.sv-prev { left: 0; }
.sv-next { right: 0; width: 65%; }
.sv-caption { position: absolute; left: 16px; right: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 66px); z-index: 2; margin: 0; text-align: center; font-size: 16px; line-height: 1.4; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7); }
.sv-caption:empty { display: none; }
.sv-reply { position: absolute; left: 12px; right: 12px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 3; display: flex; flex-direction: row; align-items: center; gap: 8px; width: auto; }
.sv-reply input { flex: 1; min-width: 0; height: 46px; padding: 0 18px; border: 1px solid rgba(255, 255, 255, 0.4); border-radius: 999px; outline: 0; background: rgba(0, 0, 0, 0.3); color: #fff; font-size: 16px; }
.sv-like, .sv-send { flex: none; width: 46px; height: 46px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.14); color: #fff; transition: scale 300ms var(--spring-bouncy); }
.sv-like .emoji { width: 26px; height: 26px; filter: grayscale(1) brightness(1.6); transition: filter 200ms ease; }
.sv-like.is-on .emoji { filter: none; }
.sv-like.is-on { scale: 1.1; }
.sv-send svg { width: 20px; height: 20px; }
.sv-seen { position: absolute; left: 0; right: 0; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 3; display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 14px; color: rgba(255, 255, 255, 0.85); }
.sv-seen svg { width: 18px; height: 18px; }
.sv-likes { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.sv-likes .emoji { width: 18px; height: 18px; }

/* ---------- Поиск: вкладки и медиа ---------- */
.search-tabs { display: flex; gap: 6px; padding: 0 16px 8px; max-width: 680px; width: 100%; margin: 0 auto; }
.search-tabs button { flex: 1; height: 36px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.06); color: var(--c-text-2); font-weight: 600; font-size: 14px; }
.search-tabs [aria-selected="true"] { background: var(--c-accent); color: #fff; }
html[data-theme="material"] .search-tabs [aria-selected="true"] { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; border-radius: 16px; overflow: hidden; }
.media-cell { position: relative; aspect-ratio: 1; padding: 0; border: 0; background: #111; overflow: hidden; cursor: zoom-in; }
.media-cell img, .media-cell video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

/* ---------- Аккаунты ---------- */
.account-row .avatar { width: 36px; height: 36px; }
.account-row .row-text { display: flex; flex-direction: column; line-height: 1.25; }
.account-row .row-text b { font-weight: 600; font-size: 16px; }
.account-row .row-text small { font-size: 13px; color: var(--c-text-2); }
.account-row.is-current { cursor: default; color: inherit; }
.account-check { width: 22px; height: 22px; color: var(--c-accent); stroke-width: 2.6; }
.auth-cancel { position: fixed; z-index: 7; top: max(16px, env(safe-area-inset-top)); left: 16px; display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Вход по QR ---------- */
.qr-box svg { width: 100%; height: 100%; border-radius: 16px; }
.qr-code { margin: 4px 0 0; text-align: center; color: var(--c-text-2); font-size: 15px; }
.qr-code b { color: var(--c-text); font-size: 20px; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.qr-loading { width: 100%; height: 100%; border-radius: 16px; background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.14), rgba(255,255,255,0.06)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.qr-fallback { display: grid; place-items: center; width: 100%; height: 100%; font-size: 28px; font-weight: 700; letter-spacing: 0.1em; }
.scan-box { position: relative; aspect-ratio: 1; border-radius: 24px; overflow: hidden; background: #000; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, 0.9); border-radius: 24px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35); }
.scan-hint { position: absolute; left: 0; right: 0; bottom: 12px; margin: 0; text-align: center; color: #fff; font-size: 14px; }
.scan-box.is-off { aspect-ratio: auto; height: 80px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.06); }
.scan-box.is-off video, .scan-box.is-off .scan-frame { display: none; }
.scan-box.is-off .scan-hint { position: static; color: var(--c-text-2); padding: 0 16px; }
.link-modal #link-code { text-transform: uppercase; letter-spacing: 0.2em; text-align: center; font-size: 20px; font-variant-numeric: tabular-nums; }
.menu-sub > span svg { width: 22px; height: 22px; flex: none; }
.chat-menu { width: 290px; }
.menu-sub .seg-btn { white-space: nowrap; font-size: 12px; padding: 0 4px; }
.pill-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---------- Ввод кода с сервера ---------- */
.code-hint { margin: -6px 0 18px; color: var(--c-text-2); font-size: 15px; text-align: center; }
.code-resend { margin-top: 22px; }
.code-resend:disabled { color: var(--c-text-3); }
.otp.is-checking { opacity: 0.6; pointer-events: none; }
.otp.is-error .otp-cells { animation: shake 420ms cubic-bezier(0.36, 0.07, 0.19, 0.97); }
.otp.is-error .otp-cell { border-color: var(--c-error) !important; }
