/* ===== TG Clone — стили ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #fff;
  --bg2: #f4f4f5;
  --border: #e7e7e7;
  --text: #000;
  --text2: #707579;
  --accent: #3390ec;
  --accent-hover: #2b85dd;
  --hover: #f4f4f5;
  --active: #3390ec;
  --out-bg: #effdde;
  --out-text: #000;
  --in-bg: #fff;
  --chat-bg: #d6e3ee;
  --chat-pattern: radial-gradient(circle at 25% 25%, rgba(255,255,255,.25) 1.5px, transparent 1.5px), radial-gradient(circle at 75% 75%, rgba(255,255,255,.18) 1.5px, transparent 1.5px);
  --check: #4fae4e;
  --badge: #3390ec;
  --menu-bg: #fff;
  --shadow: 0 2px 12px rgba(0,0,0,.18);
  --link: #2678b6;
  --reply-bg: rgba(51,144,236,.08);
  --service-bg: rgba(0,0,0,.25);
  --reaction-bg: rgba(51,144,236,.12);
  --reaction-mine: #3390ec;
}
body.dark {
  --bg: #212121;
  --bg2: #181818;
  --border: #303030;
  --text: #fff;
  --text2: #aaa;
  --hover: #2c2c2c;
  --out-bg: #766ac8;
  --out-text: #fff;
  --in-bg: #212121;
  --chat-bg: #0f0f0f;
  --chat-pattern: radial-gradient(circle at 25% 25%, rgba(255,255,255,.05) 1.5px, transparent 1.5px), radial-gradient(circle at 75% 75%, rgba(255,255,255,.04) 1.5px, transparent 1.5px);
  --check: #aee8ff;
  --menu-bg: #2c2c2c;
  --shadow: 0 2px 14px rgba(0,0,0,.5);
  --link: #6ab3f3;
  --reply-bg: rgba(255,255,255,.08);
  --service-bg: rgba(0,0,0,.4);
  --reaction-bg: rgba(255,255,255,.14);
  --reaction-mine: #5a4fb0;
}
html, body { height: 100%; }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg2);
  color: var(--text);
  overflow: hidden;
}
.hidden { display: none !important; }
button { border: 0; background: none; cursor: pointer; color: inherit; font: inherit; }
input, textarea { font: inherit; color: var(--text); }
a { color: var(--link); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,.45); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Экран входа ===== */
.auth {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.auth-card { width: 340px; max-width: 92vw; text-align: center; padding: 24px 0 60px; }
.auth-logo { margin-bottom: 22px; }
.auth-card h1 { font-size: 26px; margin-bottom: 8px; }
.auth-sub { color: var(--text2); margin-bottom: 24px; font-size: 14px; }
.auth-card input {
  display: block; width: 100%; margin-bottom: 12px; padding: 13px 14px;
  border: 1px solid var(--border); border-radius: 10px; outline: none;
  background: var(--bg); font-size: 15px;
}
.auth-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.btn-primary {
  display: block; width: 100%; padding: 13px; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15px;
  text-transform: uppercase; letter-spacing: .3px;
}
.btn-primary:hover { background: var(--accent-hover); }
.auth-toggle { display: inline-block; margin-top: 16px; color: var(--accent); cursor: pointer; font-size: 14px; }
.auth-error {
  background: #fde8e8; color: #c33; border-radius: 8px; padding: 10px 12px;
  margin-bottom: 12px; font-size: 13px; text-align: left;
}
body.dark .auth-error { background: #4a2222; color: #ff9d9d; }

/* ===== Каркас ===== */
.app { display: flex; height: 100%; }
.left {
  width: 400px; min-width: 270px; max-width: 480px;
  background: var(--bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: relative; z-index: 5;
}
.center { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* ===== Шапка списка ===== */
.left-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.icon-btn {
  width: 40px; height: 40px; min-width: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2); font-size: 20px;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.search-wrap { flex: 1; position: relative; }
.search-wrap input {
  width: 100%; padding: 9px 36px 9px 16px; border-radius: 22px;
  border: 1px solid transparent; background: var(--bg2); outline: none;
}
body.dark .search-wrap input { background: #2c2c2c; }
.search-wrap input:focus { border-color: var(--accent); background: var(--bg); }
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%; color: var(--text2); font-size: 18px;
}
.search-clear:hover { background: var(--hover); }
.connbar { padding: 6px 16px; background: var(--accent); color: #fff; font-size: 13px; text-align: center; }

/* ===== Список чатов ===== */
.chatlist { flex: 1; overflow-y: auto; padding: 0 8px 80px; }
.section-title { padding: 14px 12px 6px; color: var(--text2); font-size: 14px; font-weight: 600; }
.chat-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 10px; cursor: pointer; user-select: none;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); color: #fff; }
.chat-item.active .ci-last, .chat-item.active .ci-time, .chat-item.active .ci-name,
.chat-item.active .typing, .chat-item.active .ticks { color: #fff !important; }
.avatar {
  width: 54px; height: 54px; min-width: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 19px; font-weight: 600; position: relative;
  overflow: hidden;
}
.avatar.sm { width: 40px; height: 40px; min-width: 40px; font-size: 15px; }
.avatar.xs { width: 34px; height: 34px; min-width: 34px; font-size: 13px; }
.avatar.lg { width: 80px; height: 80px; min-width: 80px; font-size: 30px; }
.avatar.saved { background: linear-gradient(135deg, #69b4f2, #3390ec); }
.avatar svg { width: 50%; height: 50%; fill: #fff; }
.online-dot {
  position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px;
  background: #4fae4e; border: 2px solid var(--bg); border-radius: 50%;
}
.ci-body { flex: 1; min-width: 0; }
.ci-top { display: flex; align-items: baseline; gap: 6px; }
.ci-name {
  font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; flex: 1; display: flex; align-items: center; gap: 4px;
}
.ci-name .ch-icon { font-size: 12px; color: var(--text2); }
.ci-time { font-size: 12px; color: var(--text2); white-space: nowrap; }
.ci-bottom { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.ci-last {
  flex: 1; color: var(--text2); font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.ci-last .you { color: var(--text); }
.ci-last.service-prev { font-style: italic; }
.badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--badge); color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.chat-item.active .badge { background: #fff; color: var(--accent); }
.ticks { color: var(--check); font-size: 13px; letter-spacing: -3px; }
.typing { color: var(--accent); }
.typing-dots::after { content: '…'; animation: dots 1.2s infinite; }
@keyframes dots { 0% { content: '.'; } 33% { content: '..'; } 66% { content: '…'; } }

/* ===== FAB ===== */
.fab {
  position: absolute; right: 16px; bottom: 16px; width: 56px; height: 56px;
  border-radius: 50%; background: var(--accent); color: #fff;
  box-shadow: 0 4px 12px rgba(51,144,236,.45);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  transition: transform .15s;
}
.fab:hover { background: var(--accent-hover); transform: scale(1.06); }
.fab svg { width: 24px; height: 24px; fill: #fff; }

/* ===== Меню ===== */
.menu {
  position: fixed; z-index: 1000; background: var(--menu-bg);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
  min-width: 200px; animation: pop .1s ease-out;
}
@keyframes pop { from { transform: scale(.95); opacity: 0; } }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; text-align: left;
}
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: #e53935; }
.menu-item .mi-icon { width: 20px; text-align: center; font-size: 16px; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 8px; }
.menu-reactions { display: flex; gap: 2px; padding: 4px 6px 8px; }
.menu-reactions button { font-size: 21px; padding: 4px; border-radius: 50%; transition: transform .1s; }
.menu-reactions button:hover { transform: scale(1.25); }

/* ===== Чат ===== */
.emptychat { flex: 1; display: flex; align-items: center; justify-content: center;
  background: var(--chat-bg) var(--chat-pattern); background-size: 56px 56px; }
.emptychat span, .day span {
  background: var(--service-bg); color: #fff; padding: 5px 12px;
  border-radius: 14px; font-size: 13px;
}
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0;
  background: var(--chat-bg) var(--chat-pattern); background-size: 56px 56px; position: relative; }
.chat-head {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: var(--bg); border-bottom: 1px solid var(--border); z-index: 10;
}
.back { display: none; }
.head-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; border-radius: 10px; padding: 3px 8px 3px 3px; }
.head-info:hover { background: var(--hover); }
.head-text { min-width: 0; }
.head-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-status { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-status.online, .head-status.typing { color: var(--accent); }
.head-actions { display: flex; }

/* поиск по чату */
.chatsearch { position: relative; display: flex; gap: 6px; padding: 6px 12px; background: var(--bg); border-bottom: 1px solid var(--border); z-index: 9; }
.chatsearch input { flex: 1; padding: 8px 14px; border-radius: 18px; border: 1px solid var(--border); background: var(--bg2); outline: none; }
.chatsearch input:focus { border-color: var(--accent); }
.chatsearch-res {
  position: absolute; top: 100%; left: 0; right: 0; max-height: 320px; overflow-y: auto;
  background: var(--menu-bg); box-shadow: var(--shadow); z-index: 50;
}
.cs-item { padding: 9px 16px; cursor: pointer; border-bottom: 1px solid var(--border); }
.cs-item:hover { background: var(--hover); }
.cs-item .cs-name { font-weight: 600; font-size: 13px; }
.cs-item .cs-text { color: var(--text2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* закреп */
.pinbar, .replybar {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px;
  background: var(--bg); border-bottom: 1px solid var(--border); cursor: pointer; z-index: 8;
}
.replybar { border-top: 1px solid var(--border); border-bottom: 0; cursor: default; }
.pin-line { width: 2px; align-self: stretch; background: var(--accent); border-radius: 2px; }
.pin-body { flex: 1; min-width: 0; }
.pin-title { color: var(--accent); font-size: 13px; font-weight: 600; }
.pin-text { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinbar .icon-btn, .replybar .icon-btn { width: 32px; height: 32px; min-width: 32px; font-size: 17px; }

/* ===== Сообщения ===== */
.msgs { flex: 1; overflow-y: auto; padding: 12px 14px 8px; display: flex; flex-direction: column; }
.day { text-align: center; margin: 10px 0; position: sticky; top: 4px; z-index: 2; }
.row { display: flex; margin: 1px 0; align-items: flex-end; gap: 8px; }
.row.out { justify-content: flex-end; }
.row.grouped { margin-top: 1px; }
.row:not(.grouped) { margin-top: 7px; }
.row .avatar { margin-bottom: 2px; }
.row-spacer { width: 34px; min-width: 34px; }
.service-row { text-align: center; margin: 8px 0; }
.service-row span {
  background: var(--service-bg); color: #fff; padding: 4px 12px;
  border-radius: 14px; font-size: 13px; display: inline-block; max-width: 80%;
}
.bubble {
  max-width: min(480px, 76%); padding: 6px 10px 7px; border-radius: 13px;
  background: var(--in-bg); position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.08);
  word-wrap: break-word; overflow-wrap: break-word;
}
.row.out .bubble { background: var(--out-bg); color: var(--out-text); }
.bubble.flash { animation: flash 1.6s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent); } }
.b-name { font-weight: 600; font-size: 13px; margin-bottom: 1px; }
.b-fwd { font-size: 13px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.row.out .b-fwd, .row.out .b-name { color: inherit; opacity: .85; }
.b-reply {
  display: flex; gap: 7px; margin: 2px 0 4px; padding: 3px 8px 3px 0;
  background: var(--reply-bg); border-radius: 6px; cursor: pointer; overflow: hidden;
}
.b-reply .pin-line { min-width: 2px; }
.b-reply-name { font-size: 13px; font-weight: 600; color: var(--accent); }
.row.out .b-reply-name { color: inherit; }
.b-reply-text { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.row.out .b-reply-text { color: inherit; opacity: .75; }
.b-text { white-space: pre-wrap; font-size: 15px; }
.b-text a { word-break: break-all; }
.b-img { max-width: 100%; max-height: 340px; border-radius: 8px; display: block; cursor: pointer; margin: 2px 0; }
.b-file { display: flex; align-items: center; gap: 10px; padding: 4px 2px; text-decoration: none; color: inherit; }
.b-file-icon {
  width: 44px; height: 44px; min-width: 44px; border-radius: 50%;
  background: var(--accent); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 18px;
}
.b-file-name { font-weight: 600; font-size: 14px; word-break: break-all; }
.b-file-size { font-size: 13px; color: var(--text2); }
.row.out .b-file-size { color: inherit; opacity: .7; }
.b-meta {
  float: right; margin: 6px -2px -4px 8px; font-size: 11.5px; color: var(--text2);
  display: flex; align-items: center; gap: 3px; user-select: none;
}
.row.out .b-meta { color: #4fae4e; }
body.dark .row.out .b-meta { color: rgba(255,255,255,.75); }
.b-meta .ticks { font-size: 13px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction {
  display: flex; align-items: center; gap: 4px; padding: 2px 8px 2px 5px;
  border-radius: 12px; background: var(--reaction-bg); font-size: 13px; cursor: pointer;
}
.reaction.mine { background: var(--reaction-mine); color: #fff; }
.reaction:hover { filter: brightness(1.08); }

.jump {
  position: absolute; right: 18px; bottom: 78px; width: 44px; height: 44px;
  border-radius: 50%; background: var(--bg); box-shadow: var(--shadow);
  font-size: 22px; color: var(--text2); z-index: 20;
}
.jump-badge {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  background: var(--badge); color: #fff; border-radius: 10px; min-width: 20px;
  height: 20px; font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

/* ===== Композер ===== */
.composer {
  display: flex; align-items: flex-end; gap: 4px; padding: 8px 12px;
  background: var(--bg); z-index: 8;
}
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none; background: transparent;
  max-height: 140px; padding: 9px 4px; font-size: 15px; line-height: 1.35;
}
.sendbtn {
  width: 44px; height: 44px; min-width: 44px; border-radius: 50%;
  background: var(--accent); color: #fff; display: flex; align-items: center;
  justify-content: center; transition: transform .1s;
}
.sendbtn:hover { background: var(--accent-hover); }
.sendbtn svg { width: 22px; height: 22px; fill: #fff; margin-left: 2px; }
.sendbtn.edit-mode svg { margin-left: 0; }
.joinbar { background: var(--bg); padding: 0; z-index: 8; }
.joinbar button, .joinbar .joininfo {
  display: block; width: 100%; padding: 14px; text-align: center;
  color: var(--accent); font-weight: 600; text-transform: uppercase; font-size: 14px;
}
.joinbar .joininfo { color: var(--text2); cursor: default; text-transform: none; font-weight: 400; }
.joinbar button:hover { background: var(--hover); }

/* ===== Эмодзи и стикеры ===== */
.emojipanel {
  position: fixed; z-index: 1000; width: 320px; height: 300px;
  background: var(--menu-bg); border-radius: 14px; box-shadow: var(--shadow);
  padding: 10px; display: flex; flex-direction: column;
}
.ep-tabs { display: flex; gap: 6px; padding-bottom: 8px; }
.ep-tab { flex: 1; padding: 7px; border-radius: 8px; font-size: 13px; color: var(--text2); background: var(--bg2); }
body.dark .ep-tab { background: #222; }
.ep-tab.sel { background: var(--accent); color: #fff; }
.ep-grid {
  flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; align-content: start;
}
.ep-grid button { font-size: 22px; padding: 4px; border-radius: 8px; }
.ep-grid button:hover { background: var(--hover); }
.ep-grid.ep-stickers { grid-template-columns: repeat(4, 1fr); }
.ep-stickers button img { width: 60px; height: 60px; display: block; }

/* ===== Модальные окна ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 900;
  display: flex; align-items: center; justify-content: center; animation: fade .12s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 420px; max-width: 94vw; max-height: 86vh; overflow-y: auto;
  background: var(--menu-bg); border-radius: 14px; box-shadow: var(--shadow);
  animation: pop .12s ease-out;
}
.modal header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; font-weight: 600; font-size: 17px;
  position: sticky; top: 0; background: var(--menu-bg); z-index: 2;
}
.modal header .x { font-size: 22px; color: var(--text2); width: 32px; height: 32px; border-radius: 50%; }
.modal header .x:hover { background: var(--hover); }
.mbody { padding: 0 18px 18px; }
.mbody input[type=text], .mbody textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; outline: none; background: var(--bg); margin-bottom: 12px;
}
.mbody input:focus, .mbody textarea:focus { border-color: var(--accent); }
.mbody textarea { resize: vertical; min-height: 64px; }
.mbody .btn-primary { border-radius: 10px; }
.mlabel { font-size: 13px; color: var(--text2); margin: 4px 2px 6px; }
.profile-head { display: flex; align-items: center; gap: 14px; padding: 6px 0 16px; }
.profile-head .pname { font-weight: 600; font-size: 17px; }
.profile-head .pstatus { color: var(--text2); font-size: 13px; }
.profile-head .pstatus.online { color: var(--accent); }
.color-row { display: flex; gap: 10px; margin: 4px 0 16px; }
.color-dot { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.color-dot.sel { border-color: var(--accent); }
.info-row { display: flex; gap: 14px; padding: 10px 0; align-items: center; }
.info-row .ir-icon { width: 24px; text-align: center; color: var(--text2); font-size: 17px; }
.info-row .ir-main { flex: 1; min-width: 0; }
.info-row .ir-val { font-size: 15px; word-break: break-word; }
.info-row .ir-cap { font-size: 13px; color: var(--text2); }
.member-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; border-radius: 10px; }
.member-row:hover { background: var(--hover); }
.member-row .mr-name { font-weight: 600; font-size: 14px; }
.member-row .mr-status { font-size: 13px; color: var(--text2); }
.member-row .mr-role { margin-left: auto; font-size: 12px; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  display: flex; align-items: center; gap: 6px; background: var(--reply-bg);
  border-radius: 14px; padding: 4px 10px; font-size: 13px;
}
.chip button { color: var(--text2); font-size: 15px; }
.mrow-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 6px;
  border-radius: 10px; font-size: 14px; text-align: left;
}
.mrow-btn:hover { background: var(--hover); }
.mrow-btn.danger { color: #e53935; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 6px; }

/* ===== Просмотр фото ===== */
.viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 1100;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.viewer img { max-width: 94vw; max-height: 94vh; border-radius: 4px; }

/* ===== Тост ===== */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 18px;
  border-radius: 10px; z-index: 1200; font-size: 14px; max-width: 80vw;
}

/* ===== Результаты поиска ===== */
.sr-empty { text-align: center; color: var(--text2); padding: 30px 10px; font-size: 14px; }

/* ===== Стикеры в сообщениях ===== */
.bubble.sticker-bubble { background: transparent !important; box-shadow: none; padding: 0; }
.b-sticker { width: 160px; height: 160px; display: block; }
.bubble.sticker-bubble .b-meta {
  float: none; display: flex; justify-content: flex-end; background: var(--service-bg);
  color: #fff !important; border-radius: 10px; padding: 2px 8px; width: fit-content;
  margin: 2px 0 0 auto;
}
.bubble.sticker-bubble .b-meta .ticks { color: #fff; }

/* ===== Голосовые сообщения ===== */
.b-voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 3px 0; }
.v-play {
  width: 42px; height: 42px; min-width: 42px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 15px;
}
.row.out .v-play { background: #4fae4e; }
body.dark .row.out .v-play { background: rgba(255,255,255,.25); }
.v-track { flex: 1; height: 4px; background: rgba(128,128,128,.35); border-radius: 2px; overflow: hidden; }
.v-prog { width: 0; height: 100%; background: var(--accent); }
.row.out .v-prog { background: #4fae4e; }
body.dark .row.out .v-prog { background: #fff; }
.v-time { font-size: 12.5px; color: var(--text2); }
.row.out .v-time { color: inherit; opacity: .75; }

/* ===== Запись голосового ===== */
.recbar { flex: 1; display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #e53935; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .15; } }
#rec-time { font-size: 15px; min-width: 44px; }
#rec-cancel { color: var(--text2); font-size: 14px; padding: 6px 12px; border-radius: 8px; }
#rec-cancel:hover { background: var(--hover); color: #e53935; }
body.recording #input, body.recording #attach, body.recording #emoji-btn, body.recording #mic { display: none; }

/* ===== Секретные чаты ===== */
.lock { color: #4fae4e; font-style: normal; }
.ch-icon.lock { color: #4fae4e; }

/* ===== Звонки ===== */
.callui {
  position: fixed; inset: 0; z-index: 1300; background: #18222d;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
#call-remote {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  background: #000; display: none;
}
.callui.video.connected #call-remote { display: block; }
.call-info { position: relative; z-index: 2; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.callui.video.connected .call-info { position: absolute; top: 26px; left: 0; right: 0; }
.callui.video.connected .call-info .avatar { display: none; }
.call-name { font-size: 22px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.call-status { font-size: 15px; opacity: .85; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.call-emojis { font-size: 24px; letter-spacing: 6px; margin-top: 6px; cursor: help; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
#call-local {
  position: absolute; right: 16px; bottom: 116px; width: 180px; max-height: 140px;
  border-radius: 10px; z-index: 3; background: #000; display: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.callui.video #call-local { display: block; }
.call-actions {
  position: absolute; bottom: 30px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 18px; z-index: 4;
}
.call-btn {
  width: 58px; height: 58px; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}
.call-btn:hover { background: rgba(255,255,255,.32); }
.call-btn.end { background: #e53935; }
.call-btn.end:hover { background: #c62828; }
.call-btn.ok { background: #43a047; }
.call-btn.ok:hover { background: #388e3c; }
.call-btn.off { background: #fff; color: #18222d; }
.incoming {
  position: fixed; inset: 0; z-index: 1290; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
}
.inc-card {
  background: var(--menu-bg); color: var(--text); border-radius: 18px;
  padding: 30px 46px; text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 8px; box-shadow: var(--shadow); animation: pop .15s ease-out;
}
.inc-card .call-name, .inc-card .call-status { text-shadow: none; }
.inc-card .call-status { color: var(--text2); }
.inc-actions { display: flex; gap: 24px; margin-top: 14px; }

/* ===== Истории ===== */
.stories {
  display: flex; gap: 10px; padding: 6px 14px 10px; overflow-x: auto;
  border-bottom: 1px solid var(--border); min-height: 88px;
}
.story-item { text-align: center; cursor: pointer; min-width: 62px; }
.story-circle {
  width: 60px; height: 60px; margin: 0 auto; border-radius: 50%;
  border: 2px solid var(--border); display: flex; align-items: center;
  justify-content: center; padding: 2px;
}
.story-item.unviewed .story-circle { border-color: var(--accent); }
.story-circle.plus { font-size: 26px; color: var(--accent); border: 2px dashed var(--accent); }
.story-circle .avatar { width: 50px; height: 50px; min-width: 50px; font-size: 17px; }
.story-name {
  font-size: 11.5px; color: var(--text2); margin-top: 3px; max-width: 62px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.storyview {
  position: fixed; inset: 0; z-index: 1250; background: #000;
  display: flex; align-items: center; justify-content: center;
}
#sv-img { max-width: 100vw; max-height: 100vh; user-select: none; }
.sv-progress { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; z-index: 4; }
.sv-seg { flex: 1; height: 3px; background: rgba(255,255,255,.3); border-radius: 2px; overflow: hidden; }
.sv-seg .sv-fill { width: 0; height: 100%; background: #fff; }
.sv-seg.done .sv-fill { width: 100%; }
.sv-seg.cur .sv-fill { animation: svfill 5s linear forwards; }
@keyframes svfill { to { width: 100%; } }
.sv-head { position: absolute; top: 22px; left: 14px; right: 10px; display: flex; align-items: center; gap: 10px; color: #fff; z-index: 4; }
.sv-name { font-weight: 600; font-size: 14px; }
.sv-time { font-size: 12px; opacity: .75; }
.sv-head > div:nth-child(2) { flex: 1; }
.sv-head #sv-del { color: #fff; }
.sv-head #sv-close { color: #fff; font-size: 26px; }
.sv-caption {
  position: absolute; bottom: 48px; left: 0; right: 0; text-align: center;
  color: #fff; padding: 0 30px; z-index: 3; text-shadow: 0 1px 4px #000; font-size: 15px;
}
.sv-views { position: absolute; bottom: 16px; left: 18px; color: #fff; z-index: 4; font-size: 14px; }
.sv-nav { position: absolute; inset: 0; display: flex; z-index: 2; }
#sv-prev { width: 35%; cursor: w-resize; }
#sv-next { flex: 1; cursor: e-resize; }

/* ===== Мобильная вёрстка ===== */
@media (max-width: 900px) {
  .left { width: 100%; max-width: none; border-right: 0; }
  .center { position: fixed; inset: 0; z-index: 30; transform: translateX(100%); transition: transform .2s; background: var(--chat-bg); }
  body.chat-open .center { transform: translateX(0); }
  .back { display: flex; }
  .bubble { max-width: 84%; }
  #call-local { width: 110px; bottom: 130px; }
}

/* ===== v2.1 ===== */
.avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.b-video { max-width: 100%; max-height: 340px; border-radius: 8px; display: block; margin: 2px 0; background: #000; }
.md-code { background: rgba(128,128,128,.18); padding: 1px 5px; border-radius: 5px; font-family: Consolas, Menlo, monospace; font-size: 13.5px; }
.md-pre { background: rgba(128,128,128,.15); padding: 8px 10px; border-radius: 8px; font-family: Consolas, Menlo, monospace; font-size: 13px; overflow-x: auto; margin: 3px 0; white-space: pre-wrap; }
.spoiler { background: var(--text2); color: transparent; border-radius: 4px; cursor: pointer; user-select: none; text-shadow: none; }
.spoiler:not(.revealed) a, .spoiler:not(.revealed) code { visibility: hidden; }
.spoiler.revealed { background: rgba(128,128,128,.22); color: inherit; }
.mute-icon { font-size: 12px; opacity: .55; margin-left: 3px; }
.badge.muted { background: #9aa3ab; }
.pin-mini { font-size: 11px; color: var(--text2); margin-right: 2px; }
.draft { color: #e53935; }
.archive-row .avatar { font-size: 24px; }
.ava-edit { position: relative; cursor: pointer; }
.ava-cam {
  position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px;
  background: var(--accent); border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 13px; border: 2px solid var(--menu-bg);
}
.ava-edit:hover .ava-cam { background: var(--accent-hover); }

/* ===== v2.2 ===== */
.b-poll { min-width: 240px; max-width: 340px; padding: 2px 0; }
.poll-q { font-weight: 600; font-size: 15px; }
.poll-type { font-size: 12.5px; color: var(--text2); margin: 1px 0 8px; }
.row.out .poll-type { color: inherit; opacity: .7; }
.poll-opt { display: flex; gap: 9px; padding: 5px 0; cursor: pointer; align-items: flex-start; }
.poll-check {
  width: 20px; height: 20px; min-width: 20px; border-radius: 50%;
  border: 2px solid var(--text2); display: flex; align-items: center;
  justify-content: center; font-size: 12px; color: #fff; margin-top: 1px;
}
.poll-opt.my .poll-check { background: var(--accent); border-color: var(--accent); }
.poll-opt.voted:not(.my) .poll-check { opacity: .35; }
.poll-body { flex: 1; min-width: 0; }
.poll-text { font-size: 14.5px; }
.poll-bar { height: 4px; background: rgba(128,128,128,.25); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.poll-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .25s; }
.row.out .poll-fill { background: #4fae4e; }
body.dark .row.out .poll-fill { background: #fff; }
.poll-pct { font-size: 13px; font-weight: 600; min-width: 38px; text-align: right; }
.poll-voters { font-size: 12.5px; color: var(--text2); margin-top: 6px; text-align: center; }
.row.out .poll-voters { color: inherit; opacity: .75; }
.poll-retract { color: var(--accent); cursor: pointer; }
.row.out .poll-retract { color: inherit; text-decoration: underline; }

.selbar {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  background: var(--bg); border-bottom: 1px solid var(--border); z-index: 9;
}
.sel-count { flex: 1; font-weight: 600; font-size: 14px; }
.selbtn { padding: 8px 14px; border-radius: 9px; color: var(--accent); font-weight: 600; font-size: 14px; }
.selbtn:hover { background: var(--hover); }
.selbtn.danger { color: #e53935; }
.row.selected { background: var(--reply-bg); border-radius: 10px; }
.row.selected .bubble { outline: 2px solid var(--accent); }

.mention { color: var(--accent); cursor: pointer; }
.row.out .mention { color: inherit; font-weight: 600; text-decoration: underline; }
.composer { position: relative; }
.mentionbox {
  position: absolute; bottom: 100%; left: 8px; right: 8px; max-height: 230px;
  overflow-y: auto; background: var(--menu-bg); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 40; margin-bottom: 4px;
}
.mentionbox .member-row { padding: 6px 8px; }

.v-speed {
  font-size: 11.5px; color: var(--text2); border: 1px solid var(--border);
  border-radius: 9px; padding: 2px 7px; min-width: 36px;
}
.row.out .v-speed { color: inherit; border-color: rgba(0,0,0,.18); }
body.dark .row.out .v-speed { border-color: rgba(255,255,255,.35); }

.switch-row { cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.swatch-row { display: flex; gap: 12px; margin: 6px 0 14px; }
.swatch { width: 38px; height: 38px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.swatch.sel { border-color: var(--text); }
.bg-row { display: flex; gap: 10px; margin: 6px 0 14px; }
.bg-sw { flex: 1; height: 56px; border-radius: 10px; cursor: pointer; border: 3px solid transparent; }
.bg-sw.sel { border-color: var(--accent); }

/* ===== v2.3 ===== */
.tabs {
  display: flex; gap: 2px; padding: 0 10px 6px; overflow-x: auto;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 7px 10px; border-radius: 9px 9px 0 0; font-size: 13.5px;
  color: var(--text2); white-space: nowrap; display: flex; align-items: center; gap: 5px;
  border-bottom: 2px solid transparent;
}
.tab:hover { background: var(--hover); }
.tab.sel { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab.dragging { opacity: .4; }
.tab.drag-over { background: var(--hover); box-shadow: inset 2px 0 0 var(--accent); }
.tab-badge {
  background: var(--badge); color: #fff; border-radius: 9px; min-width: 18px;
  height: 18px; font-size: 11px; display: inline-flex; align-items: center;
  justify-content: center; padding: 0 5px; font-weight: 600;
}

.b-round { width: 220px; height: 220px; border-radius: 50%; object-fit: cover; display: block; cursor: pointer; background: #000; }
.roundrec {
  position: fixed; inset: 0; z-index: 1310; background: rgba(10, 18, 26, .92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: #fff;
}
#roundpreview { width: 300px; height: 300px; border-radius: 50%; object-fit: cover; background: #000; box-shadow: 0 0 0 4px var(--accent); }

.b-loc { display: flex; align-items: center; gap: 10px; padding: 4px 2px; text-decoration: none; color: inherit; }
.loc-pin {
  width: 44px; height: 44px; min-width: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #54cb68, #2e9e44); display: flex;
  align-items: center; justify-content: center; font-size: 20px;
}

.sched-prev {
  background: var(--reply-bg); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; margin-bottom: 12px; word-break: break-word;
}
.mbody input[type=datetime-local] {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; outline: none; background: var(--bg); margin-bottom: 12px;
  color: var(--text);
}
.mbody input[type=datetime-local]:focus { border-color: var(--accent); }
.info-row .sc-del, .member-row .ct-del { margin-left: auto; width: 34px; height: 34px; min-width: 34px; font-size: 15px; }

/* ===== v2.4 ===== */
.b-bigemoji { font-size: 46px; line-height: 1.15; padding: 2px 0; }
.b-preview {
  display: flex; gap: 8px; margin-top: 5px; padding: 4px 8px 6px 0;
  background: var(--reply-bg); border-radius: 8px; text-decoration: none;
  color: inherit; overflow: hidden; max-width: 360px;
}
.bp-body { min-width: 0; flex: 1; }
.bp-site { color: var(--accent); font-size: 13px; font-weight: 600; }
.row.out .bp-site { color: inherit; }
.bp-title { font-weight: 600; font-size: 14px; margin-top: 1px; }
.bp-desc { font-size: 13px; color: var(--text2); margin-top: 1px; max-height: 54px; overflow: hidden; }
.row.out .bp-desc { color: inherit; opacity: .75; }
.bp-img { max-width: 100%; max-height: 160px; border-radius: 6px; margin-top: 6px; display: block; object-fit: cover; }
.ep-add {
  font-size: 26px; color: var(--accent); border: 2px dashed var(--accent);
  border-radius: 12px; min-height: 60px;
}
.ep-add:hover { background: var(--reply-bg); }

/* ===== v2.5 ===== */
.gcbar {
  display: flex; align-items: center; gap: 10px; padding: 7px 14px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  color: #fff; z-index: 8;
}
.gc-ico { font-size: 18px; }
.gc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.gc-info b { font-size: 13.5px; }
.gc-info span { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gc-btn {
  background: rgba(255,255,255,.22); color: #fff; padding: 7px 12px;
  border-radius: 9px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.gc-btn:hover { background: rgba(255,255,255,.34); }
.gc-btn.danger { background: rgba(0,0,0,.25); }

/* Видео в голосовом чате */
.gc-videos {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 10px;
  background: rgba(0,0,0,.55); z-index: 7;
}
.gc-tile {
  position: relative; width: 160px; max-width: 31%; aspect-ratio: 4/3;
  border-radius: 8px; overflow: hidden; background: #1c2733; flex: 0 1 auto;
}
.gc-tile.off { display: none; }
.gc-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gc-tile.me video { transform: scaleX(-1); }
.gc-tile-name {
  position: absolute; left: 6px; bottom: 4px; font-size: 11px; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.8); max-width: 90%; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
}

.unread-div { text-align: center; margin: 10px 0; }
.unread-div span {
  display: block; background: var(--service-bg); color: #fff;
  padding: 4px 12px; border-radius: 0; font-size: 13px; width: 100%;
  border-radius: 8px;
}

#sv-video { max-width: 100vw; max-height: 100vh; }
.sv-views { cursor: pointer; }
.sv-views:hover { text-decoration: underline; }

/* ===== v2.6 ===== */
.react-more {
  font-size: 17px; color: var(--text2); border: 1px dashed var(--text2);
  border-radius: 50%; width: 30px; height: 30px; margin-left: 2px;
}
.react-more:hover { color: var(--accent); border-color: var(--accent); }
.react-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  width: 300px; max-height: 240px; overflow-y: auto; padding: 4px;
}
.react-grid button { font-size: 21px; padding: 4px; border-radius: 8px; }
.react-grid button:hover { background: var(--hover); }

body[data-bubble="violet"] .row.out .bubble:not(.sticker-bubble) { background: linear-gradient(135deg, #8774e1, #6f5bd0); color: #fff; }
body[data-bubble="sunset"] .row.out .bubble:not(.sticker-bubble) { background: linear-gradient(135deg, #ff9d6e, #e8568c); color: #fff; }
body[data-bubble="ocean"] .row.out .bubble:not(.sticker-bubble) { background: linear-gradient(135deg, #4fc3f7, #2a9ef1); color: #fff; }
body[data-bubble="violet"] .row.out .b-meta, body[data-bubble="sunset"] .row.out .b-meta, body[data-bubble="ocean"] .row.out .b-meta { color: rgba(255,255,255,.85); }
body[data-bubble="violet"] .row.out .poll-fill, body[data-bubble="sunset"] .row.out .poll-fill, body[data-bubble="ocean"] .row.out .poll-fill { background: #fff; }
body[data-bubble="violet"] .row.out .v-play, body[data-bubble="sunset"] .row.out .v-play, body[data-bubble="ocean"] .row.out .v-play { background: rgba(255,255,255,.3); }
.bub-sw { border-radius: 14px 14px 4px 14px; }

/* ===== v2.7 ===== */
.mono { font-family: Consolas, Menlo, monospace; font-size: 12px; word-break: break-all; }
.media-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.media-grid img, .media-vid {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.media-vid { background: #18222d; color: #fff; font-size: 22px; text-decoration: none; }
.media-grid img:hover, .media-vid:hover { opacity: .85; }
.ep-sec { grid-column: 1 / -1; font-size: 12px; color: var(--text2); padding: 5px 4px 2px; font-weight: 600; }

/* ===== v2.8 ===== */
.dropzone {
  position: absolute; inset: 8px; z-index: 60;
  background: rgba(51,144,236,.16); border: 3px dashed var(--accent);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.dropzone span { background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 600; }
.info-row .ses-kill { margin-left: auto; width: 34px; height: 34px; min-width: 34px; font-size: 15px; }

/* ===== v2.9 ===== */
.theme-opt {
  flex: 1; padding: 9px; border-radius: 9px; background: var(--bg2);
  color: var(--text2); font-size: 13.5px; border: 2px solid transparent;
}
body.dark .theme-opt { background: #222; }
.theme-opt.sel { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.badge.dot { font-size: 7px; min-width: 14px; height: 14px; padding: 0; }
#pin-title-txt { cursor: pointer; }

/* ===== v3.0 ===== */
.cmd-slash {
  width: 34px; height: 34px; min-width: 34px; border-radius: 50%;
  background: var(--accent); color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 16px;
}

/* Стикер-паки */
.ep-grid button.sel { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 10px; }
.ep-pkdel { float: right; background: none; border: 0; color: var(--text2); cursor: pointer; font-size: 12px; padding: 0 2px; }
.ep-pkdel:hover { color: #e05252; }

/* Фильтры глобального поиска (3.8.0) */
.search-filters { display: flex; gap: 6px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--bg); }
.search-filters input { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 7px; font-size: 12.5px; min-width: 0; }
#sf-from { flex: 1.3; width: 0; }
#sf-date1, #sf-date2 { flex: 1; width: 0; color-scheme: light; }
body.dark #sf-date1, body.dark #sf-date2 { color-scheme: dark; }
.sf-media { display: flex; align-items: center; gap: 2px; cursor: pointer; user-select: none; font-size: 14px; }
.sf-media input { accent-color: var(--accent); margin: 0; }
