/*
 * СОБРАННЫЙ ФАЙЛ — не редактировать.
 *
 * Правьте исходники в styles/ и запускайте:
 *   node scripts/build-assets.js
 *
 * Порядок склейки задан в styles/index.css (14 файлов).
 */
/* ===== tokens.css ===== */
/* Палитры в стиле Telegram: dark = Night, light = Day, blue = Tinted Blue */

:root {
  --bg: #0e1621;
  --bg-2: #0e1621;
  --panel: #17212b;
  --panel-2: #1c2733;
  --surface: #17212b;
  --surface-2: #242f3d;
  --surface-3: #2b3847;
  --hover: #202b36;

  --line: rgba(255, 255, 255, 0.07);
  --text: #f5f5f5;
  --muted: #708499;

  --primary: #5288c1;
  --primary-2: #4a76a8;
  --danger: #ef5b5b;
  --success: #4fae4e;

  --chat-bg: #0e1621;
  --bubble-in: #182533;
  --bubble-out: #2b5278;
  --bubble-in-text: #f5f5f5;
  --bubble-out-text: #f5f5f5;
  --meta-in: rgba(255, 255, 255, 0.45);
  --meta-out: rgba(255, 255, 255, 0.55);
  --check: #71bbe7;
  --badge: #4a76a8;
  --date-pill-bg: rgba(0, 0, 0, 0.3);
  --date-pill-text: #ffffff;

  --system-bubble: rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --highlight-ring: rgba(82, 136, 193, 0.75);
  --reply-accent: #6ab3f3;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-2: #f1f4f7;
  --panel: #ffffff;
  --panel-2: #f7f7f7;
  --surface: #ffffff;
  --surface-2: #f1f1f1;
  --surface-3: #e8ecef;
  --hover: #f0f2f5;

  --line: rgba(0, 0, 0, 0.08);
  --text: #000000;
  --muted: #707579;

  --primary: #3390ec;
  --primary-2: #2e83d7;
  --danger: #e53935;
  --success: #4fae4e;

  --chat-bg: #d6e3ef;
  --bubble-in: #ffffff;
  --bubble-out: #effdde;
  --bubble-in-text: #000000;
  --bubble-out-text: #000000;
  --meta-in: #a0acb6;
  --meta-out: #62ac55;
  --check: #4fae4e;
  --badge: #3390ec;
  --date-pill-bg: rgba(0, 0, 0, 0.22);
  --date-pill-text: #ffffff;

  --system-bubble: rgba(0, 0, 0, 0.22);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  --highlight-ring: rgba(51, 144, 236, 0.6);
  --reply-accent: #3390ec;
}

:root[data-theme="blue"] {
  --bg: #0f1c2e;
  --bg-2: #0f1c2e;
  --panel: #16273c;
  --panel-2: #1a2d45;
  --surface: #16273c;
  --surface-2: #21344e;
  --surface-3: #283d5a;
  --hover: #1e3350;

  --line: rgba(144, 182, 255, 0.12);
  --text: #edf4ff;
  --muted: #7d95b5;

  --primary: #529ef4;
  --primary-2: #3d8ae0;
  --danger: #ef5b5b;
  --success: #4fae4e;

  --chat-bg: #0f1c2e;
  --bubble-in: #1c2f47;
  --bubble-out: #2f5a86;
  --bubble-in-text: #edf4ff;
  --bubble-out-text: #edf4ff;
  --meta-in: rgba(237, 244, 255, 0.45);
  --meta-out: rgba(237, 244, 255, 0.6);
  --check: #7cc4ff;
  --badge: #529ef4;
  --date-pill-bg: rgba(0, 0, 0, 0.32);
  --date-pill-text: #ffffff;

  --system-bubble: rgba(0, 0, 0, 0.32);
  --shadow: 0 4px 24px rgba(2, 6, 23, 0.4);
  --highlight-ring: rgba(111, 176, 255, 0.75);
  --reply-accent: #8fc2ff;
}

/* ===== base.css ===== */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, var(--bg) 0%, var(--bg-2) 45%, #070d18 100%);
  color: var(--text);
}

/* ===== utilities.css ===== */
.hidden {
  display: none !important;
}

/* Инлайновые SVG-иконки (Lucide-стиль): цвет наследуется от кнопки
   через currentColor, размер задаётся контекстом */
.icon {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.ghost-icon .icon {
  width: 21px;
  height: 21px;
}

/* Активное состояние иконки-переключателя (закреплённый чат) */
.ghost-icon.is-active {
  color: var(--primary);
}

.ghost-icon.is-active .icon {
  fill: color-mix(in srgb, var(--primary) 22%, transparent);
}

.ghost-icon.small .icon {
  width: 17px;
  height: 17px;
}

.search-icon .icon {
  width: 18px;
  height: 18px;
}

.fab-mini .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.4;
}

.primary-send .icon {
  width: 20px;
  height: 20px;
  transform: translateX(1px);
}

.scroll-to-bottom .icon {
  width: 22px;
  height: 22px;
}

.ghost-circle .icon,
.success-circle .icon,
.danger-circle .icon {
  width: 24px;
  height: 24px;
}

.call-avatar .icon {
  width: 44px;
  height: 44px;
  stroke-width: 1.6;
  margin: 0 auto;
}

.upload-preview-fallback .icon {
  width: 48px;
  height: 48px;
  stroke-width: 1.6;
  color: var(--muted);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #355899, #1e3560);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.avatar.large {
  width: 52px;
  height: 52px;
  border-radius: 50%;
}

.avatar.xlarge {
  border-radius: 50%;
}

.avatar-clickable {
  cursor: pointer;
}

.avatar.online::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid #0b1425;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.avatar:hover .avatar-img {
  transform: scale(1.05);
}

.avatar-fallback {
  font-weight: 700;
}

.primary-btn,
.primary-send,
.primary-chip {
  border: 0;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}

.primary-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 17px;
  box-shadow: none;
}

.primary-send.is-disabled,
.primary-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.primary-send:hover:not(:disabled) {
  filter: brightness(1.2);
}

.ghost-icon,
.ghost-circle,
.ghost-chip {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: 0.15s ease;
}

.ghost-icon:hover:not(:disabled):not(.is-disabled) {
  background: var(--hover);
  color: var(--text);
}

.ghost-chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.ghost-icon:hover:not(:disabled):not(.is-disabled),
.ghost-circle:hover,
.ghost-chip:hover,
.primary-send:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.ghost-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
}

.ghost-icon.small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 15px;
}

.ghost-icon:disabled,
.ghost-icon.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

label.ghost-icon.is-disabled {
  pointer-events: none;
}

.ghost-circle,
.success-circle,
.danger-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  color: #fff;
  font-size: 20px;
}

.success-circle {
  background: var(--success);
}

.danger-circle {
  background: var(--danger);
}

.ghost-circle {
  background: var(--hover);
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost-chip,
.primary-chip {
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
}

.theme-select {
  width: 100%;
  height: 42px;
  border-radius: 8px;
  padding: 0 34px 0 12px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  outline: none;
}

.theme-select,
.settings-select-row select,
.admin-role-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.theme-select:focus {
  border-color: rgba(79, 140, 255, 0.4);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.08);
}

.status-check {
  font-size: 11px;
  letter-spacing: -0.02em;
}

.status-check.read,
.status-check.delivered {
  color: var(--check);
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: rgba(11, 19, 34, 0.95);
  border: 1px solid var(--line);
  color: #fff;
  padding: 12px 14px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  min-width: 220px;
}

.toast.hide {
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,0.88);
  display: grid;
  place-items: center;
  z-index: 70;
}

.image-preview-img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.image-close {
  position: fixed;
  top: 18px;
  right: 18px;
}

.auth-logo img {
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* ===== auth.css ===== */
/*
 * Экран входа занимает высоту окна, а не экрана: с viewport-fit=cover
 * страница уходит под системные полосы, и кнопка «Войти» на невысоком
 * телефоне оказывалась под кнопками навигации.
 */
.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) calc(24px + env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

.auth-shell {
  width: min(100%, 1040px);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
}

.auth-brand,
.auth-card {
  background: var(--panel-2);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.auth-brand {
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-logo {
  width: 74px;
  height: 74px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 36px;
  background: linear-gradient(135deg, #4f8cff, #7c5cff);
  margin-bottom: 22px;
}

.auth-brand h1 {
  margin: 0 0 12px;
  font-size: 42px;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.auth-card {
  padding: 26px;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  background: var(--surface-2);
  padding: 6px;
  border-radius: 16px;
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
}

.auth-tab.active {
  background: var(--hover);
  color: var(--text);
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.auth-label input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 14px;
  outline: none;
}

.auth-textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 14px;
  outline: none;
  resize: vertical;
}

.unblock-appeal-box {
  margin-top: 16px;
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-2) 76%, transparent);
}

.auth-section-title {
  color: var(--text);
  font-weight: 800;
}

.auth-image-preview {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-2);
}

.auth-image-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
}

.auth-submit {
  padding: 14px 16px;
  border-radius: 14px;
  font-weight: 700;
  margin-top: 6px;
}

.auth-hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.auth-error,
.auth-success {
  margin-top: 10px;
  min-height: 20px;
  font-size: 14px;
}

.auth-error {
  color: #ff8a8a;
}

.auth-success {
  color: #75f0a1;
}


/* --- Помощь с паролем --- */

.password-row {
  position: relative;
  display: flex;
  align-items: center;
}

.password-row input {
  flex: 1 1 auto;
  padding-right: 40px;
}

.password-icon-btn {
  position: absolute;
  right: 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 6px;
  opacity: 0.6;
}

.password-icon-btn:hover {
  opacity: 1;
}

.password-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: -4px;
}

.password-tools.hidden {
  display: none;
}

.password-strength {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.password-strength-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

/* Ширина и цвет задаются из JS по фактической оценке в битах */
.password-strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 160ms ease, background-color 160ms ease;
}

.password-strength-text {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.password-generate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.password-gen-btn {
  padding: 7px 13px;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12.5px;
  cursor: pointer;
}

.password-gen-btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.password-gen-btn.hidden {
  display: none;
}

.password-gen-btn:hover {
  opacity: 0.9;
}

/*
 * Сгенерированный пароль показываем моноширинным: в нём легко перепутать
 * похожие символы, а его придётся переписывать или диктовать
 */
.password-generated .password-row input {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
}

/* Пароль и его повтор разошлись */
.auth-label input.field-mismatch,
.auth-label input.field-mismatch:focus {
  border-color: var(--danger);
}

.password-save-hint {
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.password-save-hint.hidden {
  display: none;
}

/*
 * Поле кода и кнопка «выслать» — в одну строку.
 *
 * Кнопка узкая и по смыслу относится к полю рядом, а не к форме
 * целиком: ставить её отдельной строкой значит делать вид, что это
 * ещё один шаг регистрации.
 */
.auth-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.secondary-btn {
  height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.secondary-btn:hover:not(:disabled) { border-color: rgba(79, 140, 255, 0.4); }
.secondary-btn:disabled { opacity: 0.5; cursor: default; }

/* ===== layout.css ===== */
/*
 * Безопасные зоны: вырез iPhone и системные кнопки Android.
 *
 * В meta viewport стоит viewport-fit=cover — страница занимает весь
 * экран, включая полосы, которые рисует система. Без отступов шапка
 * уезжает под «чёлку», а поле ввода — под полосу жеста или под кнопки
 * «назад / домой / приложения». Начиная с Android 15 система рисует их
 * поверх содержимого всегда, так что это уже не редкий случай.
 *
 * Высота задаётся здесь, а не на .app-layout: тот считает свои сто
 * процентов от этой высоты за вычетом отступов, и вычитать зоны второй
 * раз не нужно. Раньше .app-layout был объявлен дважды — сперва с
 * вычитанием зон, потом просто на 100dvh, — и второе правило затирало
 * первое. Приложение получалось ровно на высоту экрана, а отступы
 * добавлялись сверху: низ уходил под кнопки и обрезался overflow.
 *
 * На устройствах без выреза env(...) равен нулю, поэтому правило безвредно.
 */
.chat-body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  box-sizing: border-box;
  background: var(--bg);
}

.app-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

.sidebar {
  position: relative;
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.sidebar-top {
  flex: 0 0 auto;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
}

.sidebar-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px 10px 10px;
}

.chat-area {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
}

.empty-state {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 24px;
}

.empty-state-card {
  width: min(100%, 420px);
  text-align: center;
  padding: 18px;
}

.empty-illustration {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  margin: 0 auto 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.empty-illustration img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty-state-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.empty-state-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.chat-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== sidebar.css ===== */
.sidebar-appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.me-block {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.me-meta {
  min-width: 0;
}

.me-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.me-status {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.sidebar-appbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-search-section {
  display: grid;
  gap: 12px;
}

.search-wrap,
.search-wrap-main {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 14px 0 38px;
  border-radius: 20px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: 0.15s ease;
}

.search-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 8;
}

.search-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
}

.search-item:hover {
  background: var(--hover);
}

.sidebar-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-inline: contain;
}

.sidebar-tabs::-webkit-scrollbar {
  display: none;
}

.sidebar-tab {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: 0.15s ease;
}

.sidebar-tab:hover {
  color: var(--text);
}

.sidebar-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

.online-strip-section {
  display: grid;
  gap: 10px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.section-head.compact {
  padding: 0 2px;
}

.section-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-link {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.section-link:disabled,
.section-link.is-disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.55;
}

.online-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 4px;
  scrollbar-width: none;
}

.online-strip::-webkit-scrollbar {
  display: none;
}

.online-strip-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 4px;
}

.online-user-chip {
  width: 68px;
  min-width: 68px;
  display: grid;
  gap: 6px;
  justify-items: center;
  cursor: pointer;
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}

.online-user-chip .avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  box-shadow: none;
}

.online-user-name {
  width: 100%;
  font-size: 11px;
  text-align: center;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-users-drawer-list {
  display: grid;
}

.online-drawer-user {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.online-drawer-user:last-child {
  border-bottom: 0;
}

.online-drawer-user:hover {
  color: var(--primary);
}

.online-drawer-user .avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.online-drawer-user-meta {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.online-drawer-user-meta b,
.online-drawer-user-meta span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-drawer-user-meta span {
  color: var(--muted);
  font-size: 12px;
}

.fab-mini {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-size: 18px;
  box-shadow: 0 10px 24px rgba(43, 110, 243, 0.24);
}

.dialogs-list,
#userList {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: 4px;
}

.dialog-item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  margin-bottom: 1px;
  border-radius: 10px;
  background: transparent;
  transition: 0.12s ease;
  cursor: pointer;
}

.dialog-item:hover {
  background: var(--hover);
  transform: none;
}

.dialog-item.active {
  background: var(--primary);
}

.dialog-item.active .dialog-name,
.dialog-item.active .dialog-last,
.dialog-item.active .time,
.dialog-item.active .dialog-last.draft {
  color: #fff;
}

.dialog-item.active .dialog-last,
.dialog-item.active .time {
  opacity: 0.85;
}

.dialog-item.active .badge {
  background: #fff;
  color: var(--primary);
}

.dialog-item.active .entity-badge,
.dialog-item.active .entity-pin {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.dialog-item .avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
}

.dialog-main {
  min-width: 0;
}

.dialog-top,
.dialog-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.dialog-top {
  align-items: center;
  margin-bottom: 4px;
}

.dialog-name-wrap {
  min-width: 0;
}

.dialog-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dialog-flags {
  margin-top: 3px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.dialog-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.4);
}

.dialog-status-dot.online {
  background: var(--success);
}

.entity-badge,
.entity-pin {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.entity-muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.entity-badge {
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}

.entity-pin {
  background: rgba(79,140,255,0.14);
  color: var(--primary);
}

.dialog-last {
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dialog-last.draft {
  color: #ffcf81;
  font-weight: 700;
}

.time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--badge);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.empty-dialogs {
  padding: 24px 14px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.compact-sidebar .dialog-item {
  padding: 9px 10px;
}

.compact-sidebar .dialog-item .avatar {
  width: 46px;
  height: 46px;
}


.search-results {
  max-height: min(72vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.search-section + .search-section {
  border-top: 1px solid rgba(148, 163, 184, 0.08);
}

.search-section-title {
  padding: 10px 14px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-item-rich {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.search-item-rich mark {
  background: rgba(79, 140, 255, 0.18);
  color: inherit;
  border-radius: 6px;
  padding: 0 2px;
}

.search-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.search-item-main {
  min-width: 0;
}

.search-item-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.search-item-title,
.search-item-subtitle,
.search-item-time {
  min-width: 0;
}

.search-item-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-time {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.search-empty-state {
  padding: 16px 14px;
}

.search-empty-title {
  font-size: 14px;
  font-weight: 800;
}

.search-empty-text {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

/* ===== chat.css ===== */
.chat-header {
  padding: 7px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: 0 0 auto;
  min-height: 56px;
}

.chat-user {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-back-button {
  display: none;
  flex: 0 0 auto;
}

.chat-user .avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.chat-user-meta {
  min-width: 0;
}

.chat-name {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-status {
  margin-top: 1px;
  font-size: 13px;
  color: var(--muted);
}

.chat-actions {
  gap: 2px;
}

#contactToggleBtn.active { color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); }

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-toolbar {
  padding: 8px 14px;
  flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.chat-search-wrap {
  position: relative;
  padding: 0;
}

.chat-search-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 14px 0 38px;
  border-radius: 19px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: 0.15s ease;
}

.chat-search-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.chat-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 8;
}

.chat-search-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
}

.chat-search-item:hover {
  background: var(--hover);
}

.chat-search-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-search-time {
  color: var(--muted);
  font-size: 12px;
}

.typing-indicator {
  padding: 8px 18px 0;
  color: var(--reply-accent);
  font-size: 13px;
  flex: 0 0 auto;
}

.messages-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.scroll-to-bottom {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.scroll-to-bottom:hover {
  background: var(--hover);
  color: var(--text);
}

.upload-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: 18px;
}

.upload-preview-card {
  width: min(100%, 460px);
  border-radius: 26px;
  border: 1px solid var(--line);
  background: rgba(10, 16, 29, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.upload-preview-head,
.upload-preview-actions {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.upload-preview-title {
  font-size: 18px;
  font-weight: 800;
}

.upload-preview-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.upload-preview-body {
  padding: 0 18px 18px;
  display: grid;
  gap: 14px;
}

.upload-preview-visual {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.upload-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-preview-fallback {
  font-size: 56px;
}

.upload-preview-name {
  font-size: 16px;
  font-weight: 700;
}

.upload-preview-info,
.upload-progress-text {
  color: var(--muted);
  font-size: 13px;
}

.upload-progress-block {
  display: grid;
  gap: 8px;
}


/* Полоса закреплённого сообщения под шапкой чата */
.pinned-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.pinned-bar.hidden {
  display: none;
}

.pinned-bar .icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--primary);
}

.pinned-bar-text {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-bar-text:hover {
  text-decoration: underline;
}

/* Имя в шапке открывает карточку собеседника — подсказываем это курсором */
.chat-user-meta-clickable {
  cursor: pointer;
  border-radius: 8px;
  padding: 2px 6px;
  margin: -2px -6px;
  transition: background 0.15s;
}

.chat-user-meta-clickable:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.chat-user-meta-clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ===== messages.css ===== */
.messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.messages-divider {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.messages-divider span {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--date-pill-bg);
  color: var(--date-pill-text);
  font-size: 13px;
  font-weight: 600;
}

.messages-divider.unread span {
  background: var(--primary);
  color: #fff;
}

.message {
  display: flex;
}

.message.me {
  justify-content: flex-end;
}

.message.system {
  justify-content: center;
}

.message-bubble {
  position: relative;
  max-width: min(66%, 480px);
  padding: 7px 11px 6px;
  border-radius: 15px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  overflow: visible;
  font-size: 15px;
}

.message.them .message-bubble {
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  border-bottom-left-radius: 5px;
}

.message.me .message-bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-text);
  border-bottom-right-radius: 5px;
}

.message.system .message-bubble {
  max-width: 420px;
  border-radius: 999px;
  background: var(--system-bubble);
  color: var(--date-pill-text);
  padding: 5px 14px;
  font-size: 13px;
}

.message-highlight .message-bubble {
  box-shadow: 0 0 0 2px var(--highlight-ring), 0 6px 20px rgba(2, 6, 23, 0.18);
}

.message.is-pending .message-bubble {
  opacity: 0.88;
}

.message.is-failed .message-bubble {
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.26), 0 12px 26px rgba(2, 6, 23, 0.14);
}

.group-sender-label {
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--reply-accent);
}

.message-text {
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.system-text {
  text-align: center;
}

.deleted-text {
  opacity: 0.72;
  font-style: italic;
}

.message-meta {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--meta-in);
}

.message.me .message-meta {
  color: var(--meta-out);
}

.message.system .message-meta {
  justify-content: center;
  color: inherit;
  opacity: 0.75;
}


.message-link {
  color: var(--reply-accent);
  font-weight: 600;
  text-decoration: none;
}

.image-wrap {
  display: grid;
  gap: 8px;
  width: min(320px, 42vw);
  max-width: 100%;
}

.message.me .image-wrap,
.message.them .image-wrap {
  width: min(320px, 42vw);
}

.chat-image-thumb {
  display: block;
  width: 100%;
  max-width: 320px;
  max-height: 260px;
  border-radius: 18px;
  cursor: pointer;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.18);
}

.image-caption {
  font-size: 13px;
  opacity: .92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-wrap audio {
  display: none;
}

.voice-message-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(320px, 100%);
  max-width: 100%;
  min-width: 0;
}

.voice-message-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 0;
  background: rgba(255,255,255,0.14);
  color: currentColor;
  cursor: pointer;
  flex: 0 0 36px;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

.voice-message-icon:disabled {
  cursor: default;
  opacity: 0.52;
}

.voice-message-icon:not(:disabled):hover,
.voice-message-icon.is-playing {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.24);
}

.voice-message-icon .icon {
  width: 20px;
  height: 20px;
}

.message-file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.message-file-link .icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* Лёгкая подсветка сообщения при наведении, как в Telegram */
.message.them .message-bubble:hover {
  filter: brightness(1.04);
}

.message.me .message-bubble:hover {
  filter: brightness(1.03);
}

@media (max-width: 900px) {
  .image-wrap,
  .message.me .image-wrap,
  .message.them .image-wrap {
    width: min(280px, 58vw);
  }

  .chat-image-thumb {
    max-width: 280px;
    max-height: 220px;
  }
}

@media (max-width: 640px) {
  .image-wrap,
  .message.me .image-wrap,
  .message.them .image-wrap {
    width: min(240px, 72vw);
  }

  .chat-image-thumb {
    max-width: 240px;
    max-height: 200px;
  }
}

.encryption-lock-badge {
  font-size: 11px;
  line-height: 1.2;
  opacity: 0.78;
  margin-bottom: 6px;
}


.voice-player-wrap,
.voice-message-main {
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
  width: min(280px, calc(100vw - 220px));
  max-width: 280px;
  min-width: 220px;
}

.voice-player-wrap audio,
.voice-message-main audio {
  display: none;
}

/*
 * Полоски раскладываются на всю ширину блока.
 *
 * Раньше они шли слева с постоянным промежутком и занимали 117 пикселей
 * из 212 — то есть чуть больше половины. Кликом перематывалась вся ширина,
 * включая пустое место справа, и попадание не совпадало с тем, что видно.
 *
 * space-between разносит их от края до края, gap задаёт лишь нижнюю
 * границу промежутка на узких экранах.
 */
.voice-wave {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  height: 30px;
  min-width: 0;
  /* Подстраховка: если пузырь окажется уже, чем помещается набор полосок,
     лучше обрезать край, чем выпустить их за границу сообщения */
  overflow: hidden;
}

.voice-wave span {
  width: 3px;
  height: var(--h, 16px);
  border-radius: 999px;
  background: currentColor;
  opacity: 0.38;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.voice-wave span.is-active {
  opacity: 0.92;
  transform: scaleY(1.08);
}

.message.me .voice-wave span {
  opacity: 0.46;
}

.message.me .voice-wave span.is-active {
  opacity: 0.94;
}

.voice-duration-label {
  font-size: 12px;
  color: inherit;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

.message-media-load { min-width:210px; min-height:48px; display:grid; grid-template-columns:28px minmax(0,1fr) auto; align-items:center; gap:10px; border:0; border-radius:8px; padding:9px 12px; background:color-mix(in srgb, var(--primary) 12%, var(--surface-2)); color:var(--text); cursor:pointer; text-align:left; }
.message-media-load .icon { width:22px; height:22px; color:var(--primary); }
.message-media-load span { font-weight:700; }
.message-media-load small { color:var(--muted); }


@media (max-width: 640px) {
  .voice-message-card {
    width: min(280px, 100%);
  }

  .voice-player-wrap,
  .voice-message-main {
    width: min(220px, calc(100vw - 170px));
    min-width: 160px;
  }
}

/* Перемотка и скорость голосовых */
.voice-wave[role="slider"] {
  cursor: pointer;
  /* Полоса тонкая, а попасть по ней надо пальцем — расширяем область
     нажатия отступами, не трогая внешний вид */
  padding: 6px 0;
  margin: -6px 0;
}

.voice-wave[role="slider"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.voice-message-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.voice-speed-btn {
  flex: 0 0 auto;
  min-width: 34px;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.voice-speed-btn:hover {
  color: var(--text);
}

.voice-speed-btn.is-fast {
  color: var(--primary);
  border-color: var(--primary);
}

/*
 * Упоминания.
 *
 * Обращение лично к вам выделяется сильнее прочих: смысл упоминания
 * в том, чтобы его заметили, пролистывая длинный групповой чат.
 */
.mention {
  color: var(--accent, #4f8cff);
  font-weight: 600;
}

.mention-me {
  background: rgba(79, 140, 255, 0.18);
  border-radius: 4px;
  padding: 0 3px;
}

/* Подсказка при наборе «@» — над полем ввода */
.mention-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 200px;
  max-width: 320px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 2px;
}

.mention-option {
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.mention-option:hover,
.mention-option.is-active { background: rgba(79, 140, 255, 0.16); }

/*
 * Карточка геопозиции.
 *
 * Без картинки карты: чтобы её показать, пришлось бы ходить за
 * изображением к стороннему сервису, а тот узнавал бы координаты
 * и адрес получателя. В мессенджере, где переписка зашифрована,
 * это было бы странно. Координаты и две кнопки решают ту же задачу.
 */
.location-card {
  display: grid;
  gap: 10px;
  min-width: 190px;
}

.location-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.location-pin { font-size: 20px; }

.location-coords {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.location-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.location-open {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.location-open.primary {
  background: rgba(255, 255, 255, 0.18);
  border-color: transparent;
  font-weight: 600;
}

.location-open:hover { background: rgba(255, 255, 255, 0.28); }

/* ===== composer.css ===== */
.composer-shell {
  position: relative;
  flex: 0 0 auto;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  z-index: 6;
}

.composer-meta {
  min-height: 16px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-hint,
.composer-status {
  font-size: 12px;
  line-height: 1.3;
}

.composer-hint {
  color: var(--muted);
}

.composer-status {
  color: var(--reply-accent);
  text-align: right;
  min-width: 120px;
}

.reply-bar,
.forward-bar {
  display: grid;
  grid-template-columns: 3px 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.reply-bar-line {
  height: 100%;
  border-radius: 999px;
  background: var(--reply-accent);
}

.reply-bar-content {
  min-width: 0;
}

.reply-bar-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--reply-accent);
}

.reply-bar-text {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-input-wrap {
  min-width: 0;
  display: flex;
  align-items: flex-end;
}

.message-input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  max-height: 160px;
  padding: 11px 16px;
  border-radius: 22px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: 0.15s ease;
  font-size: 15px;
  font: inherit;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
  display: block;
}

.message-input:focus {
  border-color: var(--primary);
}

.composer-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: flex-end;
}

.voice-recorder {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  padding: 12px 14px;
}

.voice-recorder-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.voice-recorder-title {
  font-size: 13px;
  font-weight: 700;
}

.voice-recorder-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.voice-recorder-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.12);
  animation: pulseDot 1.2s infinite;
}

.voice-preview-play {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.1);
  color: var(--text);
  flex: 0 0 36px;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

.voice-preview-play:disabled {
  cursor: default;
  opacity: 0.42;
}

.voice-preview-play.ready:not(:disabled):hover,
.voice-preview-play.is-playing {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--primary) 28%, rgba(255,255,255,0.12));
}

.voice-preview-play .icon {
  width: 18px;
  height: 18px;
}

.voice-preview-wave {
  width: min(260px, 38vw);
}

.voice-recorder.is-preview-playing .voice-preview-wave span {
  animation: voiceWavePulse 0.84s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 45ms);
  opacity: 0.85;
}

.voice-recorder.is-preview-playing .voice-preview-wave span:nth-child(2n) {
  animation-delay: 80ms;
}

.voice-recorder.is-preview-playing .voice-preview-wave span:nth-child(3n) {
  animation-delay: 140ms;
}

@keyframes voiceWavePulse {
  0%, 100% { transform: scaleY(0.72); }
  50% { transform: scaleY(1.18); }
}

@keyframes pulseDot {
  0% { transform: scale(1); opacity: 1; }
  70% { transform: scale(1.2); opacity: .55; }
  100% { transform: scale(1); opacity: 1; }
}

.record-time {
  min-width: 48px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.emoji-panel {
  position: absolute;
  left: 18px;
  bottom: calc(100% + 10px);
  border-radius: 20px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  z-index: 12;
}

.emoji-panel button {
  border: 0;
  background: var(--hover);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 20px;
}

/* ===== reactions.css ===== */
.reply-preview {
  display: grid;
  grid-template-columns: 4px 1fr;
  gap: 10px;
  border-radius: 14px;
  background: rgba(255,255,255,0.07);
  padding: 8px 10px;
  margin-bottom: 10px;
}

.reply-line,
.reply-bar-line {
  background: var(--reply-accent);
  border-radius: 999px;
}

.reply-label,
.reply-bar-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--reply-accent);
}

.reply-snippet,
.reply-bar-text {
  font-size: 13px;
  color: rgba(229, 238, 252, 0.86);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.forward-bar,
.reply-bar {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 10px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  padding: 10px 12px;
}

.reply-bar-content {
  min-width: 0;
}

.forward-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--reply-accent);
  font-size: 12px;
  font-weight: 700;
}

.forward-name {
  opacity: .9;
}

.reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.reactions-row:empty {
  display: none;
}

/* Чипы реакций под сообщением — как в Telegram: пилюля,
   своя реакция залита синим */
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  border: 0;
  color: var(--reply-accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: 0.15s ease;
}

.reaction-chip:hover {
  background: color-mix(in srgb, var(--primary) 26%, transparent);
}

.reaction-chip.mine {
  background: var(--primary);
  color: #fff;
}

/* Кнопка быстрой реакции у угла пузыря — появляется при наведении,
   как в Telegram Desktop */
.quick-react-corner {
  position: absolute;
  bottom: -2px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  font-size: 15px;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease, filter 0.15s ease;
  pointer-events: none;
  filter: grayscale(1) opacity(0.85);
  z-index: 3;
}

.message.them .quick-react-corner {
  right: -38px;
}

.message.me .quick-react-corner {
  left: -38px;
}

.message:hover .quick-react-corner {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.quick-react-corner:hover {
  filter: none;
  transform: scale(1.15);
}

/* ===== drawers.css ===== */
/*
 * Панели во весь экран.
 *
 * dvh, а не vh: на телефоне vh считается по экрану без учёта адресной
 * строки и системных полос, и низ панели — где как раз стоят кнопки
 * «Сохранить» и «Выйти» — оказывался под ними.
 */
.calls-drawer,
.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 94vw);
  height: 100vh;
  height: 100dvh;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 55;
  display: flex;
  flex-direction: column;
}

.drawer-head-spacer { width: 34px; }
.privacy-note { display:flex; gap:14px; align-items:center; padding:14px; background:color-mix(in srgb, var(--primary) 12%, var(--surface)); border-radius:8px; color:var(--primary); }
.privacy-note .icon { width:24px; height:24px; flex:0 0 auto; }
.privacy-note div { display:grid; gap:3px; }
.privacy-note span, .settings-select-row small, .settings-action-row small { display:block; color:var(--muted); font-size:12px; line-height:1.4; }
.settings-select-row { grid-template-columns:minmax(0,1fr) minmax(118px, auto); align-items:center; padding:8px 0; }
.settings-select-row select { appearance:none; -webkit-appearance:none; min-width:118px; height:42px; border:1px solid rgba(148, 163, 184, 0.12); background-color:var(--surface-2); background-image:linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position:calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size:5px 5px, 5px 5px; background-repeat:no-repeat; color:var(--text); border-radius:8px; padding:0 34px 0 12px; outline:none; }
.settings-select-row select:focus { border-color:rgba(79, 140, 255, 0.4); box-shadow:0 0 0 4px rgba(79, 140, 255, 0.08); }
.settings-action-row { height:auto; min-height:54px; display:flex; justify-content:space-between; align-items:center; }
.devices-list { display:grid; }
.device-row { display:grid; grid-template-columns:38px minmax(0,1fr) auto; gap:10px; align-items:center; padding:11px 0; border-bottom:1px solid var(--line); }
.device-row:last-child { border-bottom:0; }
.device-icon { width:36px; height:36px; border-radius:50%; display:grid; place-items:center; background:color-mix(in srgb, var(--primary) 16%, transparent); color:var(--primary); font-weight:800; }
.device-meta { min-width:0; display:grid; gap:3px; }
.device-meta b, .device-meta span { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.device-meta span { color:var(--muted); font-size:12px; }
.device-remove { border:0; background:transparent; color:var(--danger); cursor:pointer; font-weight:700; }
.settings-action-value { color:var(--muted); font-size:13px; font-weight:700; }
.blocked-users-list { display:grid; }
.blocked-user-row { display:grid; grid-template-columns:42px minmax(0,1fr) auto; gap:11px; align-items:center; padding:10px 0; border-bottom:1px solid var(--line); }
.blocked-user-row:last-child { border-bottom:0; }
.blocked-user-meta { min-width:0; display:grid; gap:3px; }
.blocked-user-meta b, .blocked-user-meta span { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.blocked-user-meta span { color:var(--muted); font-size:12px; }
.blocked-user-remove { min-height:36px; border:0; background:transparent; color:var(--danger); cursor:pointer; font-weight:700; padding:6px 4px; }
.blocked-user-remove:disabled { opacity:.55; cursor:wait; }
.settings-inline-note { color:var(--muted); font-size:12px; line-height:1.5; padding:0 2px; }
.password-form { gap:14px; }
.settings-form-error { color:var(--danger); font-size:13px; line-height:1.4; }
.media-storage-summary { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.media-storage-summary > div { min-width:0; display:grid; gap:3px; }
.media-storage-summary b { font-size:22px; }
.media-storage-summary span { color:var(--muted); font-size:12px; }
.media-storage-track { height:6px; overflow:hidden; border-radius:4px; background:var(--surface-2); }
.media-storage-track span { display:block; width:0; height:100%; background:var(--primary); transition:width .2s ease; }
.admin-users-list { display:grid; gap:10px; }
.admin-user-row { display:grid; gap:10px; padding:10px 0; border-bottom:1px solid var(--line); }
.admin-user-row:last-child { border-bottom:0; }
/*
 * Три колонки, а не две: галочка рассылки, аватар и текст. Раньше колонок
 * было две, третий элемент переносился на новую строку в колонку шириной
 * 40 пикселей — весь текст карточки сжимался в узкую полосу.
 */
.admin-user-main {
  min-width:0; display:grid;
  grid-template-columns:auto 40px minmax(0,1fr);
  gap:10px; align-items:center;
}
.admin-user-avatar { width:40px; height:40px; border-radius:50%; display:grid; place-items:center; background:color-mix(in srgb, var(--primary) 18%, var(--surface-2)); color:var(--primary); font-weight:800; }
.admin-user-meta { min-width:0; display:grid; gap:3px; }
/*
 * В одну строку с многоточием сжимаем только логин: он бывает длинным
 * и ломает сетку. Остальное переносится — раньше обрезалось всё подряд,
 * и карточка показывала «va...», «Адми...», «Регис...» вместо данных.
 */
.admin-user-meta b { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.admin-user-meta span, .admin-user-meta small {
  color:var(--muted); font-size:12px; line-height:1.4;
  white-space:normal; overflow-wrap:anywhere;
}
.admin-user-actions { display:flex; gap:8px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }
.admin-role-select { appearance:none; -webkit-appearance:none; min-height:36px; border:1px solid var(--line); border-radius:8px; background-color:var(--surface-2); background-image:linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position:calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size:5px 5px, 5px 5px; background-repeat:no-repeat; color:var(--text); padding:0 34px 0 8px; outline:none; }
.admin-role-select:focus { border-color:rgba(79, 140, 255, 0.4); box-shadow:0 0 0 4px rgba(79, 140, 255, 0.08); }
.admin-role-pill { min-height:32px; display:inline-flex; align-items:center; padding:0 10px; border-radius:999px; background:color-mix(in srgb, var(--primary) 14%, transparent); color:var(--primary); font-size:12px; font-weight:800; }
.admin-user-details { display:grid; gap:12px; padding:12px; border-radius:8px; background:var(--surface-2); border:1px solid var(--line); }
.admin-user-details.hidden { display:none; }
.admin-details-grid { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:8px; }
.admin-details-grid > div { min-width:0; display:grid; gap:3px; padding:8px; border-radius:6px; background:color-mix(in srgb, var(--surface) 70%, transparent); }
.admin-details-grid span { color:var(--muted); font-size:11px; font-weight:700; text-transform:uppercase; }
.admin-details-grid b, .admin-user-agent { min-width:0; color:var(--text); font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.admin-user-agent { padding:8px; border-radius:6px; background:color-mix(in srgb, var(--surface) 70%, transparent); color:var(--muted); }
.admin-details-form { display:grid; gap:10px; }
.admin-details-actions { display:flex; align-items:center; justify-content:flex-end; gap:8px; flex-wrap:wrap; }
.admin-reports-list { display:grid; gap:10px; }
.admin-report-row { display:grid; gap:10px; padding:12px; border:1px solid var(--line); border-radius:8px; background:var(--surface-2); }
.admin-report-head { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; }
.admin-report-meta { min-width:0; display:grid; gap:3px; }
.admin-report-meta b, .admin-report-meta span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.admin-report-meta span, .admin-report-footer span { color:var(--muted); font-size:12px; }
.admin-report-status { flex:0 0 auto; min-height:28px; display:inline-flex; align-items:center; border-radius:999px; padding:0 9px; background:color-mix(in srgb, var(--primary) 14%, transparent); color:var(--primary); font-size:12px; font-weight:800; }
.admin-report-description { color:var(--text); font-size:13px; line-height:1.45; overflow-wrap:anywhere; }
.admin-report-actions, .admin-report-footer { display:flex; align-items:center; justify-content:space-between; gap:8px; flex-wrap:wrap; }
.admin-report-note { gap:6px; }
.report-screenshot-preview { border:1px solid var(--line); border-radius:8px; overflow:hidden; background:var(--surface-2); }
.report-screenshot-preview img { display:block; width:100%; max-height:260px; object-fit:contain; }

.settings-drawer-head,
.calls-drawer-head {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.settings-title,
.calls-title {
  font-size: 18px;
  font-weight: 800;
}

.settings-content {
  padding: 14px;
  /* Последняя кнопка списка не должна упираться в системные кнопки */
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 18px;
  overflow-y: auto;
}

.settings-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  border: 1px solid var(--line);
}

.settings-group-title {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.settings-field {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

/*
 * Подсказка под подписью, а не в строку с ней.
 *
 * Такое правило было только для settings-select-row — раскладки
 * «подпись слева, поле справа». Настройки, которые рисуются по
 * описанию с сервера, ставят подпись сверху, и без этого правила
 * подсказка приклеивалась к названию: «Служба рассылкиПока служба...».
 */
.settings-field > span > small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  font-weight: 400;
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.settings-toggle-title {
  font-size: 14px;
  font-weight: 700;
}

.settings-toggle-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.settings-toggle {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 46px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  outline: none;
  transition: background 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.settings-toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transition: transform 0.16s ease, background 0.16s ease;
}

.settings-toggle:checked {
  background: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 72%, white);
}

.settings-toggle:checked::after {
  transform: translateX(20px);
  background: #fff;
}

.settings-toggle:focus-visible {
  box-shadow: inset 0 0 0 1px var(--primary), 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent);
}

.settings-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-action {
  height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 8px;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 600;
}

/* Контекстное меню сообщения в стиле Telegram:
   ряд реакций сверху, компактные пункты с иконками */
.message-action-menu {
  position: fixed;
  min-width: 200px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(20px);
  z-index: 80;
  animation: menuPop 0.12s ease;
  transform-origin: top left;
}

@keyframes menuPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.menu-reactions-row {
  display: flex;
  gap: 2px;
  padding: 2px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.menu-reaction {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 19px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, background 0.12s ease;
  padding: 0;
}

.menu-reaction:hover {
  transform: scale(1.25);
}

.menu-reaction.active {
  background: color-mix(in srgb, var(--primary) 24%, transparent);
}

.message-action-menu .menu-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  align-items: center;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.message-action-menu .menu-item svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.message-action-menu .menu-item:hover {
  background: var(--hover);
}

.message-action-menu .menu-item.danger,
.message-action-menu .menu-item.danger svg {
  color: var(--danger);
}

.message-action-menu .hidden {
  display: none !important;
}

.me-block-button {
  cursor: pointer;
}

.me-block-button:focus-visible {
  outline: 2px solid rgba(79, 140, 255, 0.45);
  outline-offset: 6px;
  border-radius: 8px;
}

.settings-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  border: 1px solid var(--line);
}

.settings-profile-meta {
  min-width: 0;
}

.settings-profile-name {
  font-size: 16px;
  font-weight: 800;
}

.settings-profile-subtitle,
.settings-inline-hint,
.settings-empty-state,
.group-member-status {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.avatar.xlarge {
  width: 72px;
  height: 72px;
  border-radius: 24px;
}

.settings-input,
.settings-textarea {
  width: 100%;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

.settings-input:focus,
.settings-textarea:focus {
  border-color: rgba(79, 140, 255, 0.35);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.08);
}

.settings-textarea {
  resize: vertical;
  min-height: 108px;
}

.settings-primary-action {
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #4f8cff 0%, #2f6dff 100%);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.settings-primary-action:disabled,
.small-action:disabled {
  opacity: 0.55;
  cursor: default;
}

.settings-modal-card {
  width: min(100%, 520px);
}

.settings-modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

.member-picker-list,
.group-members-list {
  display: grid;
  gap: 0;
}

.member-picker-item,
.group-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.member-picker-item:last-child,
.group-member-row:last-child {
  border-bottom: 0;
}

.member-picker-item {
  justify-content: flex-start;
  cursor: pointer;
}

.member-picker-item input {
  accent-color: #4f8cff;
}

.member-picker-name {
  font-size: 14px;
  font-weight: 600;
}

.group-member-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.group-member-avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(79, 140, 255, 0.18);
  color: var(--text);
  font-weight: 800;
  flex: 0 0 38px;
}

.group-member-meta {
  min-width: 0;
}

.group-member-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.group-member-name {
  font-size: 14px;
  font-weight: 700;
}

.group-role-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.14);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.small-action {
  height: 36px;
  padding: 0 12px;
}

.fingerprint-block {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  word-break: break-all;
  user-select: all;
}

.fingerprint-list {
  display: grid;
  gap: 10px;
}

.fingerprint-device {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.fingerprint-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.encryption-hint {
  line-height: 1.5;
}

.direct-info-profile { align-items: flex-start; }
.direct-info-bio { margin-top: 8px; color: var(--text); font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.direct-info-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.direct-info-action { min-width: 0; min-height: 68px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--primary); display: grid; place-items: center; align-content: center; gap: 6px; cursor: pointer; font-size: 12px; }
.direct-info-action .icon { width: 21px; height: 21px; }
.direct-info-action.active { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.direct-media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.direct-media-thumb { aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--surface-2); }
.direct-media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.direct-media-file { grid-column: 1 / -1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 6px; background: var(--surface-2); color: var(--text); text-decoration: none; }
.direct-media-file .icon { width: 20px; height: 20px; flex: 0 0 auto; color: var(--primary); }
.direct-media-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.direct-media-empty { grid-column: 1 / -1; }
.direct-danger-action { display: flex; align-items: center; gap: 10px; color: var(--danger); }
.direct-danger-action .icon { width: 19px; height: 19px; }
.direct-danger-action.is-blocked { color: var(--primary); }


/* --- Приглашения в админке --- */

.invite-create-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.invite-result {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.invite-result.hidden {
  display: none;
}

/* QR приходит как SVG — задаём размер контейнеру, а не картинке */
.invite-qr {
  width: 200px;
  height: 200px;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
}

.invite-qr svg {
  width: 100%;
  height: 100%;
  display: block;
}

.invite-code-value {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--text);
  user-select: all;
}

.invite-link {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  text-align: center;
}

.invites-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 12px;
}

.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.invite-row-code {
  font-family: "JetBrains Mono", Consolas, monospace;
  color: var(--text);
}

.invite-row-meta {
  color: var(--muted);
  font-size: 12px;
}

.invite-row.is-inactive .invite-row-code {
  text-decoration: line-through;
  opacity: 0.6;
}

/* --- Модерация: дата регистрации и выбор получателей --- */

.admin-user-select {
  margin-right: 10px;
  flex: 0 0 auto;
}

.admin-user-dates {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* Явный признак того, что приглашение только что создано */
.invite-created-mark {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin-bottom: 8px;
}

/* Точечные разрешения: писать, слать файлы, звонить */
.admin-perms-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 13px;
}

.admin-perms-label {
  color: var(--muted);
}

.admin-perm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

/* Снятая галочка — действующее ограничение, его видно сразу */
.admin-perm:has(input:not(:checked)) {
  color: var(--danger);
}

.admin-perm input {
  cursor: pointer;
}

.admin-wipe-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}


/* --- Режим администратора --- */

/*
 * Админка была узкой боковой шторкой: таблицы пользователей и жалоб
 * в 360 пикселей не помещались. Теперь это отдельный полноэкранный слой,
 * а мессенджер остаётся под ним нетронутым — переключение мгновенное
 * и не теряет открытый чат.
 */
.admin-console {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.admin-console.hidden {
  display: none;
}

.admin-console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.admin-console-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.admin-console-title .icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.admin-console-exit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.admin-console-exit:hover {
  background: var(--hover);
}

.admin-console-exit .icon {
  width: 16px;
  height: 16px;
}

/* Секции раскладываются в колонки — на широком экране их видно разом */
.admin-console-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 24px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  align-items: start;
  gap: 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.admin-console-body .settings-group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  margin: 0;
}

/* Списки внутри режима не должны растягивать страницу до бесконечности */
.admin-console-body .admin-users-list,
.admin-console-body .admin-reports-list,
.admin-console-body .invites-list {
  max-height: 460px;
  overflow-y: auto;
}

/* Кнопка режима подсвечивается, когда режим активен */
.mode-toggle.is-active {
  color: var(--primary);
  background: var(--accent-soft, rgba(82, 136, 193, 0.14));
}

.mode-toggle.hidden {
  display: none;
}

@media (max-width: 720px) {
  .admin-console-head {
    padding: 12px 14px;
  }

  .admin-console-exit span {
    display: none;
  }

  .admin-console-body {
    padding: 14px;
    grid-template-columns: 1fr;
  }
}


/* --- Помощь с паролем в настройках (те же классы, что на странице входа) --- */

.password-form .password-strength {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: -4px;
}

.password-form .password-strength-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.password-form .password-strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 160ms ease, background-color 160ms ease;
}

.password-form .password-strength-text {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.password-form .password-generate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.password-form .password-gen-btn {
  padding: 7px 13px;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12.5px;
  cursor: pointer;
}

.password-form .password-gen-btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.password-form .password-gen-btn.hidden {
  display: none;
}

.password-form .password-save-hint {
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.password-form .password-save-hint.hidden {
  display: none;
}

/* Сгенерированный пароль показываем открыто и моноширинным */
.password-form.is-generated #newPasswordInput,
.password-form.is-generated #confirmPasswordInput {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
}

/* Ссылка-приглашение в группу: код с пояснением слева, кнопки справа */
.invite-row-main { min-width: 0; display: grid; gap: 2px; }
.invite-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.invite-row-actions .settings-action { width: auto; padding: 6px 10px; font-size: 12px; }

/*
 * «Фото и файлы» — список вложений чата.
 *
 * Фото и видео — плиткой с предпросмотром, остальное — списком:
 * у документа или голосового показывать нечего, и в плитке они
 * выглядели бы одинаковыми пустыми квадратами.
 */
.chat-media-list {
  display: grid;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
}

.chat-media-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
}

.chat-media-row:hover { background: var(--surface-2); }

.chat-media-thumb {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 18px;
  overflow: hidden;
}

.chat-media-thumb img { width: 100%; height: 100%; object-fit: cover; }

.chat-media-main { min-width: 0; }

.chat-media-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-media-time { font-size: 11px; color: var(--muted); }

/* Управление памятью: раздел, объём и доля от общего */
.storage-breakdown { display: grid; gap: 12px; margin: 10px 0 12px; }

.storage-row { display: grid; gap: 4px; }

.storage-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
}

.storage-row-name { color: var(--text); }

.storage-row-size {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.storage-row-count { font-size: 11px; color: var(--muted); }

/*
 * Вкладки файлового раздела.
 *
 * Прокручиваются вбок: шесть названий в узкую панель не помещаются,
 * а переносить их в две строки — терять место, которого и так мало.
 * Пустые разделы отключены, но видны: так понятно, что их искать
 * не надо, и не создаётся ощущение, что чего-то не хватает.
 */
.media-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 6px;
  scrollbar-width: none;
}

.media-tabs::-webkit-scrollbar { display: none; }

.media-tab {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.media-tab span {
  opacity: 0.7;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.media-tab:hover:not(:disabled) { background: var(--surface-2); }

.media-tab.is-active {
  background: rgba(79, 140, 255, 0.16);
  color: var(--text);
  font-weight: 600;
}

.media-tab:disabled { opacity: 0.35; cursor: default; }

/*
 * Плитка предпросмотра — разделы «Фото» и «Видео».
 *
 * Три в ряд: при ширине панели около 300 пикселей это плитка примерно
 * в сто, на которой лицо или документ уже узнаваемы. Четыре в ряд
 * превращают снимки в неразличимые марки.
 */
.chat-media-list.is-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  max-height: 360px;
}

.media-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
  cursor: pointer;
  display: block;
}

.media-tile:hover { filter: brightness(1.06); }

.media-tile:focus-visible {
  outline: 2px solid var(--accent, #4f8cff);
  outline-offset: 2px;
}

/* Значок до предпросмотра и картинка после него живут в одном месте */
.media-tile-fill {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  opacity: 0.55;
}

.media-tile-fill img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-tile.has-preview .media-tile-fill { opacity: 1; }

/*
 * Пока идёт расшифровка — тихое мерцание.
 *
 * Крутящийся значок на каждой из двадцати плиток превращает панель
 * в рябь, а понять по нему всё равно нечего.
 */
.media-tile.is-loading .media-tile-fill { animation: media-tile-pulse 1.2s ease-in-out infinite; }

@keyframes media-tile-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
  .media-tile.is-loading .media-tile-fill { animation: none; }
}

.media-tile.is-failed .media-tile-fill { opacity: 0.25; }

/* Подписи поверх снимка: тень нужна, потому что кадр под ними любой */
.media-tile-stamp,
.media-tile-duration {
  position: absolute;
  bottom: 3px;
  font-size: 10px;
  line-height: 1.3;
  color: #fff;
  padding: 1px 4px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.45);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.media-tile-stamp { left: 3px; }
.media-tile-duration { right: 3px; }
.media-tile-duration:empty { display: none; }

/* Треугольник проигрывания: отличает видео от снимка ещё до кадра */
.media-tile-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 11px;
  padding-left: 2px;
  pointer-events: none;
}


/* Ссылка в списке файлов не должна выглядеть как обычная подпись */
a.chat-media-name { color: var(--accent, #4f8cff); text-decoration: none; }
a.chat-media-name:hover { text-decoration: underline; }

/* ===== call.css ===== */
.call-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.5);
  display: grid;
  place-items: center;
  z-index: 50;
}

.call-card {
  width: min(92vw, 360px);
  padding: 22px;
  background: rgba(10, 16, 29, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-align: center;
}

.call-card.video-call { width:min(96vw,760px); }
.call-video-stage { position:relative; width:100%; aspect-ratio:16/9; margin:14px 0 12px; overflow:hidden; border-radius:8px; background:#05080f; }
.call-remote-video { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; z-index:2; }
.call-video-placeholder { position:absolute; inset:0; display:grid; place-items:center; color:var(--muted); z-index:1; }
.call-video-placeholder .icon { width:54px; height:54px; }
.call-local-video { position:absolute; right:12px; bottom:12px; width:min(26%,170px); aspect-ratio:3/4; object-fit:cover; border-radius:8px; border:2px solid rgba(255,255,255,.75); background:#111827; z-index:3; }
.call-local-video.camera-off { opacity:.18; }

/*
 * Обмен местами: нажатие на маленькое окно делает его большим.
 *
 * Меняются роли, а не потоки: каждый элемент остаётся при своём
 * видео, переставляются только размер и положение. Подмена srcObject
 * перезапустила бы воспроизведение, и картинка моргала бы на каждое
 * нажатие.
 */
.call-video-stage.swapped .call-local-video {
  inset:0; right:auto; bottom:auto;
  width:100%; height:100%;
  aspect-ratio:auto;
  border:0; border-radius:0;
  z-index:2;
}

.call-video-stage.swapped .call-remote-video {
  inset:auto; right:12px; bottom:12px;
  width:min(26%,170px); height:auto;
  aspect-ratio:3/4;
  border:2px solid rgba(255,255,255,.75); border-radius:8px;
  background:#111827;
  z-index:3;
}

/* Видно, что по картинке можно нажать */
.call-remote-video, .call-local-video { cursor:pointer; }
.call-card.video-call .call-avatar { display:none; }
.call-card.minimized .call-video-stage { display:none; }

.call-card.minimized {
  width: 260px;
  padding: 16px;
}

.call-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.call-state {
  color: var(--reply-accent);
  font-size: 14px;
}

.call-avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #28467d, #17305c);
  margin: 16px auto 14px;
  color: #fff;
}

.call-name {
  font-size: 24px;
  font-weight: 800;
}

.call-subtitle {
  margin-top: 6px;
  color: var(--muted);
}

.call-timer {
  margin-top: 14px;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.call-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 22px;
}

.calls-list {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.call-log-item {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  margin-bottom: 8px;
}

@media (max-width:640px) {
  .call-card.video-call { width:100vw; min-height:100dvh; border:0; border-radius:0; display:flex; flex-direction:column; justify-content:center; }
  .call-video-stage { aspect-ratio:3/4; max-height:62vh; }
  .call-local-video { width:28%; right:8px; bottom:8px; }
  .call-video-stage.swapped .call-remote-video { width:28%; right:8px; bottom:8px; }
  .call-video-stage.swapped .call-local-video { width:100%; right:auto; bottom:auto; }
  .call-log-item { grid-template-columns:40px minmax(0,1fr) auto; gap:9px; }
  .call-log-time { display:none; }
}

.call-log-avatar { width:40px; height:40px; border-radius:50%; display:grid; place-items:center; background:color-mix(in srgb, var(--primary) 18%, transparent); color:var(--primary); font-weight:800; }
.call-log-main { min-width:0; }
.call-log-name { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.call-log-item.is-missed .call-log-meta { color:var(--danger); }
.call-log-redial { width:38px; height:38px; border:0; border-radius:50%; display:grid; place-items:center; background:transparent; color:var(--primary); cursor:pointer; }
.call-log-redial:hover { background:color-mix(in srgb, var(--primary) 12%, transparent); }
.call-log-redial .icon { width:19px; height:19px; }
.badge-button { position:relative; }
.button-badge { position:absolute; top:-4px; right:-4px; min-width:18px; height:18px; padding:0 5px; border-radius:9px; display:grid; place-items:center; background:var(--danger); color:#fff; font-size:11px; font-weight:800; border:2px solid var(--panel); }

.call-log-name {
  font-weight: 700;
}

.call-log-meta,
.call-log-time,
.calls-empty {
  color: var(--muted);
  font-size: 13px;
}


/* --- Групповой звонок (mesh) --- */

.group-call-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
}

.group-call-modal.hidden {
  display: none;
}

.group-call-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.group-call-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.group-call-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  align-content: start;
  overflow-y: auto;
}

.group-call-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
}

.group-call-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* В аудиозвонке видео нет — показываем только подпись */
.group-call-tile.audio-only video {
  display: none;
}

.group-call-tile.audio-only::before {
  content: '🎤';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  opacity: 0.5;
}

.group-call-name {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--date-pill-bg);
  color: var(--date-pill-text);
  font-size: 12px;
}

.group-call-join {
  align-self: center;
  margin: 6px auto;
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.group-call-join.hidden {
  display: none;
}

/*
 * Выключенное состояние кнопок в звонке.
 *
 * Прежде оно обозначалось только прозрачностью и на глаз не читалось.
 * Теперь заливка, рамка и цвет значка меняются разом — состояние видно
 * с одного взгляда, не приглядываясь.
 */
.call-actions .ghost-circle.is-off {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.call-actions .ghost-circle.is-off .icon {
  color: var(--danger);
}

.call-actions .ghost-circle:not(.is-off) {
  /* Включённое состояние тоже делаем явным, а не «просто кнопкой» */
  background: color-mix(in srgb, var(--text) 10%, transparent);
  border: 1px solid transparent;
  color: var(--text);
}

.call-actions .ghost-circle:disabled {
  /* Недоступно — приглушаем, но состояние всё равно читается по значку */
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== safety.css ===== */
/*
 * Блокировка приложения, предупреждения безопасности, папки чатов,
 * выбор аудиоустройств и поиск по номеру.
 *
 * Собраны в одном файле не по признаку внешнего вида, а по признаку
 * времени жизни: всё это появилось вместе и правится вместе.
 */

/*
 * Экран блокировки.
 *
 * Кроет всё, включая панели настроек, поэтому z-index выше их. Фон
 * непрозрачный: размытие поверх переписки выглядит красивее, но
 * читаемые куски сообщений сквозь него — ровно то, что блокировка
 * должна скрыть.
 */
.app-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Карточка не должна попадать под вырез и под системные кнопки */
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--bg, #14161a);
}

.app-lock-card {
  width: 100%;
  max-width: 320px;
  display: grid;
  gap: 10px;
  padding: 22px;
  border-radius: 16px;
  background: var(--surface-1, #1b1e24);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.app-lock-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.app-lock-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

/* Код набирают, а не читают: разрядка помогает не сбиться */
.app-lock-input {
  text-align: center;
  letter-spacing: 6px;
  font-size: 18px;
}

.app-lock-error {
  min-height: 16px;
  font-size: 12px;
  color: var(--danger, #ff6b6b);
}

.app-lock-forgot {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}

/*
 * Полоса «новое устройство».
 *
 * Сверху и по центру: это единственное сообщение в приложении, ради
 * которого человека стоит отвлечь от переписки.
 *
 * Поверх панелей настроек — намеренно. Сначала она была под ними, и
 * открытая панель наезжала на неё, срезая как раз кнопки «это я» и
 * «завершить сеанс». Предупреждение, у которого не видно действий,
 * бесполезно; экран блокировки при этом всё равно выше — под ним
 * показывать нечего.
 */
.security-alert-bar {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 24px));
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--warning-border, rgba(255, 176, 32, 0.4));
  background: var(--surface-1, #1b1e24);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.security-alert-bar .icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--warning, #ffb020);
}

.security-alert-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
}

.security-alert-text span {
  font-size: 12px;
  color: var(--muted);
}

.security-alert-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.security-alert-actions .settings-action {
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
}

/* Точка на строке «Устройства», пока предупреждение не подтверждено */
.settings-action-row.has-alert {
  position: relative;
}

.settings-action-row.has-alert::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 26px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger, #ff6b6b);
}

@media (max-width: 560px) {
  /* На телефоне полоса разворачивается: кнопки в строку не влезают */
  .security-alert-bar {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .security-alert-text {
    flex: 1 1 100%;
    order: 1;
  }
}

/* --- Папки чатов --- */

.folder-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.folder-add-row .settings-input { flex: 1 1 auto; }

.folder-add-row .settings-primary-action,
.folder-add-row .settings-action {
  width: auto;
  flex: 0 0 auto;
  padding: 8px 14px;
}

.folder-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--surface-2);
}

.folder-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.folder-card-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.folder-card-title small {
  font-size: 11px;
  color: var(--muted);
}

.folder-card-actions {
  display: flex;
  gap: 6px;
}

.folder-card-actions .settings-action {
  width: auto;
  padding: 5px 10px;
  font-size: 12px;
}

/*
 * Список чатов папки прокручивается.
 *
 * Иначе шестьдесят чатов растягивают карточку папки на весь экран,
 * и остальные папки уезжают из вида.
 */
.folder-chat-list {
  max-height: 240px;
  overflow-y: auto;
  display: grid;
  gap: 2px;
  padding-top: 4px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}

.folder-chat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.folder-chat-row:hover { background: var(--surface-1); }

.folder-chat-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Проверка микрофона --- */

.mic-level-track {
  height: 6px;
  margin: 8px 0 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.mic-level-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent, #4f8cff);
  /* Короткий переход, чтобы полоска не дёргалась на каждом кадре */
  transition: width 80ms linear;
}

/* --- Поиск по номеру --- */

.phone-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  margin-top: 6px;
  border-radius: 10px;
  background: var(--surface-2);
  flex-wrap: wrap;
}

.phone-result-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.phone-result-main small {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.phone-result-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.phone-result-actions .settings-action {
  width: auto;
  padding: 5px 10px;
  font-size: 12px;
}

/* Ввод номеров — многострочный, но без ручного изменения размера */
#phoneLookupInput {
  resize: vertical;
  min-height: 64px;
  font-family: inherit;
}

/* ===== responsive.css ===== */
@media (max-width: 1080px) {
  .app-layout {
    grid-template-columns: 320px 1fr;
  }

  .message-bubble {
    max-width: min(78%, 640px);
  }
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: 100%;
    max-height: 100%;
  }

  .chat-area {
    display: none;
  }

  .chat-body.chat-open .sidebar {
    display: none;
  }

  .chat-body.chat-open .chat-area {
    display: flex;
  }

  .calls-drawer,
  .settings-drawer {
    width: 100vw;
  }

  .chat-back-button {
    display: inline-flex;
  }

  .chat-actions {
    gap: 6px;
  }
}


@media (max-width: 640px) {
  .settings-drawer-head .ghost-icon.small,
  .calls-drawer-head .ghost-icon.small {
    width: 40px;
    height: 40px;
    min-width: 40px;
    flex: 0 0 40px;
  }

  .blocked-user-remove { min-height:44px; }

  .drawer-head-spacer {
    width: 40px;
  }

  .settings-select-row select {
    min-height: 40px;
  }

  .sidebar-top {
    padding: 12px 10px 10px;
  }

  .sidebar-body {
    padding: 10px 8px 8px;
  }

  .online-user-chip {
    width: 62px;
    min-width: 62px;
  }

  .online-user-chip .avatar {
    width: 50px;
    height: 50px;
  }

  .chat-header,
  .chat-toolbar,
  .messages,
  .composer-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .chat-toolbar {
    padding-top: 8px;
  }

  .composer-row {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 8px;
  }

  .message-bubble {
    max-width: 88%;
    border-radius: 18px;
  }

  .voice-recorder {
    align-items: flex-start;
    flex-direction: column;
  }

  .voice-recorder-actions {
    width: 100%;
  }

  .voice-recorder-actions .ghost-chip,
  .voice-recorder-actions .primary-chip {
    flex: 1;
    justify-content: center;
  }

  .ghost-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .primary-send {
    width: 46px;
    height: 46px;
    border-radius: 16px;
  }

  .message-hover-reactions {
    top: -16px;
    left: 10px;
    right: auto;
    max-width: calc(100vw - 120px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .message-hover-reactions::-webkit-scrollbar {
    display: none;
  }

  .message.me .message-hover-reactions {
    right: 38px;
  }

  .quick-reaction-btn {
    min-width: 30px;
    height: 30px;
    font-size: 14px;
  }
}
