/* ===== Пузыри сообщений в стиле макета с главной страницы =====
   Подключается последним: перекрывает слои chat/cozy/flat/type/calm.
   Свои сообщения — светло-серые с тёмным текстом (по умолчанию) или светло-зелёные (при выборе «зелёного»),
   чужие — тёмно-серые; мягкие скругления с «хвостиком» у последнего сообщения в серии,
   голосовые — зелёная круглая кнопка + волна + длительность, «печатает…» — аватарка, три точки и подпись. */

.chat{--mb-in:#1f1f22;--mb-in-fg:#ececee;--mb-out:#ececee;--mb-out-fg:#0b0b0c;--mb-r:20px;--mb-tail:6px}
/* свои сообщения: «светлые» (по умолчанию) — светло-серые с тёмным текстом; «зелёные» — по выбору */
.chat[data-bub=light]{--mb-out:#ececee;--mb-out-fg:#0b0b0c;--mb-me:#0b0b0c}
.chat[data-bub=green]{--mb-out:#5fd49a;--mb-out-fg:#06140d;--mb-me:#2bb672}

/* ---- общая форма ---- */
html .chat .m-bub{border-radius:var(--mb-r);border:0;padding:9px 14px;box-shadow:none;font-size:15.5px;line-height:1.38}
html .chat .msg.them:not(.cont) .m-bub{border-end-start-radius:var(--mb-tail)}
html .chat .msg.me:not(.cont) .m-bub{border-end-end-radius:var(--mb-tail)}
html .chat .msg.them.cont .m-bub{border-start-start-radius:10px}
html .chat .msg.me.cont .m-bub{border-start-end-radius:10px}
html .chat .msg{margin-top:8px}
html .chat .msg.cont{margin-top:3px}
html .chat .msg .m-text{font-size:inherit;line-height:inherit}

/* ---- входящие ---- */
html:not(#mb) .chat .msg.them .m-bub:not(.only-media){background:var(--mb-in)!important;color:var(--mb-in-fg)}

/* ---- исходящие: зелёный (по умолчанию) ---- */
html:not(#mb) .chat:is([data-bub=green],[data-bub=light]) .msg.me .m-bub:not(.only-media){background:var(--mb-out)!important;color:var(--mb-out-fg)!important}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-text,.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-text a{color:var(--mb-out-fg)}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-text a{text-decoration:underline;text-underline-offset:2px;text-decoration-color:rgba(15,15,17,0.4)}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-text a.mention{color:var(--mb-out-fg);font-weight:700;text-decoration:none}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-time,.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-time em{color:rgba(15,15,17,0.58)}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-st,.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-st.rd{color:#343436}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-quote{border-color:rgba(15,15,17,0.55);background:rgba(15,15,17,0.08);color:rgba(15,15,17,0.8)}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-quote b{color:var(--mb-out-fg)}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-fwd,.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-fwd *{color:rgba(15,15,17,0.75)}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-tr{color:rgba(15,15,17,0.7)}
.chat:is([data-bub=green],[data-bub=light]) .msg.me ::selection{background:rgba(15,15,17,0.25)}

/* ---- имя автора в группе ---- */
html .chat .m-who{font-size:13px;font-weight:650;margin-bottom:2px}

/* ---- аватарки рядом с сообщениями: крупнее и с мягким объёмом, как на макете ---- */
html .chat .m-ava{width:36px}
html .chat .m-ava .ava{width:36px!important;height:36px!important;font-size:14px;font-weight:700;background-image:linear-gradient(140deg,rgba(255,255,255,.22),rgba(0,0,0,.18));box-shadow:none}
html .chat .m-ava .ava img{background-image:none}

/* ---- голосовые как в Telegram: крупная круглая кнопка, тонкая волна у нижнего края,
        под ней «0:05» и точка «не прослушано», время с галочками — внизу справа ---- */
html .chat .m-bub.voice{display:block;width:fit-content;min-width:0;max-width:none;padding:10px 12px 6px 10px}
html .chat .m-bub.voice>.m-who{display:block;padding-inline-start:4px;margin-bottom:4px}
html .chat .vmsg{display:flex;align-items:center;gap:12px;padding:0;min-width:0}
html .chat .vm-play{width:48px;height:48px;background:var(--accent);color:#0f0f11;box-shadow:none!important}
html .chat .vm-play svg{width:20px;height:20px}
html .chat .vmsg:not(.playing) .vm-play svg{margin-inline-start:3px}
html .chat .vmsg{--vm-off:rgba(236,236,238,0.38);--vm-on:var(--accent)}
html .chat .vm-body{display:flex;flex-direction:column;align-items:flex-start;gap:7px;min-width:0;padding:2px 0 0}
html .chat .vmsg .vm-wave{flex:none;width:176px;height:22px}
html .chat .vm-meta{display:flex;align-items:center;gap:7px;height:auto;font:500 13.5px/1 var(--f-b,inherit);font-variant-numeric:tabular-nums;color:rgba(236,236,238,0.55)}
html .chat .vm-new{display:inline-block;width:6px;height:6px;border-radius:50%;background:currentColor;opacity:.9}
html .chat .vmsg.heard .vm-new,html .chat .msg.me .vm-new{display:none}
html .chat .vmsg.playing .vm-t{color:var(--accent)}
html .chat .vmsg:not(.playing) .vm-speed:not(.set){display:none}
html:not(#mb) .chat .m-bub.voice>.m-time{position:static;display:flex;justify-content:flex-end;align-items:center;gap:3px;margin:2px -2px 0 0;float:none;font-size:11.5px;color:rgba(236,236,238,0.5)!important;opacity:1}
/* в своём пузыре любого цвета — белая кнопка с треугольником цвета пузыря, волна и подписи — цветом текста пузыря */
html:not(#mb) .chat .msg.me .vm-play{background:#fff;color:var(--mb-me,var(--bub))}
html .chat .msg.me .vmsg{--vm-off:color-mix(in srgb,currentColor 40%,transparent);--vm-on:currentColor}
html .chat .msg.me .vm-meta,html .chat .msg.me .vmsg.playing .vm-t{color:color-mix(in srgb,currentColor 70%,transparent)}
html:not(#mb) .chat .msg.me .m-bub.voice>.m-time{color:color-mix(in srgb,currentColor 65%,transparent)!important}

.chat:is([data-bub=green],[data-bub=light]) .msg.me .vm-speed{background:rgba(15,15,17,0.12);color:var(--mb-out-fg)}
html:not(#mb) .chat[data-bub=light] .msg.me .vm-play{background:#0b0b0c;color:#ececee}
@media (max-width:380px){html .chat .vmsg .vm-wave{width:140px}}

/* ---- стикеры и большие эмодзи: без пузыря, крупно ---- */
html .chat .m-stk img{width:160px;height:160px;filter:drop-shadow(0 8px 18px rgba(0,0,0,.35))}
html .chat .msg.bare .m-time{background:rgba(13,13,15,0.6);color:var(--fg)}

/* ---- «печатает…»: аватарка, пузырь с точками и подпись ---- */
.ch-typing.mb-ty{position:static;display:flex;align-items:center;gap:10px;padding:2px 14px 8px;min-height:36px;font-size:14px;color:var(--dim);pointer-events:none}
.ch-typing.mb-ty[hidden]{display:none}
.mb-ty .ava{width:26px!important;height:26px!important;font-size:11px;flex:none;background-image:linear-gradient(140deg,rgba(255,255,255,.22),rgba(0,0,0,.18))}
.mb-dots{display:inline-flex;align-items:center;gap:4px;padding:9px 12px;border-radius:16px;border-end-start-radius:6px;background:var(--mb-in)}
.mb-dots i{width:6px;height:6px;border-radius:50%;background:rgba(236,236,238,0.6);animation:mbDot 1.2s ease-in-out infinite}
.mb-dots i:nth-child(2){animation-delay:.15s}.mb-dots i:nth-child(3){animation-delay:.3s}
.mb-dots.voice i{border-radius:2px;width:3px;height:10px;animation-name:mbBar}
@keyframes mbDot{0%,60%,100%{opacity:.35;transform:translateY(0)}30%{opacity:1;transform:translateY(-3px)}}
@keyframes mbBar{0%,100%{transform:scaleY(.45)}50%{transform:scaleY(1.15)}}
.mb-ty b{color:var(--muted);font-weight:600}
.mb-ty.in{animation:mbIn .25s var(--ease,ease) both}
@keyframes mbIn{from{opacity:0;transform:translateY(6px)}}
@media (prefers-reduced-motion:reduce){.mb-dots i,.mb-ty.in{animation:none}}

/* голосовые компактнее: кнопка 54px по центру, время на одной строке с длительностью, без лишнего низа */
html .chat .m-bub.voice{position:relative;padding:9px 12px 9px 9px}
html:not(#mb) .chat .vmsg .vm-play{width:54px;height:54px}
html:not(#mb) .chat .vmsg .vm-play svg{width:22px;height:22px}
html .chat .vmsg{align-items:center}
html .chat .vm-body{padding:0;justify-content:center}
html:not(#mb) .chat .m-bub.voice>.m-time{position:absolute;inset-inline-end:12px;bottom:14px;margin:0;line-height:1}

/* на светло-зелёных своих пузырях всё второстепенное — тёмное, чтобы читалось (цитата, опрос, подписи) */
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-bub:not(.only-media) :is(.muted,.dim,small,.m-quote span){color:rgba(15,15,17,0.66)!important}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-poll :is(.mp-q,.mp-o,.mp-o b,.mp-c){color:var(--mb-out-fg)!important}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-poll .mp-o{background:rgba(15,15,17,0.08)!important;border-color:rgba(15,15,17,0.1)!important}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-poll .mp-bar{background:rgba(15,15,17,0.14)!important}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-poll .mp-ic{background:rgba(15,15,17,0.1)!important;color:var(--mb-out-fg)!important}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-poll :is(.mp-rd,.mp-box){border-color:rgba(15,15,17,0.45)!important}
.chat:is([data-bub=green],[data-bub=light]) .msg.me .m-poll .mp-f button:not(.pri){color:rgba(15,15,17,0.75)!important}

/* свои сообщения тёмно-серыми с белым текстом (по умолчанию) — заметно светлее чужих */
.chat[data-bub=dgray]{--mb-out:#38383c;--mb-out-fg:#f2f2f4}
html:not(#mb) .chat[data-bub=dgray] .msg.me .m-bub:not(.only-media){background:var(--mb-out)!important;color:var(--mb-out-fg)!important}
.chat[data-bub=dgray] .msg.me :is(.m-text,.m-text a){color:var(--mb-out-fg)}
.chat[data-bub=dgray] .msg.me :is(.m-time,.m-time em){color:rgba(242,242,244,.5)}
.chat[data-bub=dgray] .msg.me .m-quote{border-color:rgba(255,255,255,.5);background:rgba(255,255,255,.07)}
.chat[data-bub=dgray] .msg.me .m-quote b{color:#fff}
.look-bub [data-bub=dgray]{box-shadow:inset 0 0 0 1px rgba(255,255,255,.18)}

/* голосовые — компактнее: меньше кнопка, короче волна, тоньше пузырь */
html:not(#mb) .chat .m-bub.voice{padding:7px 11px 5px 7px}
html:not(#mb) .chat .vmsg{gap:9px}
html:not(#mb) .chat .vmsg .vm-play{width:40px;height:40px}
html:not(#mb) .chat .vmsg .vm-play svg{width:16px;height:16px}
html:not(#mb) .chat .vmsg .vm-body{gap:5px}
html:not(#mb) .chat .vmsg .vm-wave{width:150px;height:18px}
html:not(#mb) .chat .vmsg .vm-meta{font-size:12px;gap:6px}
@media (max-width:380px){html:not(#mb) .chat .vmsg .vm-wave{width:124px}}
