/* ==========================================================================
   OPS — общие стили
   ========================================================================== */

:root {
  --bg: #000;
  --surface: #0a0a0a;
  --surface-2: #141414;
  --surface-3: #1c1c1c;
  --border: #262626;
  --border-focus: #3d3d3d;

  --text: #fff;
  --text-2: #a1a1a1;
  --muted: #7a7a7a;
  --placeholder: #666;

  --accent: #1f7bff;
  --danger: #ff5a5f;
  --online: #3ecf6e;

  --radius: 14px;
  --radius-lg: 18px;
  --pill: 999px;

  --sidebar-w: 260px;
  --rail-w: 88px;
  --list-w: 360px;
  --tabbar-h: 64px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; flex-shrink: 0; }

::selection { background: rgba(31, 123, 255, .35); }

/* скроллбар */
* { scrollbar-width: thin; scrollbar-color: #2a2a2a transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

.logo {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
  user-select: none;
}

/* ==========================================================================
   Поля и кнопки
   ========================================================================== */

.field { margin-bottom: 20px; }

.field__label {
  display: block;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 500;
}

.input-wrap { position: relative; }

.input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  outline: none;
  transition: border-color .15s, background-color .15s;
}
.input::placeholder { color: var(--placeholder); }
.input:hover { border-color: #303030; }
.input:focus { border-color: var(--border-focus); background: #0d0d0d; }
.input.is-invalid { border-color: var(--danger); }
.input--with-btn { padding-right: 52px; }

.input-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--muted);
  transition: color .15s;
}
.input-btn:hover { color: var(--text); }

.field__error {
  display: none;
  margin-top: 8px;
  font-size: 13px;
  color: var(--danger);
}
.field__error.is-visible { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border-radius: var(--pill);
  font-size: 16px;
  font-weight: 500;
  transition: opacity .15s, background-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn--primary { background: #fff; color: #000; }
.btn--primary:hover { background: #e9e9e9; }
.btn--ghost { background: var(--surface-3); color: var(--text); }
.btn--ghost:hover { background: #262626; }
.btn--danger { background: var(--surface-3); color: var(--danger); }
.btn--danger:hover { background: #262626; }
.btn--block { width: 100%; }
.btn--sm { height: 40px; padding: 0 18px; font-size: 14px; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Страницы входа / регистрации
   ========================================================================== */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px 32px;
}

.auth__logo { margin-bottom: 64px; }

.auth__card {
  width: 100%;
  max-width: 358px;
  margin: auto 0;
}

.auth__title {
  margin: 0 0 12px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth__subtitle {
  margin: 0 0 40px;
  color: var(--muted);
  font-size: 16px;
}

.auth__forgot {
  display: block;
  margin: -6px 0 36px;
  text-align: right;
  font-size: 14px;
  color: var(--muted);
}
.auth__forgot:hover { color: var(--text); text-decoration: none; }

.auth__terms {
  margin: -4px 0 32px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.auth__footer {
  margin-top: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.auth__alert {
  display: none;
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 90, 95, .1);
  border: 1px solid rgba(255, 90, 95, .3);
  color: #ff8a8d;
  font-size: 14px;
}
.auth__alert.is-visible { display: block; }

@media (max-height: 700px) {
  .auth { padding-top: 28px; }
  .auth__logo { margin-bottom: 36px; }
  .auth__subtitle { margin-bottom: 28px; }
}

/* ==========================================================================
   Приложение
   ========================================================================== */

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- боковое меню ---------- */

/* На компьютере видны только иконки; меню разворачивается поверх содержимого,
   когда курсор наводится на стрелку внизу. */
.app { padding-left: var(--rail-w); }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  padding: 32px 14px 20px;
  background: var(--bg);
  border-right: 1px solid #141414;
  overflow: hidden;
  transition: width .22s ease, box-shadow .22s ease;
}
.sidebar.is-expanded {
  width: var(--sidebar-w);
  box-shadow: 16px 0 48px rgba(0, 0, 0, .65);
}

.sidebar__brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 0 0 0 8px;
  margin-bottom: 36px;
  white-space: nowrap;
}

.sidebar__version {
  font-size: 15px;
  font-weight: 500;
  color: #5c5c5c;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 52px;
  padding: 0 19px;
  white-space: nowrap;
  border-radius: var(--radius-lg);
  color: var(--text-2);
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  transition: background-color .15s, color .15s;
}
.nav__item svg { width: 22px; height: 22px; }
.nav__item:hover { color: var(--text); background: #0f0f0f; }
.nav__item.is-active { color: var(--text); background: var(--surface-3); font-weight: 600; }

.nav__badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--pill);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 22px;
  text-align: center;
}
.nav__badge[hidden] { display: none; }

/* Подписи видны только у развёрнутого меню */
.nav__label,
.sidebar__version {
  opacity: 0;
  transition: opacity .12s;
}
.sidebar.is-expanded .nav__label,
.sidebar.is-expanded .sidebar__version {
  opacity: 1;
  transition-delay: .08s;
}

.nav__badge {
  position: absolute;
  top: 7px;
  left: 36px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 18px;
}
.sidebar.is-expanded .nav__badge { position: static; margin-left: auto; }

.sidebar__logout {
  margin-top: auto;
  font-size: 15px;
  color: var(--muted);
}

.sidebar__toggle {
  margin-top: 4px;
  font-size: 15px;
  color: var(--muted);
}
.sidebar__toggle svg { transition: transform .22s ease; }
.sidebar.is-expanded .sidebar__toggle svg { transform: rotate(180deg); }

/* ---------- основная область ---------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  position: relative;
}

.view {
  flex: 1;
  min-width: 0;
  display: none;
}
.view.is-active { display: flex; }
.view.page.is-active { display: block; }

[hidden] { display: none !important; }
a.nav__item:hover, a.icon-btn:hover { text-decoration: none; }

.view__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 36px 24px 20px;
}

.view__title {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

.page__inner {
  max-width: 680px;
  margin: 0 auto;
  padding-bottom: 32px;
}

.search-box {
  position: relative;
  margin: 0 24px 12px;
}
.search-box svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search-box .input { height: 48px; padding-left: 46px; font-size: 15px; }

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}
.empty__icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
}
.empty__icon svg { width: 30px; height: 30px; }
.empty__title { margin: 0; color: var(--text); font-size: 18px; font-weight: 600; }
.empty__text { margin: 0; max-width: 300px; font-size: 14px; }

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

.avatar {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  user-select: none;
}
.avatar--sm { width: 40px; height: 40px; font-size: 15px; }
.avatar--xl { width: 112px; height: 112px; font-size: 40px; }
.avatar.is-online::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--bg);
}

/* ---------- список (чаты, поиск, уведомления) ---------- */

.list { list-style: none; margin: 0; padding: 0 12px; }

.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  text-align: left;
  transition: background-color .12s;
}
.list-item:hover { background: #0f0f0f; }
.list-item.is-active { background: var(--surface-3); }

.list-item__body { flex: 1; min-width: 0; }

.list-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.list-item__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 15px;
}

.list-item__meta { flex-shrink: 0; font-size: 12px; color: var(--muted); }

.list-item__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3px;
  font-size: 14px;
  color: var(--muted);
}
.list-item__text b { color: var(--text-2); font-weight: 500; }

.unread {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--pill);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}

/* ---------- чаты ---------- */

.chats { flex: 1; min-width: 0; }

.chatlist {
  width: var(--list-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #141414;
}
.chatlist__scroll { flex: 1; overflow-y: auto; padding-bottom: 16px; }

.chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 14px 20px;
  border-bottom: 1px solid #141414;
}
.chat__head-info { flex: 1; min-width: 0; }
.chat__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 16px;
}
.chat__status { font-size: 13px; color: var(--muted); }
.chat__status.is-online { color: var(--online); }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 12px;
  color: var(--text-2);
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }

.chat__back { display: none; margin-left: -8px; }

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 24px;
}

.day-sep {
  align-self: center;
  margin: 12px 0;
  padding: 4px 12px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: min(520px, 78%);
  padding: 9px 14px 7px;
  border-radius: 18px;
  font-size: 15px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  animation: msg-in .18s ease-out;
}
.msg--in { align-self: flex-start; background: var(--surface-3); border-bottom-left-radius: 6px; }
.msg--out { align-self: flex-end; background: #fff; color: #000; border-bottom-right-radius: 6px; }
.msg + .msg--in, .msg + .msg--out { margin-top: 2px; }
.msg--in + .msg--out, .msg--out + .msg--in { margin-top: 10px; }

.msg__time {
  align-self: flex-end;
  margin-top: 2px;
  font-size: 11px;
  opacity: .55;
}

.typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: var(--surface-3);
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-2);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid #141414;
}

.composer__input {
  flex: 1;
  min-height: 48px;
  max-height: 160px;
  padding: 13px 18px;
  resize: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  transition: border-color .15s;
}
.composer__input::placeholder { color: var(--placeholder); }
.composer__input:focus { border-color: var(--border-focus); }

.composer__send {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  color: #000;
  transition: opacity .15s, transform .1s;
}
.composer__send:disabled { opacity: .3; cursor: default; }
.composer__send:not(:disabled):active { transform: scale(.94); }
.composer__send svg { width: 20px; height: 20px; }

/* ---------- уведомления ---------- */

.notif__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
}
.notif__icon svg { width: 20px; height: 20px; }
.notif.is-unread .list-item__title::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
.notif .list-item__text { white-space: normal; }

/* ---------- профиль ---------- */

.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 24px 0;
  text-align: center;
}
.profile__name { margin: 20px 0 4px; font-size: 24px; font-weight: 600; }
.profile__username { color: var(--muted); font-size: 15px; }
.profile__bio { max-width: 460px; margin: 16px 0 0; color: var(--text-2); font-size: 15px; white-space: pre-wrap; }

.profile__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }

.card {
  margin: 28px 24px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.card__row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  font-size: 15px;
}
.card__row + .card__row { border-top: 1px solid var(--border); }
.card__label { color: var(--muted); }
.card__value { text-align: right; overflow-wrap: anywhere; }

.profile-form { width: 100%; max-width: 420px; margin-top: 28px; text-align: left; }
.profile-form textarea.input { height: 112px; padding: 14px 16px; resize: vertical; }
.profile-form__actions { display: flex; gap: 10px; }
.profile-form__actions .btn { flex: 1; }

/* ---------- тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: 20px;
  z-index: 150;
  transform: translate(-50%, -20px);
  padding: 12px 20px;
  border-radius: var(--pill);
  background: #fff;
  color: #000;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Адаптация
   ========================================================================== */

/* Ноутбуки и планшеты: список чатов уже */
@media (max-width: 1100px) {
  :root { --list-w: 320px; }
}

/* Узкие планшеты: список чатов уже */
@media (max-width: 900px) {
  :root { --list-w: 280px; }
}

/* Телефоны: нижняя панель, один экран за раз */
@media (max-width: 767px) {
  .app { flex-direction: column; padding-left: 0; }

  .main { order: 1; flex: 1; min-height: 0; }

  .sidebar, .sidebar.is-expanded {
    position: static;
    order: 2;
    width: 100%;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 8px env(safe-area-inset-bottom);
    flex-direction: row;
    border-right: 0;
    border-top: 1px solid #161616;
    background: var(--bg);
    box-shadow: none;
    overflow: visible;
    transition: none;
  }
  .sidebar__brand, .sidebar__logout, .sidebar__toggle { display: none; }

  .nav { flex: 1; flex-direction: row; gap: 0; height: 100%; }
  .nav__item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    height: 100%;
    padding: 0;
    border-radius: 0;
    background: none !important;
    color: #6a6a6a;
  }
  .nav__item.is-active { color: var(--text); }
  .nav__label { display: block; opacity: 1; font-size: 11px; font-weight: 500; }
  .nav__badge { top: 8px; left: auto; right: calc(50% - 22px); }

  .view__head { padding: 20px 16px 14px; }
  .view__title { font-size: 24px; }
  .search-box { margin: 0 16px 10px; }
  .list { padding: 0 6px; }
  .list-item { padding: 10px; }

  .chatlist { width: 100%; border-right: 0; }

  .chat { display: none; }
  .app.is-chat-open .chat {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 20;
    height: 100vh;
    height: 100dvh;
  }
  .app.is-chat-open .sidebar { display: none; }
  .app.is-chat-open .chatlist { display: none; }
  .chat__empty { display: none; }
  .chat__back { display: grid; }

  .chat__head { min-height: 64px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .messages { padding: 16px 12px; }
  .msg { max-width: 85%; }
  .composer { padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

  .card { margin: 24px 16px 0; }
  .profile { padding: 4px 16px 0; }
  .avatar--xl { width: 96px; height: 96px; font-size: 34px; }

  .toast { top: calc(12px + env(safe-area-inset-top)); max-width: calc(100% - 32px); }
}

@media (max-width: 360px) {
  .nav__item span:not(.nav__badge) { font-size: 10px; }
  .card__row { flex-direction: column; gap: 4px; }
  .card__value { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Регистрация по шагам
   ========================================================================== */

.steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}

.steps__dot {
  width: 30px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  transition: background-color .2s;
}
.steps__dot.is-active { background: #fff; }

.step { display: none; }
.step.is-active { display: block; animation: step-in .2s ease-out; }

@keyframes step-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

.avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.avatar-picker__btn {
  position: relative;
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px dashed #333;
  color: var(--muted);
  font-size: 34px;
  font-weight: 600;
  overflow: hidden;
  transition: border-color .15s, color .15s;
}
.avatar-picker__btn:hover { border-color: #4a4a4a; color: var(--text-2); }
.avatar-picker__btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-picker__badge {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid var(--bg);
  background: #fff;
  color: #000;
}
.avatar-picker__badge svg { width: 16px; height: 16px; }

.avatar-picker__hint {
  font-size: 13px;
  color: var(--muted);
  transition: color .15s;
}
button.avatar-picker__hint:hover { color: var(--text); }

.input-prefix {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
  pointer-events: none;
}
.input--prefixed { padding-left: 34px; }

.field__hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.avatar__img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* ==========================================================================
   Настройки профиля: разделы и переключатель
   ========================================================================== */

.settings {
  margin: 16px 24px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.settings__row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  color: var(--text);
  transition: background-color .15s;
}
.settings__row:hover { background: var(--surface-2); }
.settings__row + .settings__row { border-top: 1px solid var(--border); }

.settings__icon {
  display: grid;
  place-items: center;
  color: var(--text-2);
}
.settings__icon svg { width: 20px; height: 20px; }

.settings__title { flex: 1; }

.settings__chevron { color: var(--muted); }
.settings__chevron svg {
  width: 18px;
  height: 18px;
  transition: transform .2s ease;
}
.settings__row.is-open .settings__chevron svg { transform: rotate(90deg); }

.settings__body {
  padding: 4px 18px 20px;
  border-top: 1px solid var(--border);
  animation: step-in .18s ease-out;
}
.settings__body .profile-form { max-width: none; margin-top: 16px; }
.settings__body .field__hint { margin-top: 12px; }

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch__track {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 28px;
  border-radius: var(--pill);
  background: var(--surface-3);
  transition: background-color .18s;
}
.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #8a8a8a;
  transition: transform .18s, background-color .18s;
}
.switch input:checked + .switch__track { background: #fff; }
.switch input:checked + .switch__track .switch__thumb {
  background: #000;
  transform: translateX(18px);
}
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

.switch__label { font-size: 15px; }

@media (max-width: 767px) {
  .settings { margin: 16px 16px 0; }
}

/* ==========================================================================
   Экраны настроек
   ========================================================================== */

.view__title { flex: 1; }

a.settings__row { color: var(--text); text-decoration: none; }
a.settings__row:hover { text-decoration: none; }

.settings__subtitle {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.settings-user {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 24px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background-color .15s;
}
.settings-user:hover { background: var(--surface-2); text-decoration: none; }
.settings-user__info { flex: 1; min-width: 0; }
.settings-user__name { display: block; font-size: 16px; font-weight: 600; }
.settings-user__hint { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }

.settings-logout { margin: 20px 24px 0; }

.profile-form--wide { max-width: 420px; margin: 20px auto 0; }

/* ==========================================================================
   Файлы в переписке
   ========================================================================== */

.composer__attach {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
  color: var(--muted);
  transition: background-color .15s, color .15s;
}
.composer__attach:hover { background: var(--surface-2); color: var(--text); }
.composer__attach svg { width: 22px; height: 22px; }

.msg--file { padding: 6px 6px 4px; max-width: min(360px, 82%); }

.msg__image,
.msg__video {
  display: block;
  width: 100%;
  max-height: 340px;
  border-radius: 14px;
  background: #000;
  object-fit: cover;
}
.msg__image { cursor: zoom-in; }
.msg__video { object-fit: contain; }

.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
}
.file-card__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: rgba(127, 127, 127, .18);
}
.file-card__icon svg { width: 20px; height: 20px; }
.file-card__info { min-width: 0; }
.file-card__name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
}
.file-card__size { display: block; margin-top: 2px; font-size: 12px; opacity: .6; }

.msg__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 6px 0;
}
.msg__download {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: inherit;
  opacity: .6;
  transition: opacity .15s, background-color .15s;
}
.msg__download:hover { opacity: 1; background: rgba(127, 127, 127, .2); text-decoration: none; }
.msg__download svg { width: 16px; height: 16px; }
.msg--file .msg__time { margin-top: 0; }

/* ==========================================================================
   Окно загрузки файла
   ========================================================================== */

.uploader {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .82);
  backdrop-filter: blur(6px);
}

.uploader__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.uploader__ring {
  position: relative;
  width: 132px;
  height: 132px;
  margin-bottom: 10px;
}
.uploader__ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.uploader__track {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 8;
}
.uploader__bar {
  fill: none;
  stroke: #fff;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset .15s linear;
}
.uploader__percent {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 600;
}

.uploader__name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 500;
}
.uploader__size { margin-bottom: 10px; font-size: 13px; color: var(--muted); }

/* ==========================================================================
   Просмотр фото
   ========================================================================== */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, .95);
}

.viewer__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.viewer__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}
.viewer__bar .icon-btn { color: var(--text-2); }
.viewer__bar .icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .1); }

.viewer__img {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  padding: 0 16px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

@media (max-width: 767px) {
  .settings-user, .settings-logout { margin-left: 16px; margin-right: 16px; }
  .msg--file { max-width: 88%; }
  .composer__attach { width: 42px; height: 42px; }
}

/* ==========================================================================
   Компактная карточка файла и меню сообщения
   ========================================================================== */

.msg--doc {
  max-width: min(270px, 78%);
  padding: 4px 4px 2px;
}
.msg--doc .msg__time {
  display: block;
  padding: 0 8px 2px;
  text-align: right;
}

a.file-card {
  gap: 10px;
  padding: 7px 9px;
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
  transition: background-color .15s;
}
a.file-card:hover { background: rgba(127, 127, 127, .18); text-decoration: none; }

.file-card__icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}
.file-card__icon svg { width: 17px; height: 17px; }
.file-card__name { font-size: 13.5px; }
.file-card__size { font-size: 11.5px; }

.ctx {
  position: fixed;
  z-index: 140;
  min-width: 184px;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .6);
  animation: msg-in .12s ease-out;
}

.ctx__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  text-align: left;
  text-decoration: none;
  transition: background-color .12s;
}
.ctx__item:hover { background: #242424; text-decoration: none; }
.ctx__item svg { width: 18px; height: 18px; color: var(--text-2); }
.ctx__item--danger { color: var(--danger); }
.ctx__item--danger svg { color: var(--danger); }

/* ==========================================================================
   Группы: окно создания и оформление в переписке
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 125;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(4px);
}

.modal__box {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  border-radius: 22px;
  background: #0b0b0b;
  border: 1px solid var(--border);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .7);
  overflow: hidden;
  animation: msg-in .18s ease-out;
}

.modal__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 6px;
}
.modal__title {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}
.modal__head .icon-btn { color: var(--text-2); }

.modal .steps { margin: 6px 0 18px; }

.modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 20px;
}
.modal__body .list { padding: 0; }
.modal__body .field:last-child { margin-bottom: 8px; }

.modal__foot {
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid #161616;
}

.avatar-picker__icon svg { width: 42px; height: 42px; color: var(--muted); }

.search-box--flat { margin: 0 0 14px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.chips[hidden] { display: none; }

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 10px 5px 5px;
  border-radius: var(--pill);
  background: var(--surface-3);
  color: var(--text);
  font-size: 14px;
  transition: background-color .15s;
}
.chip:hover { background: #262626; }
.chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; color: var(--muted); }

.avatar--xs { width: 24px; height: 24px; font-size: 10px; }

.pick {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: background-color .15s, color .15s, border-color .15s;
}
.pick svg { width: 17px; height: 17px; }
.list-item.is-picked .pick {
  background: #fff;
  border-color: #fff;
  color: #000;
}

.group-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0 20px;
  text-align: center;
}
.group-confirm__title { margin: 16px 0 4px; font-size: 20px; font-weight: 600; }
.group-confirm__count { margin: 0; color: var(--muted); font-size: 14px; }

.list-item__note { color: var(--muted); font-weight: 400; }

.list-item__group {
  display: inline-grid;
  place-items: center;
  vertical-align: -3px;
  margin-right: 6px;
  color: var(--muted);
}
.list-item__group svg { width: 15px; height: 15px; }

.msg__author {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
  font-weight: 600;
}
.msg--doc .msg__author,
.msg--file .msg__author { padding: 2px 8px 0; }

@media (max-width: 767px) {
  .modal { padding: 0; }
  .modal__box {
    max-width: none;
    height: 100%;
    border: 0;
    border-radius: 0;
  }
  .modal__head { padding-top: calc(14px + env(safe-area-inset-top)); }
  .list-item.is-picked { background: #101010; }
  .pick { width: 36px; height: 36px; }
}

/* ==========================================================================
   Настройки группы
   ========================================================================== */

.chat__settings { margin-left: -4px; }

.gp__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0 22px;
  text-align: center;
}
.gp__title { margin: 16px 0 4px; font-size: 20px; font-weight: 600; }
.gp__count { margin: 0; color: var(--muted); font-size: 14px; }

.gp__actions {
  display: flex;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid #161616;
}

.gp__action {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  transition: background-color .15s;
}
.gp__action:hover { background: var(--surface-2); }
.gp__action svg { width: 22px; height: 22px; color: var(--text-2); }

.gp__members { padding-top: 14px; }

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

.gp__members-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
}

.gp__members .list-item { cursor: default; }
.gp__members .list-item__text.is-online { color: var(--online); }

.badge-owner {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(31, 123, 255, .16);
  color: #6ea8ff;
  font-size: 11px;
  font-weight: 600;
}

.gp__hint { padding: 10px 12px 4px; }

/* ==========================================================================
   Правки окон: ровная шапка и аккуратный выбор участников
   ========================================================================== */

/* Заголовок всегда по центру, даже когда кнопки «назад» нет */
.modal__head {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 4px;
}
.modal__head > .icon-btn:first-child { grid-column: 1; justify-self: start; }
.modal__title { grid-column: 2; margin: 0; text-align: center; }
.modal__head > .icon-btn:last-child { grid-column: 3; justify-self: end; }

.modal__search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  margin-bottom: 14px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color .15s;
}
.modal__search:focus-within { border-color: var(--border-focus); }
.modal__search svg { width: 18px; height: 18px; color: var(--muted); }
.modal__search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: none;
  border: 0;
  outline: none;
  font-size: 15px;
}
.modal__search input::placeholder { color: var(--placeholder); }
.modal__search input::-webkit-search-cancel-button { display: none; }

/* Строки выбора участников */
.modal__body .list-item {
  gap: 12px;
  padding: 10px 8px;
  border-radius: 14px;
}
.modal__body .list-item.is-picked { background: #131313; }
.modal__body .list-item.is-picked:hover { background: #181818; }
.modal__body .list-item__body { display: flex; flex-direction: column; justify-content: center; }
.modal__body .list-item__title { line-height: 1.25; }
.modal__body .list-item__text { margin-top: 2px; line-height: 1.25; }

.modal__body .empty { padding: 28px 12px; }

.chips { margin: 0 0 14px; padding: 0 2px; }

/* ==========================================================================
   Документы: соглашение и политика конфиденциальности
   ========================================================================== */

.legal {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 20px 64px;
}

.legal__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid #141414;
  z-index: 10;
}
.legal__top .logo:hover { text-decoration: none; }

.legal__doc {
  max-width: 760px;
  margin: 0 auto;
  padding-top: 36px;
  color: #d8d8d8;
  font-size: 15.5px;
  line-height: 1.65;
}

.legal__title {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.legal__updated {
  margin: 0 0 36px;
  color: var(--muted);
  font-size: 14px;
}

.legal__doc h2 {
  margin: 36px 0 14px;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.legal__doc h3 {
  margin: 24px 0 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.legal__doc p { margin: 0 0 12px; }

.legal__doc ul {
  margin: 0 0 16px;
  padding-left: 22px;
}
.legal__doc li { margin-bottom: 6px; }
.legal__doc li::marker { color: var(--muted); }

.legal__links {
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid #161616;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 767px) {
  .legal { padding: 0 16px 48px; }
  .legal__top { padding: 16px 0; padding-top: calc(16px + env(safe-area-inset-top)); }
  .legal__doc { padding-top: 26px; font-size: 15px; }
  .legal__title { font-size: 25px; }
  .legal__doc h2 { font-size: 18px; margin-top: 30px; }
}

/* ==========================================================================
   Экран заблокированного аккаунта
   ========================================================================== */

.blocked {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: var(--bg);
  text-align: center;
}
.blocked__title { margin: 0; font-size: 26px; font-weight: 700; }
.blocked__text { margin: 0 0 10px; max-width: 420px; color: var(--muted); font-size: 15px; }

/* ==========================================================================
   Админ-панель
   ========================================================================== */

.admin {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.admin__side {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 16px 20px;
  border-right: 1px solid #141414;
}

.admin__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  margin-bottom: 30px;
}

.admin__badge {
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(31, 123, 255, .16);
  color: #6ea8ff;
  font-size: 11px;
  font-weight: 600;
}

.admin__tabs { display: flex; flex-direction: column; gap: 6px; }

.admin__tab {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  transition: background-color .15s, color .15s;
}
.admin__tab svg { width: 20px; height: 20px; }
.admin__tab:hover { color: var(--text); background: #0f0f0f; }
.admin__tab.is-active { color: var(--text); background: var(--surface-3); font-weight: 600; }

.admin__back {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 14px;
}
.admin__back:hover { color: var(--text); text-decoration: none; }
.admin__back svg { width: 16px; height: 16px; }

.admin__main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 32px 32px 64px;
}

.admin__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}
.admin__title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.admin__hint { color: var(--muted); font-size: 13px; }

.admin__section { margin-bottom: 34px; }
.admin__subtitle {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.gauges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.gauge {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.gauge__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.gauge__label { font-size: 15px; font-weight: 500; }
.gauge__value { font-size: 20px; font-weight: 700; }
.gauge__track { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.gauge__fill { height: 100%; border-radius: 4px; background: #fff; transition: width .4s ease; }
.gauge__fill.is-hot { background: var(--danger); }
.gauge__caption {
  margin-top: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12.5px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.stat {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.stat__value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat__label { margin-top: 4px; color: var(--muted); font-size: 13px; }

.admin__search { max-width: 480px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

.filter {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--pill);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 14px;
  transition: background-color .15s, color .15s;
}
.filter:hover { color: var(--text); background: #262626; }
.filter.is-active { background: #fff; color: #000; font-weight: 500; }

.users { display: flex; flex-direction: column; gap: 10px; }

.user {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.user.is-banned { border-color: rgba(255, 90, 95, .35); }
.user__info { flex: 1; min-width: 0; }
.user__name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 15px;
  font-weight: 600;
}
.user__meta {
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.tag {
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}
.tag--admin { background: rgba(31, 123, 255, .16); color: #6ea8ff; }
.tag--banned { background: rgba(255, 90, 95, .16); color: #ff8a8d; }
.tag--online { background: rgba(62, 207, 110, .16); color: var(--online); }

.denied {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}
.denied__title { margin: 0; font-size: 26px; font-weight: 700; }
.denied__text { margin: 0 0 10px; max-width: 420px; color: var(--muted); }

@media (max-width: 900px) {
  .admin { flex-direction: column; }
  .admin__side {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 12px;
    padding-top: calc(12px + env(safe-area-inset-top));
    border-right: 0;
    border-bottom: 1px solid #141414;
    overflow-x: auto;
  }
  .admin__brand { margin: 0; padding: 0 6px; }
  .admin__tabs { flex-direction: row; }
  .admin__tab { height: 40px; padding: 0 12px; font-size: 14px; }
  .admin__tab span { display: none; }
  .admin__back { margin: 0 0 0 auto; padding: 8px; }
  .admin__back span { display: none; }
  .admin__main { padding: 20px 16px 48px; }
  .admin__title { font-size: 24px; }
  .user { flex-wrap: wrap; }
  .user .btn { width: 100%; }
}

/* ==========================================================================
   Админка: вкладка управления
   ========================================================================== */

.controls {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
  cursor: pointer;
}
.control + .control { border-top: 1px solid var(--border); }
.control--column {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  cursor: default;
}
.control--column .field__label { margin-bottom: 0; }
.control--column textarea.input { height: 92px; padding: 12px 16px; resize: vertical; }

.control__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.control__title { font-size: 15px; font-weight: 500; }
.control__hint { color: var(--muted); font-size: 13px; }

.control__input {
  width: 120px;
  height: 44px;
  flex-shrink: 0;
  text-align: center;
}

.control .switch { margin-top: 0; flex-shrink: 0; }

#settings-save { min-width: 180px; }

@media (max-width: 600px) {
  .control { flex-wrap: wrap; }
  .control__input { width: 100%; }
  #settings-save { width: 100%; }
}

/* ==========================================================================
   Подписка Premium
   ========================================================================== */

.pin {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 4px;
  vertical-align: -3px;
  object-fit: contain;
}
.pin--lg { width: 24px; height: 24px; margin: 0; vertical-align: middle; }

.premium {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 24px 0;
  text-align: center;
}

.premium__star {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #4a3a12, #14120b 70%);
  border: 1px solid #3a2f14;
}
.premium__star svg {
  width: 62px;
  height: 62px;
  color: #f5c451;
  filter: drop-shadow(0 6px 18px rgba(245, 196, 81, .35));
}

.premium__lead {
  max-width: 420px;
  margin: 22px 0 0;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
}

.premium__status {
  margin-top: 14px;
  padding: 7px 16px;
  border-radius: var(--pill);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}
.premium__status.is-active {
  background: rgba(245, 196, 81, .14);
  color: #f5c451;
}

.premium__list {
  width: 100%;
  max-width: 460px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.premium__item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.premium__item + .premium__item { margin-top: 10px; }

.premium__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: #f5c451;
}
.premium__icon svg { width: 20px; height: 20px; }

.premium__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.premium__text b { font-size: 15px; font-weight: 600; }
.premium__text span { color: var(--muted); font-size: 13.5px; line-height: 1.45; }

.premium__hint { margin-top: 18px; text-align: center; }

/* ---------- выдача подписки в админке ---------- */

.user__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.user__premium {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.user__premium-label {
  margin-right: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.user__premium .btn { height: 32px; padding: 0 12px; font-size: 13px; }

.tag--premium { background: rgba(245, 196, 81, .16); color: #f5c451; }

@media (max-width: 900px) {
  .user__actions { align-items: stretch; width: 100%; }
  .user__premium { justify-content: flex-start; }
  .premium { padding-left: 16px; padding-right: 16px; }
}

/* ==========================================================================
   Экран подписки и цвет ника
   ========================================================================== */

.nick-premium {
  color: #9ad9ff;
  background: linear-gradient(95deg, #7be7ff 0%, #a9a2ff 48%, #ffb0ef 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

.promo {
  max-width: 460px;
  margin: 0 auto;
  padding: 4px 4px 8px;
}

.promo__title {
  margin: 0 0 26px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  text-transform: uppercase;
}

.promo__label {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.promo__preview { margin-bottom: 28px; }

.promo__profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.promo__nick {
  display: flex;
  align-items: center;
  font-size: 16px;
}
.promo__nick .pin { margin-left: 6px; }
.promo__time { margin-top: 2px; color: var(--muted); font-size: 13px; }

.promo__video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  object-fit: cover;
}

.promo__list {
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}

.promo__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  font-size: 15px;
  font-weight: 500;
}
.promo__item + .promo__item { border-top: 1px solid #141414; }
.promo__item > span:last-child { min-width: 0; }

.promo__icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: #f5c451;
}
.promo__icon svg { width: 20px; height: 20px; }

.promo__dot {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(140deg, #7be7ff, #a9a2ff 55%, #ffb0ef);
}

.promo__note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
}

.promo__pay {
  width: 100%;
  height: 54px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.promo__pay:hover { background: #1a6ee0; }

@media (max-width: 767px) {
  .promo { padding: 0 4px 8px; }
  .promo__title { font-size: 26px; }
}

/* ==========================================================================
   Активные сеансы
   ========================================================================== */

.sessions-wrap {
  max-width: 420px;
  margin: 36px auto 0;
}

.sessions {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.sessions .empty { padding: 24px; }

.session {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.session + .session { border-top: 1px solid var(--border); }

.session__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
}
.session__icon svg { width: 20px; height: 20px; }

.session__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.session__title { font-size: 15px; font-weight: 500; }
.session__meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.session__current { color: var(--accent); font-weight: 500; }
.session__online { color: var(--online); }

.session .btn { flex-shrink: 0; height: 34px; padding: 0 14px; font-size: 13px; }

.sessions__end-all {
  height: 48px;
  border-top: 1px solid var(--border);
  border-radius: 0;
}
.sessions__hint { margin: 0; padding: 12px 16px 14px; border-top: 1px solid var(--border); }

@media (max-width: 767px) {
  .sessions-wrap { margin: 28px 16px 0; }
}

/* ==========================================================================
   Двухфакторная аутентификация
   ========================================================================== */

/* ---------- карточка в настройках безопасности ---------- */

.tfa-card {
  max-width: 420px;
  margin: 20px auto 0;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.tfa-card.is-on { border-color: rgba(62, 207, 110, .35); }

.tfa-card__top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.tfa-card__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text-2);
}
.tfa-card.is-on .tfa-card__icon { background: rgba(62, 207, 110, .14); color: var(--online); }
.tfa-card__icon svg { width: 22px; height: 22px; }

.tfa-card__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tfa-card__title { font-size: 15px; font-weight: 600; }
.tfa-card__text { color: var(--muted); font-size: 13px; line-height: 1.45; }

.tfa-card__status {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}
.tfa-card.is-on .tfa-card__status { background: rgba(62, 207, 110, .16); color: var(--online); }

/* ---------- шаги настройки ---------- */

.tfa-setup { padding-bottom: 8px; }

.tfa-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.tfa-step__num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  color: #000;
  font-size: 13px;
  font-weight: 700;
}
.tfa-step__text { display: flex; flex-direction: column; gap: 2px; }
.tfa-step__text b { font-size: 15px; font-weight: 600; }
.tfa-step__text span { color: var(--muted); font-size: 13px; line-height: 1.45; }

.tfa-qr {
  display: grid;
  place-items: center;
  width: 216px;
  height: 216px;
  margin: 8px auto 18px;
  padding: 14px;
  border-radius: 20px;
  background: #fff;
  color: #000;
}
.tfa-qr img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.tfa-qr__fallback { margin: 0; color: #444; font-size: 13px; text-align: center; }

.tfa-key {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.tfa-key__label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.tfa-key__row { display: flex; align-items: center; gap: 8px; }
.tfa-key__value {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 15px;
  letter-spacing: .06em;
}
.tfa-key .icon-btn svg { width: 18px; height: 18px; }

/* Ссылка otpauth:// имеет смысл только на телефоне */
.tfa-open { display: none; margin-top: 12px; }
@media (max-width: 767px), (hover: none) {
  .tfa-open { display: flex; }
}
a.tfa-open, a.tfa-open:hover { color: var(--text); text-decoration: none; }

/* ---------- ввод кода ---------- */

.tfa-code,
.tfa-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0 12px;
  text-align: center;
}

.tfa-code__icon,
.tfa-done__icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--surface-2);
  color: #fff;
}
.tfa-code__icon svg { width: 34px; height: 34px; }

.tfa-done__icon { background: rgba(62, 207, 110, .16); color: var(--online); }
.tfa-done__icon svg { width: 36px; height: 36px; }

.tfa-code__lead { margin: 0 0 6px; font-size: 19px; font-weight: 600; }
.tfa-code__text { max-width: 320px; margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.5; }

.tfa-code .auth__alert { width: 100%; margin: 16px 0 0; text-align: left; }

.otp {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.otp__cell {
  width: 48px;
  height: 58px;
  padding: 0;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  outline: none;
  caret-color: var(--accent);
  transition: border-color .15s, background-color .15s;
}
.otp__cell:focus { border-color: #fff; background: #0e0e0e; }
.otp__cell:disabled { opacity: .5; }

.otp.is-error .otp__cell { border-color: var(--danger); animation: otp-shake .3s ease; }

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

@media (max-width: 380px) {
  .otp { gap: 6px; }
  .otp__cell { width: 42px; height: 52px; font-size: 21px; }
}

@media (max-width: 767px) {
  .tfa-card,
  /* width: auto — иначе 100% ширины плюс отступы вылезают за экран */
  .profile-form--wide { width: auto; margin-left: 16px; margin-right: 16px; }
}

/* ==========================================================================
   Верификация
   ========================================================================== */

.verified {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 5px;
  vertical-align: -3px;
  object-fit: contain;
}
.verified + .pin { margin-left: 4px; }
.profile__name .verified { width: 20px; height: 20px; vertical-align: -2px; }
.verified--btn { margin: 0; vertical-align: middle; }

.user__buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.tag--verified { background: rgba(31, 123, 255, .16); color: #6ea8ff; }

@media (max-width: 900px) {
  .user__buttons { justify-content: flex-start; }
  .user__buttons .btn { flex: 1; }
}

/* Галочка размером с букву: подстраивается под шрифт, где бы ни стояла */
.verified,
.profile__name .verified {
  width: 1em;
  height: 1em;
  margin-left: .25em;
  vertical-align: -.125em;
}
.verified--btn { margin-left: 0; }

/* ==========================================================================
   Медленный режим: отсчёт на кнопке отправки
   ========================================================================== */

.composer__send.is-cooldown svg { display: none; }
.composer__send.is-cooldown::after {
  content: attr(data-left);
  font-size: 17px;
  font-weight: 700;
}
.composer__send.is-cooldown:disabled {
  opacity: 1;
  background: var(--surface-3);
  color: var(--text-2);
}
.composer__attach:disabled { opacity: .35; cursor: default; }

/* ==========================================================================
   Состояние соединения рядом с заголовком «Чаты»
   ========================================================================== */

.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  vertical-align: middle;
  white-space: nowrap;
}
.conn-status::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ==========================================================================
   Приложения: баннер на странице входа и выбор системы
   ========================================================================== */

.app-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 110;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(680px, calc(100% - 24px));
  padding: 12px 12px 12px 16px;
  border-radius: 20px;
  background: rgba(20, 20, 20, .92);
  border: 1px solid #2a2a2a;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
  backdrop-filter: blur(14px);
  transform: translate(-50%, calc(-100% - 30px));
  opacity: 0;
  transition: transform .45s cubic-bezier(.2, .9, .3, 1.15), opacity .3s ease;
}
.app-banner.is-visible { transform: translate(-50%, 0); opacity: 1; }

.app-banner__icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 13px;
  background: var(--surface-3);
  color: #fff;
}
.app-banner__icon svg { width: 22px; height: 22px; }

.app-banner__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.app-banner__text b { font-size: 15px; font-weight: 600; }
.app-banner__text span { color: var(--muted); font-size: 13px; }

.app-banner__download { flex-shrink: 0; }
.app-banner__close { flex-shrink: 0; width: 36px; height: 36px; color: var(--muted); }
.app-banner__close svg { width: 18px; height: 18px; }

/* ---------- полноэкранный выбор ---------- */

.apps {
  position: fixed;
  inset: 0;
  z-index: 130;
  overflow-y: auto;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(31, 123, 255, .16), transparent 70%),
    #000;
  opacity: 0;
  transition: opacity .25s ease;
}
.apps.is-open { opacity: 1; }

.apps__close {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  right: 18px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
}
.apps__close svg { width: 20px; height: 20px; }

.apps__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100%;
  justify-content: center;
  padding: 72px 24px 48px;
  text-align: center;
  transform: translateY(14px);
  transition: transform .35s ease;
}
.apps.is-open .apps__inner { transform: none; }

.apps__logo { font-size: 30px; margin-bottom: 28px; }
.apps__title { margin: 0 0 10px; font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.apps__subtitle { margin: 0 0 40px; max-width: 460px; color: var(--muted); font-size: 16px; }

.apps__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 260px));
  gap: 18px;
}

.apps__tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 22px 22px;
  border-radius: 26px;
  background: linear-gradient(180deg, #141414, #0b0b0b);
  border: 1px solid #242424;
  color: var(--text);
  text-decoration: none;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.apps__tile:hover {
  transform: translateY(-4px);
  border-color: #3a3a3a;
  box-shadow: 0 22px 50px rgba(0, 0, 0, .6);
  text-decoration: none;
}
.apps__tile:active { transform: translateY(-1px) scale(.99); }
.apps__tile.is-recommended { border-color: rgba(31, 123, 255, .55); }

.apps__badge {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: var(--pill);
  background: rgba(31, 123, 255, .18);
  color: #6ea8ff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  display: none;
}
.apps__tile.is-recommended .apps__badge { display: block; }

.apps__os-icon {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin: 12px 0 18px;
  border-radius: 28px;
}
.apps__os-icon svg { width: 52px; height: 52px; }
.apps__os-icon--windows { background: rgba(0, 120, 212, .14); color: #3aa0ff; }
.apps__os-icon--android { background: rgba(61, 220, 132, .12); color: #3ddc84; }

.apps__os-name { font-size: 22px; font-weight: 700; }
.apps__os-meta { margin: 6px 0 22px; color: var(--muted); font-size: 13px; }

.apps__action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 46px;
  border-radius: var(--pill);
  background: #fff;
  color: #000;
  font-size: 15px;
  font-weight: 600;
  transition: background-color .2s ease, color .2s ease;
}
.apps__tile.is-started .apps__action { background: rgba(62, 207, 110, .16); color: var(--online); }

.apps__hint { margin: 30px 0 0; max-width: 420px; color: #5f5f5f; font-size: 13px; }

@media (max-width: 640px) {
  .app-banner { top: calc(10px + env(safe-area-inset-top)); gap: 10px; padding: 10px 8px 10px 12px; }
  .app-banner__icon { display: none; }
  .app-banner__text b { font-size: 14px; }
  .app-banner__text span { font-size: 12px; }
  .app-banner__download { height: 36px; padding: 0 14px; }

  .apps__inner { justify-content: flex-start; padding-top: 84px; }
  .apps__title { font-size: 26px; }
  .apps__subtitle { margin-bottom: 28px; font-size: 15px; }
  .apps__grid { grid-template-columns: minmax(0, 340px); width: 100%; justify-content: center; }
  .apps__tile { padding: 30px 18px 18px; }
  .apps__os-icon { width: 80px; height: 80px; margin-bottom: 14px; }
  .apps__os-icon svg { width: 44px; height: 44px; }
}

/* Плитка для текущего устройства — первой */
.apps__tile.is-recommended { order: -1; }
