/* public/chat.css — «💬 Чат сотрудников» (Ч1 + Ч2, 2026-10-23a). Вид — по холсту Claude Design
   «BelstCRM — Чат сотрудников»: панели 18px, строки списка 12px, пузыри 14px (угол к автору 4px),
   кнопки и поля 10–12px, чипы и реакции — круглые. Синий #1F6699, Капля — #E3F1F8, непрочитанное — оранжевый. */

:root {
  --ch-blue: #1F6699; --ch-blue-d: #0B3B5C; --ch-ink: #0B2B44; --ch-muted: #4D6577; --ch-muted2: #3A5468;
  --ch-line: #D9E3EC; --ch-line2: #C7D4DF; --ch-bg: #F4F7FA; --ch-bg2: #F8FAFC; --ch-panel: #FFFFFF;
  --ch-k: #E3F1F8; --ch-sel: #EEF5FA; --ch-orange: #C2410C; --ch-other: #FFFFFF; --ch-other-b: #D9E3EC;
}
html[data-theme="dark"] {
  --ch-blue: #3D8FCB; --ch-blue-d: #9CCBEE; --ch-ink: #E6EDF3; --ch-muted: #9AAAB8; --ch-muted2: #B4C2CE;
  --ch-line: #2C3744; --ch-line2: #36424F; --ch-bg: #11161D; --ch-bg2: #161C24; --ch-panel: #1A212B;
  --ch-k: #18303F; --ch-sel: #1E2C3A; --ch-orange: #F08A4B; --ch-other: #222B36; --ch-other-b: #2F3B48;
}

/* кнопка меню */
#btn-chat .ch-nav-count { background: var(--ch-orange); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 4px; line-height: 16px; display: inline-block; }
#btn-chat .ch-nav-count[hidden] { display: none; }

/* экран */
#chat-view { padding: 0; background: transparent; border: 0; box-shadow: none; }
.ch-wrap { display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); gap: 16px; height: calc(100vh - var(--topbar-h, 120px) - 48px); min-height: 520px; color: var(--ch-ink); font-family: Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.ch-aside, .ch-main { background: var(--ch-panel); border: 1px solid var(--ch-line); border-radius: 18px; min-height: 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.ch-aside-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 8px; }
.ch-aside-head h2 { margin: 0; font-size: 20px; flex: 1; color: var(--ch-ink); }
.ch-ibtn { border: 1px solid transparent; background: none; color: var(--ch-muted2); border-radius: 10px; min-width: 34px; height: 34px; padding: 0 8px; font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.ch-ibtn:hover { background: var(--ch-bg); color: var(--ch-ink); }
.ch-plus { background: var(--ch-blue) !important; color: #fff !important; font-size: 20px; font-weight: 600; }
.ch-plus:hover { filter: brightness(1.08); }
.ch-search { padding: 0 16px 8px; }
.ch-search input, .ch-side input[type=search], .ch-pick-q { width: 100%; height: 38px; border: 1px solid var(--ch-line2); border-radius: 12px; padding: 0 12px; background: var(--ch-bg2); color: var(--ch-ink); }
.ch-filters, .ch-tabs { display: flex; gap: 6px; padding: 0 16px 10px; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.ch-tabs { padding: 0 0 12px; }
.ch-filters::-webkit-scrollbar { display: none; }
.ch-chip { border: 1px solid var(--ch-line2); background: var(--ch-panel); color: var(--ch-muted2); border-radius: 999px; height: 30px; padding: 0 12px; font-size: 13px; white-space: nowrap; cursor: pointer; flex: none; }
.ch-chip.on { background: var(--ch-blue); border-color: var(--ch-blue); color: #fff; }
.ch-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.ch-row { display: flex; gap: 12px; width: 100%; text-align: left; border: 0; background: none; border-radius: 12px; padding: 10px 10px; cursor: pointer; color: inherit; align-items: center; position: relative; }
.ch-row:hover { background: var(--ch-bg); }
.ch-row.on { background: var(--ch-sel); box-shadow: inset 3px 0 0 var(--ch-blue); }
.ch-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ch-row-top, .ch-row-sub { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ch-row-title { flex: 1; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-has-unread .ch-row-title { font-weight: 700; }
.ch-row-time { font-size: 12px; color: var(--ch-muted); flex: none; }
.ch-row-last { flex: 1; min-width: 0; font-size: 13px; color: var(--ch-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-row-last b { font-weight: 600; color: var(--ch-muted2); }
.ch-tag { background: var(--ch-k); color: var(--ch-blue-d); border-radius: 999px; font-size: 11px; padding: 1px 8px; flex: none; font-weight: 600; }
.ch-unread { background: var(--ch-orange); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; flex: none; }
.ch-at { color: var(--ch-orange); font-weight: 800; flex: none; }
.ch-mute, .ch-pin-ic { font-size: 12px; flex: none; margin-right: 2px; }
.ch-empty { color: var(--ch-muted); padding: 24px 12px; text-align: center; font-size: 14px; }
.ch-found { border-top: 1px solid var(--ch-line); margin-top: 8px; padding-top: 6px; }
.ch-found-h { font-size: 12px; font-weight: 700; color: var(--ch-muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px 4px; }
.ch-found-row { display: block; width: 100%; text-align: left; border: 0; background: none; border-radius: 12px; padding: 8px 10px; cursor: pointer; color: inherit; font-size: 13px; }
.ch-found-row:hover { background: var(--ch-bg); }
.ch-found-row div { color: var(--ch-muted2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* аватары: люди — круг, группы и карточки — квадрат 10px */
.ch-av { width: 42px; height: 42px; flex: none; border-radius: 50%; background: #DCE8F1; color: #0B3B5C; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; position: relative; letter-spacing: .02em; }
.ch-av-sq { border-radius: 10px; background: var(--ch-k); color: var(--ch-blue-d); font-size: 12px; }
.ch-av-lg { width: 44px; height: 44px; }
.ch-av-k { background: var(--ch-k); }
.ch-av-k img { width: 26px; height: 32px; }
.ch-online { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #1A8754; border: 2px solid var(--ch-panel); }
.ch-msgs .ch-av, .ch-mem .ch-av, .ch-pick .ch-av, .ch-ac .ch-av, .chd-mems .ch-av { width: 34px; height: 34px; font-size: 12px; }
.ch-av-gap { width: 34px; flex: none; }

/* Telegram */
.ch-tg { margin: 0 12px 8px; display: flex; gap: 10px; background: var(--ch-k); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.ch-tg-ic { font-size: 20px; color: var(--ch-blue); }
.ch-tg-btns { display: flex; gap: 6px; margin-top: 8px; }

/* шапка чата */
.ch-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--ch-line); }
.ch-head-t { flex: 1; min-width: 0; }
.ch-head-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-head-sub { font-size: 13px; color: var(--ch-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-on { color: #1A8754; }
.ch-head-btns { display: flex; gap: 6px; flex: none; }
.ch-hbtn { border: 1px solid var(--ch-line2); background: var(--ch-panel); color: var(--ch-muted2); border-radius: 10px; height: 34px; padding: 0 10px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.ch-hbtn:hover { background: var(--ch-bg); color: var(--ch-ink); }
.ch-back { display: none; font-size: 26px; }
.ch-link { border: 0; background: none; color: var(--ch-blue); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.ch-pins { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--ch-line); background: var(--ch-bg2); font-size: 13px; }
.ch-pins-t { flex: 1; min-width: 0; text-align: left; border: 0; background: none; color: var(--ch-muted2); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0; }
.ch-pins-more { display: flex; gap: 4px; }
.ch-pins-more .ch-chip { height: 24px; padding: 0 8px; font-size: 12px; }

/* лента */
.ch-body { flex: 1; display: flex; min-height: 0; }
.ch-scroll { flex: 1; overflow-y: auto; padding: 8px 20px 16px; background: var(--ch-bg2); }
.ch-msgs { display: flex; flex-direction: column; gap: 2px; }
.ch-day { text-align: center; margin: 14px 0 8px; }
.ch-day span { background: var(--ch-panel); border: 1px solid var(--ch-line); color: var(--ch-muted); font-size: 12px; border-radius: 999px; padding: 3px 12px; }
.ch-older { text-align: center; padding: 6px; }
.ch-sys { align-self: center; font-size: 12.5px; color: var(--ch-muted); background: var(--ch-panel); border: 1px dashed var(--ch-line2); border-radius: 12px; padding: 5px 12px; margin: 6px 0; max-width: 90%; text-align: center; }
.ch-msg { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; position: relative; max-width: 100%; }
.ch-msg.grouped { margin-top: 2px; }
.ch-msg.mine { flex-direction: row-reverse; }
.ch-bwrap { max-width: min(640px, 78%); min-width: 0; display: flex; flex-direction: column; }
.ch-msg.mine .ch-bwrap { align-items: flex-end; }
.ch-meta { font-size: 12.5px; color: var(--ch-muted); margin: 0 0 3px 2px; }
.ch-meta b { color: var(--ch-ink); font-weight: 700; }
.ch-bubble { min-width: 0; max-width: 100%; background: var(--ch-other); border: 1px solid var(--ch-other-b); border-radius: 4px 14px 14px 14px; padding: 9px 12px; font-size: 14.5px; line-height: 1.45; overflow-wrap: anywhere; color: var(--ch-ink); }
.ch-msg.grouped:not(.mine) .ch-bubble { border-radius: 14px; }
.ch-msg.mine .ch-bubble { background: var(--ch-blue); border-color: var(--ch-blue); color: #fff; border-radius: 14px 4px 14px 14px; }
.ch-msg.mine.grouped .ch-bubble { border-radius: 14px; }
.ch-msg.mine .ch-bubble a, .ch-msg.mine .ch-ment { color: #fff; }
.ch-msg.kaplya .ch-bubble { background: var(--ch-k); border-color: #BFDDEE; }
.ch-msg.private .ch-bubble { border: 1.5px dashed var(--ch-blue); background: var(--ch-k); color: var(--ch-ink); }
.ch-private-l { font-size: 12px; color: var(--ch-blue-d); font-weight: 600; margin: 0 0 3px 2px; }
.ch-msg.at-me:not(.mine) .ch-bubble { box-shadow: inset 3px 0 0 var(--ch-orange); }
.ch-msg.urgent .ch-bubble { border-color: var(--ch-orange); }
.ch-msg.mine.urgent .ch-bubble { box-shadow: 0 0 0 2px var(--ch-orange); }
.ch-urgent-l { color: var(--ch-orange); font-weight: 700; font-size: 12.5px; }
.ch-msg.mine .ch-urgent-l { color: #FFE2CF; }
.ch-ment { color: var(--ch-blue); font-weight: 600; }
.ch-quote { display: block; width: 100%; max-width: 100%; overflow: hidden; text-align: left; border: 0; border-left: 3px solid var(--ch-blue); background: rgba(31, 102, 153, .08); border-radius: 6px; padding: 4px 8px; margin: 0 0 6px; cursor: pointer; color: inherit; font-size: 13px; }
.ch-quote b { display: block; font-size: 12px; }
.ch-quote span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.ch-msg.mine .ch-quote { border-left-color: #fff; background: rgba(255, 255, 255, .16); }
.ch-fwd { font-size: 12.5px; opacity: .85; margin-bottom: 4px; font-style: italic; }
.ch-task { margin-top: 6px; font-size: 12.5px; background: rgba(0, 0, 0, .05); border-radius: 8px; padding: 4px 8px; }
.ch-msg.mine .ch-task { background: rgba(255, 255, 255, .16); }
.ch-img { display: block; margin-top: 6px; }
.ch-img img { max-width: min(320px, 100%); max-height: 260px; border-radius: 10px; display: block; }
.ch-file { display: flex; align-items: center; gap: 10px; margin-top: 6px; background: var(--ch-bg2); border: 1px solid var(--ch-line); border-radius: 12px; padding: 8px 10px; color: var(--ch-ink); min-width: 220px; }
.ch-file-ic { width: 36px; height: 36px; border-radius: 8px; background: var(--ch-k); color: var(--ch-blue-d); font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ch-file-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-file-t a { color: var(--ch-ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.ch-file-t .hint a { color: var(--ch-blue); font-weight: 400; }
.ch-file-dl { color: var(--ch-blue); text-decoration: none; font-size: 16px; }
.ch-under { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 3px; padding: 0 2px; }
.ch-time { font-size: 11.5px; color: var(--ch-muted); }
.ch-ticks { font-size: 12px; color: var(--ch-muted); }
.ch-ticks.on { color: var(--ch-blue); }
.ch-readers { border: 0; background: none; font-size: 11.5px; color: var(--ch-muted); cursor: pointer; padding: 0; text-decoration: underline dotted; }
.ch-react { border: 1px solid var(--ch-line2); background: var(--ch-panel); border-radius: 999px; height: 24px; padding: 0 8px; font-size: 12.5px; cursor: pointer; color: var(--ch-ink); }
.ch-react.mine { background: var(--ch-k); border-color: var(--ch-blue); }
.ch-more { position: absolute; top: 2px; right: 0; opacity: 0; border: 1px solid var(--ch-line2); background: var(--ch-panel); color: var(--ch-muted2); border-radius: 999px; width: 30px; height: 26px; cursor: pointer; font-size: 16px; line-height: 1; }
.ch-msg.mine .ch-more { right: auto; left: 0; }
.ch-msg:hover .ch-more, .ch-more:focus-visible { opacity: 1; }
.ch-flash .ch-bubble { animation: chFlash 1.6s ease; }
@keyframes chFlash { 0%, 40% { box-shadow: 0 0 0 3px var(--ch-orange); } 100% { box-shadow: none; } }
.ch-blank { margin: auto; text-align: center; color: var(--ch-muted); padding: 40px 20px; max-width: 380px; }
.ch-blank-ic { font-size: 40px; margin-bottom: 8px; }
.ch-blank-sm { padding: 30px 10px; }

/* правая панель */
.ch-side { width: 300px; flex: none; border-left: 1px solid var(--ch-line); padding: 12px 14px; overflow-y: auto; background: var(--ch-panel); font-size: 13.5px; }
.ch-side[hidden] { display: none; }
.ch-side-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 15px; }
.ch-who { background: var(--ch-k); border-radius: 12px; padding: 8px 10px; color: var(--ch-blue-d); font-size: 13px; }
.ch-mem-h { font-weight: 700; margin: 12px 0 6px; display: flex; justify-content: space-between; align-items: center; }
.ch-mem { display: flex; gap: 8px; align-items: center; padding: 5px 0; }
.ch-mem-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-mem-t .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-side-f { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.ch-flist .ch-frow { padding: 7px 0; border-bottom: 1px solid var(--ch-line); display: flex; flex-direction: column; }
.ch-frow a { color: var(--ch-ink); text-decoration: none; overflow-wrap: anywhere; }
.ch-lbl { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 13px; color: var(--ch-muted2); }
.ch-lbl input, .ch-lbl select, .ch-lbl textarea { border-radius: 10px; }
.ch-check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; font-size: 13.5px; }
.ch-check.ch-big { font-size: 15px; }
.ch-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.ch-inline input[type=text] { flex: 1; min-width: 140px; }

/* поле ввода */
.ch-compose { border-top: 1px solid var(--ch-line); padding: 10px 14px 10px; background: var(--ch-panel); position: relative; }
.ch-crow { display: flex; gap: 6px; align-items: flex-end; }
.ch-crow textarea { flex: 1; resize: none; min-height: 40px; max-height: 180px; border: 1px solid var(--ch-line2); border-radius: 12px; padding: 9px 12px; font: inherit; font-size: 14.5px; line-height: 1.4; background: var(--ch-bg2); color: var(--ch-ink); }
.ch-crow textarea:focus { outline: 2px solid rgba(31, 102, 153, .35); border-color: var(--ch-blue); }
.ch-clip { cursor: pointer; height: 40px; }
.ch-crow .ch-ibtn { height: 40px; }
.ch-urg { height: 40px; border: 1px solid var(--ch-line2); background: var(--ch-panel); color: var(--ch-muted2); border-radius: 10px; padding: 0 10px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.ch-urg.on { background: #FFF1E8; border-color: var(--ch-orange); color: var(--ch-orange); font-weight: 700; }
html[data-theme="dark"] .ch-urg.on { background: #3A2416; }
.ch-send { height: 40px; border-radius: 10px; padding: 0 16px; background: var(--ch-blue) !important; border-color: var(--ch-blue) !important; }
.ch-hint { font-size: 11.5px; color: var(--ch-muted); margin-top: 5px; }
.ch-bar { display: flex; align-items: center; gap: 8px; background: var(--ch-bg2); border-left: 3px solid var(--ch-blue); border-radius: 8px; padding: 4px 6px 4px 10px; margin-bottom: 8px; font-size: 13px; }
.ch-bar[hidden], .ch-pend[hidden], .ch-ac[hidden], .ch-drop[hidden] { display: none; }
.ch-bar-l { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-pend { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ch-pf { display: inline-flex; align-items: center; gap: 6px; background: var(--ch-k); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12.5px; max-width: 100%; }
.ch-pf.err { background: #FDE8E5; color: #8A1C12; }
.ch-pf button { border: 0; background: none; cursor: pointer; color: inherit; width: 22px; height: 22px; border-radius: 50%; }
.ch-ro { border-top: 1px solid var(--ch-line); padding: 14px 16px; color: var(--ch-muted); font-size: 13.5px; background: var(--ch-bg2); }
.ch-ac { position: absolute; left: 14px; bottom: calc(100% - 4px); background: var(--ch-panel); border: 1px solid var(--ch-line2); border-radius: 12px; box-shadow: 0 10px 30px rgba(11, 43, 68, .14); padding: 4px; min-width: 280px; max-width: calc(100% - 28px); z-index: 30; }
.ch-ac-row { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; border-radius: 8px; padding: 5px 8px; cursor: pointer; text-align: left; color: var(--ch-ink); font-size: 13.5px; }
.ch-ac-row.on, .ch-ac-row:hover { background: var(--ch-sel); }
.ch-drop { position: absolute; inset: 0; background: rgba(31, 102, 153, .12); border: 2px dashed var(--ch-blue); border-radius: 18px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--ch-blue-d); z-index: 20; pointer-events: none; }

/* меню сообщения, смайлы */
.ch-menu { position: fixed; z-index: 3000; background: var(--ch-panel); border: 1px solid var(--ch-line2); border-radius: 12px; box-shadow: 0 12px 34px rgba(11, 43, 68, .18); padding: 6px; min-width: 210px; color: var(--ch-ink); }
.ch-menu-r { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--ch-line); margin-bottom: 4px; }
.ch-menu-r button, .ch-emoji button { border: 0; background: none; font-size: 20px; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; }
.ch-menu-r button:hover, .ch-emoji button:hover { background: var(--ch-sel); }
.ch-mi { display: block; width: 100%; text-align: left; border: 0; background: none; border-radius: 8px; padding: 7px 10px; cursor: pointer; font-size: 14px; color: var(--ch-ink); }
.ch-mi:hover { background: var(--ch-sel); }
.ch-mi.danger { color: #B42318; }
.ch-emoji { display: grid; grid-template-columns: repeat(7, 34px); gap: 2px; min-width: 0; }

/* окна */
.ch-ov { position: fixed; inset: 0; z-index: 2500; background: rgba(11, 43, 68, .35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.ch-modal { background: var(--ch-panel); color: var(--ch-ink); border-radius: 18px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.ch-modal.wide { width: min(760px, 100%); }
.ch-modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.ch-modal-h h3 { margin: 0; font-size: 17px; }
.ch-modal-b { padding: 4px 16px 16px; overflow-y: auto; }
.ch-modal-b h4 { margin: 14px 0 6px; }
.ch-modal-f { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.ch-pick { max-height: 46vh; overflow-y: auto; margin-top: 8px; }
.ch-pick-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 12px; cursor: pointer; width: 100%; border: 0; background: none; text-align: left; color: inherit; }
.ch-pick-row:hover { background: var(--ch-bg); }
.ch-pick-row[hidden] { display: none; }
.ch-pick-row > span:nth-of-type(2), .ch-pick-row > span:last-child:not(.ch-av) { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-rd { padding: 3px 0; }

/* правила */
.ch-ack { display: flex; justify-content: center; padding: 24px 0; }
.ch-ack-card { background: var(--ch-panel); border: 1px solid var(--ch-line); border-radius: 18px; padding: 28px; max-width: 620px; text-align: center; color: var(--ch-ink); }
.ch-ack-ic { font-size: 40px; }
.ch-rules { text-align: left; background: var(--ch-k); border-radius: 12px; padding: 14px 16px; margin: 14px 0 18px; line-height: 1.55; }

/* «💬 Обсуждение» в карточке */
.chd { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; }
.chd-main { border: 1px solid var(--ch-line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; background: var(--ch-panel); }
.chd-msgs { max-height: 460px; min-height: 160px; overflow-y: auto; padding: 8px 16px 12px; background: var(--ch-bg2); }
.chd-compose { border-top: 1px solid var(--ch-line); padding: 10px 12px; position: relative; }
.chd-compose[hidden] { display: none; }
.chd-side { border: 1px solid var(--ch-line); border-radius: 18px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; align-self: start; background: var(--ch-panel); font-size: 13px; }
.chd-mems { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chd-empty { padding: 24px 6px; text-align: center; }
.ch-om { grid-column: 1 / -1; }
.ch-om .chd { grid-template-columns: minmax(0, 1fr) 220px; }
.ch-stat td { padding: 4px 12px 4px 0; vertical-align: top; font-size: 13.5px; }
.ch-stat td:first-child { color: var(--ch-muted); white-space: nowrap; }
.btn-like { display: inline-flex; align-items: center; border: 1px solid var(--ch-line2); border-radius: 10px; padding: 6px 12px; text-decoration: none; color: var(--ch-blue); }

/* ноутбук: правая панель поверх ленты, чтобы лента не сжималась */
@media (max-width: 1200px) {
  .ch-side { position: absolute; right: 0; top: 0; bottom: 0; z-index: 15; box-shadow: -12px 0 30px rgba(11, 43, 68, .12); }
  .ch-body { position: relative; }
}

/* телефон 390: одна колонка — список, потом чат, «‹» назад */
@media (max-width: 760px) {
  .ch-wrap { grid-template-columns: 1fr; height: calc(100dvh - var(--topbar-h, 110px) - 28px); min-height: 440px; gap: 0; }
  #chat-view .ch-main { display: none; }
  #chat-view.ch-phone-chat .ch-aside { display: none; }
  #chat-view.ch-phone-chat .ch-main { display: flex; }
  .ch-aside, .ch-main { border-radius: 16px; }
  .ch-back { display: inline-flex; margin-left: -6px; }
  .ch-head { padding: 10px 10px; gap: 8px; }
  .ch-head-btns { gap: 4px; }
  .ch-hbtn { padding: 0 8px; }
  .ch-hide-sm { display: none; }
  .ch-scroll { padding: 6px 10px 12px; }
  .ch-bwrap { max-width: 84%; }
  .ch-more { opacity: .55; }
  .ch-side { width: 100%; }
  .ch-compose { padding: 8px 8px; }
  .ch-hint { display: none; }
  .ch-send { padding: 0 12px; }
  .ch-urg { padding: 0 8px; }
  .ch-file { min-width: 0; }
  .chd, .ch-om .chd { grid-template-columns: 1fr; }
  .ch-modal { border-radius: 16px; }
}

/* файл в своём (синем) пузыре — тёмный текст на светлой плашке */
.ch-msg.mine .ch-file a { color: var(--ch-ink); }
.ch-msg.mine .ch-file .hint, .ch-msg.mine .ch-file .hint a { color: var(--ch-muted); }
.ch-msg.mine .ch-file .ch-file-dl { color: var(--ch-blue); }
@media (min-width: 761px) { .ch-filters { flex-wrap: wrap; overflow: visible; } }

/* тёмная тема программы красит все кнопки (theme-dark.css) — у чата свои */
html[data-theme="dark"] .ch-readers, html[data-theme="dark"] .ch-link, html[data-theme="dark"] .ch-pins-t, html[data-theme="dark"] .ch-found-row,
html[data-theme="dark"] .ch-row, html[data-theme="dark"] .ch-mi, html[data-theme="dark"] .ch-menu-r button, html[data-theme="dark"] .ch-emoji button,
html[data-theme="dark"] .ch-ac-row, html[data-theme="dark"] .ch-pick-row, html[data-theme="dark"] .ch-pf button, html[data-theme="dark"] .ch-ibtn:not(.ch-plus) { background: none; border-color: transparent; }
html[data-theme="dark"] .ch-row.on { background: var(--ch-sel); }
html[data-theme="dark"] .ch-row:hover, html[data-theme="dark"] .ch-mi:hover, html[data-theme="dark"] .ch-ac-row.on, html[data-theme="dark"] .ch-found-row:hover { background: var(--ch-sel); }
html[data-theme="dark"] .ch-quote { background: rgba(255, 255, 255, .06); border-color: var(--ch-blue); border-width: 0 0 0 3px; }
html[data-theme="dark"] .ch-more, html[data-theme="dark"] .ch-react, html[data-theme="dark"] .ch-chip:not(.on), html[data-theme="dark"] .ch-hbtn, html[data-theme="dark"] .ch-urg:not(.on) { background: var(--ch-panel); border-color: var(--ch-line2); }
html[data-theme="dark"] .ch-react.mine { background: var(--ch-k); border-color: var(--ch-blue); }
html[data-theme="dark"] .ch-chip.on { background: var(--ch-blue); border-color: var(--ch-blue); color: #fff; }

@media (max-width: 760px) {
  /* полоска «Заявок … напоминаний» внизу экрана — поле ввода над ней */
  .ch-wrap { height: calc(100dvh - var(--topbar-h, 110px) - 96px); }
  /* в открытом чате Капля не закрывает «Отправить» (в чат она придёт сама — этап Ч4) */
  body:has(#chat-view.ch-phone-chat:not([hidden])) #asst-drop { display: none; }
  .ch-more { display: none; } /* на телефоне меню сообщения — нажатием на сообщение */
  .ch-send-t { display: none; }
  .ch-send { padding: 0 14px; font-size: 18px; }
  .ch-crow { gap: 4px; }
  .ch-crow .ch-ibtn, .ch-clip { min-width: 32px; padding: 0 4px; }
  .ch-crow textarea { min-width: 0; }
}
@media (min-width: 761px) { .ch-send-i { display: none; } }
.ch-mem-t .ch-tag { align-self: flex-start; }

/* Ч4: Капля в чате — источники, варианты, оценка */
.ch-ksrc { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; font-size: 12.5px; color: var(--ch-muted2); }
.ch-ksrc-i { display: block; }
.ch-kopts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ch-kopts .ch-chip { height: auto; min-height: 30px; white-space: normal; text-align: left; padding: 4px 12px; }

/* ---------------------------------------------------------------- Ч5 (23l): отдельное окно, окошки, файлы */
#btn-chat-win.ch-nav-win { padding: 0 8px; min-width: 0; margin-left: -4px; }
#btn-chat-win[hidden] { display: none; }
.ch-wbtn { font-size: 13px; gap: 4px; border-color: var(--ch-line2); }
body.ch-winbody { margin: 0; padding: 8px; background: var(--ch-bg); min-height: 100vh; box-sizing: border-box; --topbar-h: 0px; }
body.ch-winbody #chat-view { margin: 0; }
body.ch-winbody .ch-wrap { height: calc(100vh - 16px); min-height: 0; }
body.ch-winbody .ch-aside-head { padding-top: 12px; }
.chw-login { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 16px); }
.chw-login[hidden] { display: none; }
.chw-login-card { background: var(--ch-panel); border: 1px solid var(--ch-line); border-radius: 18px; padding: 24px; max-width: 340px; text-align: center; color: var(--ch-ink); }
.chw-q { margin: 0 0 12px; }
@media (max-width: 420px) { .ch-hide-xs { display: none; } }

.ch-pops { position: fixed; right: 16px; bottom: 16px; z-index: 9000; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.ch-pop { pointer-events: auto; background: var(--ch-panel); color: var(--ch-ink); border: 1px solid var(--ch-line2); border-left: 4px solid var(--ch-blue); border-radius: 14px; box-shadow: 0 12px 32px rgba(11, 43, 68, .18); padding: 10px 12px; font-size: 14px; animation: ch-pop-in .18s ease-out; }
.ch-pop.urgent { border-left-color: var(--ch-orange); }
@keyframes ch-pop-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.ch-pop-h { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ch-pop-h .ch-pop-room { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ch-muted2); }
.ch-pop-x { min-width: 28px; height: 28px; margin-left: auto; }
.ch-pop-t { margin: 4px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ch-ink); }
.ch-pop-more { margin: -2px 0 6px; font-size: 12.5px; }
.ch-pop-b { display: flex; gap: 6px; }
.ch-pop-b[hidden], .ch-pop-r[hidden], .ch-pop-more[hidden] { display: none; }
.ch-pop-r { display: flex; gap: 6px; }
.ch-pop-r input { flex: 1; min-width: 0; border: 1px solid var(--ch-line2); border-radius: 10px; padding: 6px 10px; background: var(--ch-bg2); color: var(--ch-ink); font: inherit; }
@media (max-width: 760px) { .ch-pops { bottom: 80px; right: 8px; left: 8px; width: auto; } }

.ch-fbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; }
.ch-frow { display: flex; gap: 8px; align-items: flex-start; }
.ch-fchk { padding-top: 2px; }
.ch-frow-t { min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }

.ch-lightbox { background: rgba(5, 15, 25, .86); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 16px 16px; }
.ch-lightbox img { max-width: 100%; max-height: calc(100vh - 80px); border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); background: #fff; }
.ch-lb-bar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 10px 12px; color: #fff; flex-wrap: wrap; }
.ch-lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ch-lightbox.ch-ov { background: rgba(5, 15, 25, .9); }
.ch-lb-btn { text-decoration: none; display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 10px; background: #fff; color: #0B2B44; font-weight: 600; font-size: 13px; border: 1px solid #fff; }
.ch-lb-btn.alt { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .6); }
@media (max-width: 560px) { .ch-lb-name { flex-basis: calc(100% - 48px); } }
.ch-lb-x { color: #fff !important; font-size: 20px; }
/* окно чата средней ширины (761–1000): список уже, подсказки под полем ввода и подписи кнопок — прячем */
@media (min-width: 761px) and (max-width: 1000px) {
  body.ch-winbody .ch-wrap { grid-template-columns: minmax(230px, 280px) minmax(0, 1fr); gap: 8px; }
  body.ch-winbody .ch-hint, body.ch-winbody .ch-hide-sm { display: none; }
  body.ch-winbody .ch-send-t { display: none; }
  body.ch-winbody .ch-send-i { display: inline; }
  body.ch-winbody .ch-send { padding: 0 14px; }
}
