:root {
  --bg: #0d1117;
  --bg2: #151b23;
  --bg3: #1d2530;
  --line: #26303c;
  --text: #e6edf3;
  --muted: #8b98a5;
  --acc: #4c8dff;
  --acc2: #2f6fe4;
  --ok: #35c07a;
  --out: #245b9e;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  overscroll-behavior: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.strong { font-weight: 600; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* ---------- РІС…РѕРґ ---------- */
.auth {
  min-height: 100%; display: grid; place-items: center;
  padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, #1b2a44, var(--bg));
}
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.logo-img {
  width: 88px; height: 88px; margin: 0 auto 14px; display: block;
  border-radius: 22px; box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.auth-card h1 { margin: 0 0 6px; font-size: 26px; }
.auth-card > .muted { margin: 0 0 22px; }

.tabs { display: flex; gap: 8px; background: var(--bg2); padding: 5px; border-radius: 12px; margin-bottom: 18px; }
.tab { flex: 1; padding: 9px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--bg3); color: var(--text); }

.form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form input {
  padding: 13px 14px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 16px; outline: none;
}
.form input:focus { border-color: var(--acc); }

/* ---------- платформы на экране входа ---------- */
.platform-links { display: none; gap: 24px; justify-content: center; margin-top: 26px; }
.platform-btn {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  color: var(--muted); font-size: 12px; text-decoration: none;
}
.platform-ic {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  transition: border-color .15s, color .15s;
}
.platform-btn:hover .platform-ic, .platform-btn:active .platform-ic {
  border-color: var(--acc); color: var(--acc);
}
.platform-ic svg { width: 25px; height: 25px; }
.android-download {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg2); border: 1px solid var(--line);
}
.android-download a { color: var(--acc); font-weight: 600; text-decoration: none; }
.android-download .tiny { margin-top: 4px; }
@media (max-width: 760px) {
  .platform-links { display: flex; }
}

.primary {
  padding: 13px 16px; border-radius: 11px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, var(--acc), var(--acc2));
}
.primary:active { transform: translateY(1px); }
.primary.small { padding: 9px 12px; font-size: 13px; width: 100%; }
.ghost { padding: 11px; border-radius: 11px; background: var(--bg3); width: 100%; margin-top: 12px; }

.error { margin-top: 14px; padding: 11px 13px; border-radius: 10px; background: #3a1d22; color: #ff9aa6; font-size: 13px; text-align: left; }

/* ---------- РїСЂРёР»РѕР¶РµРЅРёРµ ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }

.sidebar { width: 320px; flex: 0 0 320px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--bg2); }
.side-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 14px calc(14px + env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}
.me { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; border-radius: 12px; }
.me:active { opacity: .75; }
.me > div { min-width: 0; }
#myName, #myPhone { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: flex; gap: 4px; }
.icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; color: var(--muted); }
.icon:active { background: var(--bg3); }

.avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  background: linear-gradient(160deg, #3d6fd4, #6a4bd8);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  position: relative; overflow: hidden;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 76px; height: 76px; flex-basis: 76px; font-size: 24px; }

.chat-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chat-item { display: flex; gap: 11px; align-items: center; padding: 12px 14px; border-bottom: 1px solid rgba(38,48,60,.6); }
.chat-item:active { background: var(--bg3); }
.chat-item.active { background: var(--bg3); }
.chat-body { flex: 1; min-width: 0; }
.chat-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.chat-prev { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--acc); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }

.push-hint { padding: 12px 14px; border-top: 1px solid var(--line); }
.push-hint p { margin: 8px 0 0; }

/* ---------- С‡Р°С‚ ---------- */
.chat-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 12px calc(14px + env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: var(--bg2);
}
.back { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 8px; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; width: 100%; }
.msg-row.out { justify-content: flex-end; }
.msg-row.out .msg { background: var(--out); }
.msg-row .msg { max-width: 76%; align-self: flex-end; }
.msg-avatar { width: 30px; height: 30px; flex: 0 0 30px; font-size: 11px; }
.msg { padding: 9px 12px; border-radius: 14px; background: var(--bg3); align-self: flex-start; word-wrap: break-word; white-space: pre-wrap; }
.msg .who { font-size: 11px; color: var(--acc); margin-bottom: 3px; font-weight: 600; }
.msg .time { font-size: 10px; color: var(--muted); text-align: right; margin-top: 3px; }
.msg.out { align-self: flex-end; background: var(--out); }
.msg.out .who { display: none; }
.msg.pending { opacity: .6; }
.day-sep { align-self: center; font-size: 11px; color: var(--muted); background: var(--bg2); padding: 3px 10px; border-radius: 10px; }

.tick { margin-left: 5px; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: -1px; }
.tick.delivered { color: var(--acc); }
.tick.read { color: var(--muted); }

.composer { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg2); }
.composer input { flex: 1; padding: 12px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--bg3); color: var(--text); font-size: 16px; outline: none; }
.composer input:focus { border-color: var(--acc); }
.send { width: 46px; height: 44px; border-radius: 50%; padding: 0; display: grid; place-items: center; font-size: 16px; }

/* ---------- РјРѕРґР°Р»РєР° ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { width: 100%; max-width: 380px; background: var(--bg2); border-radius: 16px; padding: 18px; border: 1px solid var(--line); }
.modal-card h2 { margin: 0 0 12px; font-size: 18px; }
.user-list { max-height: 50vh; overflow-y: auto; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid rgba(38,48,60,.6); }
.user-row:active { background: var(--bg3); }

.profile-card { max-width: 420px; max-height: calc(100dvh - 40px); overflow-y: auto; }
.profile-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.profile-avatar {
  width: 76px; height: 76px; flex: 0 0 76px; border-radius: 50%;
  background: linear-gradient(160deg, #3d6fd4, #6a4bd8);
  display: grid; place-items: center; font-weight: 700; font-size: 24px;
  position: relative; overflow: hidden;
}
.profile-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.profile-title { min-width: 0; }
.profile-title .strong { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-info { display: flex; flex-direction: column; margin-bottom: 14px; }
.profile-info .row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(38,48,60,.6); font-size: 14px; }
.profile-info .row .k { color: var(--muted); flex: 0 0 auto; }
.profile-info .row .v { text-align: right; overflow: hidden; text-overflow: ellipsis; }
.profile-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.profile-field input {
  padding: 12px 14px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--bg3); color: var(--text); font-size: 16px; outline: none;
}
.profile-field input:focus { border-color: var(--acc); }
#btnProfileSave { margin-bottom: 4px; }
.profile-photo-actions { display: flex; gap: 8px; }
.profile-photo-actions .ghost { margin-top: 10px; }

/* ---------- о приложении ---------- */
.about-card { text-align: center; max-width: 340px; }
.about-icon {
  width: 76px; height: 76px; border-radius: 20px; margin: 0 auto 12px;
  display: block; box-shadow: 0 10px 26px rgba(0,0,0,.4);
}
.about-card h2 { margin: 0 0 4px; }
.about-info { margin: 18px 0 14px; text-align: left; }
.about-info .row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid rgba(38,48,60,.6); font-size: 14px;
}
.about-info .k { color: var(--muted); }
.about-info .v { text-align: right; overflow: hidden; text-overflow: ellipsis; }

.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: #232c38; color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.4); }

/* ---------- РјРµРґРёР° ---------- */
.attach, .mic {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px; color: var(--muted);
}
.attach:active, .mic:active { background: var(--bg3); }
.mic.active { background: #3a1d22; color: #ff7a86; }
.composer input { min-width: 0; }

.msg.media-only { padding: 6px; }
.media-img, .media-video {
  display: block; max-width: 280px; max-height: 340px;
  border-radius: 10px; background: #0b0f14; object-fit: cover;
}
.media-img { cursor: zoom-in; }
.voice { display: flex; align-items: center; gap: 8px; }
.voice audio { width: 220px; height: 36px; }
.voice-dur { font-size: 11px; color: var(--muted); }
.media-caption { margin-top: 6px; font-size: 14px; white-space: pre-wrap; }

.record-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: #2a1d22; border-top: 1px solid var(--line);
}
.record-bar .ghost.small { width: auto; margin: 0; padding: 6px 10px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff5c6c; animation: rec 1s infinite; }
@keyframes rec { 50% { opacity: .2; } }

.viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,.94);
  display: grid; place-items: center; z-index: 300; padding: 16px; cursor: zoom-out;
}
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- РјРѕР±РёР»СЊРЅС‹Р№ ---------- */
@media (max-width: 760px) {
  .sidebar { width: 100%; flex: 1 1 auto; border-right: 0; }
  .chat-panel { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .chat-panel { display: flex; }
  .back { display: grid; }
  .msg { max-width: 84%; }
  .attach, .mic { width: 36px; flex-basis: 36px; font-size: 16px; }
  .media-img, .media-video { max-width: 240px; }
}

/* ---------- ???: ?????, ??????, ????????? ---------- */

.chat-head-text { flex: 1; min-width: 0; }
.chat-head-text .strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-avatar { width: 36px; height: 36px; flex: 0 0 36px; font-size: 14px; }
.chat-head .icon:last-child { margin-left: auto; }

.group-top { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.group-avatar { width: 64px; height: 64px; flex: 0 0 64px; font-size: 22px; }
.group-user-list { max-height: 32vh; }

.user-row.selectable { cursor: pointer; }
.user-row.selected { background: var(--bg3); }
.user-row .check {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 24px;
  border: 1px solid var(--line); display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 700;
}
.user-row.selected .check { background: var(--acc); border-color: var(--acc); }

.settings-card { max-width: 420px; max-height: calc(100dvh - 40px); overflow-y: auto; }
.settings-photo-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.settings-block { margin: 14px 0; padding-top: 12px; border-top: 1px solid var(--line); }
.settings-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.settings-card .user-list { max-height: 30vh; margin-bottom: 8px; }
.compact-row { padding: 7px 2px; }
.compact-row .avatar { width: 34px; height: 34px; flex-basis: 34px; font-size: 12px; }
.settings-card .ghost.small { margin: 4px 6px 0 0; }

.segmented { display: flex; gap: 6px; background: var(--bg3); padding: 4px; border-radius: 11px; }
.segmented button {
  flex: 1; padding: 9px 6px; border-radius: 8px; color: var(--muted);
  font-size: 12px; font-weight: 600;
}
.segmented button.active { background: var(--bg2); color: var(--text); }

.invite-box { display: flex; gap: 8px; margin-top: 10px; }
.invite-box input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg3); color: var(--text); font-size: 13px;
}
.invite-box .ghost { flex: 0 0 auto; margin: 0; }


.video-tile {
  position: relative; width: 240px; max-width: 100%; aspect-ratio: 16 / 10;
  border-radius: 10px; overflow: hidden; background: #1b2530;
  display: grid; place-items: center; cursor: pointer;
}
.video-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-play {
  position: relative; z-index: 1; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center;
  font-size: 18px; padding-left: 3px;
}
.video-dur {
  position: absolute; right: 8px; bottom: 6px; z-index: 1;
  font-size: 11px; color: #fff; background: rgba(0,0,0,.55);
  padding: 2px 7px; border-radius: 8px;
}
.viewer video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.viewer img.hidden, .viewer video.hidden { display: none; }
.ghost.danger { color: #ff7b86; }

/* ---------- ??????, ???????????, ???? ????????? ---------- */

.pinned-bar {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
.pinned-body { flex: 1; min-width: 0; cursor: pointer; border-left: 3px solid var(--acc); padding-left: 10px; }
.pinned-label { font-size: 10px; color: var(--acc); font-weight: 700; }
.pinned-text { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.reply-bar {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px;
  background: var(--bg2); border-top: 1px solid var(--line);
}
.reply-bar-body { flex: 1; min-width: 0; border-left: 3px solid var(--acc); padding-left: 10px; }
.reply-bar-label { font-size: 10px; color: var(--acc); font-weight: 700; }
.reply-bar-text { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.reply-quote {
  border-left: 3px solid var(--acc); padding: 4px 8px; margin-bottom: 6px;
  background: rgba(255,255,255,.04); border-radius: 6px; cursor: pointer;
}
.rq-name { font-size: 11px; color: var(--acc); font-weight: 700; }
.rq-text { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fwd-title { font-size: 11px; color: var(--acc); font-weight: 700; margin-bottom: 4px; }
.fwd-date { color: var(--muted); font-weight: 400; }
.deleted-text { color: var(--muted); font-style: italic; font-size: 13px; }
.msg.deleted { background: var(--bg3); }

.menu-card { max-width: 360px; }
.menu-list { display: flex; flex-direction: column; margin-bottom: 10px; }
.menu-item {
  text-align: left; padding: 12px 10px; border-bottom: 1px solid rgba(38,48,60,.6);
  color: var(--text); font-size: 14px; background: transparent;
}
.menu-item:active { background: var(--bg3); }
.menu-item.danger { color: #ff7b86; }

.flash { animation: flash 1.2s ease; }
@keyframes flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76,141,255,0); }
  30% { box-shadow: 0 0 0 3px rgba(76,141,255,.55); }
}

/* ---------- ??????? ---------- */

.reaction-bar {
  display: flex; justify-content: space-between; gap: 4px;
  padding: 0 0 12px; margin-bottom: 6px; border-bottom: 1px solid var(--line);
}
.reaction-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  font-size: 21px; background: var(--bg3); color: var(--text);
}
.reaction-btn.active { background: rgba(76,141,255,.22); box-shadow: inset 0 0 0 2px var(--acc); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction-chip {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px;
  border-radius: 12px; background: rgba(255,255,255,.08); font-size: 13px; color: var(--text);
}
.reaction-chip.active { background: rgba(76,141,255,.28); }
.reaction-chip .rc-count { font-size: 11px; color: var(--muted); }

/* ??????? ??? ?????????? */
.msg-stack {
  display: flex; flex-direction: column; align-items: flex-start;
  max-width: 76%; min-width: 0;
}
.msg-row.out .msg-stack { align-items: flex-end; }
.msg-stack .msg { max-width: 100%; align-self: auto; }
.msg-stack .reactions { margin-top: 4px; }
@media (max-width: 760px) {
  .msg-stack { max-width: 84%; }
}

/* ??????????? ???? ????????? */
.context-layer { position: fixed; inset: 0; z-index: 80; background: transparent; }
.msg-menu-card {
  position: absolute; width: 300px; max-width: calc(100vw - 16px);
  background: #1b2530; border: 1px solid #2b3947; border-radius: 18px;
  padding: 6px; box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.msg-menu-card .reaction-bar { justify-content: space-between; gap: 2px; padding: 4px 2px 8px; }
.msg-menu-card .reaction-btn { width: 40px; height: 40px; font-size: 20px; }
.msg-menu-card .menu-list { display: flex; flex-direction: column; margin: 0; }
.msg-menu-card .menu-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 10px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text);
  font-size: 15px; text-align: left;
}
.msg-menu-card .menu-item:active { background: var(--bg3); }
.menu-icon { width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; color: var(--muted); }
.menu-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.msg-menu-card .menu-item.danger .menu-icon { color: #ff7b86; }

/* ????????? ???????? ?????? ??????? ??? ???? */
.reaction-pill {
  position: absolute; display: flex; align-items: center; justify-content: space-between;
  gap: 2px; padding: 4px 6px; background: #1b2530; border: 1px solid #2b3947;
  border-radius: 24px; box-shadow: 0 14px 34px rgba(0,0,0,.5);
}
.reaction-pill .reaction-btn {
  width: 38px; height: 38px; font-size: 20px; background: transparent;
}
.reaction-pill .reaction-btn.active { background: rgba(76,141,255,.22); box-shadow: none; }

/* ?????????? ? ???????? ???? ??? ???????? ???? */
.msg-backdrop {
  position: fixed; z-index: 70;
  background: rgba(0,0,0,.34);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.msg-row.menu-focus { position: relative; z-index: 75; }
.msg-row.out .reactions { align-self: flex-end; }
.msg-row:not(.out) .reactions { align-self: flex-start; }

/* ---------- ??????? ????? ? ????? Telegram ---------- */

.main-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
}
.app-name { font-size: 22px; font-weight: 800; letter-spacing: .2px; }
.head-actions { display: flex; gap: 2px; }

.side-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-tabs {
  display: flex; gap: 4px; margin: 0 12px 8px; padding: 4px;
  background: #1a2430; border-radius: 14px;
}
.chat-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 6px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 14px;
}
.chat-tab.active { background: #2b3b4f; color: var(--text); }
.tab-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--acc); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center;
}

.search-row { padding: 0 12px 8px; }
.search-row input {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--bg3); color: var(--text); font-size: 15px; outline: none;
}
.search-row input:focus { border-color: var(--acc); }

.chat-context-bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
}
.ctx-count { font-size: 18px; font-weight: 700; }
.ctx-actions { margin-left: auto; display: flex; gap: 4px; }

.bottom-nav {
  display: flex; border-top: 1px solid var(--line); background: var(--bg2);
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; color: var(--muted); font-size: 11px; background: transparent;
}
.nav-item.active { color: var(--acc); }
.nav-ic {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 19px; line-height: 1; position: relative; overflow: hidden;
}
.nav-ic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.fab-new {
  position: absolute; right: 16px; bottom: 74px; z-index: 5;
  width: 52px; height: 52px; border-radius: 50%; background: var(--acc);
  color: #fff; font-size: 28px; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 8px 22px rgba(0,0,0,.4);
}

.sub-head {
  padding: calc(8px + env(safe-area-inset-top)) 16px 10px;
  font-size: 20px; font-weight: 700;
}
.sub-scroll { flex: 1; overflow-y: auto; padding: 0 12px 16px; }
.settings-row {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 14px 10px; border-bottom: 1px solid rgba(38,48,60,.6);
  color: var(--text); font-size: 15px; text-align: left; background: transparent;
}
.settings-row.danger-row { color: #ff7b86; }
.side-view .user-list { max-height: none; }
.side-view .settings-label { margin: 0 4px 6px; }

.chat-item.ctx-selected { background: #263445; }

@media (max-width: 760px) {
  .main-head { padding-top: calc(8px + env(safe-area-inset-top)); }
  .bottom-nav { position: sticky; bottom: 0; }
}

.sidebar { position: relative; }

.main-head .icon svg, .chat-context-bar .icon svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-ic svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.chat-context-bar .icon { color: var(--text); }

.main-head .icon svg.solid, .nav-ic svg.solid { fill: currentColor; stroke: none; }

/* ?????? ?????? ???? ???? ??????? ????, ? ?????? safe-area iPhone */
.fab-new { bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ????????? iPhone: ?????? ?????? ?? ?????? ????, ?????? «+» ??? ??? */
@media (max-width: 760px) {
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  }
  .sidebar {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
  .fab-new {
    position: fixed; right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 41;
  }
  .app.chat-open .bottom-nav,
  .app.chat-open .fab-new { display: none; }
}

.invite-btn {
  flex: 0 0 auto; margin-left: 8px; padding: 7px 14px;
  border-radius: 999px; background: #2fa84f; color: #fff;
  font-size: 12px; font-weight: 700;
}

/* ????????? ???????? ?????? ??????, ??? ? Telegram */
.bottom-nav {
  margin: 0 10px 8px;
  border: 1px solid #2b3947;
  border-radius: 26px;
  background: #1b2530;
  padding: 4px 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.38);
  overflow: hidden;
}
.nav-item.active { background: rgba(76,141,255,.10); border-radius: 18px; }

@media (max-width: 760px) {
  .bottom-nav {
    position: fixed; left: 10px; right: 10px; bottom: calc(8px + env(safe-area-inset-bottom));
    margin: 0; padding: 4px 6px; z-index: 40;
  }
  .sidebar { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  .fab-new { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
