:root {
  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --surface-2: #F9F8F5;
  --hover: #FAFAF8;
  --border: #E8E6E0;
  --border-2: #E0DED8;
  --line: #F0EFEB;
  --text: #1A1A18;
  --text-2: #666;
  --muted: #888;
  --faint: #AAA;
  --accent: #D85A30;
  --accent-hover: #C04B24;
  --accent-soft: #FFF1EC;
  --ok: #27AE60;
  --warn: #E6A23C;
  --danger: #E5533D;
  --bubble-out: #1A1A18;
  --bubble-out-text: #FFFFFF;
  --shadow: 0 8px 40px rgba(0, 0, 0, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1F1F1D;
    --surface-2: #262624;
    --hover: #252523;
    --border: #2E2E2B;
    --border-2: #3A3A36;
    --line: #2A2A27;
    --text: #ECEBE6;
    --text-2: #B5B3AC;
    --muted: #9A988F;
    --faint: #77756E;
    --accent-soft: #3A2419;
    --bubble-out: #ECEBE6;
    --bubble-out-text: #161615;
    --shadow: 0 8px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font-family: inherit; color: inherit; }

.msng { display: flex; height: 100vh; height: 100dvh; }

/* ─── Боковая панель ─────────────────────────────────────────────────────── */
.sidebar { width: 320px; min-width: 320px; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); overflow: hidden; }
.sb-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sb-row { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; }
.search-inp { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--border-2); border-radius: 8px; font-size: 13px; background: var(--surface-2); outline: none; }
.search-inp:focus { border-color: var(--accent); background: var(--surface); }
.new-conv-btn { width: 34px; height: 34px; border-radius: 8px; border: none; background: var(--accent); color: #fff; cursor: pointer; flex-shrink: 0; font-size: 20px; line-height: 1; }
.new-conv-btn:hover { background: var(--accent-hover); }
.ch-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.ch-tab, .tool-btn { padding: 4px 8px; border-radius: 6px; font-size: 12px; border: 1px solid var(--border-2); background: transparent; color: var(--text-2); cursor: pointer; white-space: nowrap; line-height: 1.4; }
.ch-tab.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.ch-tab:hover:not(.on), .tool-btn:hover { background: var(--bg); }
.ch-tab.off { opacity: .55; }
.ch-tab .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.sb-tools { display: flex; gap: 4px; margin-top: 6px; }
.sb-tools .tool-btn:last-child { margin-left: auto; }
.cnt { display: inline-block; background: var(--accent); color: #fff; border-radius: 10px; font-size: 10px; padding: 0 4px; margin-left: 4px; min-width: 14px; text-align: center; line-height: 15px; }

.conv-list { flex: 1; overflow-y: auto; }
.conv-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--accent-soft); }
.conv-av { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.conv-body { flex: 1; min-width: 0; }
.conv-r1 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.conv-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-time { font-size: 11px; color: var(--faint); flex-shrink: 0; margin-left: 6px; }
.conv-r2 { display: flex; align-items: center; gap: 5px; }
.ch-pill { font-size: 10px; padding: 2px 5px; border-radius: 4px; font-weight: 600; flex-shrink: 0; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-prev { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.unread-cnt { font-size: 10px; background: var(--accent); color: #fff; border-radius: 10px; padding: 1px 5px; min-width: 16px; text-align: center; flex-shrink: 0; line-height: 15px; }

.sb-footer { padding: 8px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sb-footer-label { font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.ch-status { display: flex; gap: 4px; flex-wrap: wrap; }
.ch-st { font-size: 10px; padding: 2px 7px; border-radius: 4px; font-weight: 600; cursor: pointer; border: none; }
.ch-st-on { background: var(--ok); color: #fff; }
.ch-st-wait { background: var(--warn); color: #fff; }
.ch-st-err { background: var(--danger); color: #fff; }
.ch-st-off { background: var(--line); color: var(--faint); }

.empty-list, .loading-convs { padding: 24px; text-align: center; font-size: 13px; color: var(--faint); }
.empty-list .link-btn { margin-top: 10px; }
.link-btn { font-size: 12px; color: var(--accent); background: none; border: none; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ─── Переписка ──────────────────────────────────────────────────────────── */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.empty-ico { font-size: 52px; margin-bottom: 14px; opacity: .6; }
.empty-title { font-size: 15px; font-weight: 500; margin-bottom: 6px; color: var(--text-2); }
.empty-sub { font-size: 13px; color: var(--faint); text-align: center; line-height: 1.6; max-width: 280px; }

.chat-inner { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 18px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.back-btn { display: none; background: none; border: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--text-2); padding: 0 4px 2px 0; }
.head-av { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.head-info { flex: 1; min-width: 0; }
.head-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; flex-shrink: 0; }
.chan-warn { background: #FFF6E5; color: #8A5A00; font-size: 12px; padding: 7px 18px; border-bottom: 1px solid #F3E2BD; flex-shrink: 0; }
@media (prefers-color-scheme: dark) { .chan-warn { background: #3A2F17; color: #F0CF8A; border-color: #4A3C1D; } }

.msgs-area { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.date-sep { text-align: center; font-size: 11px; color: var(--faint); margin: 10px 0 6px; position: relative; }
.date-sep::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--border); }
.date-sep span { background: var(--bg); padding: 0 10px; position: relative; }
.msg { display: flex; flex-direction: column; max-width: 68%; }
.msg-in { align-self: flex-start; }
.msg-out { align-self: flex-end; }
.msg-bubble { padding: 9px 13px; border-radius: 16px; font-size: 13px; line-height: 1.55; word-break: break-word; }
.msg-in .msg-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-out .msg-bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-right-radius: 4px; }
.msg-failed .msg-bubble { opacity: .65; }
.msg-ts { font-size: 10px; color: var(--faint); margin-top: 2px; }
.msg-out .msg-ts { text-align: right; }
.msg-ts .st-failed { color: var(--danger); font-weight: 600; }
.msg-ts .retry { color: var(--accent); background: none; border: none; cursor: pointer; font-size: 10px; text-decoration: underline; padding: 0; margin-left: 4px; }
.media-lbl { font-style: italic; opacity: .7; }
.msg-img { max-width: 260px; max-height: 260px; border-radius: 10px; display: block; cursor: zoom-in; object-fit: cover; }
.msg-img-wrap { padding: 4px; }
.msg-img-wrap + .msg-caption { padding: 2px 9px 4px; }
.msg-audio { max-width: 240px; height: 36px; display: block; }
.no-msgs { text-align: center; color: var(--faint); font-size: 13px; padding: 32px; flex: 1; display: flex; align-items: center; justify-content: center; }

#img-lightbox { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0, 0, 0, .88); align-items: center; justify-content: center; cursor: zoom-out; }
#img-lightbox.open { display: flex; }
#img-lightbox img { max-width: 92vw; max-height: 90vh; border-radius: 8px; object-fit: contain; cursor: default; }
#img-lightbox-close { position: fixed; top: 16px; right: 20px; font-size: 32px; color: #fff; cursor: pointer; line-height: 1; user-select: none; opacity: .85; }

/* ─── Ввод ───────────────────────────────────────────────────────────────── */
.compose { background: var(--surface); border-top: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 10px; align-items: flex-end; flex-shrink: 0; position: relative; }
.compose-inp { flex: 1; padding: 9px 14px; font-size: 13px; border: 1px solid var(--border-2); border-radius: 20px; resize: none; background: var(--surface-2); outline: none; min-height: 38px; max-height: 120px; overflow-y: auto; line-height: 1.4; }
.compose-inp:focus { border-color: var(--accent); background: var(--surface); }
.send-btn { width: 38px; height: 38px; background: var(--accent); color: #fff; border: none; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: var(--border-2); cursor: default; }
.compose-disabled { background: var(--surface); border-top: 1px solid var(--border); padding: 12px 16px; text-align: center; font-size: 12px; color: var(--faint); flex-shrink: 0; }
.tmpl-btn { width: 34px; height: 38px; background: transparent; border: 1px solid var(--border-2); border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; }
.tmpl-btn:hover { background: var(--bg); color: var(--text); }
.tmpl-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.tmpl-popup { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 4px 24px rgba(0, 0, 0, .12); z-index: 50; max-height: 300px; display: flex; flex-direction: column; overflow: hidden; }
.tmpl-popup-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tmpl-popup-title { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tmpl-popup-mgr { font-size: 12px; color: var(--accent); background: none; border: none; cursor: pointer; padding: 0; }
.tmpl-popup-mgr:hover { text-decoration: underline; }
.tmpl-list, .slash-list { overflow-y: auto; padding: 4px 0; }
.tmpl-item { padding: 8px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.tmpl-item:last-child { border-bottom: none; }
.tmpl-item:hover, .tmpl-item.sel { background: var(--accent-soft); }
.tmpl-item-name { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.tmpl-item-prev { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tmpl-empty { padding: 20px; text-align: center; color: var(--faint); font-size: 12px; }
#slash-popup { position: fixed; z-index: 500; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 28px rgba(0, 0, 0, .14); max-height: 280px; display: flex; flex-direction: column; overflow: hidden; min-width: 260px; }

/* ─── Модальные окна ─────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--surface); border-radius: 18px; padding: 26px 26px 20px; max-width: 400px; width: 100%; box-shadow: var(--shadow); max-height: calc(100dvh - 32px); overflow-y: auto; }
.modal-box h3, .modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.x-btn { background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; color: var(--faint); }
.modal-field { margin-bottom: 13px; }
.modal-label { font-size: 12px; color: var(--muted); margin-bottom: 5px; display: block; }
.modal-inp, .modal-sel, .modal-ta { width: 100%; padding: 9px 12px; border: 1px solid var(--border-2); border-radius: 8px; font-size: 13px; background: var(--surface-2); outline: none; }
.modal-inp:focus, .modal-sel:focus, .modal-ta:focus { border-color: var(--accent); background: var(--surface); }
.modal-ta { resize: vertical; min-height: 84px; line-height: 1.45; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.modal-btn { padding: 9px 18px; border-radius: 8px; font-size: 13px; cursor: pointer; font-weight: 500; border: none; }
.modal-btn-cancel { background: var(--bg); color: var(--text-2); border: 1px solid var(--border-2); }
.modal-btn-cancel:hover { background: var(--line); }
.modal-btn-submit { background: var(--accent); color: #fff; }
.modal-btn-submit:hover { background: var(--accent-hover); }
.modal-btn-submit:disabled { background: var(--border-2); cursor: default; }
.form-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-bottom: 4px; }
.field-hint { font-size: 11px; color: var(--muted); line-height: 1.5; margin: -6px 0 12px; word-break: break-word; }
.login-box { max-width: 320px; }

.acc-box { max-width: 560px; }
.worker-warn { background: #FDECEA; color: #A3261A; padding: 9px 12px; border-radius: 8px; font-size: 12px; margin-bottom: 12px; }
@media (prefers-color-scheme: dark) { .worker-warn { background: #3D1D18; color: #F3A79B; } }
.acc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.acc-row { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.acc-r1 { display: flex; align-items: center; gap: 8px; }
.acc-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.acc-name { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-kind { font-size: 11px; color: var(--muted); }
.acc-state { font-size: 12px; margin-top: 6px; line-height: 1.5; }
.acc-state.ok { color: var(--ok); }
.acc-state.err { color: var(--danger); }
.acc-state.wait { color: #B07A12; }
.acc-state.off { color: var(--faint); }
.acc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.acc-actions .tool-btn.danger { color: var(--danger); }
.acc-qr { margin-top: 10px; display: flex; gap: 14px; align-items: center; }
.acc-qr img { width: 180px; height: 180px; border-radius: 8px; background: #fff; padding: 4px; flex-shrink: 0; }
.acc-qr p { font-size: 12px; color: var(--muted); line-height: 1.6; }
.acc-form { border-top: 1px solid var(--border); padding-top: 14px; margin-bottom: 8px; }
.empty-acc { font-size: 13px; color: var(--muted); padding: 12px 0; line-height: 1.6; }

/* Плитки «Добавить канал» */
.acc-chooser { border-top: 1px solid var(--border); padding-top: 14px; margin-bottom: 8px; }
.acc-chooser-title { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.acc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.acc-tile { text-align: left; border: 1px solid var(--border-2); border-radius: 12px; padding: 12px; background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.acc-tile:hover { border-color: var(--accent); background: var(--accent-soft); }
.acc-tile.main { grid-column: span 1; }
.acc-tile-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.acc-tile-sub { font-size: 11px; color: var(--muted); line-height: 1.4; }
.acc-tile-fast { font-size: 10px; font-weight: 600; color: var(--ok); text-transform: uppercase; letter-spacing: .04em; }
details.adv { margin: 4px 0 10px; }
details.adv summary { font-size: 12px; color: var(--muted); cursor: pointer; margin-bottom: 10px; }
.tool-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool-btn.primary:hover { background: var(--accent-hover); }

/* Сеть */
.net-summary { width: 100%; text-align: left; border: 1px solid var(--border-2); border-radius: 12px; padding: 10px 14px; background: var(--surface-2); cursor: pointer; margin-bottom: 12px; font-size: 13px; line-height: 1.5; }
.net-summary:hover { border-color: var(--accent); }
.net-summary b { font-weight: 600; }
.net-summary .ok { color: var(--ok); }
.net-summary .err { color: var(--danger); }
.net-summary .wait { color: #B07A12; }
.net-box { max-width: 560px; }
.net-state { font-size: 13px; margin: 12px 0; line-height: 1.5; }
.net-state .err { color: var(--danger); }
.net-exits { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.net-exit { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.net-exit.off { opacity: .55; }
.net-exit-r1 { display: flex; align-items: center; gap: 8px; }
.net-exit-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net-exit-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.net-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.net-badge { font-size: 11px; padding: 2px 7px; border-radius: 5px; background: var(--line); color: var(--muted); }
.net-badge.ok { background: rgba(39, 174, 96, .14); color: var(--ok); }
.net-badge.err { background: rgba(229, 83, 61, .12); color: var(--danger); }
.net-badge.auto { background: var(--accent-soft); color: var(--accent); }
.modal-sel.route-sel { margin-bottom: 0; }

/* Окно подключения */
.connect-box { max-width: 440px; }
.cn-center { text-align: center; }
.cn-qr { width: 264px; height: 264px; border-radius: 12px; background: #fff; padding: 6px; display: block; margin: 0 auto 14px; border: 1px solid var(--border); }
.cn-steps { font-size: 13px; line-height: 1.6; padding-left: 20px; margin: 0 0 12px; color: var(--text-2); }
.cn-steps li { margin-bottom: 3px; }
.cn-steps b { color: var(--text); font-weight: 600; }
.cn-code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 34px; font-weight: 700; letter-spacing: .12em; text-align: center; padding: 14px 0; margin: 4px 0 14px; background: var(--surface-2); border-radius: 12px; user-select: all; }
.cn-note { font-size: 12px; color: var(--muted); line-height: 1.55; margin-bottom: 12px; }
.cn-hint { font-size: 13px; color: var(--text-2); line-height: 1.5; margin-bottom: 12px; }
.cn-err { color: var(--danger); font-size: 12px; min-height: 0; margin: -4px 0 10px; }
.cn-err:empty { display: none; }
.cn-alt { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.cn-form .modal-inp { font-size: 15px; }
.cn-form .code-inp { font-size: 22px; letter-spacing: .3em; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; }
.cn-wait { padding: 34px 0 26px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 14px; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cn-done { text-align: center; padding: 18px 0 8px; }
.cn-done-ico { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 34px; line-height: 64px; margin: 0 auto 14px; }
.cn-done-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.cn-done-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
@media (max-width: 760px) { .cn-qr { width: 230px; height: 230px; } }

.tmpl-box { max-width: 480px; }
.tmpl-mgr-form { background: var(--surface-2); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.tmpl-mgr-inp, .tmpl-mgr-ta { width: 100%; padding: 8px 10px; border: 1px solid var(--border-2); border-radius: 7px; font-size: 13px; background: var(--surface); outline: none; }
.tmpl-mgr-inp:focus, .tmpl-mgr-ta:focus { border-color: var(--accent); }
.tmpl-mgr-inp { margin-bottom: 8px; }
.tmpl-mgr-ta { min-height: 84px; resize: vertical; line-height: 1.45; }
.tmpl-mgr-save { margin-top: 8px; padding: 8px 18px; border-radius: 8px; background: var(--accent); color: #fff; border: none; font-size: 13px; font-weight: 500; cursor: pointer; }
.tmpl-mgr-save:hover { background: var(--accent-hover); }
.tmpl-mgr-save:disabled { background: var(--border-2); cursor: default; }
#tmpl-form-cancel { margin-left: 6px; }
.tmpl-mgr-list { max-height: 260px; overflow-y: auto; }
.tmpl-mgr-item { display: flex; align-items: flex-start; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tmpl-mgr-item:last-child { border-bottom: none; }
.tmpl-mgr-body { flex: 1; min-width: 0; }
.tmpl-mgr-iname { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.tmpl-mgr-itext { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tmpl-mgr-edit { flex-shrink: 0; background: none; border: 1px solid var(--border-2); border-radius: 6px; color: var(--text-2); cursor: pointer; font-size: 12px; padding: 3px 8px; }
.tmpl-mgr-del { flex-shrink: 0; background: none; border: none; color: var(--faint); cursor: pointer; font-size: 17px; padding: 2px 4px; line-height: 1; }
.tmpl-mgr-del:hover { color: var(--danger); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 20px; border-radius: 10px; font-size: 13px; z-index: 1000; box-shadow: 0 4px 20px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px); }

/* ─── Телефон: список и переписка по очереди ─────────────────────────────── */
@media (max-width: 760px) {
  .sidebar { width: 100%; min-width: 0; border-right: none; }
  .chat { display: none; }
  body.chat-open .sidebar { display: none; }
  body.chat-open .chat { display: flex; }
  .back-btn { display: block; }
  .chat-head { padding: 10px 12px; }
  .msgs-area { padding: 12px; }
  .msg { max-width: 85%; }
  .compose { padding: 10px; gap: 8px; }
  .acc-qr { flex-direction: column; align-items: flex-start; }
}
