:root {
  --bg: #0a0e17;
  --bg2: #111726;
  --card: #151c2c;
  --card2: #1b2436;
  --line: #243049;
  --txt: #e8edf7;
  --muted: #8a97b2;
  --accent: #5b8cff;
  --accent2: #7b5bff;
  --green: #2ed47a;
  --red: #ff5b6e;
  --yellow: #ffc24b;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Атрибут hidden должен прятать элемент даже при display:flex/grid ниже. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  background:
    radial-gradient(1100px 600px at 85% -12%, rgba(123,91,255,.18), transparent),
    radial-gradient(900px 500px at 10% 0%, rgba(91,140,255,.14), transparent),
    var(--bg);
  color: var(--txt);
  min-height: 100vh;
}

#app { max-width: 720px; margin: 0 auto; padding: 14px 14px 40px; }

/* topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
  box-shadow: 0 6px 20px rgba(91, 140, 255, .4);
}
.brand-title { font-weight: 800; font-size: 19px; letter-spacing: .5px; }
.brand-sub { color: var(--muted); font-size: 12px; }

/* tabs */
.tabs-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin-top: 0; padding-bottom: 2px;
}
.tabs {
  display: flex; gap: 6px; background: var(--bg2); padding: 5px; border-radius: 14px;
  border: 1px solid var(--line); width: max-content; min-width: 100%;
}
.tab {
  flex: 0 0 auto; padding: 10px 14px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tab.active { background: var(--card2); color: var(--txt); box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.tab-short { display: none; }

/* телефон: вкладки в 2 ряда, «Админ» — отдельной строкой, всегда виден */
@media (max-width: 520px) {
  .tabs-scroll { overflow-x: visible; }
  .tabs {
    flex-wrap: wrap;
    width: 100%;
    gap: 5px;
  }
  .tab {
    flex: 1 1 calc(50% - 4px);
    min-width: calc(50% - 4px);
    padding: 9px 6px;
    font-size: 12px;
    text-align: center;
  }
  #adminTab {
    flex: 1 1 100%;
    min-width: 100%;
    order: 10;
    border: 1px solid rgba(255, 200, 80, .35);
    background: rgba(255, 200, 80, .08);
  }
  #adminTab.active {
    background: rgba(255, 200, 80, .18);
    border-color: rgba(255, 200, 80, .55);
  }
  .tab-long { display: none; }
  .tab-short { display: inline; }
  #adminTopBtn:not([hidden]) {
    border: 1px solid rgba(255, 200, 80, .55);
    background: rgba(255, 200, 80, .14);
    box-shadow: 0 0 0 1px rgba(255, 200, 80, .12);
  }
}

.tabview { margin-top: 14px; }

.impersonate-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 10px 0 0; padding: 10px 12px; border-radius: 12px;
  background: rgba(255, 180, 50, .12); border: 1px solid rgba(255, 180, 50, .35);
  font-size: 13px;
}
.btn-sm { padding: 6px 10px; font-size: 12px; }

.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px;
}
.admin-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; }
.admin-card-sub { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.admin-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.admin-dot { font-size: 14px; }

/* toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.stat { color: var(--muted); font-size: 13px; }

.selectbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sel-count { color: var(--accent); font-size: 13px; font-weight: 600; }

.massbar { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; max-height: 0; overflow: hidden; transition: max-height .25s, opacity .2s; opacity: 0; }
.massbar.show { max-height: 240px; opacity: 1; }

/* buttons */
.btn { border: 0; border-radius: 12px; padding: 11px 15px; font-weight: 650; font-size: 14px; cursor: pointer; transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 4px 16px rgba(91,140,255,.35); }
.btn-ghost { background: var(--card2); color: var(--txt); border: 1px solid var(--line); }
.btn.full { width: 100%; margin-top: 6px; }

.chip {
  background: var(--card2); border: 1px solid var(--line); color: var(--txt);
  padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .08s;
}
.chip:hover {
  border-color: rgba(91, 140, 255, .45);
  background: rgba(91, 140, 255, .1);
  box-shadow: 0 0 0 1px rgba(91, 140, 255, .12);
}
.chip:active { transform: scale(.96); }
.chip-danger { color: var(--red); border-color: #3a2330; }
.chip-danger:hover {
  border-color: rgba(255, 91, 110, .55);
  background: rgba(255, 91, 110, .12);
  box-shadow: 0 0 0 1px rgba(255, 91, 110, .15);
}
.btn-danger { background: rgba(255, 80, 80, .14); color: var(--red); border: 1px solid #5a2020; }

/* account list */
.list { display: flex; flex-direction: column; gap: 10px; }
.acc {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px; display: flex; flex-direction: column; gap: 10px;
  animation: accIn .32s ease both;
}
@keyframes accIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.acc-top { display: flex; align-items: center; gap: 11px; }
.acc-av {
  width: 44px; height: 44px; flex: none; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  background: linear-gradient(135deg, #2a3550, #1a2030); color: var(--accent); font-size: 17px;
}
.acc-av img { width: 100%; height: 100%; object-fit: cover; }
.tag.fa-warn { color: #ff6b6b !important; border-color: #5a2020 !important; background: rgba(255,80,80,.12); }
.acc-check { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.acc-main { flex: 1; min-width: 0; }
.acc-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-phone { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.tag.otlegka {
  color: var(--accent); border-color: rgba(91, 140, 255, .35);
  background: rgba(91, 140, 255, .08); font-variant-numeric: tabular-nums;
}
.acc-meta {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding-left: calc(20px + 11px + 44px + 11px);
  margin-top: -4px;
}
.tag { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.tag.ok { color: var(--green); border-color: #1d3a2b; }
.tag.dead { color: var(--red); border-color: #3a2330; }
.tag.warn { color: var(--yellow); border-color: #3a3320; }
.tag.fa { color: var(--accent); border-color: #233052; }
.tag-act {
  cursor: pointer; font: inherit; line-height: inherit;
  transition: opacity .12s, filter .12s;
}
.tag-act:active { opacity: .75; }

.acc-actions {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.acc-actions .chip,
.acc-act-ph {
  width: 100%; height: 34px;
}
.acc-actions .chip {
  padding: 0 6px; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  white-space: nowrap; line-height: 1; overflow: hidden; text-overflow: ellipsis;
}
.acc-act-ph {
  visibility: hidden; pointer-events: none;
}
.acc-actions .chip-accent {
  border-color: rgba(91, 140, 255, .45);
  background: rgba(91, 140, 255, .12);
}
.acc-actions .chip-accent:hover {
  background: rgba(91, 140, 255, .2);
  box-shadow: 0 0 0 1px rgba(91, 140, 255, .25);
}
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 14px; }

/* proxies */
.proxy-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.proxy-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.proxy-head h3 { margin: 0; font-size: 16px; }
.badge { background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
textarea {
  width: 100%; min-height: 92px; resize: vertical; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--txt); padding: 11px; font-size: 13px; font-family: ui-monospace, monospace;
}
.row { display: flex; gap: 8px; margin-top: 10px; }
.row .btn { flex: 1; }
.proxy-list { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow-y: auto; }
.proxy-item { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); padding: 7px 10px; background: var(--bg2); border-radius: 9px; word-break: break-all; }

/* fields */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field span { font-size: 13px; color: var(--muted); }
.field input, .field select {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; color: var(--txt);
  padding: 12px; font-size: 15px; width: 100%;
}
.checkbox { display: flex; align-items: center; gap: 9px; color: var(--txt); font-size: 14px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }
.checkbox.big { margin: 6px 0 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(5,8,14,.75); backdrop-filter: blur(4px); display: grid; place-items: end center; z-index: 85; padding: 0; }
.modal-card {
  width: 100%; max-width: 720px; background: var(--card); border-top-left-radius: 22px; border-top-right-radius: 22px;
  border: 1px solid var(--line); padding: 18px 16px 26px; animation: slideUp .25s ease;
  max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal-head { position: sticky; top: -2px; background: var(--card); padding-top: 2px; z-index: 2; }
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 18px; }

/* overlay */
.overlay { position: fixed; inset: 0; background: rgba(5,8,14,.82); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 80; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay-card {
  display: grid; place-items: center; gap: 16px; padding: 26px 30px;
  background: rgba(21,28,44,.9); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5); animation: popIn .25s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes popIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.loader { display: flex; gap: 9px; align-items: center; height: 26px; }
.loader span {
  width: 13px; height: 13px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  animation: bounce 1.1s ease-in-out infinite; box-shadow: 0 0 14px rgba(91,140,255,.55);
}
.loader span:nth-child(2) { animation-delay: .16s; }
.loader span:nth-child(3) { animation-delay: .32s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0) scale(.7); opacity: .5; }
  40% { transform: translateY(-12px) scale(1); opacity: 1; }
}
.overlay-text { color: var(--txt); font-size: 14px; text-align: center; font-weight: 600; }
.ov-sub { color: var(--muted); font-size: 12px; font-weight: 400; }
/* старый одиночный спиннер (на случай переиспользования) */
.spinner { width: 46px; height: 46px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* segmented switch (upload / sms) */
.seg { display: flex; gap: 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 5px; margin-bottom: 16px; }
.seg-btn { flex: 1; padding: 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 650; font-size: 14px; cursor: pointer; }
.seg-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 3px 12px rgba(91,140,255,.35); }

/* dropzone */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: 14px; padding: 22px 14px; text-align: center;
  cursor: pointer; background: var(--bg2); transition: border-color .15s, background .15s;
}
.dropzone:active { border-color: var(--accent); background: var(--card2); }
.dz-icon { font-size: 30px; }
.dz-title { font-weight: 700; font-size: 15px; margin-top: 6px; }
.dz-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.dz-name { margin-top: 10px; color: var(--accent); font-size: 13px; word-break: break-all; }

.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 12px; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .field { margin-bottom: 6px; }

/* proxy status dots */
.proxy-item { display: flex; align-items: center; gap: 8px; }
.ptext { flex: 1; min-width: 0; word-break: break-all; }
.pdot { font-size: 12px; flex: none; }
.pdot.ok { color: var(--green); }
.pdot.dead { color: var(--red); }

/* messenger */
.topbar-actions { display: flex; gap: 8px; }
.icon-btn { padding: 9px 12px; font-size: 17px; line-height: 1; }
.chip-accent { color: var(--accent); border-color: rgba(91, 140, 255, .35); }
.chip-accent:hover { border-color: rgba(91, 140, 255, .55); }

.screen {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; flex-direction: column; animation: slideLeft .22s ease;
}
@keyframes slideLeft { from { transform: translateX(30px); opacity: .3; } to { transform: none; opacity: 1; } }

.chat-top {
  display: flex; align-items: center; gap: 10px; padding: 12px 12px;
  border-bottom: 1px solid var(--line); background: var(--bg2); flex: none;
}
.chat-top .icon-btn { font-size: 24px; padding: 4px 10px; }
.chat-top-main { flex: 1; min-width: 0; }
.chat-top-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-top-sub { color: var(--muted); font-size: 12px; }

.dlg-unread-bar.is-off { display: none !important; }

.chat-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 700;
  overflow: hidden;
}
.chat-avatar img, .dlg-av img { width: 100%; height: 100%; object-fit: cover; display: block; }

.dlg-unread-bar {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  padding: 9px 14px;
  background: linear-gradient(90deg, rgba(91,140,255,.12), rgba(91,140,255,.05));
  border-bottom: 1px solid rgba(91,140,255,.2);
  font-size: 13px;
}
.dlg-unread-count {
  font-size: 18px; font-weight: 800; line-height: 1; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.dlg-unread-text { color: var(--muted); }
.dialogs { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.dlg { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid rgba(36,48,73,.5); cursor: pointer; }
.dlg.pinned { background: rgba(91,140,255,.06); }
.dlg:active { background: var(--card2); }
.dlg-pin { flex: none; font-size: 12px; opacity: .85; margin-right: 2px; }
.dlg-folder { flex: none; font-size: 11px; opacity: .75; margin-right: 4px; color: var(--accent2, #8ab4ff); }

.folder-list {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px;
  max-height: 36vh; overflow-y: auto;
}
.folder-pick {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.folder-pick input { accent-color: var(--accent); }
.folder-pick.on { border-color: var(--accent); background: rgba(91,140,255,.08); }
.folder-pick-name { flex: 1; font-size: 14px; font-weight: 500; }
.folder-pick-count { font-size: 12px; color: var(--muted); }
.dlg-av {
  width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, #2a3550, #384668); color: #cfe0ff; font-weight: 700; font-size: 19px;
  overflow: hidden;
}
.dlg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.dlg-row1, .dlg-row2 { display: flex; align-items: center; gap: 8px; }
.dlg-title { flex: 1; min-width: 0; font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-time { color: var(--muted); font-size: 11px; flex: none; }
.dlg-last { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-badge { flex: none; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; }

.messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg-load { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
.msg { display: flex; max-width: 82%; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; }
.msg-bubble {
  padding: 8px 12px 6px; border-radius: 14px; font-size: 14px; line-height: 1.35;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; max-width: 100%;
}
.msg.in .msg-bubble { background: var(--card2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.out .msg-bubble { background: linear-gradient(135deg, #2b5bd0, #4a3bd0); color: #fff; border-bottom-right-radius: 5px; }
.msg-time { display: block; text-align: right; font-size: 10px; opacity: .6; margin-top: 3px; }
.msg-who { font-size: 11px; color: var(--accent); font-weight: 600; margin: 0 0 2px 4px; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-text code { font-family: ui-monospace, Menlo, Consolas, monospace; background: rgba(0,0,0,.28); padding: 0 4px; border-radius: 4px; font-size: 92%; }
.msg-text a { color: #8fb3ff; }
.msg-text .msg-q { display: block; border-left: 3px solid var(--accent); padding-left: 8px; opacity: .9; }
.msg-text .msg-h { font-size: 1.05em; }
.msg-att { font-size: 12px; opacity: .85; margin-top: 3px; }

/* эмодзи-пикер */
.emoji-btn { flex: none; font-size: 20px; padding: 6px 8px; }
.emoji-panel {
  flex: none; display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 10px; max-height: 180px;
  overflow-y: auto; background: var(--bg2); border-top: 1px solid var(--line);
}
.emoji-i { font-size: 22px; line-height: 1; padding: 6px; background: none; border: none; cursor: pointer; border-radius: 8px; }
.emoji-i:active { background: rgba(255,255,255,.1); }

/* панель форматирования выделенного текста */
.fmt-bar { flex: none; display: flex; gap: 6px; padding: 6px 10px; background: var(--bg2); border-top: 1px solid var(--line); }
.fmt-bar button {
  min-width: 36px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255,255,255,.06); color: var(--text); cursor: pointer; font-size: 14px;
}
.fmt-bar button:active { background: rgba(91,140,255,.2); }
.fmt-bar .fmt-b { font-weight: 800; }
.fmt-bar .fmt-i { font-style: italic; }
.fmt-bar .fmt-u { text-decoration: underline; }
.fmt-bar .fmt-s { text-decoration: line-through; }
.fmt-bar .fmt-m { font-family: monospace; }

/* масс-диалоги: метка аккаунта-владельца */
.dlg-acc { display: inline-block; font-size: 11px; color: var(--accent); background: rgba(91,140,255,.14);
  border-radius: 6px; padding: 0 5px; margin-right: 6px; vertical-align: middle; }
.chip-accent { border-color: var(--accent) !important; color: var(--accent) !important; }

/* загрузка списка диалогов */
.dlg-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--muted, #8a93a6); font-size: 14px; text-align: center; }
.dlg-loading .spinner { display: inline-block; flex: none; width: 20px; height: 20px; border-width: 2px; }

/* фильтр диалогов */
.dlg-folder-tabs {
  flex: none; display: flex; gap: 8px; padding: 10px 12px 6px;
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
.dlg-folder-tabs .ftab {
  flex: 1; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card2); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
}
.dlg-folder-tabs .ftab.on {
  color: var(--txt); border-color: var(--accent);
  background: rgba(91,140,255,.14); box-shadow: inset 0 0 0 1px rgba(91,140,255,.12);
}

.dlg-filter { flex: none; display: flex; gap: 8px; padding: 8px 12px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; }
.dlg-filter .flt {
  flex: none; padding: 6px 12px; border-radius: 20px; font-size: 13px; cursor: pointer;
  background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--line); opacity: .5;
}
.dlg-filter .flt.on { opacity: 1; border-color: var(--accent); background: rgba(91,140,255,.16); color: var(--accent); }

/* вложения */
.att-photo { position: relative; margin-bottom: 4px; display: inline-block; }
.att-photo img { display: block; max-width: 220px; max-height: 280px; border-radius: 12px; cursor: zoom-in; object-fit: cover; }
.att-photo.att-broken { padding: 10px 12px; background: rgba(255,255,255,.06); border-radius: 10px; }
.att-dl {
  position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  background: rgba(0,0,0,.55); color: #fff; text-decoration: none; backdrop-filter: blur(2px);
}
.att-dl:active { background: rgba(0,0,0,.75); }
.att-sticker { max-width: 128px; max-height: 128px; margin-bottom: 4px; }
.att-audio { display: block; max-width: 240px; margin: 4px 0; height: 36px; }
.att-file {
  display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; margin: 4px 0;
  background: rgba(255,255,255,.06); border-radius: 10px; cursor: pointer; max-width: 240px;
}
.att-file span { font-size: 13px; font-weight: 600; word-break: break-word; }
.att-file small { font-size: 11px; opacity: .6; }
.att-file:active { background: rgba(255,255,255,.12); }
.att-share {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; margin: 4px 0;
  background: rgba(255,255,255,.06); border-left: 3px solid var(--accent); border-radius: 8px;
  text-decoration: none; color: inherit; max-width: 240px;
}
.att-share b { font-size: 13px; color: var(--accent); }
.att-share span { font-size: 12px; opacity: .8; }

/* лайтбокс */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 8px; }
.lb-close, .lb-dl {
  position: absolute; top: 14px; width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: rgba(255,255,255,.14); color: #fff; border: none; cursor: pointer; text-decoration: none;
}
.lb-close { right: 14px; }
.lb-dl { right: 66px; }

/* контекстное меню */
.ctx-menu {
  position: fixed; z-index: 210; min-width: 170px; padding: 6px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 2px;
}
.ctx-menu button {
  text-align: left; padding: 10px 12px; background: none; border: none; color: var(--txt);
  font-size: 14px; border-radius: 8px; cursor: pointer;
}
.ctx-menu button:active { background: rgba(255,255,255,.1); }

/* панель ответа */
.reply-bar {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg2); border-top: 1px solid var(--line); border-left: 3px solid var(--accent);
}
.reply-info { flex: 1; min-width: 0; }
.reply-name { font-size: 12px; font-weight: 600; color: var(--accent); }
.reply-text { font-size: 12px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { padding: 6px 10px; }

/* пересылка */
.fwd-search { width: 100%; margin-bottom: 10px; }
.fwd-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.fwd-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.fwd-item:active { background: rgba(255,255,255,.08); }
.fwd-item span { font-size: 14px; font-weight: 500; }
.fwd-av { width: 36px; height: 36px; flex: none; }

.composer { flex: none; display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg2); align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 120px; background: var(--card2); border: 1px solid var(--line);
  border-radius: 18px; color: var(--txt); padding: 10px 14px; font-size: 14px; font-family: inherit; line-height: 1.3;
}
.tpl-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%; padding: 0; border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(91,140,255,.22), rgba(120,90,255,.12));
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.tpl-btn:active { transform: scale(.96); }
.tpl-icon {
  position: relative; width: 18px; height: 18px; display: block;
}
.tpl-icon::before {
  content: ""; position: absolute; left: 0; top: 2px; width: 9px; height: 12px;
  border: 2px solid var(--accent); border-radius: 2px; opacity: .85;
}
.tpl-icon::after {
  content: ""; position: absolute; right: 0; top: 4px;
  border-style: solid; border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent var(--accent2, #8ab4ff);
}

.tpl-sheet {
  position: fixed; inset: 0; z-index: 205; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.tpl-sheet[hidden] { display: none !important; }
.tpl-sheet-card {
  width: 100%; max-width: 520px; max-height: 55vh; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column; animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.tpl-pick-list { overflow-y: auto; padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.tpl-pick-item {
  padding: 12px 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line);
  cursor: pointer; text-align: left;
}
.tpl-pick-item:active { background: rgba(91,140,255,.12); border-color: var(--accent); }
.tpl-pick-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.tpl-pick-item.on { background: rgba(91,140,255,.12); border-color: var(--accent); }
.transfer-pick-list { max-height: 220px; margin-bottom: 10px; }

.tpl-hint { padding: 0 14px 8px; margin: 0; }
.tpl-list { padding: 0 12px 20px; display: flex; flex-direction: column; gap: 10px; }
.tpl-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.tpl-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tpl-card-name { flex: 1; font-weight: 700; font-size: 15px; }
.tpl-order { display: flex; flex-direction: column; gap: 2px; }
.tpl-order button {
  width: 28px; height: 22px; padding: 0; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card2); color: var(--txt); font-size: 12px; cursor: pointer;
}
.tpl-card-text { font-size: 13px; color: var(--muted); white-space: pre-wrap; margin-bottom: 10px; max-height: 72px; overflow: hidden; }
.tpl-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.send-btn { border-radius: 50%; width: 44px; height: 44px; padding: 0; font-size: 18px; flex: none; }

/* toasts */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90; pointer-events: none; padding: 0 12px; }
.toast { background: var(--card2); border: 1px solid var(--line); color: var(--txt); padding: 11px 16px; border-radius: 12px; font-size: 13px; max-width: 100%; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: toastIn .2s ease; }
.toast.ok { border-color: #1d3a2b; }
.toast.err { border-color: #3a2330; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* масс-рассылка */
.bc-scroll { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.bc-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.bc-label { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.bc-check { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; cursor: pointer; }
.bc-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.bc-delay-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.field.compact { flex: 1; min-width: 90px; margin: 0; }
.field.compact input { width: 100%; }
.bc-delay-unit { color: var(--muted); font-size: 13px; padding-bottom: 10px; }
.bc-plan { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; animation: fadeIn .25s ease; }
.bc-plan-title { font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.bc-plan-list { font-size: 12px; color: var(--muted); max-height: 120px; overflow-y: auto; }
.bc-plan-item { padding: 3px 0; }
.bc-progress {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; animation: popIn .3s ease;
}
@keyframes popIn { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.bc-prog-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.bc-prog-nums { font-weight: 800; font-size: 20px; letter-spacing: -.3px; }
.bc-prog-pct { font-weight: 700; font-size: 18px; color: var(--accent); font-variant-numeric: tabular-nums; }
.bc-prog-track {
  height: 10px; border-radius: 99px; background: var(--bg2); overflow: hidden;
  border: 1px solid var(--line); margin-bottom: 10px;
}
.bc-prog-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--green));
  background-size: 200% 100%;
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
  animation: bcShine 2s linear infinite;
}
@keyframes bcShine { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
.bc-prog-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.bc-prog-cur { font-size: 13px; color: var(--txt); min-height: 18px; margin-bottom: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
