/* Предпросмотр поста 1:1 как в Telegram. Цвета — из тем Telegram (iOS day/night, Telegram Desktop day/night), не из палитры панели. */

.tg { --tg-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: var(--tg-font); -webkit-font-smoothing: antialiased; user-select: none; }

/* ---------- Телефон (iOS) ---------- */
.tg-phone { width: 390px; height: 844px; border-radius: 44px; background: var(--phone-frame); padding: 8px; box-shadow: var(--shadow-3); transition: background 160ms ease-out; }
.tg-phone .screen { width: 100%; height: 100%; border-radius: 36px; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.tg-ios { --bg: #7FB1A2; --header: rgba(246, 246, 246, 0.94); --header-text: #000000; --header-sub: #8E8E93; --bubble: #FFFFFF; --text: #000000; --link: #2481CC; --time: #8D9AA5; --date: #FFFFFF; --service: rgba(76, 94, 108, 0.5); --kb: rgba(255, 255, 255, 0.18); --kb-text: #FFFFFF; --code-bg: rgba(0, 0, 0, 0.06); --quote: #2481CC; --quote-bg: rgba(36, 129, 204, 0.1); --spoiler: #8E8E93; --preview-bar: #2481CC; --preview-bg: rgba(36, 129, 204, 0.1); --wallpaper: radial-gradient(120% 90% at 10% 10%, #c8dfd3 0%, transparent 60%), radial-gradient(100% 80% at 90% 20%, #c7d3b9 0%, transparent 60%), radial-gradient(120% 100% at 50% 100%, #9fc4b1 0%, transparent 65%), linear-gradient(170deg, #b6d2c2 0%, #a3c4b5 50%, #b9cfb0 100%); --tabbar: rgba(246, 246, 246, 0.94); }
.tg-ios.dark { --bg: #000000; --header: rgba(28, 28, 29, 0.94); --header-text: #FFFFFF; --header-sub: #8E8E93; --bubble: #262628; --text: #FFFFFF; --link: #5AC8FA; --time: #8E8E93; --date: #FFFFFF; --service: rgba(0, 0, 0, 0.5); --kb: rgba(255, 255, 255, 0.12); --kb-text: #FFFFFF; --code-bg: rgba(255, 255, 255, 0.08); --quote: #5AC8FA; --quote-bg: rgba(90, 200, 250, 0.12); --spoiler: #8E8E93; --preview-bar: #5AC8FA; --preview-bg: rgba(90, 200, 250, 0.12); --wallpaper: radial-gradient(120% 90% at 10% 10%, #1c2a25 0%, transparent 60%), radial-gradient(100% 80% at 90% 20%, #1e2422 0%, transparent 60%), linear-gradient(170deg, #121a17 0%, #0d1311 50%, #141a15 100%); --tabbar: rgba(28, 28, 29, 0.94); }
.screen.tg-ios { background: var(--wallpaper); color: var(--text); }
.tg-ios .statusbar { height: 54px; display: flex; align-items: flex-end; justify-content: space-between; padding: 0 36px 10px; font-size: 15px; font-weight: 600; color: var(--header-text); background: var(--header); backdrop-filter: blur(20px); }
.tg-ios .statusbar .right { display: flex; gap: 6px; align-items: center; }
.tg-ios .statusbar .batt { width: 25px; height: 12px; border: 1.5px solid currentColor; border-radius: 4px; position: relative; opacity: 0.9; }
.tg-ios .statusbar .batt::after { content: ""; position: absolute; inset: 2px; right: 3px; background: currentColor; border-radius: 1.5px; }
.tg-ios .header { height: 44px; display: grid; grid-template-columns: 64px 1fr 44px; align-items: center; background: var(--header); backdrop-filter: blur(20px); border-bottom: 0.5px solid rgba(0, 0, 0, 0.2); color: var(--header-text); }
.tg-ios.dark .header { border-bottom-color: rgba(255, 255, 255, 0.15); }
.tg-ios .header .back { color: var(--link); display: flex; align-items: center; gap: 2px; padding-left: 8px; font-size: 17px; }
.tg-ios .header .back svg { width: 12px; height: 20px; }
.tg-ios .header .title { text-align: center; min-width: 0; }
.tg-ios .header .title .n { font-size: 17px; font-weight: 600; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ios .header .title .s { font-size: 13px; line-height: 16px; color: var(--header-sub); }
.tg-ios .header .ava { width: 37px; height: 37px; border-radius: 999px; margin: 0 auto; }
.tg-ios .messages { flex: 1; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 8px 8px 8px; gap: 4px; }
.tg-ios .date { align-self: center; background: var(--service); color: var(--date); font-size: 13px; font-weight: 500; line-height: 18px; padding: 2px 10px; border-radius: 12px; margin-bottom: 4px; backdrop-filter: blur(10px); }
.tg-ios .bubble { position: relative; max-width: 320px; background: var(--bubble); border-radius: 17px 17px 17px 4px; color: var(--text); font-size: 17px; line-height: 22px; align-self: flex-start; overflow: hidden; }
.tg-ios .bubble.has-tail::before { content: ""; position: absolute; left: -6px; bottom: 0; width: 14px; height: 18px; background: var(--bubble); clip-path: path("M14 0 C14 10 10 16 0 18 C6 17 10 14 12 8 Z"); }
.tg-ios .bubble .text { padding: 6px 12px 7px; white-space: pre-wrap; word-break: break-word; }
.tg-ios .bubble .text.has-meta { padding-bottom: 7px; }
.tg-ios .bubble .text .meta-space { display: inline-block; width: 64px; height: 1px; }
.tg-ios .meta { position: absolute; right: 10px; bottom: 5px; display: flex; align-items: center; gap: 4px; font-size: 11px; line-height: 13px; color: var(--time); }
.tg-ios .meta.on-media { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, 0.4); color: #fff; padding: 2px 6px; border-radius: 10px; backdrop-filter: blur(6px); }
.tg-ios .meta svg { width: 14px; height: 10px; }
.tg-ios .kb { display: flex; flex-direction: column; gap: 4px; max-width: 320px; margin-top: 4px; }
.tg-ios .kb .krow { display: flex; gap: 4px; }
.tg-ios .kb .kbtn { flex: 1; min-width: 0; height: 36px; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px; border-radius: 10px; background: var(--kb); color: var(--kb-text); backdrop-filter: blur(16px); font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ios .kb .kbtn span { overflow: hidden; text-overflow: ellipsis; }
.tg-ios .kb .kbtn svg { width: 13px; height: 13px; opacity: 0.8; flex: none; }
.tg-ios .kb .kbtn.primary { background: #3390EC; }
.tg-ios .kb .kbtn.success { background: #34C759; }
.tg-ios .kb .kbtn.danger { background: #FF3B30; }
.tg-ios .kb .kbtn.primary, .tg-ios .kb .kbtn.success, .tg-ios .kb .kbtn.danger { color: #fff; }
.tg-ios .composer { height: 50px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--tabbar); backdrop-filter: blur(20px); border-top: 0.5px solid rgba(0, 0, 0, 0.2); color: var(--header-text); }
.tg-ios.dark .composer { border-top-color: rgba(255, 255, 255, 0.15); }
.tg-ios .composer .mute { flex: 1; text-align: center; font-size: 17px; font-weight: 600; color: var(--link); }
.tg-ios .home { height: 34px; display: flex; align-items: center; justify-content: center; background: var(--tabbar); }
.tg-ios .home i { width: 134px; height: 5px; border-radius: 3px; background: var(--header-text); opacity: 0.9; }

/* ---------- Десктоп (Telegram Desktop) ---------- */
.tg-desktop { width: 720px; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-3); display: flex; flex-direction: column; height: 640px; }
.tg-desk { --tg-font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; --bg: #99BA92; --header: #FFFFFF; --header-text: #000000; --header-sub: #999999; --bubble: #FFFFFF; --text: #000000; --link: #168ACD; --time: #A0ACB6; --date: #FFFFFF; --service: rgba(0, 0, 0, 0.26); --kb: rgba(0, 0, 0, 0.2); --kb-text: #FFFFFF; --code-bg: rgba(0, 0, 0, 0.05); --quote: #168ACD; --quote-bg: rgba(22, 138, 205, 0.1); --spoiler: #999999; --preview-bar: #168ACD; --preview-bg: rgba(22, 138, 205, 0.08); --side: #FFFFFF; --side-border: #E7E7E7; --wallpaper: radial-gradient(110% 80% at 0% 0%, #b9d4b6 0%, transparent 60%), radial-gradient(100% 80% at 100% 10%, #c2d8c9 0%, transparent 60%), linear-gradient(165deg, #b1cfae 0%, #9dc0a3 55%, #afcbb0 100%); --input: #FFFFFF; }
.tg-desk.dark { --bg: #0E1621; --header: #17212B; --header-text: #FFFFFF; --header-sub: #6D7F8F; --bubble: #182533; --text: #FFFFFF; --link: #71BAF2; --time: #6D7F8F; --date: #FFFFFF; --service: rgba(0, 0, 0, 0.3); --kb: rgba(255, 255, 255, 0.12); --kb-text: #FFFFFF; --code-bg: rgba(255, 255, 255, 0.07); --quote: #71BAF2; --quote-bg: rgba(113, 186, 242, 0.12); --spoiler: #6D7F8F; --preview-bar: #71BAF2; --preview-bg: rgba(113, 186, 242, 0.1); --side: #17212B; --side-border: #101921; --wallpaper: radial-gradient(110% 80% at 0% 0%, #142029 0%, transparent 60%), linear-gradient(165deg, #0f1a24 0%, #0b141d 60%, #0e1921 100%); --input: #17212B; }
.tg-desk { display: grid; grid-template-columns: 220px 1fr; height: 100%; font-family: var(--tg-font); font-size: 13px; }
.tg-desk .side { background: var(--side); border-right: 1px solid var(--side-border); display: flex; flex-direction: column; }
.tg-desk .side .search { margin: 10px; height: 32px; border-radius: 16px; background: var(--code-bg); display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--header-sub); font-size: 13px; }
.tg-desk .side .search svg { width: 16px; height: 16px; }
.tg-desk .side .item { display: grid; grid-template-columns: 46px 1fr; gap: 10px; padding: 8px 10px; align-items: center; color: var(--header-text); }
.tg-desk .side .item.active { background: var(--link); color: #fff; }
.tg-desk .side .item .ava { width: 46px; height: 46px; border-radius: 999px; }
.tg-desk .side .item .n { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-desk .side .item .p { font-size: 12px; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-desk .side .item.ghost { opacity: 0.55; }
.tg-desk .side .item.ghost .ava { background: var(--code-bg); }
.tg-desk .side .item.ghost .n, .tg-desk .side .item.ghost .p { height: 10px; border-radius: 5px; background: var(--code-bg); }
.tg-desk .chat { display: flex; flex-direction: column; min-width: 0; }
.tg-desk .header { height: 54px; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--header); border-bottom: 1px solid var(--side-border); color: var(--header-text); }
.tg-desk .header .ava { width: 36px; height: 36px; border-radius: 999px; }
.tg-desk .header .n { font-weight: 600; font-size: 14px; line-height: 18px; }
.tg-desk .header .s { font-size: 12px; line-height: 16px; color: var(--header-sub); }
.tg-desk .messages { flex: 1; background: var(--wallpaper); display: flex; flex-direction: column; justify-content: flex-end; padding: 8px 12px; gap: 6px; overflow: hidden; color: var(--text); }
.tg-desk .date { align-self: center; background: var(--service); color: var(--date); font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 10px; margin-bottom: 4px; }
.tg-desk .bubble { position: relative; max-width: 430px; background: var(--bubble); border-radius: 12px; color: var(--text); font-size: 13px; line-height: 17px; align-self: flex-start; overflow: hidden; }
.tg-desk .bubble .text { padding: 6px 10px 7px; white-space: pre-wrap; word-break: break-word; }
.tg-desk .bubble .text .meta-space { display: inline-block; width: 70px; height: 1px; }
.tg-desk .meta { position: absolute; right: 8px; bottom: 4px; display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--time); }
.tg-desk .meta.on-media { background: rgba(0, 0, 0, 0.35); color: #fff; padding: 1px 6px; border-radius: 8px; right: 6px; bottom: 6px; }
.tg-desk .meta svg { width: 14px; height: 10px; }
.tg-desk .kb { display: flex; flex-direction: column; gap: 4px; max-width: 430px; margin-top: 2px; }
.tg-desk .kb .krow { display: flex; gap: 4px; }
.tg-desk .kb .kbtn { flex: 1; min-width: 0; height: 32px; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 8px; border-radius: 8px; background: var(--kb); color: var(--kb-text); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-desk .kb .kbtn span { overflow: hidden; text-overflow: ellipsis; }
.tg-desk .kb .kbtn svg { width: 12px; height: 12px; opacity: 0.8; flex: none; }
.tg-desk .kb .kbtn.primary { background: #3390EC; color: #fff; }
.tg-desk .kb .kbtn.success { background: #4DCD5E; color: #fff; }
.tg-desk .kb .kbtn.danger { background: #E53935; color: #fff; }
.tg-desk .composer { height: 48px; background: var(--input); border-top: 1px solid var(--side-border); display: flex; align-items: center; justify-content: center; color: var(--link); font-weight: 600; font-size: 14px; }

/* ---------- Общее содержимое пузыря ---------- */
.tg .bubble a { color: var(--link); text-decoration: none; }
.tg .bubble b { font-weight: 600; }
.tg .bubble .spoiler { background: var(--spoiler); color: transparent; border-radius: 3px; cursor: pointer; }
.tg .bubble .spoiler.open { background: var(--code-bg); color: inherit; }
.tg .bubble code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; background: var(--code-bg); border-radius: 4px; padding: 0 3px; }
.tg .bubble .pre { display: block; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; background: var(--code-bg); border-radius: 6px; padding: 6px 8px; margin: 2px 0; white-space: pre-wrap; }
.tg .bubble .bq { display: block; position: relative; border-left: 3px solid var(--quote); background: var(--quote-bg); padding: 4px 8px 4px 10px; border-radius: 0 6px 6px 0; margin: 2px 0; }
.tg .bubble .bq.expandable { max-height: 72px; overflow: hidden; padding-right: 24px; }
.tg .bubble .bq.expandable::after { content: "⌄"; position: absolute; right: 8px; bottom: 2px; color: var(--quote); font-size: 14px; }
.tg .bubble .bq.expandable.open { max-height: none; }
.tg .bubble .bq.expandable.open::after { content: "⌃"; }
.tg .bubble .media { position: relative; display: block; overflow: hidden; }
.tg .bubble .media img, .tg .bubble .media video { display: block; width: 100%; height: 100%; object-fit: cover; }
.tg .bubble .media.single { width: 100%; max-height: 420px; }
.tg .bubble .media.single img, .tg .bubble .media.single video { max-height: 420px; object-fit: contain; background: var(--code-bg); }
.tg .bubble .album { display: grid; gap: 2px; width: 100%; }
.tg .bubble .album .media { width: 100%; height: 100%; }
.tg .bubble .spoiler-media { position: absolute; inset: 0; backdrop-filter: blur(24px); background: rgba(0, 0, 0, 0.2); display: flex; align-items: center; justify-content: center; }
.tg .bubble .spoiler-media img { filter: blur(20px); }
.tg .bubble .spoiler-media .eye { width: 44px; height: 44px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; color: #fff; }
.tg .bubble .spoiler-media .eye svg { width: 22px; height: 22px; }
.tg .bubble .doc { display: flex; gap: 10px; align-items: center; padding: 8px 12px 8px 10px; }
.tg .bubble .doc .ic { width: 44px; height: 44px; border-radius: 999px; background: var(--link); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.tg .bubble .doc .ic svg { width: 22px; height: 22px; }
.tg .bubble .doc .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.tg .bubble .doc .s { font-size: 0.85em; color: var(--time); }
.tg .bubble .doc .meta-space { display: inline-block; width: 64px; }
.tg .bubble .video-badge { position: absolute; left: 6px; top: 6px; background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 8px; }
.tg .bubble .lp { margin: 2px 12px 8px; border-left: 3px solid var(--preview-bar); background: var(--preview-bg); border-radius: 0 8px 8px 0; padding: 6px 8px 6px 10px; overflow: hidden; }
.tg .bubble .lp .site { color: var(--link); font-weight: 600; font-size: 0.95em; }
.tg .bubble .lp .t { font-weight: 600; margin-top: 2px; }
.tg .bubble .lp .d { color: inherit; opacity: 0.9; font-size: 0.95em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tg .bubble .lp .im { margin-top: 6px; border-radius: 6px; overflow: hidden; max-height: 180px; }
.tg .bubble .lp .im img { width: 100%; display: block; object-fit: cover; max-height: 180px; }
.tg .bubble .lp.small { display: grid; grid-template-columns: 1fr 48px; gap: 8px; }
.tg .bubble .lp.small .im { margin: 0; width: 48px; height: 48px; }
.tg .bubble .lp.small .im img { width: 48px; height: 48px; }
.tg .bubble .text.caption-above { padding-bottom: 6px; }
.tg .bubble .empty { padding: 6px 12px 7px; color: var(--time); font-style: italic; }
.tg .bubble .empty .meta-space { display: inline-block; width: 64px; height: 1px; }
.tg .reactions { display: inline-flex; gap: 4px; padding: 0 8px 6px; }
.tg .views svg { width: 14px; height: 10px; }
