/* ============================================================
   Volna — стили клиента
   ============================================================ */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --accent-1: #2aabee;
  --accent-2: #229ed9;
  --accent-grad: linear-gradient(135deg, #37b9ff, #1f7fd4);
  --danger: #ff5c6c;
  --ok: #6ee7b7;
  --sidebar-w: 380px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

html[data-theme="dark"] {
  --bg: #0e1621;
  --bg-elev: #17212b;
  --bg-elev-2: #242f3d;
  --sidebar: #17212b;
  --chat-bg: #0e1621;
  --chat-pattern: radial-gradient(rgba(255,255,255,.022) 1px, transparent 1px);
  --chat-pattern-size: 22px 22px;
  --text: #f1f5f9;
  --text-dim: #8ba0b3;
  --text-faint: #5f7184;
  --line: #0b141c;
  --line-strong: rgba(255,255,255,.12);
  --bubble-in: #182533;
  --bubble-out: #2b5278;
  --bubble-out-solid: #2b5278;
  --bubble-out-text: #ffffff;
  --bubble-out-dim: rgba(255,255,255,.72);
  --bubble-out-soft: rgba(255,255,255,.16);
  --hover: #202b36;
  --active: #2b5278;
  --shadow: 0 18px 50px rgba(0,0,0,.5);
  --field: #1e2c39;
  --unread: #2aabee;
}

html[data-theme="light"] {
  --accent-1: #2aabee;
  --accent-2: #229ed9;
  --accent-grad: linear-gradient(135deg, #37b9ff, #1f7fd4);
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-elev-2: #f0f2f5;
  --sidebar: #ffffff;
  --chat-bg: #e7ebf0;
  --chat-pattern: radial-gradient(rgba(0,0,0,.03) 1px, transparent 1px);
  --chat-pattern-size: 22px 22px;
  --text: #000000;
  --text-dim: #707579;
  --text-faint: #a2abb3;
  --line: rgba(0,0,0,.08);
  --line-strong: rgba(0,0,0,.14);
  --bubble-in: #ffffff;
  --bubble-out: #effdde;
  --bubble-out-solid: #effdde;
  --bubble-out-text: #0f172a;
  --bubble-out-dim: rgba(15,23,42,.55);
  --bubble-out-soft: rgba(0,0,0,.05);
  --hover: rgba(0,0,0,.04);
  --active: rgba(42,171,238,.16);
  --shadow: 0 18px 50px rgba(15,23,42,.12);
  --field: #f0f2f5;
  --unread: #2aabee;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font-family: inherit; color: inherit; }
input, textarea { font-family: inherit; }

.hidden, [hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ----------------------------- аватары --------------------------------- */

.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .3px;
  background: var(--accent-grad);
  overflow: hidden;
  flex: none;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--32 { width: 32px; height: 32px; font-size: 12px; }
.avatar--40 { width: 40px; height: 40px; font-size: 15px; }
.avatar--54 { width: 54px; height: 54px; font-size: 19px; }
.avatar--96 { width: 96px; height: 96px; font-size: 34px; }
.avatar--xl { width: 110px; height: 110px; font-size: 38px; }

.avatar-wrap { position: relative; flex: none; }
.avatar-wrap .online-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ok);
  border: 2.5px solid var(--sidebar);
}

/* ============================== ВХОД ================================== */

.auth {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(42,171,238,.18), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(55,185,255,.16), transparent 50%),
    var(--bg);
}

.auth__card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
  animation: rise .45s var(--ease) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.auth__brand { text-align: center; margin-bottom: 22px; }

.auth__logo, .empty__logo {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  border-radius: 20px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  font-size: 30px; font-weight: 700; color: #fff;
  box-shadow: 0 10px 30px rgba(42,171,238,.45);
}

.auth__brand h1 { margin: 0; font-size: 26px; letter-spacing: -.4px; }
.auth__tagline { margin: 6px 0 0; color: var(--text-dim); font-size: 14px; }

.auth__tabs {
  display: flex;
  gap: 4px;
  background: var(--field);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 18px;
}

.auth__tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: .18s var(--ease);
}
.auth__tab.is-active { background: var(--bg-elev-2); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.12); }

.auth__form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--text-dim); padding-left: 4px; }
.field input {
  background: var(--field);
  border: 1.5px solid transparent;
  border-radius: 13px;
  padding: 13px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: .16s;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus { border-color: var(--accent-1); background: var(--bg-elev-2); }

.auth__error {
  background: rgba(255,92,108,.12);
  border: 1px solid rgba(255,92,108,.3);
  color: #ff8b96;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.auth__hint { margin: 18px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--text-faint); text-align: center; }

.btn {
  border: 0;
  border-radius: 13px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-elev-2);
  color: var(--text);
  transition: .16s var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.985); }
.btn--primary { background: var(--accent-grad); color: #fff; box-shadow: 0 10px 24px rgba(42,171,238,.35); }
.btn--block { width: 100%; }
.btn--danger { background: rgba(255,92,108,.14); color: #ff7d8a; }
.btn--ghost { background: transparent; border: 1px solid var(--line-strong); }
.btn:disabled { opacity: .55; cursor: default; }

/* ============================ ПРИЛОЖЕНИЕ =============================== */

.app {
  display: flex;
  height: 100dvh;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 3;
}

.sidebar__top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 10px;
}

.avatar-btn {
  border: 0; padding: 0; background: transparent; cursor: pointer;
  border-radius: 50%;
  line-height: 0;
}

.search {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}
.search__icon {
  position: absolute; left: 11px;
  width: 18px; height: 18px;
  color: var(--text-faint);
  pointer-events: none;
}
.search input {
  width: 100%;
  background: var(--field);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 32px 9px 36px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: .16s;
  -webkit-appearance: none;
}
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { border-color: var(--accent-1); background: var(--bg-elev-2); }
.search input::placeholder { color: var(--text-faint); }
.search__clear {
  position: absolute; right: 6px;
  border: 0; background: transparent; color: var(--text-faint);
  cursor: pointer; padding: 4px; line-height: 0; border-radius: 8px;
}
.search__clear .icon { width: 16px; height: 16px; }
.search__date {
  position: absolute; right: 30px;
  border: 0; background: transparent; color: var(--text-faint);
  cursor: pointer; padding: 4px; line-height: 0; border-radius: 8px;
}
.search__date:hover { color: var(--text); }
.search__date .icon { width: 16px; height: 16px; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  width: 38px; height: 38px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: .15s;
  flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn--accent { background: var(--accent-grad); color: #fff; box-shadow: 0 6px 18px rgba(42,171,238,.35); }
.icon-btn--accent:hover { color: #fff; filter: brightness(1.06); }

/* список чатов */

.chat-folders {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
}
.chat-folder {
  flex: 1 1 0;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.chat-folder:hover { background: var(--hover); }
.chat-folder.is-active { background: var(--active); color: var(--accent-1); }

.chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 8px 12px;
  min-height: 0;
}

.chat-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 8px;
  border: 0;
  background: transparent;
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
  position: relative;
}
.chat-item:hover { background: var(--hover); }
.chat-item.is-active { background: var(--active); }

.chat-item__body { flex: 1; min-width: 0; }
.chat-item__row { display: flex; align-items: baseline; gap: 8px; }
.chat-item__title {
  font-size: 14.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.chat-item__time { font-size: 11.5px; color: var(--text-faint); flex: none; }
.chat-item__preview {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.chat-item__preview .icon { width: 14px; height: 14px; flex: none; }
.chat-item__preview-text { overflow: hidden; text-overflow: ellipsis; }

.badge {
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--unread);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.badge--muted { background: var(--text-faint); }

.chat-item__end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }

.sidebar__footer {
  padding: 6px 14px 10px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.conn::before {
  content: ""; display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint); margin-right: 6px;
  vertical-align: middle;
}
.conn.is-online::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.conn.is-offline::before { background: var(--danger); }

/* поиск пользователей */

.search-results {
  position: absolute;
  inset: 62px 8px auto 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 8px;
  max-height: 60vh;
  overflow-y: auto;
  z-index: 5;
}
.search-results__title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-faint); padding: 8px 10px 6px; font-weight: 700;
}
.user-row {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 8px 10px; border: 0; background: transparent;
  border-radius: 12px; cursor: pointer; text-align: left;
}
.user-row:hover { background: var(--hover); }
.user-row__name { font-size: 14px; font-weight: 600; }
.user-row__sub { font-size: 12.5px; color: var(--text-dim); }

/* ================================ ЧАТ ================================== */

.chat-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  background-image: var(--chat-pattern);
  background-size: var(--chat-pattern-size, 22px 22px);
  position: relative;
}

/* обои чата */
.chat-pane.wall-1 {
  background-image: radial-gradient(circle at 15% 20%, rgba(42,171,238,.16), transparent 52%),
                    radial-gradient(circle at 85% 80%, rgba(55,185,255,.12), transparent 52%);
}
.chat-pane.wall-2 {
  background-image: radial-gradient(circle at 12px 12px, color-mix(in srgb, var(--text) 7%, transparent) 1.2px, transparent 2px);
  background-size: 24px 24px;
}
.chat-pane.wall-3 {
  background-image: repeating-linear-gradient(45deg, color-mix(in srgb, var(--text) 4%, transparent) 0 6px, transparent 6px 14px);
}
.chat-pane.wall-4 {
  background-image: linear-gradient(160deg, color-mix(in srgb, var(--accent-1) 14%, transparent), transparent 55%),
                    linear-gradient(20deg, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 55%);
}

/* свотчи выбора обоев в настройках */
.wall-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.wall-swatch {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--line-strong);
  cursor: pointer;
  background: var(--chat-bg) var(--chat-pattern);
}
.wall-swatch.wall-1 { background-image: radial-gradient(circle at 15% 20%, rgba(42,171,238,.5), transparent 60%), radial-gradient(circle at 85% 80%, rgba(55,185,255,.4), transparent 60%); }
.wall-swatch.wall-2 { background-image: radial-gradient(circle at 6px 6px, color-mix(in srgb, var(--text) 35%, transparent) 1.4px, transparent 2px); background-size: 12px 12px; }
.wall-swatch.wall-3 { background-image: repeating-linear-gradient(45deg, color-mix(in srgb, var(--text) 24%, transparent) 0 4px, transparent 4px 9px); }
.wall-swatch.wall-4 { background-image: linear-gradient(160deg, color-mix(in srgb, var(--accent-1) 60%, transparent), color-mix(in srgb, var(--accent-2) 55%, transparent)); }
.wall-swatch.is-active { border-color: var(--accent-1); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-1) 55%, transparent); }

.chat-top {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--chat-bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 2;
  flex: none;
}
.chat-top__back { display: none; }
.chat-top__meta { flex: 1; min-width: 0; }
.chat-top__title {
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-top__subtitle {
  font-size: 12.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.chat-top__subtitle.is-online { color: var(--accent-1); }
.chat-top__actions { display: flex; gap: 2px; flex: none; }

/* сообщения */

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
}
.messages__inner { padding: 8px 0 10px; }
.messages__list { display: flex; flex-direction: column; padding: 0 clamp(8px, 4vw, 42px); }

.load-more {
  display: block;
  margin: 6px auto 12px;
  border: 0;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12.5px;
  cursor: pointer;
}

.day-sep {
  text-align: center;
  margin: 14px 0 10px;
}
.day-sep span {
  display: inline-block;
  background: color-mix(in srgb, var(--bg-elev) 75%, transparent);
  backdrop-filter: blur(6px);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 20px;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 2px;
  animation: msgIn .22s var(--ease);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.msg--out { flex-direction: row-reverse; }
.msg--first { margin-top: 10px; }
.msg--grouped { margin-top: 2px; }
.msg__avatar-slot { width: 30px; flex: none; align-self: flex-end; }
.msg--out .msg__avatar-slot { display: none; }

.bubble {
  position: relative;
  max-width: min(620px, 82%);
  background: var(--bubble-in);
  border-radius: var(--radius);
  padding: 7px 11px 6px;
  font-size: 14.5px;
  line-height: 1.38;
  box-shadow: 0 1px 2px rgba(0,0,0,.14);
  overflow-wrap: anywhere;
}
html[data-theme="light"] .msg--in .bubble { box-shadow: 0 1px 3px rgba(15,23,42,.08); }

.msg--out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); }
.msg--out .bubble .quote,
.msg--out .bubble .bubble__sender { color: var(--bubble-out-text); opacity: .9; }

.msg--first .bubble { border-bottom-left-radius: 6px; }
.msg--out.msg--first .bubble { border-bottom-left-radius: var(--radius); border-bottom-right-radius: 6px; }

.bubble__sender {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-1);
  margin-bottom: 2px;
}

.bubble__text {
  white-space: pre-wrap;
  word-break: break-word;
  display: inline;
}

.bubble__text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bubble__text a.hashtag { color: var(--accent-1); text-decoration: none; font-weight: 600; }
.bubble__text a.hashtag:hover { text-decoration: underline; }

/* блок кода в сообщении */
.code-block {
  margin: 4px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,.18);
  max-width: 100%;
}
.code-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(127,127,127,.08);
}
.code-block__lang {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.code-block__copy {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.code-block__copy:hover { color: var(--text); }
.code-block__pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre;
  color: var(--text);
}

/* геолокация */
.location { margin: 2px 0; }
.location__link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.location__link:hover { background: var(--hover); }
.location__pin { font-size: 22px; line-height: 1; }
.location__body { display: flex; flex-direction: column; gap: 1px; }
.location__coords { font-size: 13px; font-weight: 600; }
.location__open { font-size: 11.5px; color: var(--accent-1); }

/* перевод сообщения */
.translate__orig {
  font-size: 14px;
  color: var(--text-dim);
  padding: 10px 12px;
  background: var(--field);
  border-radius: 10px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.translate__result {
  font-size: 15px;
  color: var(--text);
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble--deleted { font-style: italic; opacity: .65; }

.bubble__meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 6px 0 -1px 10px;
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  user-select: none;
}
.msg--out .bubble__meta { color: var(--bubble-out-dim); }
.bubble__meta .icon { width: 15px; height: 15px; stroke-width: 2.1; }
.bubble__meta .edited { font-size: 10.5px; }

.quote {
  display: block;
  border-left: 3px solid var(--accent-1);
  padding: 2px 8px;
  margin-bottom: 5px;
  background: rgba(127,127,127,.12);
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  overflow: hidden;
}
.quote__name { font-weight: 700; color: var(--accent-1); display: block; font-size: 12px; }
.quote__text { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
.msg--out .quote { background: var(--bubble-out-soft); border-left-color: var(--bubble-out-dim); }
.msg--out .quote__name { color: var(--bubble-out-text); }

/* реакции на сообщения */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--bg-elev) 70%, transparent);
  border-radius: 14px;
  padding: 2px 7px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.reaction:hover { background: var(--hover); }
.reaction.is-me { background: var(--active); border-color: var(--accent-1); }
.reaction__emoji { font-size: 14px; line-height: 1; }
.reaction__count { font-weight: 600; color: var(--text-dim); }
.reaction.is-me .reaction__count { color: var(--accent-1); }

/* панель выбора реакции */
.reaction-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.reaction-picker__btn {
  font-size: 26px;
  line-height: 1;
  padding: 10px 0;
  border: 0;
  background: var(--bg-elev-2);
  border-radius: 12px;
  cursor: pointer;
  transition: background .12s, transform .12s;
}
.reaction-picker__btn:hover { background: var(--hover); transform: translateY(-1px); }

/* конфетти */
.confetti-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -16px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: confettiFall 1.6s ease-in forwards;
}
@keyframes confettiFall {
  to { transform: translateY(106vh) translateX(var(--x, 0)) rotate(680deg); opacity: 0; }
}

.attachment { margin: 2px 0 2px; }
.attachment img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  border-radius: 12px;
  cursor: zoom-in;
  background: rgba(0,0,0,.08);
}
.attachment--single { margin: -1px -7px 2px; }
.attachment--single img { border-radius: 12px; max-height: 380px; }

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px 2px;
  color: inherit;
  text-decoration: none;
  min-width: 190px;
}
.file-card__icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(127,127,127,.18);
  display: grid; place-items: center;
  flex: none;
}
.msg--out .file-card__icon { background: var(--bubble-out-soft); }
.file-card__name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.file-card__size { font-size: 11.5px; color: var(--text-dim); }
.msg--out .file-card__size { color: var(--bubble-out-dim); }

.voice { padding: 2px 0; }
.voice audio { width: 250px; max-width: 100%; height: 38px; display: block; }

.msg--system {
  justify-content: center;
  margin: 8px 0;
}
.msg--system .bubble {
  background: color-mix(in srgb, var(--bg-elev) 80%, transparent);
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 20px;
  box-shadow: none;
  max-width: 90%;
  text-align: center;
}

.typing-bar {
  padding: 0 clamp(10px, 4vw, 44px) 4px;
  font-size: 12.5px;
  color: var(--text-dim);
  height: 18px;
}

/* композер */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px clamp(8px, 3vw, 18px) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--chat-bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  flex: none;
}

.composer__field {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: var(--field);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 3px 3px 3px 12px;
  transition: border-color .16s;
  min-width: 0;
}
.composer__field:focus-within { border-color: var(--accent-1); }

#composer-input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  padding: 8px 0;
  resize: none;
  outline: none;
  max-height: 132px;
  min-height: 20px;
  scrollbar-width: thin;
}
#composer-input::placeholder { color: var(--text-faint); }
.composer__emoji { width: 34px; height: 34px; border-radius: 50%; }
.composer__emoji .icon { width: 21px; height: 21px; }

.send-btn {
  width: 44px; height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: .16s var(--ease);
  box-shadow: 0 6px 18px rgba(42,171,238,.4);
}
.send-btn:hover { transform: translateY(-1px) scale(1.03); }
.send-btn:active { transform: scale(.94); }
.send-btn .icon { width: 20px; height: 20px; stroke-width: 2; }
.send-btn--mic { background: var(--bg-elev-2); color: var(--text-dim); box-shadow: none; display: none; }
.send-btn--mic.is-visible { display: grid; }
.send-btn--rec { background: linear-gradient(135deg, #ff4d5e, #ff7a5c); display: none; }
.send-btn--rec.is-visible { display: grid; animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,77,94,.55); }
  50% { box-shadow: 0 0 0 12px rgba(255,77,94,0); }
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 clamp(8px, 3vw, 18px);
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent-1);
  border-radius: 12px 12px 0 0;
}
.reply-bar__body { flex: 1; min-width: 0; }
.reply-bar__title { font-size: 12px; font-weight: 700; color: var(--accent-1); }
.reply-bar__text { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.emoji-panel {
  position: absolute;
  bottom: calc(68px + env(safe-area-inset-bottom));
  right: 16px;
  width: min(340px, calc(100vw - 32px));
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  z-index: 12;
}
.emoji-panel button {
  border: 0; background: transparent; cursor: pointer;
  font-size: 21px; line-height: 1;
  padding: 6px 0; border-radius: 8px;
}
.emoji-panel button:hover { background: var(--hover); }

/* пустое состояние */

.empty {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  background-image: var(--chat-pattern);
  background-size: var(--chat-pattern-size, 22px 22px);
}
.empty__inner { text-align: center; max-width: 320px; }
.empty__logo { width: 76px; height: 76px; border-radius: 24px; font-size: 34px; margin-bottom: 16px; }
.empty h2 { margin: 0 0 6px; font-size: 19px; }
.empty p { margin: 0 0 18px; color: var(--text-dim); font-size: 14px; }

/* ============================== МОДАЛКИ ================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, .62);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 60;
  animation: fade .18s both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 430px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  animation: rise .24s var(--ease) both;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal--wide { max-width: 480px; }
.modal__head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 12px;
}
.modal__title { font-size: 16px; font-weight: 700; flex: 1; }
.modal__body { padding: 0 18px 8px; overflow-y: auto; }
.modal__foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px 16px;
}
.modal__body .field { margin-bottom: 12px; }

.picker {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  max-height: 240px;
  overflow-y: auto;
}
.picker__empty { padding: 14px; text-align: center; color: var(--text-faint); font-size: 13px; }

.member-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.member-row:hover { background: var(--hover); }
.member-row__body { flex: 1; min-width: 0; }
.member-row__name { font-size: 14px; font-weight: 600; }
.member-row__sub { font-size: 12px; color: var(--text-dim); }

.profile-head { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 16px; }
.profile-head .avatar { cursor: pointer; }
.profile-head__hint { font-size: 11.5px; color: var(--text-faint); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; }
.switch__label { font-size: 14px; }

.menu-list { display: flex; flex-direction: column; padding: 4px; }
.menu-list button {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; text-align: left;
  padding: 11px 12px; border-radius: 12px; font-size: 14px; cursor: pointer;
}
.menu-list button:hover { background: var(--hover); }
.menu-list button.is-danger { color: #ff7d8a; }

.ctx-menu {
  position: fixed;
  z-index: 80;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 5px;
  min-width: 178px;
  animation: fade .12s both;
}
.ctx-menu button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; border: 0; background: transparent; text-align: left;
  padding: 9px 11px; border-radius: 9px; font-size: 13.5px; cursor: pointer;
}
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.is-danger { color: #ff7d8a; }
.ctx-menu .icon { width: 17px; height: 17px; }

/* лайтбокс */

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

/* тосты */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toastIn .22s var(--ease) both;
  max-width: 80vw;
}
.toast--error { border-color: rgba(255,92,108,.4); color: #ff97a1; }
.toast--undo { display: flex; align-items: center; gap: 12px; pointer-events: auto; }
.toast__text { flex: 1; min-width: 0; }
.toast__action {
  border: 0;
  background: transparent;
  color: var(--accent-1);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  padding: 0;
  flex: none;
}
.toast__action:hover { text-decoration: underline; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* =============================== ЗВОНОК ================================ */

.call {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: #070a11;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.call__bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 30% 25%, rgba(42,171,238,.22), transparent 55%),
    radial-gradient(circle at 75% 75%, rgba(55,185,255,.20), transparent 55%);
}
.call__remote {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
  display: none;
}
.call.is-video .call__remote { display: block; }
.call__local {
  position: absolute;
  right: 18px; bottom: 130px;
  width: 118px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 16px;
  background: #10161f;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  display: none;
  z-index: 3;
  transform: scaleX(-1);
}
.call.is-video .call__local { display: block; }
.call.is-video .call__local.is-cam-off { display: none; }
.call__info {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
}
.call__name { font-size: 22px; font-weight: 700; }
.call__status { font-size: 14px; color: rgba(255,255,255,.7); }

/* Видеозвонок: убираем большой аватар из центра, имя/статус — компактной
   плашкой сверху, чтобы не перекрывали видео собеседника. */
.call.is-video .call__info {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
  gap: 2px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, .38);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  text-align: center;
  max-width: 82%;
}
.call.is-video .call__info .avatar { display: none; }
.call.is-video .call__name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.call.is-video .call__status { font-size: 12.5px; }
.call__controls {
  position: absolute;
  bottom: calc(36px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 14px;
  z-index: 4;
}
.call__btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,.14);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: .16s;
}
.call__btn:hover { background: rgba(255,255,255,.22); }
.call__btn .icon { width: 24px; height: 24px; }
.call__btn.is-off { background: rgba(255,255,255,.9); color: #111; }
.call__btn--end { background: #ff4d5e; transform: rotate(135deg); }
.call__btn--end:hover { background: #ff6474; }
.call__btn--accept { background: #2ecc71; }
.call__btn--accept:hover { background: #48d98a; }
.call__btn.is-active { background: #4f8cff; }
.call__btn.is-active:hover { background: #6a9dff; }

/* Панель статистики звонка */
.call__stats {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top));
  left: 18px;
  z-index: 5;
  min-width: 224px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(10,15,24,.74);
  border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
  font-size: 12.5px;
  line-height: 1.55;
  pointer-events: none;
}
.call__stats-row { display: flex; justify-content: space-between; gap: 18px; }
.call__stats-row span { color: rgba(255,255,255,.62); }
.call__stats-row b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ======================= ВИДЕОСООБЩЕНИЕ (КРУЖОК) ======================= */

.video-msg {
  position: fixed;
  inset: 0;
  z-index: 72;
  background: #070a11;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.video-msg #video-msg-cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  background: #000;
}
.video-msg__top {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 3;
}
.video-msg__timer {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,.4);
  padding: 6px 12px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
}
.video-msg__controls {
  position: absolute;
  bottom: calc(34px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 3;
}
.video-msg__record {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(255,77,94,.9);
  cursor: pointer;
  transition: transform .12s, background .12s;
}
.video-msg__record:active { transform: scale(.94); }
.video-msg__record.is-recording {
  background: #ff4d5e;
  border-radius: 22px;
  width: 56px;
  height: 56px;
  animation: pulse 1.4s infinite;
}
.video-msg__record.is-send {
  background: #2ecc71;
  border-radius: 50%;
  width: 68px;
  height: 68px;
}

/* Кружок в ленте сообщений */
.msg-circle {
  position: relative;
  width: min(46vw, 200px);
  height: min(46vw, 200px);
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  flex: none;
}
.msg-circle video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.msg-circle__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(0,0,0,.28);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.msg-circle__play .icon { width: 40px; height: 40px; }
.msg-circle__time {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .call__controls { gap: 8px; }
  .call__btn { width: 52px; height: 52px; }
  .call__stats { left: 10px; right: 10px; min-width: 0; }
}

/* =============================== АДАПТИВ =============================== */

@media (max-width: 900px) {
  :root { --sidebar-w: 100%; }

  .chat-pane {
    position: fixed;
    inset: 0;
    transform: translateX(100%);
    transition: transform .26s var(--ease);
    z-index: 10;
    will-change: transform;
  }
  .app.chat-open .chat-pane { transform: none; }
  .app.chat-open .sidebar { transform: translateX(-12%); }

  .chat-top__back { display: inline-grid; }
  .empty { display: none; }
  .messages__list { padding: 0 8px; }
  .bubble { max-width: 84%; font-size: 15px; }
  .composer { gap: 4px; }
  #composer-input { font-size: 16px; }

  .sidebar { transition: transform .26s var(--ease); }

  .auth__card { padding: 26px 20px 20px; border-radius: 22px; }
  .call__local { width: 100px; bottom: 120px; right: 12px; }
}

@media (max-width: 420px) {
  .chat-top { padding: 8px 8px; }
  .chat-top__actions .icon-btn { width: 34px; height: 34px; }
  #btn-video { display: none; }
  .send-btn { width: 42px; height: 42px; }
}

@media (hover: none) {
  .bubble__meta { margin-left: 8px; }
}

/* тонкие скроллбары */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================
   Читаемость: чётче текст, крупнее эмодзи
   ============================================================ */

:root {
  --font-size: 15px;
  --emoji-size: 1.35em;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
  letter-spacing: .006em;
}

.bubble__text,
.chat-item__preview-text,
.chat-item__title,
.composer textarea,
.mv-text {
  font-size: var(--font-size);
}

.bubble__text {
  line-height: 1.45;
}

.bubble__text .emoji { font-size: var(--emoji-size); line-height: 1; vertical-align: -0.12em; display: inline-block; }

.emoji-panel button,
.emoji-panel span {
  font-size: var(--emoji-size);
  line-height: 1.15;
}

body.is-wide .messages__list { max-width: 980px; }

/* ============================================================
   Просмотр медиа и документов
   ============================================================ */

.mv {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  flex-direction: column;
  background: rgba(4, 7, 13, .94);
  backdrop-filter: blur(6px);
  animation: mvIn .16s var(--ease);
}

@keyframes mvIn { from { opacity: 0; } to { opacity: 1; } }

.mv-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 22, .72);
}

.mv-bar__title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mv-bar__actions { display: flex; align-items: center; gap: 6px; }

.mv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
}

.mv-btn:hover { background: rgba(255, 255, 255, .12); }
.mv-btn--close { color: var(--danger); }
.mv-zoom { font-size: 12px; color: var(--text-dim); min-width: 42px; text-align: center; }

.mv-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.mv-body--media {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mv-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  cursor: zoom-in;
}

.mv-stage.is-dragging { cursor: grabbing; }

.mv-img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  transition: transform .08s linear;
  user-select: none;
  -webkit-user-drag: none;
}

.mv-video {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #000;
}

.mv-pdf { width: 100%; height: 100%; border: 0; border-radius: 12px; background: #fff; }

.mv-body--audio { display: flex; align-items: center; justify-content: center; }

.mv-audio-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(520px, 100%);
  padding: 22px;
  border-radius: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
}

.mv-audio-card__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
}

.mv-audio-card .vp { flex: 1; }

.mv-text {
  margin: 0;
  padding: 16px;
  border-radius: 14px;
  background: var(--bg-elev);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  max-width: 1000px;
  margin: 0 auto;
}

.mv-table-wrap { overflow: auto; border-radius: 12px; background: var(--bg-elev); padding: 6px; }
.mv-table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.mv-table th, .mv-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mv-table th { position: sticky; top: 0; background: var(--bg-elev-2); font-weight: 600; }
.mv-table tr:nth-child(even) td { background: rgba(255, 255, 255, .02); }

.mv-loading, .mv-note { padding: 18px; color: var(--text-dim); font-size: 14px; text-align: center; }
.mv-fallback { max-width: 420px; margin: 40px auto; text-align: center; color: var(--text-dim); }
.mv-fallback .btn { margin-top: 12px; }

/* ============================================================
   Плеер голосовых
   ============================================================ */

.vp {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: 100%;
}

.vp-play {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  cursor: pointer;
}

.vp-play .icon { width: 16px; height: 16px; }

.vp-wave {
  position: relative;
  flex: 1;
  min-width: 90px;
  cursor: pointer;
  padding: 4px 0;
}

.vp-wave__base,
.vp-wave__fill {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
}

.vp-wave__fill {
  position: absolute;
  inset: 4px auto 4px 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

.vp-bar {
  flex: 0 0 auto;
  width: 2px;
  border-radius: 2px;
  background: var(--text-faint);
}

.vp-wave__fill .vp-bar { background: var(--accent-1); }
.vp.is-playing .vp-wave__fill .vp-bar { background: var(--accent-2); }

.vp-time {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.vp-speed {
  flex: 0 0 auto;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
}

.vp-dl { flex: 0 0 auto; color: var(--text-dim); display: inline-flex; }
.vp-dl:hover { color: var(--text); }
.vp-dl .icon { width: 18px; height: 18px; }

.attachment--voice { padding: 8px 10px; }
.attachment--video { position: relative; padding: 0; overflow: hidden; border-radius: 12px; }
.inline-video { display: block; width: 100%; max-width: 360px; border-radius: 12px; background: #000; }
.inline-video__expand {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}

/* ============================================================
   Стикеры
   ============================================================ */

.sticker-panel {
  position: absolute;
  right: 14px;
  bottom: 74px;
  width: min(340px, calc(100vw - 28px));
  max-height: 44vh;
  overflow: auto;
  padding: 12px;
  border-radius: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  z-index: 90;
}

.sticker-panel__pack {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-faint);
  margin: 2px 0 8px;
}

.sticker-panel__hint { font-size: 13px; color: var(--text-dim); padding: 10px; }

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.sticker-item {
  border: 0;
  padding: 6px;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: background .15s var(--ease), transform .15s var(--ease);
}

.sticker-item:hover { background: var(--hover); transform: translateY(-1px); }
.sticker-item img { width: 100%; display: block; }

.sticker-msg img {
  width: 132px;
  height: 132px;
  display: block;
}

.msg--out .sticker-msg { margin-left: auto; }

/* ============================================================
   Настройки
   ============================================================ */

.settings {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: mvIn .16s var(--ease);
}

@media (min-width: 720px) {
  .settings {
    inset: 4vh auto 4vh 50%;
    transform: translateX(-50%);
    width: min(620px, 92vw);
    border-radius: 20px;
    border: 1px solid var(--line-strong);
    overflow: hidden;
    box-shadow: var(--shadow);
  }
}

.settings__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.settings__title { flex: 1; font-size: 17px; font-weight: 700; color: var(--text); }

.settings__tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.settings__tab {
  padding: 7px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.settings__tab.is-active { background: var(--active); color: var(--text); }

.settings__body { flex: 1; overflow: auto; padding: 16px; }

.set-pane { display: flex; flex-direction: column; gap: 14px; }

.set-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
}

.set-field { display: flex; flex-direction: column; gap: 6px; }
.set-field__label { font-size: 12px; color: var(--text-dim); }

.set-input, .set-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--field);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.set-range { width: 100%; accent-color: var(--accent-1); }

.set-hint { font-size: 12px; line-height: 1.5; color: var(--text-faint); }
.set-hint.is-error { color: var(--danger); }
.set-row { display: flex; gap: 8px; flex-wrap: wrap; }
.set-actions { display: flex; justify-content: flex-end; }

.set-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.set-toggle__text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.set-toggle__label { font-size: 14px; color: var(--text); }
.set-toggle__desc, .set-toggle .set-hint { font-size: 12px; color: var(--text-faint); }
.set-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 42px; height: 24px; border-radius: 12px;
  background: var(--line-strong); position: relative; flex: 0 0 auto;
  transition: background .18s var(--ease);
}
.switch__dot {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .18s var(--ease);
}
.set-toggle input:checked ~ .switch { background: var(--accent-1); }
.set-toggle input:focus-visible ~ .switch { outline: 2px solid var(--accent-1); outline-offset: 2px; }
.set-toggle input:checked ~ .switch .switch__dot { transform: translateX(18px); }

.set-keys { display: flex; flex-direction: column; gap: 6px; }
.set-key {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; background: var(--bg-elev-2);
}
.set-key__icon { color: var(--accent-1); display: inline-flex; }
.set-key__label { flex: 1; font-size: 13px; color: var(--text); }

/* ============================================================
   Экран блокировки
   ============================================================ */

.lock {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 30% 20%, rgba(135, 116, 225, .18), transparent 55%), var(--bg);
}

.lock__card {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 20px;
  border-radius: 22px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.lock__name { font-size: 17px; font-weight: 700; color: var(--text); }
.lock__brand { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-faint); }
.lock__brand .icon { width: 14px; height: 14px; }

.lock-pin {
  margin: 8px 0 2px;
  font-size: 26px;
  letter-spacing: 6px;
  color: var(--text);
  min-height: 34px;
}
.lock-pin.is-error { color: var(--danger); animation: shake .35s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.lock-pad {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}

.lock-key {
  height: 58px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
}
.lock-key:active { transform: scale(.97); }
.lock-key--ok { background: var(--accent-grad); color: #fff; border-color: transparent; }
.lock-key--ok .icon { width: 24px; height: 24px; stroke-width: 2.2; }

.lock-msg { font-size: 12px; color: var(--text-faint); text-align: center; }
.lock-pw { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.lock-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 6px; }

/* ===================== Рамка окна (Electron) ====================== */
:root { --tb-h: 34px; }

.titlebar { display: none; }

body.is-electron .titlebar {
  display: flex;
  align-items: center;
  gap: 2px;
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--tb-h);
  z-index: 95;
  padding-left: 12px;
  color: #cbd5e5;
  background: linear-gradient(180deg, #111a29 0%, #0b1220 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  -webkit-app-region: drag;
  user-select: none;
}
html[data-theme="light"] body.is-electron .titlebar {
  color: #34435c;
  background: linear-gradient(180deg, #ffffff 0%, #f2f5fa 100%);
  border-bottom-color: rgba(16, 24, 40, .1);
}

.titlebar__brand {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .5px;
  text-transform: none;
  opacity: .85;
}
.titlebar__spacer { flex: 1; }

.titlebar__btn {
  -webkit-app-region: no-drag;
  width: 46px;
  height: var(--tb-h);
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease;
}
.titlebar__btn:hover { background: rgba(120, 140, 170, .22); }
.titlebar__btn:active { background: rgba(120, 140, 170, .32); }
.titlebar__btn--close:hover { background: #e5484d; color: #fff; }
.titlebar__btn--close:active { background: #c93b40; color: #fff; }

body.is-electron .app,
body.is-electron .auth {
  height: calc(100dvh - var(--tb-h));
  margin-top: var(--tb-h);
}

body.is-electron .call { top: var(--tb-h); }
body.is-electron .settings { top: var(--tb-h); }

/* ------------------ предпросмотр голосового сообщения ------------------- */
.voice-preview {
  position: absolute;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  width: min(520px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.voice-preview[hidden] { display: none; }

.voice-preview__track {
  flex: 1;
  height: 6px;
  min-width: 60px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-dim) 26%, transparent);
  overflow: hidden;
}
.voice-preview__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  transition: width .1s linear;
}
.voice-preview__time {
  font-size: 12.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: right;
}


/* Подсказка о разрешениях камеры и микрофона */
.permission-help p { margin: 0 0 10px; font-size: 14px; line-height: 1.5; }
.permission-help__steps {
  color: var(--text-faint);
  background: rgba(127, 127, 127, .12);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
