/* «Чат» (ig.captaindock.io): dialog list + messages + composer + AI panel. */
.content-inner.chat-inner { max-width: none; height: 100%; padding: 0; margin: 0; }
.chat-shell { display: grid; grid-template-columns: minmax(16rem, 23rem) 1fr; height: 100%; min-height: 0; }
.chat-shell.disconnected { grid-template-columns: 1fr; }
.chat-shell.disconnected .chat-list { display: none; }

/* list */
.chat-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: color-mix(in srgb, var(--card) 55%, transparent); }
.chat-list-head { padding: 0.8rem 0.8rem 0.5rem; display: grid; gap: 0.5rem; border-bottom: 1px solid var(--border); }
.chat-search { position: relative; }
.chat-search .icon { position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%); width: 0.95rem; height: 0.95rem; color: var(--muted-foreground); pointer-events: none; }
.chat-search .input { padding-left: 2rem; }
.chat-list-head .mon-chip { padding: 0.2rem 0.6rem; font-size: 0.78rem; min-height: 1.9rem; }
.chip-count { display: inline-block; margin-left: 0.2rem; font-size: 0.7rem; font-weight: 800; color: #fff; background: var(--accent); border-radius: 999px; padding: 0 0.35rem; }
.chat-sync { margin: 0; }
.chat-items { flex: 1; overflow-y: auto; min-height: 0; padding: 0.35rem; }
.chat-items .empty-card { margin: 0.5rem; }
.chat-list-foot { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.8rem; border-top: 1px solid var(--border); min-height: 2.8rem; }
.chat-list-foot span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tg-logout.confirm { color: var(--danger); font-size: 0.8rem; }

.chat-row { display: flex; gap: 0.65rem; align-items: center; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; color: var(--foreground); border-radius: 0.75rem; padding: 0.5rem 0.55rem; cursor: pointer; min-height: 3.6rem; position: relative; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.chat-row:hover { background: var(--muted); }
.chat-row-pin { flex: none; display: inline-flex; color: var(--muted-foreground); }
.chat-row-pin .icon { width: 0.8rem; height: 0.8rem; }
.chat-row.active { background: var(--muted); border-color: var(--border); }
.chat-row:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.chat-row.awaiting::before { content: ""; position: absolute; left: 0.15rem; top: 50%; width: 0.3rem; height: 0.3rem; margin-top: -0.15rem; border-radius: 50%; background: var(--accent); }
.chat-avatar { width: 2.6rem; height: 2.6rem; font-size: 0.85rem; }
.chat-avatar .icon { width: 1.15rem; height: 1.15rem; }
.chat-avatar.group { color: var(--foreground); }
.chat-row-main { flex: 1; min-width: 0; display: grid; gap: 0.15rem; }
.chat-row-top, .chat-row-sub { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.chat-row-title { flex: 1; min-width: 0; font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.awaiting .chat-row-title { font-weight: 800; }
.chat-row-time { flex: none; font-size: 0.74rem; color: var(--muted-foreground); }
.chat-row.awaiting .chat-row-time { color: var(--accent); font-weight: 700; }
.chat-row-prev { flex: 1; min-width: 0; font-size: 0.83rem; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row-badges { flex: none; display: inline-flex; gap: 0.25rem; align-items: center; }
.chat-row-badges .badge { height: 1.25rem; line-height: 1.15rem; font-size: 0.66rem; padding: 0 0.4rem; }
.chat-unread { font-size: 0.7rem; font-weight: 800; min-width: 1.25rem; height: 1.25rem; line-height: 1.25rem; padding: 0 0.35rem; border-radius: 999px; text-align: center; background: var(--muted-foreground); color: var(--background); }
.chat-row.awaiting .chat-unread { background: var(--accent); color: #fff; }
.badge.pulse { animation: chat-pulse 1.4s ease-in-out infinite; }
@keyframes chat-pulse { 50% { opacity: 0.45; } }

/* pane */
.chat-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.chat-empty { margin: auto; text-align: center; max-width: 24rem; padding: 2rem 1rem; color: var(--foreground); }
.chat-empty > .icon { width: 2rem; height: 2rem; opacity: 0.5; }
.chat-head { display: flex; align-items: center; gap: 0.65rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); min-height: 3.6rem; }
.chat-head-main { flex: 1; min-width: 0; }
.chat-head-title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .muted a { color: inherit; }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow-y: auto; min-height: 0; padding: 0.8rem 1rem 0.6rem; display: flex; flex-direction: column; gap: 0.3rem; }
.chat-loading { text-align: center; margin: 0.5rem 0; }
.chat-day { text-align: center; margin: 0.6rem 0 0.3rem; }
.chat-day span, .chat-service span { font-size: 0.74rem; font-weight: 700; color: var(--muted-foreground); background: var(--muted); border-radius: 999px; padding: 0.15rem 0.6rem; }
.chat-service { text-align: center; margin: 0.2rem 0; }
.chat-msg { display: flex; align-items: flex-end; gap: 0.3rem; max-width: min(42rem, 88%); }
.chat-msg.in { align-self: flex-start; }
.chat-msg.out { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble { border: 1px solid var(--border); background: var(--card); border-radius: 1rem; padding: 0.45rem 0.7rem 0.3rem; min-width: 4rem; overflow-wrap: anywhere; }
.chat-msg.in .chat-bubble { border-bottom-left-radius: 0.3rem; }
.chat-msg.out .chat-bubble { border-bottom-right-radius: 0.3rem; background: color-mix(in srgb, var(--accent) 14%, var(--card)); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.chat-msg.mentioned .chat-bubble { border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.chat-msg.flash .chat-bubble { outline: 2px solid var(--ring); outline-offset: 2px; }
.chat-sender { display: block; font: inherit; font-size: 0.78rem; font-weight: 800; color: var(--accent); margin-bottom: 0.1rem; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.chat-sender:hover, .chat-fwd-who:hover { text-decoration: underline; }
.chat-sender:focus-visible, .chat-fwd-who:focus-visible, .chat-head-who:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 0.3rem; }
.chat-fwd-who { font: inherit; font-weight: 700; color: inherit; padding: 0; border: 0; background: none; cursor: pointer; }
.tg-mention[data-uid] { cursor: pointer; }
.chat-head-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.65rem; padding: 0.15rem 0.3rem; margin: -0.15rem -0.3rem; border: 0; border-radius: 0.6rem; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.chat-head-who:hover { background: var(--muted); }

/* profile card: a side panel, the whole screen on a phone */
.profile-back { position: fixed; inset: 0; z-index: 900; background: rgba(0, 0, 0, 0.45); display: flex; justify-content: flex-end; }
.profile { position: relative; width: min(24rem, 100%); height: 100%; overflow-y: auto; background: var(--card); border-left: 1px solid var(--border); padding: 1.5rem 1.25rem 1.25rem; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; box-shadow: -16px 0 40px rgba(0, 0, 0, 0.35); }
.profile-x { position: absolute; top: 0.5rem; right: 0.5rem; width: 2.75rem; height: 2.75rem; }
.profile-body { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.profile-photo { width: 7.5rem; height: 7.5rem; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; font-weight: 800; color: #fff; flex: none; }
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.profile-photo .icon { width: 3rem; height: 3rem; }
.profile-name { margin: 0.2rem 0 0; font-size: 1.2rem; font-weight: 800; text-align: center; overflow-wrap: anywhere; }
.profile-seen { margin: 0; }
.profile-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: center; }
.profile-rows { width: 100%; display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-top: 0.4rem; }
.profile-row { display: flex; gap: 0.75rem; padding: 0.65rem 0.1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.profile-row > .icon { width: 1.1rem; height: 1.1rem; color: var(--muted-foreground); flex: none; margin-top: 0.15rem; }
.profile-row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.profile-line { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.profile-about { white-space: pre-wrap; line-height: 1.45; }
.profile-copy { flex: none; color: var(--muted-foreground); }
.profile-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.profile-actions .btn { flex: 1; gap: 0.4rem; min-height: 2.75rem; justify-content: center; }
.chat-text { white-space: pre-wrap; line-height: 1.45; font-size: 0.93rem; }
.chat-media { font-size: 0.85rem; font-style: italic; color: var(--muted-foreground); }
.chat-img { position: relative; display: block; width: 20rem; max-width: 100%; max-height: 24rem; margin: 0.1rem 0 0.25rem; border-radius: 0.6rem; overflow: hidden; background: var(--muted); }
.chat-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-img.sticker { width: 9rem; background: transparent; }
.chat-img.sticker img { object-fit: contain; }
.chat-img.round { width: 12rem; border-radius: 50%; }
.chat-img.failed { aspect-ratio: auto !important; padding: 0.4rem 0.6rem; font-size: 0.82rem; font-style: italic; color: var(--muted-foreground); }
.chat-img:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.chat-img-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 0.25rem; background: rgba(0, 0, 0, 0.55); color: #fff; border-radius: 999px; padding: 0.45rem 0.6rem; font-size: 0.75rem; font-weight: 800; }
.chat-img-play .icon { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.chat-avatar.saved { color: #fff; background: var(--accent); border-color: transparent; }
.chat-reacts { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.3rem 0 0.05rem; }
.chat-react { display: inline-flex; align-items: center; gap: 0.25rem; min-height: 1.6rem; padding: 0 0.5rem; border: 1px solid var(--border); border-radius: 999px; background: var(--muted); color: var(--foreground); font-size: 0.78rem; font-weight: 700; }
.chat-react.mine { background: color-mix(in srgb, var(--accent) 22%, var(--card)); border-color: var(--accent); }
.chat-react-e, .ctx-react, .ctx-who-e { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.chat-react-e { font-size: 0.95rem; line-height: 1; }
.chat-react .icon { width: 0.85rem; height: 0.85rem; }
.chat-meta { display: flex; justify-content: flex-end; align-items: center; gap: 0.25rem; font-size: 0.68rem; color: var(--muted-foreground); margin-top: 0.1rem; }
.chat-tick { display: inline-flex; }
.chat-tick .icon { width: 0.85rem; height: 0.85rem; }
.chat-tick.read { color: var(--accent); }
.chat-quote { display: grid; width: 100%; text-align: left; gap: 0.05rem; border: 0; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--muted) 70%, transparent); color: var(--foreground); border-radius: 0.4rem; padding: 0.25rem 0.5rem; margin: 0.1rem 0 0.3rem; cursor: pointer; font-size: 0.8rem; }
.chat-quote b { font-size: 0.76rem; color: var(--accent); }
.chat-quote span { color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-btn { flex: none; border: 0; background: transparent; color: var(--muted-foreground); border-radius: 50%; width: 2rem; height: 2rem; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; }
.chat-reply-btn .icon { width: 1rem; height: 1rem; }
.chat-msg:hover .chat-reply-btn, .chat-reply-btn:focus-visible { opacity: 1; }
.chat-reply-btn:hover { background: var(--muted); color: var(--foreground); }
.chat-new-pill { position: absolute; right: 1rem; bottom: 9rem; z-index: 2; border: 1px solid var(--border); background: var(--card); color: var(--foreground); border-radius: 999px; padding: 0.35rem 0.8rem; font-size: 0.8rem; font-weight: 700; display: inline-flex; gap: 0.3rem; align-items: center; cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); min-height: 2.2rem; }
.chat-new-pill .icon { width: 0.9rem; height: 0.9rem; }

/* avatars: photo or tinted initials (people) */
.chat-avatar.has-photo { background: var(--muted); }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-avatar.av-c0 { background: color-mix(in srgb, #e60165 22%, var(--card)); color: var(--foreground); }
.chat-avatar.av-c1 { background: color-mix(in srgb, #8000db 24%, var(--card)); color: var(--foreground); }
.chat-avatar.av-c2 { background: color-mix(in srgb, #2f80ed 24%, var(--card)); color: var(--foreground); }
.chat-avatar.av-c3 { background: color-mix(in srgb, #35d073 22%, var(--card)); color: var(--foreground); }
.chat-avatar.av-c4 { background: color-mix(in srgb, #ffb020 24%, var(--card)); color: var(--foreground); }
.chat-avatar.av-c5 { background: color-mix(in srgb, #12b5b0 24%, var(--card)); color: var(--foreground); }
.chat-avatar.has-photo[class*="av-c"] { background: var(--muted); }

/* folders: chips in the row and the header */
.chat-row-folders, .chat-head-folders { display: flex; flex-wrap: wrap; gap: 0.25rem; min-width: 0; }
.chat-row-folders { margin-top: 0.1rem; overflow: hidden; max-height: 1.3rem; }
.chat-head-folders { margin-top: 0.2rem; }
.chat-folder-chip { display: inline-flex; align-items: center; gap: 0.2rem; max-width: 9rem; font-size: 0.68rem; font-weight: 700; line-height: 1.15rem; height: 1.2rem; padding: 0 0.4rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted-foreground); background: color-mix(in srgb, var(--muted) 60%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-folder-chip .icon { width: 0.7rem; height: 0.7rem; flex: none; }
.chat-folder-chip.more { font-weight: 800; }

/* context menu (folders of a chat / message actions) */
.ctx-menu { position: fixed; z-index: 900; min-width: 13rem; max-width: min(20rem, calc(100vw - 1rem)); max-height: min(24rem, calc(100vh - 1rem)); overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: 0.75rem; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); padding: 0.3rem; }
.ctx-title { font-size: 0.74rem; font-weight: 800; color: var(--muted-foreground); padding: 0.35rem 0.55rem 0.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-sep { height: 1px; margin: 0.25rem 0.3rem; background: var(--border); }
.ctx-reacts { display: flex; flex-wrap: wrap; gap: 0.15rem; padding: 0.2rem 0.25rem; min-height: 2.6rem; align-items: center; }
.ctx-reacts > .muted { padding: 0 0.3rem; }
.ctx-reacts.all { max-height: 15rem; overflow-y: auto; }
.ctx-menu-msg { display: flex; flex-direction: column; }   /* the lists shrink, the commands stay visible */
.ctx-menu-msg > * { flex: none; }
.ctx-menu-msg > .ctx-reacts.all { flex: 0 1 15rem; min-height: 5.75rem; }
.ctx-menu-msg > .ctx-who { flex: 0 1 auto; min-height: 2rem; }
.ctx-react { width: 2.25rem; height: 2.25rem; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 0.5rem; background: transparent; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--muted-foreground); }
.ctx-react:hover, .ctx-react:focus-visible { background: var(--muted); outline: none; }
.ctx-react.mine { background: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.ctx-react .icon { width: 1rem; height: 1rem; }
.ctx-who { max-height: 9rem; overflow-y: auto; padding: 0 0.25rem 0.2rem; }
.ctx-who > .muted { display: block; padding: 0.2rem 0.3rem; }
.ctx-who-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0.3rem; font-size: 0.85rem; }
.ctx-who-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-who-e { width: 1.3rem; text-align: center; flex: none; display: inline-flex; justify-content: center; }
.ctx-who-e .icon { width: 0.95rem; height: 0.95rem; }
.ctx-note { margin: 0; padding: 0 0.55rem 0.4rem; }
.ctx-item { display: flex; align-items: center; gap: 0.5rem; width: 100%; min-height: 2.4rem; padding: 0.35rem 0.55rem; border: 0; border-radius: 0.5rem; background: transparent; color: var(--foreground); font: inherit; font-size: 0.88rem; text-align: left; cursor: pointer; }
.ctx-item:hover, .ctx-item:focus-visible { background: var(--muted); outline: none; }
.ctx-item:disabled { opacity: 0.5; cursor: progress; }
.ctx-item .icon { width: 1rem; height: 1rem; flex: none; }
.ctx-item.danger { color: var(--danger); }
.ctx-check { width: 1rem; height: 1rem; flex: none; display: inline-flex; color: var(--accent); }
.ctx-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-confirm { max-width: 26rem; }
.chat-confirm-quote { margin: 0.6rem 0 0; padding: 0.4rem 0.6rem; border-left: 3px solid var(--border); color: var(--muted-foreground); font-size: 0.85rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 8rem; overflow: auto; }
.chat-confirm-actions { justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.chat-confirm-actions .btn { min-height: 2.5rem; }
.chat-confirm .btn-danger { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* quick replies popup */
.chat-compose-tools { display: flex; gap: 0.4rem; margin: -0.15rem 0 0.35rem; }
.chat-compose-tools .btn { gap: 0.35rem; font-size: 0.8rem; color: var(--muted-foreground); }
.chat-compose-tools .btn .icon { width: 0.95rem; height: 0.95rem; }
.chat-compose-tools .btn:hover { color: var(--foreground); }
.chat-compose { position: relative; }
.chat-quick { position: absolute; left: 1rem; bottom: calc(100% + 0.4rem); z-index: 5; width: min(28rem, calc(100% - 2rem)); max-height: min(26rem, 60vh); display: flex; flex-direction: column; gap: 0.5rem; background: var(--card); border: 1px solid var(--border); border-radius: 0.9rem; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); padding: 0.6rem; }
.chat-quick[hidden] { display: none; }
.chat-quick-head, .chat-quick > .chat-search { flex: none; }
.chat-mention { overflow-y: auto; gap: 0.1rem; }
.chat-mention > p { margin: 0.3rem 0.4rem; flex: none; }
.chat-mention-item { flex: none; display: flex; align-items: center; gap: 0.6rem; width: 100%; min-height: 2.75rem; padding: 0.3rem 0.4rem; text-align: left; border: 0; border-radius: 0.5rem; background: transparent; color: var(--foreground); font: inherit; cursor: pointer; }
.chat-mention-item:hover, .chat-mention-item.active { background: var(--muted); }
.chat-mention-item:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.chat-mention-item .avatar { width: 2rem; height: 2rem; flex: none; font-size: 0.75rem; }
.chat-mention-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-mention-item .grow > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-mention-name { font-size: 0.9rem; font-weight: 600; }
.chat-quick-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.chat-quick-head b { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.92rem; }
.chat-quick-head b .icon { width: 1rem; height: 1rem; color: var(--accent); }
.chat-quick-list { overflow-y: auto; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 0.3rem; }
.chat-quick-list > p { margin: 0.3rem 0.2rem; }
.chat-quick-item { flex: none; position: relative; display: grid; gap: 0.15rem; width: 100%; text-align: left; border: 1px solid var(--border); background: transparent; color: var(--foreground); border-radius: 0.6rem; padding: 0.45rem 2.2rem 0.45rem 0.6rem; cursor: pointer; font: inherit; min-height: 2.75rem; }
.chat-quick-item:hover, .chat-quick-item:focus-visible { background: var(--muted); outline: none; border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.chat-quick-name { font-weight: 800; font-size: 0.85rem; color: var(--accent); }
.chat-quick-text { font-size: 0.82rem; color: var(--muted-foreground); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.chat-quick-copy { position: absolute; right: 0.6rem; top: 0.55rem; color: var(--muted-foreground); }
.chat-quick-copy .icon { width: 0.95rem; height: 0.95rem; }

/* AI panel */
.chat-ai { border-top: 1px solid var(--border); padding: 0.45rem 1rem; max-height: 42vh; overflow-y: auto; background: color-mix(in srgb, var(--success) 4%, transparent); }
.chat-ai-head { display: flex; align-items: center; gap: 0.5rem; width: 100%; border: 0; background: transparent; color: var(--foreground); font-weight: 700; font-size: 0.88rem; cursor: pointer; padding: 0.2rem 0; min-height: 2.2rem; text-align: left; }
.chat-ai-head .icon { width: 1rem; height: 1rem; flex: none; }
.chat-ai-head > .icon:first-child { color: var(--accent); }
.chat-ai-head:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 0.4rem; }
.chat-ai-body { padding-bottom: 0.3rem; }
.chat-ai-q { margin: 0.2rem 0 0.4rem; color: var(--muted-foreground); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.chat-ai-answer { font-size: 0.9rem; }

/* composer */
.chat-compose { border-top: 1px solid var(--border); padding: 0.55rem 1rem 0.7rem; }
.chat-compose-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-compose .textarea { min-height: 2.75rem; max-height: 12.5rem; resize: none; padding: 0.6rem 0.75rem; }
.composer { display: block; height: auto; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; }
.composer.is-empty::before { content: attr(data-placeholder); color: var(--muted-foreground); pointer-events: none; }
.composer-bar { position: absolute; left: 1rem; bottom: calc(100% + 0.4rem); z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem; max-width: calc(100% - 2rem); padding: 0.25rem; background: var(--card); border: 1px solid var(--border); border-radius: 0.6rem; box-shadow: 0 4px 16px rgb(0 0 0 / 0.14); }
.composer-bar[hidden] { display: none; }
.composer-fmt { width: 2.25rem; height: 2.25rem; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 0.45rem; background: transparent; color: var(--muted-foreground); cursor: pointer; }
.composer-fmt .icon { width: 1rem; height: 1rem; }
.composer-fmt:hover { background: var(--muted); color: var(--foreground); }
.composer-fmt:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.composer-fmt.on { background: color-mix(in srgb, var(--accent) 22%, var(--card)); color: var(--foreground); }
.composer-url { width: min(16rem, 60vw); }
.composer code, .chat-text code, .composer pre, .chat-text pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; background: var(--muted); border-radius: 0.3rem; }
.composer code, .chat-text code { padding: 0.05em 0.3em; }
.composer pre, .chat-text pre { margin: 0.2rem 0; padding: 0.45rem 0.6rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer blockquote, .chat-text blockquote { margin: 0.2rem 0; padding: 0.1rem 0 0.1rem 0.6rem; border-left: 3px solid var(--accent); }
.tg-spoiler { background: var(--muted-foreground); color: transparent; border-radius: 0.25rem; cursor: pointer; transition: color 0.15s; }
.tg-spoiler.revealed { background: transparent; color: inherit; cursor: text; }
.composer .tg-spoiler { background: var(--muted); color: inherit; cursor: text; border-bottom: 1px dashed var(--muted-foreground); }
.tg-mention, .composer .tg-link { color: color-mix(in srgb, var(--accent) 70%, var(--foreground)); }
.chat-text a { color: color-mix(in srgb, var(--accent) 70%, var(--foreground)); }
.chat-msg.out .tg-mention, .chat-msg.out .chat-text a { color: inherit; text-decoration: underline; }
.composer .tg-link { text-decoration: underline; }
.chat-input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.chat-input-wrap .textarea { flex: 1; padding-right: 2.9rem; }
.chat-emoji-btn { position: absolute; right: 0.15rem; bottom: 0; width: 2.75rem; height: 2.75rem; color: var(--muted-foreground); }
.chat-emoji-btn:hover { color: var(--foreground); }
.chat-emoji-btn .icon { width: 1.15rem; height: 1.15rem; }
.chat-emoji { left: auto; right: 1rem; width: min(22rem, calc(100% - 2rem)); }
.chat-emoji-list { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.chat-emoji-group { position: sticky; top: 0; z-index: 1; background: var(--card); font-size: 0.72rem; font-weight: 800; color: var(--muted-foreground); padding: 0.35rem 0.2rem 0.2rem; }
.chat-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr)); }
.chat-emoji-cell { height: 2.4rem; border: 0; border-radius: 0.5rem; background: transparent; font-size: 1.35rem; line-height: 1; cursor: pointer; padding: 0; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.chat-emoji-cell:hover, .chat-emoji-cell:focus-visible { background: var(--muted); outline: none; }
.chat-send { flex: none; width: 2.75rem; min-height: 2.75rem; padding: 0; }
.chat-send .icon { width: 1.15rem; height: 1.15rem; }
.chat-reply-bar { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.45rem; border-left: 3px solid var(--accent); padding: 0.15rem 0 0.15rem 0.6rem; font-size: 0.82rem; }
.chat-reply-bar > .icon { width: 1rem; height: 1rem; color: var(--accent); flex: none; }
.chat-reply-bar .grow { display: grid; min-width: 0; }
.chat-reply-bar b { color: var(--accent); font-size: 0.78rem; }
.chat-reply-bar span { color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* albums and forwarded messages in the feed */
.chat-album { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; width: 20rem; max-width: 100%; margin: 0.1rem 0 0.25rem; border-radius: 0.6rem; overflow: hidden; }
.chat-album .chat-img { width: 100%; max-height: none; margin: 0; border-radius: 0; aspect-ratio: 1; }
.chat-album.odd > .chat-img:first-child { grid-column: span 2; aspect-ratio: 2 / 1; }
.chat-album > .chat-media { padding: 0.4rem; background: var(--muted); }
.chat-fwd-from { display: flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; color: var(--accent); margin-bottom: 0.15rem; }
.chat-fwd-from .icon { width: 0.9rem; height: 0.9rem; flex: none; }

/* picking messages: a tick at the left edge of the feed, a click toggles */
.chat-pick { display: none; }
.chat-msgs.picking .chat-msg { position: relative; align-self: stretch; max-width: none; padding-left: 2.4rem; border-radius: 0.75rem; cursor: pointer; user-select: none; }
.chat-msgs.picking .chat-bubble { max-width: min(42rem, 88%); }
.chat-msgs.picking .chat-reply-btn { visibility: hidden; }
.chat-msgs.picking .chat-pick { display: inline-flex; position: absolute; left: 0.4rem; top: 50%; transform: translateY(-50%); width: 1.35rem; height: 1.35rem; border-radius: 50%; border: 2px solid var(--border); background: var(--card); align-items: center; justify-content: center; color: transparent; }
.chat-msgs.picking .chat-pick .icon { width: 0.85rem; height: 0.85rem; stroke-width: 3; }
.chat-msgs.picking .chat-msg.picked { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.chat-msgs.picking .chat-msg.picked .chat-pick { background: var(--accent); border-color: var(--accent); color: var(--accent-foreground, #fff); }
.chat-compose.picking > :not(.chat-pick-bar) { display: none !important; }
.chat-pick-bar { display: flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; }
.chat-pick-bar[hidden] { display: none; }
.chat-pick-n { flex: none; white-space: nowrap; }
.chat-pick-bar .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-pick-bar .btn { gap: 0.4rem; min-height: 2.5rem; }

/* forwarding: the hint over the chat list and the plate over the composer */
.chat-fwd-hint { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.35rem 0.35rem 0.6rem; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: 0.6rem; background: color-mix(in srgb, var(--accent) 10%, var(--card)); font-size: 0.82rem; font-weight: 600; }
.chat-fwd-hint[hidden] { display: none; }
.chat-fwd-hint > .icon { width: 1rem; height: 1rem; color: var(--accent); flex: none; }
.chat-fwd-hint .grow { flex: 1; min-width: 0; }
.chat-fwd-bar { display: flex; align-items: center; gap: 0.3rem; margin-bottom: 0.45rem; }
.chat-fwd-bar[hidden] { display: none; }
.chat-fwd-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.55rem; text-align: left; font: inherit; font-size: 0.82rem; color: var(--foreground); background: transparent; border: 0; border-left: 3px solid var(--accent); padding: 0.2rem 0.4rem 0.2rem 0.6rem; border-radius: 0 0.5rem 0.5rem 0; cursor: pointer; min-height: 2.75rem; }
.chat-fwd-main:hover { background: var(--muted); }
.chat-fwd-main:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.chat-fwd-main > .icon { width: 1rem; height: 1rem; color: var(--accent); flex: none; }
.chat-fwd-main .grow { display: grid; min-width: 0; flex: 1; }
.chat-fwd-main b { color: var(--accent); font-size: 0.78rem; }
.chat-fwd-main .grow > span { color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-fwd-switch { flex: none; display: inline-flex; align-items: center; gap: 0.3rem; border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem 0.55rem; font-size: 0.75rem; color: var(--muted-foreground); }
.chat-fwd-switch .icon { width: 0.85rem; height: 0.85rem; }
.chat-fwd-main[aria-pressed="true"] .chat-fwd-switch { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* pictures waiting in the composer */
.chat-attach { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 0.45rem; }
.chat-attach[hidden] { display: none; }
.chat-attach.busy .chat-att { opacity: 0.55; }
.chat-att { position: relative; width: 4rem; height: 4rem; border-radius: 0.5rem; overflow: hidden; border: 1px solid var(--border); background: var(--muted); flex: none; }
.chat-att img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-att.failed img { display: none; }
.chat-att.failed::before { content: "Фото"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; color: var(--muted-foreground); }
.chat-att-x { position: absolute; top: 0.15rem; right: 0.15rem; width: 1.5rem; height: 1.5rem; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.chat-att-x .icon { width: 0.85rem; height: 0.85rem; }
.chat-att-x:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.chat-att-n { margin-left: 0.2rem; }
.chat-attach-btn { flex: none; width: 2.75rem; min-height: 2.75rem; padding: 0; color: var(--muted-foreground); }
.chat-attach-btn:hover { color: var(--foreground); }
.chat-attach-btn .icon { width: 1.15rem; height: 1.15rem; }
.chat-pane.dropping::after { content: "Отпустите, чтобы прикрепить картинки"; position: absolute; inset: 0.5rem; z-index: 20; display: flex; align-items: center; justify-content: center; border: 2px dashed var(--ring); border-radius: 1rem; background: color-mix(in srgb, var(--background) 82%, transparent); font-weight: 700; pointer-events: none; }

/* connect */
.tg-connect { display: flex; align-items: center; justify-content: center; height: 100%; padding: 1.5rem 1rem; overflow-y: auto; }
.tg-connect-card { width: 100%; max-width: 26rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--card); padding: 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.7rem; text-align: center; }
.tg-connect-card > .icon { width: 2rem; height: 2rem; color: var(--accent); }
.tg-connect-card h2 { margin: 0; font-size: 1.2rem; letter-spacing: -0.02em; }
.tg-connect-card p { margin: 0; line-height: 1.5; }
.tg-connect-card .btn { min-height: 2.75rem; }
.tg-qr { background: #fff; border-radius: 0.75rem; padding: 0.5rem; line-height: 0; }
.tg-qr svg { display: block; width: 14rem; height: 14rem; max-width: 70vw; max-height: 70vw; shape-rendering: crispEdges; }
.tg-steps { text-align: left; margin: 0; padding-left: 1.2rem; line-height: 1.6; }
.tg-pw { display: flex; gap: 0.5rem; width: 100%; }
.tg-pw .input { flex: 1; }
.tg-dev { justify-content: center; border-top: 1px dashed var(--border); padding-top: 0.6rem; width: 100%; }

@media (max-width: 760px) {
  .chat-shell { grid-template-columns: 1fr; }
  .chat-shell[data-open="1"] .chat-list { display: none; }
  .chat-shell:not([data-open="1"]) .chat-pane { display: none; }
  .chat-shell.disconnected .chat-pane { display: flex; }
  .chat-list { border-right: 0; }
  .chat-back { display: inline-flex; width: 2.75rem; min-height: 2.75rem; }
  .chat-head { padding: 0.4rem 0.6rem; gap: 0.45rem; }
  .chat-head .btn { min-height: 2.75rem; }
  .chat-head .hide-narrow { display: none; }
  .chat-msgs { padding: 0.6rem 0.6rem 0.4rem; }
  .chat-msg { max-width: 92%; }
  .chat-reply-btn { opacity: 0.6; width: 2.75rem; height: 2.75rem; }
  .chat-ai, .chat-compose { padding-left: 0.6rem; padding-right: 0.6rem; }
  .chat-ai { max-height: 38vh; }
  .chat-ai .mon-actions .btn { min-height: 2.75rem; min-width: 2.75rem; }
  /* the action row stays on screen while the answer scrolls: one line, the secondary buttons are icons */
  .chat-ai { padding-bottom: 0; }
  .chat-ai-body { display: flex; flex-direction: column; padding-bottom: 0; }
  .chat-ai-body[hidden] { display: none; }
  .chat-ai .mon-actions { order: 1; position: sticky; bottom: 0; z-index: 1; flex-wrap: nowrap; padding: 0.3rem 0; background: color-mix(in srgb, var(--success) 4%, var(--background)); }
  .chat-ai #ai-insert { flex: 1; min-width: 0; }
  .chat-ai-lbl { display: none; }
  .chat-list-head .mon-chip { min-height: 2.75rem; padding: 0.3rem 0.75rem; }
  .chat-row { min-height: 4rem; }
  .chat-new-pill { bottom: 8rem; min-height: 2.75rem; }
  .chat-head .btn { min-width: 2.75rem; }
  .chat-ai-head { min-height: 2.75rem; }
  #tg-logout { min-height: 2.75rem; min-width: 2.75rem; }
  .chat-compose-tools .btn { min-height: 2.75rem; }
  .chat-quick, .chat-emoji { left: 0.5rem; right: 0.5rem; width: auto; }
  .composer-bar { left: 0.5rem; max-width: calc(100% - 1rem); }
  .composer-fmt { width: 2.75rem; height: 2.75rem; }
  .composer-bar .input, .composer-bar .btn { min-height: 2.75rem; }
  .composer-bar .input { font-size: 1rem; }
  .chat-reply-bar .btn { min-width: 2.75rem; min-height: 2.75rem; }
  .chat-fwd-bar .btn, .chat-fwd-hint .btn { min-width: 2.75rem; min-height: 2.75rem; }
  .chat-pick-tip { display: none; }
  .profile { width: 100%; border-left: 0; }
  .profile-copy.btn { width: 2.75rem; min-width: 2.75rem; height: 2.75rem; }
  .chat-head-who { gap: 0.45rem; }
  .chat-fwd-switch span { display: none; }
  .chat-fwd-switch { padding: 0.45rem; }
  .chat-pick-bar .btn { min-height: 2.75rem; }
  .chat-att { width: 4.5rem; height: 4.5rem; }
  /* the remove button: a 44 px target over the corner of the thumbnail */
  .chat-att-x { top: 0; right: 0; width: 2.75rem; height: 2.75rem; background: transparent; }
  .chat-att-x .icon { width: 1.5rem; height: 1.5rem; padding: 0.25rem; border-radius: 50%; background: rgba(0, 0, 0, 0.6); }
  .chat-msgs.picking .chat-msg { padding-left: 2.2rem; }
  .chat-msgs.picking .chat-pick { left: 0.2rem; }
  .chat-mention { max-width: calc(100vw - 1rem); }
  .chat-emoji-grid { grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); }
  .chat-emoji-cell { height: 2.75rem; }
  .chat-quick-head .btn { min-width: 2.75rem; min-height: 2.75rem; }
  .chat-quick .input { min-height: 2.75rem; }
  .ctx-item { min-height: 2.75rem; }
  .ctx-react { width: 2.75rem; height: 2.75rem; }
  .chat-head-folders { display: none; }
  .chat-search .input { min-height: 2.75rem; }
  /* app bar: the bottom items (theme, logout) become 44 px icon buttons, the avatar and the wordmark go away */
  #nav-items .nav-item { min-height: 2.75rem; }
  #nav-bottom .nav-item { min-height: 2.75rem; min-width: 2.75rem; justify-content: center; padding: 0.4rem; }
  #nav-bottom .nav-item .icon { display: inline-block; }
  #nav-bottom .nav-item span { display: none; }
  .sidebar-user { display: none; }
}
@media (max-width: 420px) {
  .sidebar .brand { display: none; }
}
@media (prefers-reduced-motion: reduce) { .badge.pulse { animation: none; } }

/* Sidebar: Telegram accounts of the console (switcher). */
.nav-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); padding: 0.35rem 0.9rem 0.1rem; }
.nav-acc { gap: 0.55rem; padding-left: 0.45rem; }
.nav-acc-av { width: 1.75rem; height: 1.75rem; font-size: 0.66rem; }
.nav-acc-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav-acc-av.av-c0 { background: color-mix(in srgb, #e60165 22%, var(--card)); color: var(--foreground); }
.nav-acc-av.av-c1 { background: color-mix(in srgb, #8000db 24%, var(--card)); color: var(--foreground); }
.nav-acc-av.av-c2 { background: color-mix(in srgb, #2f80ed 24%, var(--card)); color: var(--foreground); }
.nav-acc-av.av-c3 { background: color-mix(in srgb, #35d073 22%, var(--card)); color: var(--foreground); }
.nav-acc-av.av-c4 { background: color-mix(in srgb, #ffb020 24%, var(--card)); color: var(--foreground); }
.nav-acc-av.av-c5 { background: color-mix(in srgb, #12b5b0 24%, var(--card)); color: var(--foreground); }
.nav-acc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-acc.off .nav-acc-av, .nav-acc.off .nav-acc-name { opacity: 0.6; }
.nav-acc-off { width: 0.5rem; height: 0.5rem; border-radius: 50%; border: 1.5px solid var(--muted-foreground); flex: none; margin-left: auto; }
button.nav-item { font: inherit; font-size: 0.92rem; font-weight: 600; }
.nav-add { color: var(--muted-foreground); }
.tg-remove { margin-top: 0.4rem; color: var(--muted-foreground); }
@media (max-width: 760px) {
  .nav-label { display: none; }
  .nav-acc { padding-left: 0.3rem; min-height: 2.75rem; }
  .nav-acc-name { max-width: 6.5rem; }
  .nav-acc-off { margin-left: 0.3rem; }
  .nav-add { min-width: 2.75rem; min-height: 2.75rem; justify-content: center; padding: 0.4rem; }
  .nav-add span { display: none; }
  .nav-item.nav-add .icon { display: inline-block; }
}
.nav-acc-av .icon { width: 0.95rem; height: 0.95rem; display: inline-block; }
