/* Веб-чат (chat.stake-email.com). Поверх общего style.css; всё со своим префиксом ch-. */
.chat-page {
  --bg: #14161a; --panel: #1d2026; --panel2: #23262e; --line: #2a2d34; --line2: #3a4150;
  --fg: #e6e6e6; --muted: #8b919c; --ok: #2f7; --err: #f55; --warn: #fb3; --dead: #c9a0ff; --accent: #2f7;
}
.chat-page [hidden] { display: none !important; }
.chat-page a { color: #7ecbff; }
.chat-page input, .chat-page select, .chat-page textarea {
  background: var(--bg); color: var(--fg); border: 1px solid #333; border-radius: 6px;
  padding: 8px; font: inherit; font-size: 14px; box-sizing: border-box; min-width: 0;
}
.chat-page input:focus, .chat-page select:focus, .chat-page textarea:focus { outline: none; border-color: #2f7a; }
.chat-page textarea { width: 100%; resize: vertical; }
.chat-page button:disabled { opacity: .45; cursor: not-allowed; }
.ch-muted { color: var(--muted); font-size: 13px; font-weight: 400; }

/* до входа прячем вкладки */
body:not(.authed) .ch-tabs, body:not(.authed) .ch-tab { display: none !important; }

/* ---- шапка и вкладки ---- */
.ch-head { position: sticky; top: 0; z-index: 5; padding: 0 16px; border-bottom: 1px solid var(--line); }
.ch-head-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0 6px; }
.ch-title { font-size: 16px; }
.ch-vw { font-size: 13px; font-weight: 400; opacity: .9; white-space: nowrap; }
.ch-vw.off { color: var(--err); }
.ch-tabs { display: flex; gap: 4px; }
.ch-tabs a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-bottom: 2px solid transparent;
  font-weight: 500; font-size: 14px; }
.ch-tabs a:hover { color: var(--fg); }
.ch-tabs a.on { color: var(--fg); border-bottom-color: var(--accent); }
.ch-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--panel2);
  font-size: 11px; text-align: center; color: var(--muted); }

/* ---- раскладка вкладки «Рассылка» ---- */
.ch-send { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.ch-send .card { margin: 12px 6px 12px 12px; }
.ch-send .ch-status { margin: 12px 12px 12px 6px; position: sticky; top: 92px; }
.ch-tab:not(.ch-send) .card { max-width: 980px; }

/* ---- форма ---- */
.ch-form { display: flex; flex-direction: column; gap: 14px; }
.ch-field { display: flex; flex-direction: column; gap: 6px; }
.ch-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ch-label .ch-kbd { text-transform: none; letter-spacing: 0; font-size: 12px; margin-left: 6px; }
.ch-field > input, .ch-field > select { width: 100%; }
.ch-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-direction: row; }
.ch-inline input[type=number] { width: 100px; }
.ch-field.ch-inline .ch-label { min-width: 190px; }

.ch-repeat { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px; padding: 10px 12px; }
.ch-repeat-info { min-width: 0; flex: 1; }
.ch-repeat-summary { margin-top: 3px; overflow-wrap: anywhere; font-size: 14px; }
.ch-repeat-btns { display: flex; gap: 6px; }

.ch-seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.ch-seg button { background: transparent; color: var(--muted); border-radius: 0; padding: 8px 14px; font-weight: 500; }
.ch-seg button + button { border-left: 1px solid var(--line2); }
.ch-seg button.on { background: #2f72; color: var(--fg); }
.ch-seg-sm button { padding: 4px 10px; font-size: 12px; }
.ch-sub { display: flex; flex-direction: column; gap: 6px; }
.ch-sub-row { flex-direction: row; }
.ch-sub-row > * { flex: 1; }

.ch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-chips:empty { display: none; }
.ch-form > .ch-chips { margin-top: -6px; }
.ch-chip { display: inline-flex; align-items: center; max-width: 100%; background: var(--panel2);
  border: 1px solid var(--line2); border-radius: 14px; font-size: 13px; overflow: hidden; }
.ch-chip-t { background: none; color: var(--fg); padding: 4px 4px 4px 10px; border-radius: 0; font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
span.ch-chip-t { display: inline-block; }
.ch-chip-x { background: none; color: #f77a; padding: 4px 8px 4px 4px; border-radius: 0; font-size: 11px; }
.ch-chip-x:hover { color: #f77; }
.ch-chips-edit { margin: 4px 0; max-height: 280px; overflow: auto; }

.ch-checks { display: flex; gap: 18px; flex-wrap: wrap; }
.ch-checks label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.ch-more { border: 1px solid var(--line); border-radius: 8px; }
.ch-more > summary { padding: 8px 10px; font-weight: 500; font-size: 14px; }
.ch-more-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 10px 12px; }

.ch-btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--line2); font-weight: 500; }
.ch-btn-ghost:hover { background: var(--panel2); }
.ch-btn-sm { padding: 4px 10px; font-size: 12px; }

.ch-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#btn-send { min-width: 170px; padding: 11px 20px; font-size: 15px; }
.ch-dirty { color: var(--warn); font-size: 13px; }

/* ---- статус ---- */
.ch-status { display: flex; flex-direction: column; gap: 10px; }
.ch-state { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ch-state-badge { font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.ch-state-badge.run { background: #2f72; color: var(--ok); animation: ch-pulse 1.6s ease-in-out infinite; }
.ch-state-badge.done { background: #2f72; color: var(--ok); }
.ch-state-badge.stopped { background: #fb32; color: var(--warn); }
.ch-state-badge.error { background: #f552; color: var(--err); }
@keyframes ch-pulse { 50% { opacity: .6; } }
.ch-st-target { font-size: 14px; overflow-wrap: anywhere; }
.ch-progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.ch-progress > div { height: 100%; width: 0; background: var(--ok); transition: width .5s; }
.ch-counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ch-counters > div { background: var(--bg); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; align-items: center; }
.ch-counters b { font-size: 20px; }
.ch-counters span { font-size: 11px; color: var(--muted); }
.c-ok b { color: var(--ok); } .c-err b { color: var(--err); } .c-dead b { color: var(--dead); } .c-skip b { color: var(--muted); }

.ch-logbar { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.ch-logbar .ch-label { flex: 1; }
.ch-log { background: #0e0f12; border-radius: 8px; padding: 6px 8px; height: calc(100vh - 380px); min-height: 220px;
  overflow: auto; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.ch-log .ln { display: flex; gap: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-log .ts { color: #555b66; flex: 0 0 auto; }
.ch-log .ok { color: #b8e8c4; } .ch-log .err { color: #ff9a9a; } .ch-log .dead { color: var(--dead); }
.ch-log .warn { color: var(--warn); } .ch-log .info { color: #cfd3da; }
.ch-log.only-err .ln.ok, .ch-log.only-err .ln.info { display: none; }

/* ---- группы / пресеты ---- */
.ch-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.ch-toolbar select, .ch-toolbar input { min-width: 200px; }
.ch-table-wrap { overflow-x: auto; margin-top: 8px; max-height: 60vh; overflow-y: auto; }
.ch-tab .card > .ch-more, .ch-tab .card > .ch-chips, .ch-tab .card > .ch-actions { margin-top: 10px; }

/* ---- вкладки привязки (gena88 и др.) ---- */
.ch-send > .ch-col { min-width: 0; }
.b-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.b-slug { color: var(--fg); text-transform: none; }
.b-counts { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 6px; }
.b-counts > span { background: var(--bg); border-radius: 6px; padding: 4px 9px; font-size: 13px; }
.b-counts b { margin-right: 4px; }
.b-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.b-search { margin-left: auto; width: 180px; padding: 5px 8px !important; }
.b-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 55vh; overflow: auto; }
.b-row { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; }
.b-row.first { border-color: #2f77; }
.b-row .b-user { flex: 0 0 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.b-row .b-age { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.b-row input { flex: 1; padding: 6px 8px; }
.b-empty { padding: 14px; text-align: center; }
.b-st { font-size: 12px; font-weight: 600; }
.b-st.ok { color: var(--ok); } .b-st.banned { color: var(--err); } .b-st.dead { color: var(--dead); }
.b-st.no_follow, .b-st.unknown { color: var(--warn); }
tr.b-off td { opacity: .6; }
/* уже писал на канал — первым в очереди */
.b-row.sent { border-color: #7ecbff55; }
.b-row .b-sent { flex: 0 0 auto; font-size: 11.5px; font-weight: 600; color: #7ecbff; background: #7ecbff1a;
  border-radius: 999px; padding: 1px 8px; white-space: nowrap; cursor: default; }
/* привязан, но AI-чат для аккаунта на канале не включён — наверху списка привязанных */
tr.b-noai td { background: #3a2a10; }
tr.b-noai td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.b-noai-tag { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 600; color: var(--warn);
  border: 1px solid #fb35; border-radius: 999px; padding: 0 7px; white-space: nowrap; cursor: help; }
#b-bound input { width: 100%; padding: 4px 6px; }
.b-hist-row { font-size: 13px; border-bottom: 1px solid var(--line); padding: 5px 0; overflow-wrap: anywhere; }
.b-hist-row:last-child { border-bottom: 0; }
.b-preview { overflow-wrap: anywhere; }
.b-preview code, .ch-kbd code { color: var(--fg); }
#b-send { min-width: 170px; padding: 11px 20px; font-size: 15px; }

/* ---- тосты ---- */
.ch-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 20; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.ch-toast { background: #1f3a27; color: #c9f5d4; border: 1px solid #2f75; padding: 9px 14px; border-radius: 8px;
  font-size: 14px; max-width: min(420px, calc(100vw - 32px)); box-shadow: 0 4px 16px #0008; transition: opacity .4s; }
.ch-toast.err { background: #3a1a1a; color: #f5c0c0; border-color: #f555; }
.ch-toast.out { opacity: 0; }

/* ---- узкий экран: одна колонка, кнопка отправки липнет к низу ---- */
@media (max-width: 900px) {
  .ch-send { grid-template-columns: 1fr; }
  .ch-send .card, .ch-send .ch-status { margin: 10px; position: static; }
  .ch-log { height: 50vh; }
  .ch-actions { position: sticky; bottom: 0; background: var(--panel); padding: 10px 0; margin-bottom: -14px; }
  #btn-send, #b-send { flex: 1; }
  .b-row { flex-wrap: wrap; }
  .b-row .b-user { flex: 1 1 auto; }
  .b-row input { flex: 1 1 100%; }
  .b-search { margin-left: 0; width: 100%; }
  .ch-field.ch-inline .ch-label { min-width: 0; }
  .ch-sub-row { flex-direction: column; }
  .ch-repeat { flex-direction: column; align-items: stretch; }
  .ch-repeat-btns > button { flex: 1; }
  .ch-counters b { font-size: 17px; }
  .ch-toolbar select, .ch-toolbar input { min-width: 0; flex: 1 1 160px; }
}
@media (max-width: 420px) {
  .ch-seg button { padding: 8px 10px; }
  .ch-head { padding: 0 10px; }
}
/* Chat workspace: channel controls, conversation, persistent composer. */
.chat-page { --bg:#101216; --panel:#181b21; --panel2:#22262e; --line:#2b3039; --line2:#39414d; --fg:#edf0f6; --muted:#9ca6b5; --accent:#a8f0c6; --ok:#a8f0c6; --err:#ff949f; --dead:#c7aff7; font-family:Inter,Segoe UI,system-ui,sans-serif; font-size:14px; }
.chat-page * { box-sizing:border-box; }
.chat-page button, .chat-page input, .chat-page textarea, .chat-page select { font-family:inherit; }
.chat-page button { transition:background .15s,color .15s; }
.chat-page button:not(.ch-btn-ghost):not(.ch-chip-t):not(.ch-chip-x):not(.ch-username) { background:var(--accent); color:#10251a; }
.chat-page button.stop { background:#522b35 !important; color:#ffbbc2 !important; }
.chat-page button:focus-visible, .chat-page a:focus-visible, .chat-page summary:focus-visible { outline:2px solid var(--accent); outline-offset:4px; }
.chat-page input, .chat-page select { min-height:40px; border-color:var(--line); border-radius:9px; padding:10px 12px; }
.chat-page input:focus, .chat-page textarea:focus, .chat-page select:focus { border-color:var(--accent); box-shadow:0 0 0 3px #a8f0c610; }
.chat-page input[type=checkbox] { min-height:0; accent-color:var(--accent); width:16px; height:16px; }
.chat-page a { color:#b7c8ed; }
.ch-head { height:110px; background:#15181d; padding:0 26px; border-color:var(--line); }
.ch-head-top { height:62px; padding:0; justify-content:flex-start; gap:24px; }
.ch-title { display:flex; align-items:center; gap:10px; font-size:18px; font-weight:700; letter-spacing:-.4px; white-space:nowrap; }
.ch-title small { font-size:12px; color:var(--muted); font-weight:400; margin-left:8px; letter-spacing:0; }
.ch-brand { display:grid; place-items:center; width:30px; height:32px; border-radius:8px; background:var(--accent); color:#12271b; font-size:21px; font-weight:900; }
.ch-connection { margin-left:auto; color:var(--accent); font-size:12px; font-weight:400; }
.ch-connection.offline { color:var(--warn); }
.ch-vw { font-size:12px; border-left:1px solid var(--line); padding-left:20px; }
.ch-tabs { height:48px; gap:12px; }
.ch-tabs a { padding:13px 14px; font-size:13px; }
.ch-tabs a.on { color:var(--accent); }
.ch-badge { margin-left:5px; }
#tab-send { height:calc(100dvh - 110px); min-height:570px; grid-template-columns:300px minmax(0,1fr); gap:0; }
#tab-send > .ch-settings { height:100%; overflow-y:auto; margin:0; padding:24px 22px; border-radius:0; border-right:1px solid var(--line); background:#15181d; gap:16px; }
.ch-section-title { font-size:16px; font-weight:600; margin-bottom:5px; }
.ch-label { font-size:11px; letter-spacing:.06em; font-weight:600; }
.ch-field { gap:9px; }
.ch-settings .ch-sub-row { flex-direction:column; }
.ch-settings .ch-seg { display:grid; grid-template-columns:1fr 1fr; width:100%; border:0; border-radius:9px; gap:3px; background:var(--bg); padding:4px; }
.chat-page .ch-seg button { color:var(--muted) !important; background:transparent !important; border:0; border-radius:6px; padding:9px 10px; font-size:12px; }
.chat-page .ch-seg button.on { color:var(--fg) !important; background:#303943 !important; }
.ch-checks { flex-direction:column; gap:12px; font-size:13px; padding:4px 0; }
.ch-more { margin:0; border-color:var(--line); }
.ch-more > summary { font-size:12px; padding:12px; line-height:1.6; }
.ch-more #more-summary { display:block; font-size:11px; }
.ch-more-body { padding:6px 12px 14px; }
.ch-field.ch-inline .ch-label { min-width:0; }
.ch-settings .ch-inline input { width:100%; }
.ch-last { margin-top:auto; }
.ch-last .ch-repeat { border:0; background:transparent; padding:10px; flex-direction:column; align-items:stretch; }
.ch-repeat-summary { font-size:12px; line-height:1.5; max-height:100px; overflow:auto; }
.ch-repeat-btns button { flex:1; font-size:11px; padding:8px; }
.ch-settings .ch-chips { max-height:90px; overflow:auto; }
.ch-chip { max-width:100%; background:var(--panel2); border-color:var(--line); }
.ch-chip-t { max-width:220px; text-overflow:ellipsis; overflow:hidden; white-space:nowrap; color:#d4dce9; }
.ch-workspace { min-width:0; min-height:0; display:flex; flex-direction:column; padding:20px 24px; gap:12px; max-width:1500px; width:100%; margin:0 auto; }
#tab-send .ch-workspace .card { margin:0; }
.ch-conversation { flex:1; min-height:0; display:flex; flex-direction:column; padding:0; border:1px solid var(--line); border-radius:14px; overflow:hidden; }
.ch-conversation-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:20px 24px 16px; }
.ch-eyebrow { color:var(--muted); font-size:10px; letter-spacing:.13em; margin-bottom:5px; }
.ch-conversation h1 { font-size:22px; line-height:1.2; letter-spacing:-.6px; margin:0; }
.ch-view-tabs { display:flex; padding:0 24px; gap:24px; border-bottom:1px solid var(--line); }
.chat-page .ch-view-tabs button { background:transparent !important; color:var(--muted) !important; border-radius:0; border-bottom:2px solid transparent; padding:12px 0; font-size:13px; }
.chat-page .ch-view-tabs button.on { border-color:var(--accent); color:var(--fg) !important; }
.ch-live-panel { min-height:0; flex:1; display:flex; position:relative; }
.ch-live-messages { flex:1; overflow-y:auto; overscroll-behavior:contain; padding:10px 24px; scrollbar-gutter:stable; }
.ch-empty { display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; color:var(--muted); height:100%; min-height:150px; font-size:14px; line-height:1.8; padding:20px; }
.ch-empty h2 { color:var(--fg); font-size:18px; font-weight:500; margin:14px 0 0; }
.ch-empty p { margin:8px 0; }
.ch-empty-symbol { width:56px; height:56px; background:#23382f; color:var(--accent); border-radius:18px; display:grid; place-items:center; font-size:28px; }
.ch-message { display:flex; gap:12px; padding:12px 0; border-bottom:1px solid #ffffff06; }
.ch-avatar { display:grid; place-items:center; width:34px; height:34px; flex-shrink:0; border-radius:11px; font-size:11px; font-weight:600; background:#2c3440; color:#bccce7; }
.ch-message-body { flex:1; min-width:0; }
.ch-message-head { display:flex; align-items:center; gap:12px; margin-bottom:5px; }
.ch-username { padding:0; background:transparent; color:var(--accent); font-weight:600; font-size:13px; overflow-wrap:anywhere; text-align:left; }
.ch-message time { font-size:10px; color:var(--muted); }
.ch-message-text { white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.6; font-size:14px; }
.ch-emote { width:28px; height:28px; object-fit:contain; vertical-align:middle; }
.ch-new { position:absolute; bottom:14px; left:50%; transform:translateX(-50%); box-shadow:0 5px 25px #0008; white-space:nowrap; }
.ch-composer { padding:16px 20px; border:1px solid var(--line); border-radius:14px; background:#1d2128; flex-shrink:0; }
#message { border:0; background:transparent; padding:8px 0; font-size:15px; min-height:68px; max-height:180px; resize:none; line-height:1.5; box-shadow:none; }
#draft-state { text-transform:none; font-size:10px; letter-spacing:0; float:right; }
.ch-composer-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:12px; border-top:1px solid var(--line); padding-top:12px; }
.ch-composer-footer > .ch-muted { font-size:11px; }
.ch-composer .ch-actions { margin:0 !important; padding:0; position:static; background:transparent; flex-direction:row-reverse; flex:1; }
#btn-send { min-width:140px; padding:11px 20px; font-size:13px; }
#sendinfo { font-size:11px; max-width:290px; }
#msg-recent { max-height:70px; overflow:auto; }
#activity-panel { min-height:0; flex:1; overflow:auto; }
#tab-send #status-card { position:static; margin:0; padding:18px 24px; border:0; background:transparent; gap:14px; height:100%; }
#status-slot { height:100%; }
.ch-st-target { font-size:12px; max-height:60px; overflow:auto; }
.ch-counters > div { background:#12151a; border:1px solid var(--line); border-radius:9px; padding:10px 5px; }
.ch-counters b { font-size:22px; font-weight:500; }
.ch-counters span { font-size:10px; }
.ch-log { flex:1; min-height:150px; height:auto; background:transparent; padding:0; font-size:12px; line-height:1.8; }
.ch-log .ln { padding:7px 0; border-bottom:1px solid var(--line); }
.ch-log .ts { color:#8893a5; }
.ch-log:empty::before { content:'События отправки появятся здесь'; display:block; text-align:center; padding:40px 10px; color:var(--muted); font-family:Segoe UI,sans-serif; }
#log-search { width:100%; }
.ch-tab:not(#tab-send) > .card, #tab-bind .card { border:1px solid var(--line); padding:22px; border-radius:14px; }
#tab-bind { grid-template-columns:minmax(0,1fr) minmax(300px,.7fr); }
.ch-tab table th { padding:12px 8px; color:var(--muted); font-size:11px; }
.ch-tab table td { padding:10px 8px; }
.ch-toasts { z-index:30; }
#login { max-width:440px; margin:12vh auto; padding:32px; border:1px solid var(--line); border-radius:18px; }
#login h1 { font-size:24px; letter-spacing:-.5px; margin:0 0 12px; }
#login .row { flex-wrap:nowrap; margin-top:24px; }
#login input { flex:1; width:100%; }
body:not(.authed) .ch-connection, body:not(.authed) .ch-vw { display:none; }
@media(min-width:1600px) { #tab-send { grid-template-columns:330px minmax(0,1fr); } .ch-workspace { padding:26px 40px; } }
@media(max-width:1000px) { #tab-send { grid-template-columns:260px minmax(0,1fr); } .ch-workspace { padding:14px; } .ch-title small { display:none; } .ch-composer-footer { flex-wrap:wrap; } #sendinfo { max-width:220px; } }
@media(max-width:700px) {
  .ch-head { height:101px; padding:0 14px; }
  .ch-head-top { height:55px; gap:10px; flex-wrap:wrap; }
  .ch-title { font-size:16px; }
  .ch-vw { margin-left:auto; font-size:10px; padding-left:8px; }
  .ch-connection { display:none; }
  .ch-tabs { height:46px; gap:0; overflow-x:auto; }
  .ch-tabs a { padding:13px 10px; white-space:nowrap; font-size:12px; }
  #tab-send { height:auto; min-height:calc(100dvh - 101px); display:flex; flex-direction:column; }
  #tab-send > .ch-settings { height:auto; overflow:visible; border:0; border-bottom:1px solid var(--line); padding:16px; display:grid; grid-template-columns:1fr 1fr; gap:12px; }
  .ch-settings > .ch-section-title, .ch-settings > .ch-more, .ch-settings > .ch-checks, .ch-settings > #ch-recent, .ch-settings > #channel-error { grid-column:1/-1; }
  .ch-settings > .ch-section-title { font-size:14px; }
  .ch-settings > .ch-field { grid-column:1/-1; }
  .ch-settings .ch-seg { display:flex; }
  .ch-settings .ch-seg button { flex:1; padding:9px 6px; }
  .ch-settings .ch-checks { flex-direction:row; font-size:12px; }
  .ch-settings .ch-last { display:none; }
  #open-chat { grid-column:1/-1; }
  .ch-workspace { height:calc(100dvh - 115px); min-height:520px; padding:12px; gap:10px; }
  .ch-conversation-head { padding:16px; }
  .ch-conversation h1 { font-size:19px; }
  #live-state { font-size:10px; max-width:150px; text-align:right; }
  .ch-view-tabs { padding:0 16px; gap:20px; }
  .ch-live-messages { padding:8px 14px; }
  .ch-composer { padding:12px 14px; }
  .ch-composer-footer { gap:8px; }
  .ch-composer .ch-actions { flex-basis:100%; }
  #btn-send { flex:0 0 auto; min-width:140px; }
  #sendinfo { flex:1; }
  #tab-send #status-card { padding:14px; }
  .ch-logbar { flex-wrap:wrap; }
  .ch-logbar .ch-label { flex-basis:100%; }
  #tab-bind { grid-template-columns:1fr; }
  #login { margin:50px 16px; }
}
@media(prefers-reduced-motion:reduce) { .chat-page * { animation:none !important; transition:none !important; } }

.ch-workspace { height:100%; }
#settings-toggle { display:none; }
@media(max-width:700px) {
  #settings-toggle { display:inline-block; float:right; padding:5px 10px; font-size:11px; }
  .ch-settings:not(.settings-open) > .ch-field:not(label), .ch-settings:not(.settings-open) > .ch-checks, .ch-settings:not(.settings-open) > .ch-more, .ch-settings:not(.settings-open) > #ch-recent { display:none; }
  .ch-settings > #channel-error:empty { display:none; }
  .ch-workspace { height:calc(100dvh - 290px); min-height:450px; }
}
.ch-message-head { flex-wrap:wrap; }
.chat-page .ch-reply-action { margin-left:auto; background:transparent !important; color:var(--muted) !important; border:1px solid var(--line); padding:4px 8px; font-size:11px; }
.chat-page .ch-reply-action:hover { color:var(--accent) !important; border-color:var(--accent); }
.ch-reply-bar { display:flex; gap:16px; justify-content:space-between; align-items:flex-start; border-left:3px solid var(--accent); padding:9px 12px; margin-bottom:12px; background:#a8f0c60b; border-radius:0 8px 8px 0; }
.ch-reply-bar > div { min-width:0; }
.ch-reply-bar b { font-size:12px; color:var(--accent); }
#reply-text { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:600px; color:var(--fg); font-size:12px; margin:4px 0; }
.ch-reply-bar small { font-size:10px; color:var(--muted); }
.ch-reply-bar button { flex-shrink:0; padding:4px 8px; }
.ch-message-quote { color:var(--muted); border-left:2px solid var(--line2); padding:4px 10px; margin:6px 0; font-size:12px; max-height:60px; overflow:hidden; overflow-wrap:anywhere; }
@media(max-width:700px) { .ch-reply-action { min-height:32px; } #reply-text { max-width:240px; } }
.ch-conversation-head > div { min-width:0; }
#rewards-open { font-size:12px; white-space:nowrap; margin-left:auto; }
.ch-rewards-dialog { color:var(--fg); background:var(--panel); border:1px solid var(--line2); border-radius:18px; width:min(600px,calc(100vw - 28px)); padding:24px; max-height:85dvh; overflow:auto; box-shadow:0 25px 100px #0009; }
.ch-rewards-dialog::backdrop { background:#080b10bb; backdrop-filter:blur(3px); }
.ch-rewards-head, .ch-rewards-balance { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.ch-rewards-head h2 { margin:0 0 8px; font-size:22px; }
.ch-rewards-balance { background:var(--bg); border:1px solid var(--line); padding:16px; border-radius:12px; margin:24px 0 16px; }
.ch-rewards-balance b { display:block; font-size:28px; margin-top:6px; font-variant-numeric:tabular-nums; }
#rewards-status { line-height:1.6; margin:12px 0; overflow-wrap:anywhere; }
#rewards-list { display:flex; flex-direction:column; gap:10px; }
.ch-reward-card { display:flex; align-items:center; gap:16px; padding:16px; border:1px solid var(--line); border-radius:12px; }
.ch-reward-info { min-width:0; flex:1; }
.ch-reward-card h3 { font-size:15px; margin:0; overflow-wrap:anywhere; }
.ch-reward-card p { margin:7px 0 0; overflow-wrap:anywhere; }
.ch-reward-card button { flex-shrink:0; font-size:12px; }
.ch-reward-unavailable { color:var(--warn); font-size:12px; }
#reward-input { width:100%; }
#reward-buy { width:100%; margin-top:10px; padding:14px; }
#reward-detail h3 { font-size:20px; margin:18px 0 8px; }
@media(max-width:700px) { .ch-rewards-dialog { padding:18px; } .ch-reward-card { flex-wrap:wrap; } .ch-reward-card button { width:100%; } .ch-conversation-head { flex-wrap:wrap; } #rewards-open { margin-left:0; } }

.ch-account-tools { display:flex; align-items:center; gap:8px; margin-left:auto; }
.ch-account-tools button { font-size:12px; white-space:nowrap; }
.ch-profile-badge { display:inline-flex; align-items:center; flex-shrink:0; font-size:10px; line-height:1.2; color:var(--accent); gap:3px; vertical-align:middle; }
.ch-profile-badge img { display:block; width:22px; height:22px; object-fit:contain; }
.ch-message-head > .ch-profile-badge { max-width:90px; }
.ch-badge-preview { display:flex; align-items:center; gap:10px; padding:18px; background:var(--bg); border:1px solid var(--line); border-radius:12px; margin:20px 0 12px; flex-wrap:wrap; }
#badges-preview { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--muted); }
.ch-badge-group { border-top:1px solid var(--line); padding:8px 0 16px; }
.ch-badge-group h3 { font-size:14px; }
.ch-badge-option { display:flex; gap:12px; align-items:center; cursor:pointer; background:var(--bg); border:1px solid var(--line); border-radius:9px; margin:8px 0; padding:12px; }
.ch-badge-option:has(input:checked) { border-color:var(--accent); background:#a8f0c60b; }
.ch-badge-option .ch-profile-badge img { width:30px; height:30px; }
.ch-badge-option .ch-profile-badge:not(:has(img)) { display:none; }
.ch-badges-footer { display:flex; gap:8px; flex-wrap:wrap; position:sticky; bottom:-24px; padding:16px 0 0; background:var(--panel); }
#badges-save { margin-left:auto; }
#badges-status { margin-bottom:12px; line-height:1.6; }
@media(max-width:700px){ .ch-account-tools { width:100%; margin-left:0; } .ch-account-tools button { flex:1; } }


/* вкладки привязки: динамические ссылки в шапке + поля */
.b-tabs { display: contents; }
.b-tab-add { font-weight: 700; }
.b-fields { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.b-fields > span { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px 3px 9px; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.b-fields button { padding: 0 6px; min-width: 0; font-size: 12px; }
.b-row .b-inputs { flex: 1; display: flex; gap: 6px; min-width: 0; }
.b-row .b-inputs input { flex: 1; min-width: 0; }
@media (max-width: 700px) { .b-row .b-inputs { flex: 1 1 100%; flex-wrap: wrap; } }

/* ---- переключатель chat → panel ---- */
.chat-page a.ch-switch { font-size:12px; font-weight:600; color:var(--muted); text-decoration:none;
  border:1px solid var(--line); border-radius:8px; padding:5px 10px; white-space:nowrap; }
.chat-page a.ch-switch:hover { color:var(--accent); border-color:var(--accent); }

/* Выбор отправителей и разовое сообщение во вкладке привязки. */
.b-recipients { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin:14px 0; }
.b-recipients select { min-width:200px; }
.b-select-cell { width:55px; text-align:center; }
#b-bound input[type=checkbox] { width:18px; height:18px; padding:0; cursor:pointer; accent-color:var(--accent); }
#b-bound input[type=checkbox]:disabled { cursor:default; }
#b-single-msg, #b-single-user { width:100%; }
#b-single-msg { margin:12px 0; }
#b-single-info { overflow-wrap:anywhere; }
