/* «Обсуждение» — вид мессенджера. Тёмная тема по умолчанию, светлая — по настройке устройства. */
:root { --icon-reply: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 7L4 12l6 5M4 12h10a6 6 0 0 1 6 6v1'/%3E%3C/svg%3E");
  color-scheme: dark;
  --bg: #0e1621; --bg-dot: rgba(255,255,255,.035); --header: #17212b; --panel: #17212b; --panel-2: #202b36;
  --bubble-in: #182533; --bubble-out: #2b5278; --text: #f5f7fa; --muted: #8b9bab; --muted-out: #9fc1e0;
  --accent: #5eb5f7; --accent-text: #0b1a26; --link: #71baf5; --danger: #ef5b5b; --sep: rgba(255,255,255,.07);
  --chip: rgba(10,20,30,.55); --reaction: rgba(94,181,247,.16); --reaction-mine: #3a7cc0; --shadow: 0 6px 24px rgba(0,0,0,.35);
  --notice: #3b321a; --notice-border: #8a6d2a; --header-glass: rgba(23,33,43,.86);
  --tail: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 20'%3E%3Cpath d='M3 2h6v17c-.193-2.84-.876-5.767-2.05-8.782-.904-2.325-2.446-4.485-4.625-6.48A1 1 0 013 2z' transform='matrix(1 0 0 -1 0 21)'/%3E%3C/svg%3E");
  --mic-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21'/%3E%3C/svg%3E");
  --camera-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='6' width='12' height='12' rx='3'/%3E%3Cpath d='M15 10.5l6-3.5v10l-6-3.5'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #d9e4ec; --bg-dot: rgba(40,80,110,.07); --header: #ffffff; --panel: #ffffff; --panel-2: #f1f4f7;
    --bubble-in: #ffffff; --bubble-out: #e3f6d4; --text: #111b24; --muted: #7c8b99; --muted-out: #5d9a58;
    --accent: #3390ec; --accent-text: #ffffff; --link: #2a7fd4; --danger: #e0393e; --sep: rgba(0,0,0,.08);
    --chip: rgba(40,70,90,.42); --reaction: rgba(51,144,236,.12); --reaction-mine: #3390ec; --shadow: 0 6px 24px rgba(20,40,60,.18);
    --notice: #fff5d6; --notice-border: #e3c16f; --header-glass: rgba(255,255,255,.88);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
.comments-page { min-height: 100dvh; padding-top: env(safe-area-inset-top); color: var(--text); background: var(--bg); background-image: radial-gradient(var(--bg-dot) 1.4px, transparent 1.6px); background-size: 22px 22px; background-attachment: fixed; }
.comments-page[data-screen-name]:not([data-screen-name="room"]) { background-image: none; }
.comments-page [hidden] { display: none !important; }
.comments-page button { font: inherit; color: inherit; cursor: pointer; }
.comments-page button:disabled { cursor: default; opacity: .5; }
.comments-page a { color: var(--link); }
.comments-page :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.composer-field textarea:focus-visible { outline: none; }
.comments-page svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.comments-page circle { fill: currentColor; stroke: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.comments-muted { color: var(--muted); font-size: 15px; }

/* Шапка */
/* Как в Telegram: плавающая скруглённая шапка, лента видна по краям. */
.comments-top { position: sticky; top: 8px; z-index: 20; display: flex; align-items: center; gap: 2px; width: calc(100% - 16px); max-width: 744px; height: 48px; margin: 8px auto 0; padding: 0 4px; border-radius: 24px; background: var(--header-glass); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); box-shadow: 0 1px 5px -1px rgba(0,0,0,.21); }
.comments-top .icon-button { width: 40px; height: 40px; }
#comments-menu-button.has-avatar svg { display: none; }
#comments-menu-button .avatar { width: 40px; height: 40px; font-size: 15px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.icon-button:active { background: var(--sep); }
#comments-back { color: var(--text); }
.top-title { flex: 1; min-width: 0; padding: 0 6px; }
#comments-back[hidden] + .top-title { padding-left: 14px; }
.top-title h1 { margin: 0; overflow: hidden; font-size: 16px; font-weight: 600; line-height: 21px; text-overflow: ellipsis; white-space: nowrap; }
.top-subtitle { margin: 0; overflow: hidden; color: var(--muted); font-size: 14px; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.top-subtitle span:empty { display: none; }
#comments-count:not(:empty)::before { content: " · "; }

/* Всплывающая строка состояния */
.comments-status { position: fixed; top: calc(68px + env(safe-area-inset-top)); left: 50%; z-index: 40; max-width: min(92vw, 520px); margin: 0; padding: 9px 16px; border-radius: 18px; color: #fff; background: rgba(20,28,36,.92); box-shadow: var(--shadow); font-size: 15px; text-align: center; transform: translateX(-50%); transition: opacity .2s; pointer-events: none; }
.comments-status:empty, .comments-status.is-hidden { opacity: 0; }
.comments-status[data-kind="error"] { background: #8c2f35; }
.comments-status[data-kind="warning"] { background: #7a5a16; }

/* Экраны */
.comments-screen { width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 8px 24px; }
.chat-screen { display: flex; flex-direction: column; min-height: calc(100dvh - 56px - env(safe-area-inset-top)); padding-bottom: calc(var(--composer-h, 64px) + 12px); }
.chat-screen::before { content: ""; flex: 1 1 auto; }
.comments-card { margin: 10px 4px; padding: 14px 16px; border-radius: 16px; background: var(--panel); }
.comments-card h2 { margin: 0 0 6px; font-size: 17px; }
.comments-card p { margin: 0 0 10px; }
.notice-card { text-align: center; }
.notice, .comments-page .notice { border: 1px solid var(--notice-border); background: var(--notice); color: var(--text); border-radius: 14px; padding: 10px 14px; margin: 8px 4px; font-size: 15px; }
#comments-pending-operations { margin: 8px; }
#comments-pending-operations .comments-card { margin: 0 0 8px; background: transparent; padding: 0; }

/* Пост, который обсуждают */
/* Пост — первое сообщение обсуждения, целиком, под ним отметка «Начало обсуждения». */
.comments-source { align-self: flex-start; width: 100%; max-width: min(96%, 640px); margin: 6px 0 2px; padding: 8px 12px 10px; border-radius: 16px 16px 16px 6px; background: var(--bubble-in); box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.comments-source[hidden] + .source-caption { display: none; }
.source-head { display: flex; align-items: center; gap: 8px; margin-bottom: 1px; }
.source-head h2 { margin: 0; color: var(--accent); font-size: 15px; font-weight: 600; }
.comments-source .post-quote, .comments-source p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; }
.source-caption { display: block; width: fit-content; margin: 10px auto 2px; padding: 3px 12px; border-radius: 12px; color: #fff; background: var(--chip); font-size: 14px; }

/* Лента */
.comments-list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 4px 0 0; list-style: none; }
/* Дата прилипает под шапкой при прокрутке, как в Telegram. */
.day-sep { position: sticky; top: 64px; z-index: 5; align-self: center; margin: 8px 0 6px; padding: 4px 10px; border-radius: 14px; color: #fff; background: var(--chip); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-size: 15px; font-weight: 500; line-height: 20px; }
.chip-button { display: block; margin: 8px auto; padding: 7px 16px; border: 0; border-radius: 16px; color: #fff; background: var(--chip); font-size: 15px; }
.empty.chat-empty { width: fit-content; max-width: 80%; margin: 24px auto; padding: 10px 18px; border-radius: 16px; color: #fff; background: var(--chip); text-align: center; font-size: 15px; }
.empty { padding: 28px 12px; color: var(--muted); text-align: center; font-size: 15px; }

.comment { position: relative; display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.comment .bubble { touch-action: pan-y; }
.comment.swipe-back { transition: transform .25s cubic-bezier(.4,0,.2,1); }
.swipe-reply { position: absolute; top: 50%; right: 4px; width: 32px; height: 32px; margin-top: -16px; border-radius: 50%; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; }
.swipe-reply::before { content: ""; position: absolute; inset: 6px; background: #fff; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.comment.grp-first { margin-top: 4px; }
.comment.mine { justify-content: flex-end; }
.comment .avatar { visibility: hidden; }
.comment.grp-last .avatar { visibility: visible; }
.comment.mine .avatar { display: none; }
.bubble { position: relative; min-width: 76px; max-width: min(82%, 540px); padding: 5px 9px 6px; border-radius: 15px; background: var(--bubble-in); box-shadow: 0 1px 1px rgba(0,0,0,.12); overflow-wrap: anywhere; cursor: pointer; }
/* Серия сообщений как в Telegram: со стороны хвостика углы 5px, у последнего — 0 и хвостик. */
.comment:not(.grp-first) .bubble { border-top-left-radius: 5px; }
.comment:not(.grp-last) .bubble { border-bottom-left-radius: 5px; }
.comment.grp-last .bubble { border-bottom-left-radius: 0; }
.comment.mine .bubble { background: var(--bubble-out); border-top-left-radius: 15px; border-bottom-left-radius: 15px; }
.comment.mine:not(.grp-first) .bubble { border-top-right-radius: 5px; }
.comment.mine:not(.grp-last) .bubble { border-bottom-right-radius: 5px; }
.comment.mine.grp-last .bubble { border-bottom-right-radius: 0; }
.comment.grp-last .bubble::after { content: ""; position: absolute; bottom: 0; left: -8.4px; width: 11px; height: 20px; background: inherit; -webkit-mask: var(--tail) center / contain no-repeat; mask: var(--tail) center / contain no-repeat; }
.comment.mine.grp-last .bubble::after { right: -8.4px; left: auto; transform: scaleX(-1); }
.source-post-root .bubble { border-radius: 15px; }
.source-post-root .bubble::after { display: none; }
.comment.is-selected { position: relative; z-index: 46; pointer-events: none; }
.comment.is-highlighted .bubble { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 1px 1px rgba(0,0,0,.12); } }
.msg-author { display: none; margin-bottom: 1px; font-size: 15px; font-weight: 600; line-height: 1.3; }
.comment.grp-first:not(.mine) .msg-author { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.msg-badge { color: var(--muted); font-size: 13px; font-weight: 400; }
.msg-text { margin: 0; white-space: pre-wrap; font-size: 16px; line-height: 1.3125; }
.msg-text.is-deleted { color: var(--muted); font-style: italic; }
.msg-link { color: var(--link); text-decoration: none; overflow-wrap: anywhere; cursor: pointer; }
.msg-link:hover { text-decoration: underline; }
.comment.mine .msg-link { color: inherit; text-decoration: underline; }
.comment-notice { display: flex; justify-content: center; margin: 6px 0; list-style: none; }
.notice-bubble { max-width: 85%; margin: 0; padding: 6px 12px; border-radius: 14px; color: #fff; background: var(--chip); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); font-size: 14px; line-height: 1.35; text-align: center; white-space: pre-wrap; }
.msg-meta { float: right; position: relative; top: 7px; margin: -4px 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.6; white-space: nowrap; user-select: none; }
.comment.mine .msg-meta { color: var(--muted-out); }
.msg-check { margin-left: 4px; letter-spacing: -2px; }
.comment.mine .msg-check { color: var(--accent); }
.msg-meta-line { display: flex; justify-content: flex-end; margin-top: 2px; }
.msg-meta-line .msg-meta { float: none; top: 0; margin: 0; }
.comment.mine.media-only .bubble, .comment.media-only:not(.grp-first) .bubble { padding: 0; background: none; box-shadow: none; }
.comment.mine.media-only .bubble::after, .comment.media-only:not(.grp-first) .bubble::after { display: none; }
.comment.media-only .attachment-list { margin: 0; }
.comment.media-only .attachment-album, .comment.media-only .attachment-card .attachment-image { border-radius: 15px; }
.comment.mine.media-only .msg-meta-line, .comment.media-only:not(.grp-first) .msg-meta-line { position: absolute; right: 6px; bottom: 6px; margin: 0; }
.comment.mine.media-only .msg-meta, .comment.media-only:not(.grp-first) .msg-meta { padding: 0 6px; border-radius: 10px; background: rgba(0,0,0,.45); color: #fff; }
.msg-reply-quote, .msg-post-link { display: block; width: 100%; margin: 3px 0 5px; padding: 3px 8px; border: 0; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--reaction); text-align: left; font-size: 14px; line-height: 1.3; }
.msg-reply-quote { position: relative; overflow: hidden; color: var(--person, var(--accent)); border-left-color: currentColor; background: none; }
.msg-reply-quote::before { content: ""; position: absolute; inset: 0; background: currentColor; opacity: .12; pointer-events: none; }
.msg-reply-quote strong { display: block; color: inherit; font-size: 14px; }
.msg-reply-quote span { display: block; overflow: hidden; color: var(--text); opacity: .85; text-overflow: ellipsis; white-space: nowrap; }
.comment.same-thread .msg-post-link { display: none; }
.msg-reactions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px; margin: 6px 0 0; }
.msg-reactions .msg-meta { float: none; top: 0; margin: 0 0 0 auto; padding-left: 8px; }
.msg-reactions button { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 9px 0 6px; border: 0; border-radius: 15px; background: var(--reaction); color: var(--accent); font-size: 14px; font-weight: 600; transition: background-color .2s, color .2s; }
.reaction-emoji { font-size: 20px; line-height: 1; }
.msg-reactions button.is-popped .reaction-emoji { animation: reaction-pop .35s cubic-bezier(.4,0,.2,1); }
@keyframes reaction-pop { 50% { transform: scale(1.3); } }
.msg-reactions button[aria-pressed="true"] { background: var(--reaction-mine); color: #fff; }
.comment.mine .msg-reactions button { background: rgba(255,255,255,.14); color: var(--text); }
.comment.mine .msg-reactions button[aria-pressed="true"] { background: var(--reaction-mine); color: #fff; }

/* Аватары */
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; border-radius: 50%; color: #fff; font-size: 14px; font-weight: 600; object-fit: cover; user-select: none; }
.c0 { --person: #e17076; } .c1 { --person: #eda86c; } .c2 { --person: #a695e7; } .c3 { --person: #7bc862; }
.c4 { --person: #6ec9cb; } .c5 { --person: #65aadd; } .c6 { --person: #ee7aae; }
span.avatar { background-color: var(--person, #65aadd); background-image: linear-gradient(160deg, rgba(255,255,255,.14), rgba(0,0,0,.14)); }
.avatar-channel { --person: #3390ec; }
.msg-author { color: var(--person, var(--accent)); }

/* Пост канала в общей ленте */
.source-post-root { align-self: stretch; margin: 8px 0; }
.source-post-root .bubble { width: 100%; max-width: min(96%, 640px); margin: 0 auto; cursor: default; }
.post-label { display: block; margin-bottom: 2px; color: var(--accent); font-size: 14px; font-weight: 600; }
.post-text { display: -webkit-box; margin: 0; overflow: hidden; white-space: pre-wrap; -webkit-line-clamp: 4; -webkit-box-orient: vertical; font-size: 16px; }
.post-open { display: block; width: calc(100% + 20px); margin: 8px -10px -6px; padding: 10px; border: 0; border-top: 1px solid var(--sep); border-radius: 0 0 16px 16px; background: transparent; color: var(--accent); font-size: 15px; font-weight: 600; }

/* Опрос */
.comment-poll { min-width: min(64vw, 280px); margin: 4px 0 2px; }
.comment-poll h3 { margin: 0 0 2px; font-size: 16px; }
.poll-kind { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.comment.mine .poll-kind { color: var(--muted-out); }
.poll-options { display: grid; gap: 2px; }
.poll-option { position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 6px; border-radius: 10px; overflow: hidden; font-size: 16px; cursor: pointer; }
.poll-option input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.poll-option span { flex: 1; }
.poll-bar { position: absolute; left: 0; bottom: 0; height: 3px; border-radius: 2px; background: var(--accent); }
.poll-count { color: var(--muted); font-size: 14px; font-weight: 600; }
.poll-option.is-correct span::after { content: " ✓"; color: #4fbf67; font-weight: 700; }
.poll-option.is-correct .poll-bar { background: #4fbf67; }
.poll-option.is-wrong span::after { content: " ✗"; color: var(--danger); font-weight: 700; }
.poll-option.is-wrong .poll-bar { background: var(--danger); }
.poll-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; }
.poll-footer button { min-height: 36px; padding: 4px 0; border: 0; background: transparent; color: var(--accent); font-size: 15px; font-weight: 600; }
.poll-footer .comments-muted { font-size: 14px; }

/* Вложения */
.attachment-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.attachment-list img, .attachment-list video { display: block; max-width: min(100%, 320px); max-height: 360px; border-radius: 12px; }
.attachment-list audio { width: min(64vw, 280px); }
.attachment-list a, .attachment-list button { font-size: 15px; }
.attachment-list button { min-height: 36px; padding: 4px 12px; border: 0; border-radius: 12px; background: var(--reaction); color: var(--accent); }
.pending-files { margin-bottom: 8px; padding: 6px; border-radius: 18px; background: var(--panel); box-shadow: 0 1px 8px 1px rgba(0,0,0,.12); }
.pending-files:empty { display: none; }
/* Кружок: обложка — первый кадр, вокруг кольцо прогресса. */
.circle-player { position: relative; width: min(64vw, 240px); aspect-ratio: 1; margin-inline: auto; }
.circle-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.circle-ring circle { fill: none; stroke-width: 3; }
.ring-track { stroke: rgba(127,127,127,.25); }
.ring-bar { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 301.6; stroke-dashoffset: 301.6; }
.circle-player .circle-media-frame { position: absolute; inset: 5%; display: block; min-height: 0; padding: 0; overflow: hidden; border: 0; border-radius: 50%; background: var(--panel-2) center / cover no-repeat; }
.circle-player video { display: block; width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0; object-fit: cover; }
.circle-play { position: absolute; top: 50%; left: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(0,0,0,.45); }
.circle-play::before { content: ""; position: absolute; top: 17px; left: 22px; border: 11px solid transparent; border-left: 18px solid #fff; border-right: 0; }
.circle-player.is-playing .circle-play { display: none; }
.circle-badge { position: absolute; bottom: 12%; left: 50%; transform: translateX(-50%); padding: 1px 8px; border-radius: 10px; color: #fff; background: rgba(0,0,0,.45); font-size: 12px; }
.circle-badge:empty { display: none; }
.circle-player .circle-mute { position: absolute; right: 2%; bottom: 2%; z-index: 1; width: 40px; height: 40px; min-height: 0; padding: 0; border: 0; border-radius: 50%; color: #fff; background: rgba(0,0,0,.55); font-size: 18px; line-height: 40px; }
.recording-panel { margin: 0 0 8px; padding: 10px 12px; border-radius: 18px; background: var(--panel); box-shadow: 0 1px 8px 1px rgba(0,0,0,.12); }
.recording-panel p { margin: 0 0 8px; }
.recording-preview { display: block; max-width: 100%; max-height: 240px; margin: 0 auto 8px; border-radius: 12px; }
.recording-preview[data-kind="circle"] { width: min(60vw, 220px); max-height: none; aspect-ratio: 1; border-radius: 50%; object-fit: cover; transform: scaleX(-1); }
.recording-preview[data-kind="circle"][controls] { transform: none; }
.recording-wave { display: block; width: 240px; max-width: 100%; height: 40px; margin: 0 auto 8px; color: var(--accent); }
.recording-hint { font-size: 14px; }
.recording-actions, .recording-controls { display: flex; gap: 8px; justify-content: flex-end; }

/* Поле ввода */
/* Как в Telegram: «таблетка» с полем висит над лентой, круглая кнопка — рядом. */
#comments-composer-card { position: fixed; right: 0; bottom: 0; left: 0; z-index: 15; width: min(100%, 760px); margin: 0 auto; padding: 0 8px calc(8px + env(safe-area-inset-bottom)); pointer-events: none; }
#comments-composer-card > * { pointer-events: auto; }
.comments-composer { display: flex; align-items: flex-end; gap: 8px; }
.composer-pill { flex: 1; min-width: 0; border-radius: 24px; background: var(--panel); box-shadow: 0 1px 8px 1px rgba(0,0,0,.12); }
.composer-row { display: flex; align-items: flex-end; min-height: 48px; padding: 0 4px; }
.composer-row .icon-button { width: 40px; height: 40px; margin: 4px 0; }
.composer-field { position: relative; flex: 1; min-width: 0; }
.comments-composer textarea { display: block; width: 100%; min-height: 48px; max-height: 160px; margin: 0; padding: 13px 8px; border: 0; border-radius: 0; outline: none; resize: none; color: var(--text); background: transparent; font: inherit; font-size: 16px; line-height: 22px; }
.comments-composer textarea::placeholder { color: var(--muted); }
.comments-composer .send { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; color: #fff; background: var(--accent); box-shadow: 0 1px 8px 1px rgba(0,0,0,.12); transition: transform .15s; }
.comments-composer .send:active { transform: scale(.92); }
.comments-composer .send svg { stroke-width: 2.4; }
.comments-composer .send.is-mic svg { display: none; }
.comments-composer .send.is-mic { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.comments-composer .send.is-holding { transform: scale(1.3); background: var(--danger); }
.comments-composer .send.is-cancelling { background: var(--panel-2); }
.comments-composer .send.is-mic[data-mode="circle"]::before { -webkit-mask-image: var(--camera-icon); mask-image: var(--camera-icon); }
.comments-composer .send.is-mic::before { content: ""; width: 24px; height: 24px; background: currentColor; -webkit-mask: var(--mic-icon) center / contain no-repeat; mask: var(--mic-icon) center / contain no-repeat; }
.author-mode { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 48px; padding: 0; border: 0; background: transparent; }
.author-mode .avatar { width: 34px; height: 34px; font-size: 14px; }
.author-mode.as-channel .avatar { box-shadow: 0 0 0 2px var(--accent); }
#comments-compose-hint { width: fit-content; max-width: 100%; margin: 6px auto 0; padding: 2px 10px; border-radius: 12px; color: #fff; background: var(--chip); font-size: 13px; }
#comments-compose-hint:empty { display: none; }
.reply-preview { display: flex; align-items: center; gap: 8px; margin: 6px 8px 0 12px; padding: 0 0 0 10px; border-left: 3px solid var(--accent); }
.reply-preview > svg { flex: none; color: var(--accent); fill: currentColor; stroke: none; }
#comments-reply-label { flex: 1; min-width: 0; font-size: 14px; line-height: 18px; }
#comments-reply-label strong, #comments-reply-label span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#comments-reply-label strong { color: var(--accent); font-weight: 600; }
#comments-reply-label span { color: var(--muted); }
.readonly-bar { position: fixed; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); left: 8px; z-index: 15; width: auto; max-width: 744px; margin: 0 auto; padding: 13px 16px; border-radius: 24px; background: var(--panel); box-shadow: 0 1px 8px 1px rgba(0,0,0,.12); color: var(--muted); text-align: center; font-size: 15px; }
.readonly-bar p { margin: 0; }
.mention-menu { position: absolute; right: 0; bottom: calc(100% + 8px); left: 0; z-index: 30; max-height: 36dvh; overflow: auto; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.mention-menu button { display: block; width: 100%; min-height: 48px; padding: 8px 14px; border: 0; background: transparent; text-align: left; font-size: 16px; }
.mention-menu button + button { border-top: 1px solid var(--sep); }
.scroll-down { position: fixed; right: 12px; bottom: calc(var(--composer-h, 64px) + 14px); z-index: 14; display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: var(--panel); box-shadow: var(--shadow); }
.scroll-down-badge { position: absolute; top: -6px; left: 50%; min-width: 22px; height: 22px; padding: 0 6px; transform: translateX(-50%); border-radius: 11px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; line-height: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.scroll-down:not([hidden]) ~ .mention-jump { bottom: calc(var(--composer-h, 64px) + 70px); }
.mention-at { font-size: 22px; font-weight: 600; line-height: 1; }
.unread-sep { align-self: stretch; margin: 8px 0; padding: 4px 0; color: #fff; background: var(--chip); font-size: 14px; font-weight: 500; text-align: center; list-style: none; }

/* Нижние панели (меню, вложения) */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop, .msg-menu-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); animation: fade .15s; }
.sheet-panel { position: absolute; right: 0; bottom: 0; left: 0; width: min(100%, 560px); max-height: 80dvh; margin: 0 auto; padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); overflow: auto; border-radius: 18px 18px 0 0; background: var(--panel); animation: rise .18s ease-out; }
.sheet-panel button { display: block; width: 100%; min-height: 52px; padding: 12px 16px; border: 0; border-radius: 12px; background: transparent; text-align: left; font-size: 17px; }
.sheet-panel button:active { background: var(--sep); }
.sheet-panel .sheet-cancel { margin-top: 6px; background: var(--panel-2); color: var(--accent); text-align: center; font-weight: 600; }
.profile-panel { text-align: center; }
.profile-panel .profile-photo { width: 96px; height: 96px; margin: 12px auto 8px; font-size: 36px; }
.profile-panel h2 { margin: 0; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
.profile-panel p { margin: 4px 0 0; }
.msg-author-name { cursor: pointer; }
.is-new { animation: bubble-in .3s cubic-bezier(.4,0,.2,1); }
.comment.mine.is-new { transform-origin: right bottom; }
.comment.is-new { transform-origin: left bottom; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* Меню сообщения */
.msg-menu { position: fixed; inset: 0; z-index: 45; }
.msg-menu-backdrop { background: rgba(0,0,0,.35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.msg-menu-panel { position: absolute; left: 8px; display: flex; flex-direction: column; gap: 8px; width: min(calc(100vw - 16px), 300px); animation: menu-in .2s cubic-bezier(.4,0,.2,1); }
@keyframes menu-in { from { opacity: 0; transform: scale(.85); } }
.msg-menu-reactions { display: flex; flex-wrap: wrap; justify-content: space-between; padding: 4px 6px; border-radius: 26px; background: var(--panel); box-shadow: var(--shadow); }
.msg-menu-reactions:empty { display: none; }
.msg-menu-reactions button { width: 40px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 25px; }
.msg-menu-reactions button[aria-pressed="true"] { background: var(--reaction); }
.msg-menu-actions { overflow: hidden; padding: 4px 0; border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.msg-menu-actions button { display: flex; align-items: center; gap: 16px; width: calc(100% - 8px); min-height: 44px; margin: 0 4px; padding: 8px 12px; border: 0; border-radius: 12px; background: transparent; color: var(--text); text-align: left; font-size: 16px; font-weight: 500; }
.msg-menu-actions button:active { background: var(--sep); }
.msg-menu-actions button::before { content: ""; flex: none; width: 22px; height: 22px; background: currentColor; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.msg-menu-actions [data-action="reply"]::before, .swipe-reply::before { -webkit-mask-image: var(--icon-reply); mask-image: var(--icon-reply); }
.msg-menu-actions [data-action="copy"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='8' y='8' width='12' height='12' rx='2.5'/%3E%3Cpath d='M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='8' y='8' width='12' height='12' rx='2.5'/%3E%3Cpath d='M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2'/%3E%3C/svg%3E"); }
.msg-menu-actions [data-action="edit"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4L19 9a2.8 2.8 0 0 0-4-4L4 16z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4L19 9a2.8 2.8 0 0 0-4-4L4 16z'/%3E%3C/svg%3E"); }
.msg-menu-actions [data-action="delete"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M10 11v6M14 11v6M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 7V4h6v3'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M10 11v6M14 11v6M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 7V4h6v3'/%3E%3C/svg%3E"); }
.msg-menu-actions [data-action="mute"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10v4h4l5 4V6L8 10zM17 9l4 6M21 9l-4 6'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10v4h4l5 4V6L8 10zM17 9l4 6M21 9l-4 6'/%3E%3C/svg%3E"); }
.msg-menu-actions [data-action="ban"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M6 6l12 12'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M6 6l12 12'/%3E%3C/svg%3E"); }
.msg-menu-actions [data-action="report"]::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 21V4M5 4h11l-2 4 2 4H5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 21V4M5 4h11l-2 4 2 4H5'/%3E%3C/svg%3E"); }
.msg-menu-actions .danger-text { color: var(--danger); }

/* Списки и настройки */
.list-screen { padding: 8px 12px 32px; }
.screen-hint { margin: 6px 4px 12px; color: var(--muted); font-size: 15px; }
.group-title { margin: 18px 4px 8px; color: var(--muted); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.list-group:empty { display: none; }
.list-group, .settings-group { overflow: hidden; margin-bottom: 12px; border-radius: 14px; background: var(--panel); }
.comments-list-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; }
.comments-list-row + .comments-list-row { border-top: 1px solid var(--sep); }
.comments-list-row .row-main { flex: 1; min-width: 0; }
.comments-list-row strong { display: block; overflow: hidden; font-size: 16px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.comments-list-row p, .comments-list-row > span:not(.avatar) { margin: 2px 0 0; overflow: hidden; color: var(--muted); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.comments-list-row > span:not(.avatar) { flex: 1; white-space: normal; color: var(--text); }
.comments-list-row button { flex: none; min-width: 44px; min-height: 44px; padding: 6px 14px; border: 0; border-radius: 19px; background: var(--reaction); color: var(--accent); font-size: 15px; font-weight: 600; }
.moderation-row { flex-wrap: wrap; }
.moderation-row .row-main p { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.row-actions:empty { display: none; }
.comments-list-row.is-unread strong::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.chat-row { width: 100%; border: 0; background: transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.chat-row:active { background: var(--panel-2); }
.chat-row > .avatar { flex: none; width: 48px; height: 48px; font-size: 18px; }
.row-top, .row-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-top strong { flex: 1; min-width: 0; }
.row-time { flex: none; color: var(--muted); font-size: 13px; }
.row-subtitle { flex: 1; min-width: 0; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.is-unread .row-subtitle { color: var(--text); }
.chat-row.has-badge strong::after { display: none; }
.comments-unread-badge { flex: none; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; color: #fff; background: var(--accent); font-size: 14px; font-weight: 600; line-height: 24px; text-align: center; }
.settings-group { padding: 4px 0; }
.settings-group > p, .settings-group fieldset > p { margin: 8px 16px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; margin: 0; padding: 8px 16px; font-size: 16px; }
.setting-row + .setting-row, .settings-group > * + .setting-row { border-top: 1px solid var(--sep); }
.setting-row select { max-width: 55%; }
.setting-note { margin: 0 16px 8px !important; font-size: 14px; }
.setting-link { display: block; width: 100%; min-height: 52px; padding: 12px 16px; border: 0; background: transparent; color: var(--accent); text-align: left; font-size: 16px; }
.setting-link + .setting-link { border-top: 1px solid var(--sep); }
.danger-text { color: var(--danger) !important; }
.wide { display: block; width: calc(100% - 32px); margin: 10px 16px; }
.reaction-set { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 10px 16px; border: 0; border-top: 1px solid var(--sep); }
.reaction-set legend { float: left; width: 100%; margin-bottom: 6px; color: var(--muted); font-size: 14px; }
.reaction-set label { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 2px 10px; border-radius: 20px; background: var(--panel-2); font-size: 20px; }
.comments-stats-bar-row { display: grid; gap: 4px; padding: 10px 14px; }
.comments-stats-bar-row + .comments-stats-bar-row { border-top: 1px solid var(--sep); }
.comments-stats-track { display: block; height: 8px; border-radius: 4px; background: var(--reaction); overflow: hidden; }
.comments-stats-bar { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.comments-stats-bar-row > span:first-child { font-size: 15px; }
.search-row { display: flex; gap: 8px; margin: 4px 0 12px; }
.search-row input { flex: 1; }

/* Поля и кнопки */
.comments-page input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .comments-page select, .comments-page dialog textarea { min-height: 44px; max-width: 100%; padding: 9px 12px; border: 1px solid var(--sep); border-radius: 12px; outline: none; color: var(--text); background: var(--panel-2); font: inherit; font-size: 16px; }
.comments-page dialog textarea { width: 100%; resize: vertical; }
.comments-page .primary, .comments-page .danger, .dialog-actions button, .search-row button, .recording-actions button, .comments-card button { min-height: 44px; padding: 10px 18px; border: 0; border-radius: 12px; background: var(--panel-2); font-size: 16px; font-weight: 600; }
.comments-page .primary { background: var(--accent); color: var(--accent-text); }
.comments-page .danger { background: var(--danger); color: #fff; }
.link-button { min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: var(--accent); font-size: 16px; font-weight: 600; }
.switch { position: relative; flex: none; width: 48px; height: 28px; margin: 0; border-radius: 14px; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--sep); appearance: none; -webkit-appearance: none; cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; }
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); }
.field { display: grid; gap: 6px; margin: 12px 0; color: var(--muted); font-size: 14px; }
.field input, .field select { color: var(--text); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset:disabled { opacity: .6; }

/* Окна — как нижние панели */
.comments-page dialog { width: 100%; max-width: 560px; max-height: 90dvh; margin: auto auto 0; padding: 18px 16px calc(14px + env(safe-area-inset-bottom)); overflow: auto; border: 0; border-radius: 18px 18px 0 0; color: var(--text); background: var(--panel); animation: rise .18s ease-out; }
.comments-page dialog::backdrop { background: rgba(0,0,0,.5); }
.comments-page dialog h2 { margin: 0 0 10px; font-size: 19px; }
.comments-page dialog .setting-row { padding: 8px 0; }
.dialog-actions { display: flex; gap: 8px; margin-top: 16px; }
.confirm-detail { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); font-size: 14px; word-break: break-all; }
.dialog-actions button { flex: 1; }
#comments-poll-options .field { margin: 8px 0; }
.poll-option-edit { display: flex; align-items: flex-end; gap: 8px; }
.poll-option-edit label { flex: 1; }
.range { display: flex; align-items: center; gap: 8px; }
.warning-text { color: #e8b44c; }
#comments-channel-rules { margin-top: 10px; font-size: 15px; }
.comments-copy-protected .msg-text { user-select: none; -webkit-user-select: none; }

@media (min-width: 760px) { .comments-screen { padding-left: 16px; padding-right: 16px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* Вложения в ленте: фото сразу, голосовые и видео — по нажатию. */
.attachment-card { max-width: min(100%, 320px); }
.attachment-image-link { display: block; }
.attachment-album { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; flex-basis: 100%; width: min(100%, 320px); max-width: 320px; overflow: hidden; border-radius: 12px; }
.attachment-album.album-3 { grid-template-columns: 2fr 1fr; }
.album-cell { aspect-ratio: 1; overflow: hidden; background: var(--reaction); }
.album-3 .album-cell:first-child { grid-row: span 2; aspect-ratio: auto; }
.attachment-album .attachment-image-link, .attachment-album .attachment-image { width: 100%; height: 100%; max-width: none; max-height: none; min-height: 0; border-radius: 0; object-fit: cover; }
.attachment-image { display: block; max-width: min(100%, 320px); max-height: 360px; min-height: 48px; border-radius: 12px; background: var(--reaction); }
.attachment-audio { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 2px 0; }
.attachment-list .attachment-audio-btn { position: relative; flex: none; width: 48px; height: 48px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: var(--accent); transition: transform .15s; }
.attachment-list .attachment-audio-btn:active { transform: scale(.92); }
.attachment-audio-btn::before { content: ""; position: absolute; inset: 12px; background: #fff; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5.5v13a1 1 0 0 0 1.5.9l10.2-6.5a1 1 0 0 0 0-1.8L9.5 4.6A1 1 0 0 0 8 5.5z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5.5v13a1 1 0 0 0 1.5.9l10.2-6.5a1 1 0 0 0 0-1.8L9.5 4.6A1 1 0 0 0 8 5.5z'/%3E%3C/svg%3E") center / contain no-repeat; }
.attachment-audio-btn.is-playing::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='5' width='4' height='14' rx='1.5'/%3E%3Crect x='14' y='5' width='4' height='14' rx='1.5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='5' width='4' height='14' rx='1.5'/%3E%3Crect x='14' y='5' width='4' height='14' rx='1.5'/%3E%3C/svg%3E"); }
.attachment-audio-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.attachment-audio-wave { display: flex; align-items: center; gap: 1px; height: 23px; cursor: pointer; }
.attachment-audio-wave span { flex: none; width: 2px; min-height: 2px; border-radius: 1px; background: var(--accent); opacity: .35; transition: opacity .15s; }
.attachment-audio-wave span.played { opacity: 1; }
.attachment-audio-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.comment.mine .attachment-audio-btn, .comment.mine .attachment-audio-wave span { background: var(--muted-out); }
.comment.mine .attachment-audio-btn::before { background: var(--bubble-out); }
.comment.mine .attachment-audio-time { color: var(--muted-out); }
.attachment-list .attachment-video-tile { display: flex; align-items: center; justify-content: center; width: min(64vw, 240px); aspect-ratio: 16 / 9; border: 0; border-radius: 12px; background: #000; color: #fff; font-size: 16px; }
.attachment-video { display: block; max-width: min(100%, 320px); max-height: 360px; border-radius: 12px; }
.circle-media-frame .attachment-video { width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0; object-fit: cover; }
.attachment-list .attachment-file { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 6px 12px; border: 0; border-radius: 12px; background: var(--reaction); color: var(--text); font-size: 15px; text-align: left; }

/* «Кто как ответил»: вариант, под ним — выбравшие его участники. */
#comments-poll-results-content { max-height: 60vh; overflow-y: auto; }
.poll-results-option + .poll-results-option { margin-top: 14px; }
.poll-results-option h3 { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 6px; font-size: 16px; }
.poll-results-option h3 small { flex: none; color: var(--muted); font-weight: 400; font-size: 14px; }
.poll-results-voter { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.poll-results-voter .avatar { width: 32px; height: 32px; font-size: 13px; }
.own-message-row .row-main { cursor: pointer; }
.own-message-row .row-main strong { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#comments-attach-sheet .sheet-panel button:not(.sheet-cancel)::before { display: inline-block; width: 32px; margin-right: 10px; font-size: 22px; text-align: center; vertical-align: -3px; }
#comments-attach::before { content: "🖼️"; }
#comments-record-voice::before { content: "🎤"; }
#comments-record-circle::before { content: "📹"; }
#comments-create-poll::before { content: "📊"; }
.comments-pending-file { box-sizing: border-box; width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0; padding: 6px 8px; border-radius: 12px; background: var(--panel-2); }
.comments-pending-thumb { flex: none; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--reaction); }
.comments-pending-info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; line-height: 1.3; }
.comments-pending-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.comments-pending-file button { flex: none; }
dialog.photo-viewer { box-sizing: border-box; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #000; }
dialog.photo-viewer::backdrop { background: #000; }
dialog.photo-viewer { overflow: hidden; animation: none; touch-action: none; -webkit-user-select: none; user-select: none; }
.pv-track { display: flex; width: 300%; height: 100%; will-change: transform; touch-action: none; }
.pv-slide { flex: 0 0 calc(100% / 3); height: 100%; overflow: hidden; }
.pv-slide img { display: block; width: 100%; height: 100%; object-fit: contain; transform-origin: center; }
.pv-slide img:not([src]) { visibility: hidden; }
.pv-top { position: absolute; top: 0; right: 0; left: 0; display: flex; align-items: center; gap: 8px; padding: calc(6px + env(safe-area-inset-top)) 12px 18px 6px; color: #fff; background: linear-gradient(rgba(0,0,0,.6), transparent); transition: opacity .2s; }
.pv-close { display: flex; flex: none; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; color: #fff; background: none; }
.pv-close svg { width: 24px; height: 24px; }
.pv-title { display: flex; flex-direction: column; min-width: 0; }
.pv-title strong { overflow: hidden; font-size: 16px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.pv-title span { font-size: 14px; opacity: .75; }
.pv-caption { position: absolute; right: 0; bottom: 0; left: 0; max-height: 35vh; margin: 0; padding: 28px 16px calc(16px + env(safe-area-inset-bottom)); overflow: auto; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); font-size: 16px; line-height: 1.35; white-space: pre-wrap; transition: opacity .2s; }
.pv-nav { display: none; position: absolute; top: 50%; width: 48px; height: 48px; margin-top: -24px; padding: 0 0 4px; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.14); font-size: 32px; line-height: 1; }
.pv-prev { left: 16px; }
.pv-next { right: 16px; }
@media (pointer: fine) { .pv-nav:not([hidden]) { display: flex; align-items: center; justify-content: center; } }
.photo-viewer.pv-ui-hidden .pv-top, .photo-viewer.pv-ui-hidden .pv-caption, .photo-viewer.pv-ui-hidden .pv-nav,
.photo-viewer.pv-dragging .pv-top, .photo-viewer.pv-dragging .pv-caption, .photo-viewer.pv-dragging .pv-nav { opacity: 0; pointer-events: none; }
.emoji-panel { display: flex; flex-direction: column; height: 282px; margin-top: 8px; overflow: hidden; border-radius: 18px; background: var(--panel); box-shadow: 0 1px 8px 1px rgba(0,0,0,.12); animation: rise .18s ease-out; }
.emoji-panel[hidden] { display: none; }
.emoji-tabs { display: flex; flex: none; gap: 2px; padding: 4px 6px; overflow-x: auto; border-bottom: 1px solid var(--sep); scrollbar-width: none; }
.emoji-panel .emoji-tab { flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px; background: transparent; font-size: 20px; line-height: 36px; }
.emoji-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 6px 8px; }
.emoji-body h3 { margin: 10px 6px 4px; color: var(--muted); font-size: 14px; font-weight: 500; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
.emoji-panel .emoji-cell { height: 42px; padding: 0; border: 0; border-radius: 10px; background: transparent; font-size: 28px; line-height: 42px; }
.emoji-cell:active, .emoji-tab:active { background: var(--sep); }
#comments-emoji-toggle.is-open { color: var(--accent); }
.emoji-panel .emoji-erase { position: sticky; right: 0; width: 36px; height: 36px; margin-left: auto; border-radius: 10px; background: var(--panel); }
.load-newer { height: 1px; }

/* Закреплённое сообщение — стеклянная полоска под шапкой, как в Telegram. */
.pin-bar { position: sticky; top: 62px; z-index: 19; display: flex; align-items: center; width: calc(100% - 16px); max-width: 744px; height: 48px; margin: 6px auto 0; padding: 0 4px 0 0; border-radius: 24px; background: var(--header-glass); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); box-shadow: 0 1px 5px -1px rgba(0,0,0,.21); }
.pin-bar[hidden] { display: none; }
.pin-open { display: flex; flex: 1; align-items: center; gap: 10px; min-width: 0; height: 100%; padding: 0 0 0 14px; border: 0; background: transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.pin-icon { flex: none; width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.pin-marks { display: flex; flex: none; flex-direction: column; gap: 2px; width: 2px; height: 32px; }
.pin-marks[hidden] { display: none; }
.pin-marks span { flex: 1; border-radius: 1px; background: var(--accent); opacity: .35; }
.pin-marks span.is-current { opacity: 1; }
.pin-body { display: flex; flex-direction: column; min-width: 0; line-height: 18px; }
.pin-body strong { color: var(--accent); font-size: 14px; font-weight: 600; }
.pin-body span { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.pin-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.comments-page:not([data-screen-name="room"]) .pin-bar { display: none; }

/* Значок «открыть пост в канале» в правом верхнем углу карточки поста. */
.comments-source, .source-post-root .bubble { position: relative; }
.comments-source.has-post-link, .source-post-root .bubble.has-post-link { padding-right: 44px; }
.post-go { position: absolute; top: 4px; right: 4px; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--accent); cursor: pointer; }
.post-go:active { background: var(--sep); }
.comments-page .post-go svg { width: 20px; height: 20px; }
.landing { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); }
.landing[hidden] { display: none; }
.landing-card { max-width: 420px; padding: 28px 22px; border-radius: 18px; background: var(--panel); text-align: center; }
.landing-icon { font-size: 48px; line-height: 1; }
.landing h1 { margin: 14px 0 12px; font-size: 24px; line-height: 1.25; }
.landing p { margin: 0 0 12px; font-size: 17px; line-height: 1.45; color: var(--text); }
.landing-cta { display: block; margin-top: 20px; padding: 15px 18px; border-radius: 12px; background: var(--accent); color: var(--accent-text); font-size: 18px; font-weight: 600; text-decoration: none; }
/* Кнопка перехода из обсуждения поста в общее обсуждение. */
.comments-source .source-general { width: calc(100% + 24px); margin: 8px -12px -10px; border-radius: 0 0 16px 6px; }

/* Уведомления: колокольчик, окно приглашения, кнопки на карточках каналов */
.comments-top #comments-inbox-shortcut { position: relative; transform-origin: 50% 15%; }
.comments-top #comments-inbox-shortcut.needs-attention { color: var(--accent); animation: bell-ring 7s ease-in-out infinite; }
.comments-top #comments-inbox-shortcut.needs-attention::after { content: ""; position: absolute; top: 6px; right: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--panel); }
@keyframes bell-ring { 0%, 15%, 100% { transform: rotate(0); } 2% { transform: rotate(14deg); } 4% { transform: rotate(-12deg); } 6% { transform: rotate(10deg); } 8% { transform: rotate(-8deg); } 10% { transform: rotate(5deg); } 12% { transform: rotate(-3deg); } }
.notify-panel { padding: 16px; }
.notify-panel h2 { margin: 0 0 8px; font-size: 20px; }
.notify-panel > p { margin: 0 0 8px; font-size: 16px; }
.notify-panel .setting-row { padding-right: 0; padding-left: 0; }
.notify-panel .primary { margin-top: 10px; text-align: center; }
.chat-row-wrap { display: flex; align-items: center; }
.chat-row-wrap + .chat-row-wrap { border-top: 1px solid var(--sep); }
.chat-row-wrap > .chat-row { flex: 1; width: auto; min-width: 0; }
.chat-row-wrap .comments-list-row + .comments-list-row { border-top: 0; }
.chat-actions { display: flex; flex: none; padding-right: 6px; }
.chat-actions .icon-button { width: 44px; height: 44px; }

/* Оформление текста: поле с форматированием, панель над ним, отрисовка в ленте. */
.rich-input { white-space: pre-wrap; overflow-wrap: anywhere; overflow-y: auto; outline: none; color: var(--text); font-size: 16px; line-height: 22px; cursor: text; -webkit-user-select: text; user-select: text; }
.rich-input:focus-visible { outline: none; }
.rich-input:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.rich-input[contenteditable="false"] { opacity: .6; }
.comments-composer .rich-input { min-height: 48px; max-height: 160px; padding: 13px 8px; }
.comments-page dialog .rich-input { min-height: 120px; max-height: 40dvh; padding: 9px 12px; border: 1px solid var(--sep); border-radius: 12px; background: var(--panel-2); }
.rich-quote { display: block; margin: 2px 0; padding-left: 8px; border-left: 3px solid var(--accent); }
.msg-text code, .post-text code, .post-quote code, .rich-input code { padding: 0 3px; border-radius: 4px; background: var(--reaction); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; }
.msg-text mark, .post-text mark, .post-quote mark { border-radius: 3px; background: rgba(255, 210, 0, .35); color: inherit; }
.format-bar { display: flex; gap: 2px; margin: 0 0 6px; padding: 4px; overflow-x: auto; border-radius: 16px; background: var(--panel); box-shadow: 0 1px 8px 1px rgba(0,0,0,.12); }
.format-button { display: inline-flex; flex: 1 0 44px; align-items: center; justify-content: center; min-width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--text); font-size: 19px; }
.format-button[aria-pressed="true"] { background: var(--reaction); color: var(--accent); }
.format-button svg { width: 22px; height: 22px; }
.format-strong { font-weight: 700; }
.format-emphasized { font-style: italic; }
.format-underline { text-decoration: underline; }
.format-strikethrough { text-decoration: line-through; }
