/*
  Экраны: список чатов, диалог, звонки, «Вы», вход.
  Всё построено на токенах и деталях из components.css.
*/

/* ===================== Список чатов ===================== */
.chat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px var(--pad-screen);
  text-align: left;
  border-left: 3px solid transparent;   /* место под грань выбранного чата */
  transition: background var(--dur-fast) var(--ease);
}
.chat-row:hover { background: var(--surface-hover); }
/* §4.2: спокойная подложка и тонкая чернильная вертикальная грань, без тяжёлой
   сплошной заливки. Имя остаётся Semibold, но не перекрашивается ярким цветом. */
.chat-row[aria-current="true"] {
  background: var(--surface-active);
  border-left-color: var(--purple);
}
.chat-row[aria-current="true"] .chat-name { font-weight: 700; }

.chat-main { flex: 1; min-width: 0; }
.chat-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.chat-line + .chat-line { margin-top: 3px; }
.chat-name {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
}
.chat-time {
  margin-left: auto;
  flex: none;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.chat-preview {
  flex: 1;
  min-width: 0;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}
.chat-preview .sender { color: var(--text-secondary); }
.chat-typing { color: var(--accent-text); }
/* §5.3 Черновик: слово «Черновик» — Core Ink, остальной текст — вторичный серебристый. */
.chat-draft { color: var(--silver-secondary); }
.chat-draft .draft-tag { color: var(--ink-core); font-weight: 600; }
:root[data-theme="dark"] .chat-draft .draft-tag { color: var(--purple-light); }
.chat-row .strokes,
.chat-row .badge { margin-left: auto; }

/* Выбор участников группы */
.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}
.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 180px;
  height: 30px;
  padding: 0 4px 0 12px;
  border-radius: var(--r-chip);
  background: var(--purple-12);
  color: var(--purple);
  font-size: 0.8125rem;
  font-weight: 600;
}
.member-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: var(--purple);
}
.member-x svg { width: 14px; height: 14px; }
.member-check { flex: none; color: var(--purple); opacity: 0; }
.member-check svg { width: 20px; height: 20px; }
.chat-row[aria-pressed="true"] { background: var(--purple-08); }
.chat-row[aria-pressed="true"] .member-check { opacity: 1; }

/* ===================== Диалог ===================== */
.dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dialog-title { min-width: 0; flex: 1; }
.dialog-title .name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.0625rem;
  font-weight: 600;
}
.dialog-title .sub {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.dialog-title .sub.typing { color: var(--purple); }

/* Щит доверия E2EE: нейтральный / проверено / тревога */
.shield { color: var(--text-tertiary); }
.shield.verified { color: var(--online); }
.shield.alert { color: var(--danger); }

.dialog-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px var(--pad-screen) 8px;
}

.day-sep {
  align-self: center;
  margin: 12px 0 8px;
  padding: 4px 12px;
  border-radius: var(--r-chip);
  background: var(--surface-sunken);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.msg {
  display: flex;
  max-width: min(680px, 78%);
}
.msg.out { align-self: flex-end; justify-content: flex-end; }
.msg.in  { align-self: flex-start; }
.msg + .msg.same { margin-top: 0; }
.msg:not(.same) { margin-top: 8px; }

.bubble {
  position: relative;
  padding: 8px 12px 6px;
  border-radius: var(--r-bubble);
  box-shadow: var(--shadow-row);
  min-width: 92px;
}
.msg.in .bubble {
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  border-bottom-left-radius: 6px;
}
.msg.out .bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-text);
  border-bottom-right-radius: 6px;
}
.msg.same.in .bubble  { border-bottom-left-radius: var(--r-bubble); }
.msg.same.out .bubble { border-bottom-right-radius: var(--r-bubble); }

.bubble-sender {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 2px;
}
.bubble-text {
  font-size: 0.9375rem;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 2px;
  font-size: 0.6875rem;
  color: var(--text-secondary);
}
.msg.out .bubble-meta { color: color-mix(in srgb, var(--bubble-out-text) 62%, transparent); }
.bubble.pending { opacity: 0.72; }
.bubble.failed { box-shadow: inset 0 0 0 1px var(--danger); }

/* Ответ на сообщение */
.bubble-reply {
  display: block;
  margin-bottom: 6px;
  padding: 4px 8px;
  border-left: 2px solid var(--purple);
  border-radius: 6px;
  background: var(--purple-08);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Вложения */
.attach-img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 12px;
  margin: 2px 0 4px;
  object-fit: cover;
}
.attach-img.zoomable { cursor: zoom-in; }

/* §9 Лайтбокс изображений: полноэкранный просмотр с зумом. */
.imgviewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .92);
  overscroll-behavior: contain;  /* телефон: не «пробрасываем» жест в pull-to-refresh */
}
.imgviewer.hidden { display: none; }
.imgviewer-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;            /* жесты (пинч/пан/закрытие) обрабатываем сами */
}
.imgviewer-img {
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  /* Резкость при зуме: композитим на GPU без субпиксельного мыла, масштаб система
     сглаживает сама (auto), не «пикселим». */
  image-rendering: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.imgviewer-btn {
  position: absolute;
  /* Уводим кнопки из-под чёлки/скруглений телефона. */
  top: calc(14px + env(safe-area-inset-top, 0px));
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.imgviewer-btn:hover { background: rgba(255, 255, 255, .24); }
.imgviewer-btn svg { width: 22px; height: 22px; }
.imgviewer-close { right: calc(14px + env(safe-area-inset-right, 0px)); }
.imgviewer-dl { right: calc(66px + env(safe-area-inset-right, 0px)); }

/* Телефон/сенсор: крупнее зона нажатия, чтобы попадать пальцем. */
@media (hover: none) and (pointer: coarse) {
  .imgviewer-btn { width: 48px; height: 48px; }
  .imgviewer-btn svg { width: 24px; height: 24px; }
  .imgviewer-dl { right: calc(74px + env(safe-area-inset-right, 0px)); }
}
/* §4.5: блок файла отделён от сообщения третьим уровнем поверхности. */
.attach-file {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 4px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--attach-fill);
  color: inherit;
  text-align: left;
}
.attach-file svg { width: 22px; height: 22px; flex: none; color: var(--attach-icon); transition: color var(--dur-fast) var(--ease); }
.attach-file:hover svg { color: var(--attach-icon-hover); }
.attach-file:active svg { color: var(--attach-icon-pressed); }
/* §4.5: имя файла — светлое Semibold, до двух строк с многоточием; размер/тип — вторичный серебристый. */
.attach-file .name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--attach-name);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.attach-file .size { font-size: 0.75rem; color: var(--attach-meta); }
.attach-file > span { min-width: 0; }

/* Зона сброса файлов поверх диалога */
.dropzone {
  position: absolute;
  inset: 10px;
  z-index: 15;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: var(--r-card);
  border: 2px dashed var(--purple);
  background: color-mix(in srgb, var(--purple) 12%, var(--surface));
  color: var(--purple);
  pointer-events: none;
}
.col-detail.dragging .dropzone { display: flex; }
.dropzone svg { width: 40px; height: 40px; }
.dropzone-hint { font-size: 1rem; font-weight: 600; }

/* Поле ввода сообщения */
.composer {
  position: relative;   /* якорь для панели эмодзи */
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px var(--pad-screen) calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--separator);
  background: var(--glass-fill-solid);
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .composer {
    background: var(--glass-fill);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
    backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  }
}

/* §5.2 Зона предварительной подготовки вложений */
.staging {
  padding: 8px;
  border-radius: var(--r-card);
  background: var(--surface-sunken);
}
.stage-items {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.stage-item {
  position: relative;
  flex: none;
  width: 92px;
  padding: 6px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--separator);
  cursor: grab;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.stage-item.drag { opacity: 0.5; }
.stage-item:active { cursor: grabbing; }
.stage-thumb {
  width: 100%;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-active);
}
.stage-thumb.file {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--attach-icon);
}
.stage-thumb.file svg { width: 30px; height: 30px; }
.stage-name {
  margin-top: 4px;
  font-size: 0.6875rem;
  color: var(--text-secondary);
}
.stage-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(5, 6, 10, 0.6);
  color: #fff;
}
.stage-remove svg { width: 14px; height: 14px; }
/* §9 Прогресс загрузки — дорожка внизу превью */
.stage-progress {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  height: 4px;
  border-radius: 999px;
  background: rgba(5, 6, 10, 0.5);
  overflow: hidden;
}
.stage-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--purple);
  transition: width 0.12s linear;
}
/* §9 Повторить — при ошибке загрузки (слева сверху) */
.stage-retry {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--purple);
  color: #fff;
}
.stage-retry svg { width: 13px; height: 13px; }
/* §9 Загружено — галочка */
.stage-done {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--online);
  color: #fff;
}
.stage-done svg { width: 13px; height: 13px; }
.stage-item.err { border-color: var(--danger); }
.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 2px;
}
.stage-count { font-size: 0.8125rem; color: var(--text-secondary); }
.stage-clear {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--danger);
  padding: 4px 8px;
  border-radius: var(--r-chip);
}
.stage-clear:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.composer-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  border-radius: var(--r-field);
  background: var(--surface);
  border: 1px solid var(--separator);
  padding: 0 6px 0 12px;
}
.composer-field textarea {
  flex: 1;
  min-width: 0;
  max-height: 132px;
  padding: 12px 0;
  border: 0;
  background: transparent;
  resize: none;
  font-size: 0.9375rem;
  line-height: 1.35;
}
.composer-field textarea::placeholder { color: var(--text-tertiary); }
/* §11: focus показываем на самом поле (по его форме, внутри контура), а не
   прямоугольным outline у textarea. */
.composer-field:focus-within {
  border-color: var(--purple);
  box-shadow: inset 0 0 0 1px var(--purple);
}
.composer .icon-btn { flex: none; margin-bottom: 2px; }

/* §3/§8.3/§9.4: свободная область — крупная надпись NiMilex фирменного цвета
   #55207A, без рамки, со спокойной непрозрачностью. */
.detail-mark {
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink-violet);
  opacity: 0.42;
}
:root[data-theme="dark"] .detail-mark { color: var(--purple); opacity: 0.5; }
.detail-empty { gap: 4px; }
.detail-empty .detail-hint {
  font-size: 0.9375rem;
  color: var(--text-tertiary);
}

/* ===================== Звонки ===================== */
.section-head {
  padding: 16px var(--pad-screen) 6px;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.call-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px var(--pad-screen);
  text-align: left;
}
.call-row:hover { background: var(--surface-hover); }
.call-dir {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.call-dir svg { width: 14px; height: 14px; }
.call-dir .call-type,
.call-dir .call-dur { color: var(--text-tertiary); }
/* §9.2: пропущенный красный только в подписи/стрелке; имя не окрашивается. */
.call-row.missed .call-dir { color: var(--danger); }
.call-row.missed .chat-name { color: var(--text-primary); }
.call-row { cursor: pointer; }
.call-actions-inline { display: flex; gap: 2px; flex: none; }
.fav-star { color: var(--brass); font-size: 0.875rem; flex: none; }

/* §9.3 Компактная карточка контакта */
.card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.card-head .nick { color: var(--accent-text); font-weight: 600; }
.card-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.cardact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: var(--r-field);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-sunken);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.cardact:hover { background: var(--surface-active); color: var(--text-primary); }
.cardact-ic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--purple-12);
  color: var(--purple);
}
.cardact-ic svg { width: 20px; height: 20px; }
.cardact.danger { color: var(--danger); }

/* Полноэкранный звонок */
.call-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 48px var(--pad-screen) calc(40px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-center) 52%, var(--bg-bottom) 100%);
}
.call-screen.hidden { display: none; }

/* Видео-сцена: удалённое видео на весь экран, локальное — PiP. По умолчанию скрыта
   (аудиозвонок), включается классом .video-mode. */
.call-stage { position: absolute; inset: 0; overflow: hidden; display: none; }
.call-screen.video-mode .call-stage { display: block; }
.call-remote { width: 100%; height: 100%; object-fit: cover; background: #000; }
/* ТЗ 4.3 §10.1: self-preview — компактная плавающая карточка, которую можно
   перенести в один из четырёх углов; свободное размещение не требуется, при
   отпускании карточка мягко примагничивается к ближайшему углу. */
.call-local {
  position: absolute;
  width: 116px;
  height: 158px;
  object-fit: cover;
  border-radius: var(--r-card, 18px);
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  background: #000;
  cursor: grab;
  touch-action: none;
  transition: top 200ms ease, bottom 200ms ease, left 200ms ease, right 200ms ease;
}
.call-local.hidden { display: none; }
.call-local.dragging { cursor: grabbing; transition: none; box-shadow: 0 10px 28px rgba(0,0,0,.6); }
.call-local.c-tr { top: calc(16px + env(safe-area-inset-top)); right: 16px; left: auto; bottom: auto; }
.call-local.c-tl { top: calc(16px + env(safe-area-inset-top)); left: 16px; right: auto; bottom: auto; }
.call-local.c-br { bottom: calc(132px + env(safe-area-inset-bottom)); right: 16px; top: auto; left: auto; }
.call-local.c-bl { bottom: calc(132px + env(safe-area-inset-bottom)); left: 16px; top: auto; right: auto; }

/* Центральная карточка (аудио) / верхняя плашка (видео). */
.call-center {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-top: auto;
  margin-bottom: auto;
}
.call-who { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.call-state { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.call-secure {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--purple-12);
  color: var(--purple);
  font-size: 0.8125rem;
  font-weight: 600;
}
.call-secure .nmx-sign { width: 15px; height: 15px; color: currentColor; }

/* В видео-режиме центр превращается в верхнюю плашку поверх видео. */
.call-screen.video-mode .call-center {
  position: absolute;
  top: 0; left: 0; right: 0;
  margin: 0;
  padding: calc(18px + env(safe-area-inset-top)) 16px 26px;
  background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,0));
}
.call-screen.video-mode .call-avatar { display: none; }
.call-screen.video-mode .call-who,
.call-screen.video-mode .call-state { color: #F5F9FF; }

.call-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 22px;
  margin-top: auto;
}
.call-screen.video-mode .call-actions {
  position: absolute;
  bottom: calc(34px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  justify-content: center;
}
.call-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  color: #fff;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.call-btn:hover:not(:disabled) { transform: translateY(-1px); }
.call-btn:active { transform: scale(.96); }
.call-btn svg { width: 26px; height: 26px; }
.call-btn.accept { background: var(--purple); }
.call-btn.accept:hover { background: var(--purple-active); }
.call-btn.hangup { background: var(--danger); }
/* Нейтральные управляющие кнопки (микрофон/камера). */
.call-btn.control { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-row); }
.call-screen.video-mode .call-btn.control {
  background: rgba(255,255,255,.16);
  color: #fff;
  box-shadow: none;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
/* Выключенное состояние микрофона/камеры — красный акцент. */
.call-btn.control.off { color: var(--danger); }
.call-screen.video-mode .call-btn.control.off { background: rgba(229,72,77,.24); color: #fff; }
/* Активное удержание — фирменный фиолетовый акцент. */
.call-btn.control.active { background: var(--purple); color: #fff; box-shadow: none; }
.call-screen.video-mode .call-btn.control.active { background: var(--purple); color: #fff; }

/* ===================== Вы ===================== */
/* §2.2: карточка профиля выше на 110 CSS px, растёт вниз (колонка, по центру),
   не вправо. Крупное фото сверху, под ним — имя (Bold, §2.3), ник, роль · статус. */
.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  min-height: 242px;                 /* было ≈132px; +110 (ТЗ №3 §2.2) */
  /* Во всю ширину и по центру. Карточка — это <button>, у которого width:auto
     сжимается по содержимому и прижимает её влево, поэтому ширину задаём явно,
     а центрируем автоматическими полями. */
  width: calc(100% - 2 * var(--pad-screen));
  margin: 12px auto 4px;
  padding: 20px 18px;
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-row);
}
.profile-card .avatar-button { margin-bottom: 8px; }
.profile-card .chat-main { flex: none; min-width: 0; max-width: 100%; }
.profile-card .name { font-size: 1.375rem; font-weight: 700; }  /* §2.3 главный акцент */
.profile-card .nick { color: var(--accent-text); font-size: 0.9375rem; font-weight: 600; margin-top: 2px; }
.profile-card .role { color: var(--text-secondary); font-size: 0.9375rem; margin-top: 2px; }
/* §2.2 адаптивность: при низком окне карточка ужимается, иерархия сохраняется. */
@media (max-height: 720px) {
  .profile-card { min-height: 180px; padding: 14px 18px; }
}

/* §2.1 Отдельное представление профиля (шторка): крупное фото + данные. */
.profile-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  margin-bottom: 12px;
}
.profile-view .avatar.lg { width: 112px; height: 112px; }
.profile-view .name { font-size: 1.5rem; font-weight: 700; margin-top: 8px; }
.profile-view .nick { color: var(--accent-text); font-size: 0.9375rem; font-weight: 600; }
.profile-view .role { color: var(--text-secondary); font-size: 0.9375rem; }
.profile-view .btn.ghost { margin-top: 12px; }

/* Знак и поля внутри шторок раздела «Вы» */
.sheet-sign { display: flex; justify-content: center; margin: 2px 0 14px; }
.nmx-sign.big { width: 56px; height: 56px; color: var(--purple); }
.sheet-field { margin: 6px 0 4px; }
.glyph.sign svg { width: 18px; height: 18px; }
.sheet .group-title { padding-left: 2px; }
.profile-id {
  margin-top: 6px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.group {
  margin: 16px var(--pad-screen);
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-row);
}
.group-title {
  padding: 0 var(--pad-screen) 8px;
  margin: 20px 0 0;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  font-size: 1rem;
}
.group-row + .group-row { box-shadow: inset 0 1px 0 var(--separator); }
.group-row:hover { background: var(--surface-hover); }
.group-row .glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: var(--purple-12);
  color: var(--purple);
}
.group-row .glyph svg { width: 17px; height: 17px; }
.group-row .label { flex: 1; min-width: 0; }
.group-row .value { color: var(--text-secondary); font-size: 0.9375rem; }
.group-row .chev { color: var(--text-tertiary); }
.group-row .chev svg { width: 16px; height: 16px; }
.group-note {
  margin: 6px var(--pad-screen) 0;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}
.group-row.danger { color: var(--danger); }
.group-row.danger .glyph { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* §8.4 Переключатель: вкл #542366 / hover #603274 / pressed #4B176E / выкл #343840 */
.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--switch-off);
  transition: background var(--dur-fast) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--switch-knob-off);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.switch[aria-checked="true"] { background: var(--switch-on); }
.switch[aria-checked="true"]:hover { background: var(--switch-hover); }
.switch[aria-checked="true"]:active { background: var(--switch-pressed); }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: var(--switch-knob); }

/* Сегменты (выбор темы) */
.group-row .segmented { flex: 1; min-width: 0; }
.segmented {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: var(--r-chip);
  background: var(--surface-sunken);
}
.segmented button {
  flex: 1;
  height: 30px;
  border-radius: var(--r-chip);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-row);
}

/* ===================== Вход ===================== */
.auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
}
.auth-card {
  width: min(400px, 100%);
  padding: 28px 24px;
  border-radius: var(--r-panel);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.auth-brand {
  text-align: center;
  margin-bottom: 22px;
}
.auth-brand .mark {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.auth-brand .sub {
  margin-top: 4px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.auth-field + .auth-field { margin-top: 14px; }
.auth-card .btn { margin-top: 20px; }
.auth-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 0.875rem;
}
.auth-alt {
  margin-top: 16px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Заставка до загрузки ядра */
.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 100dvh;
  color: var(--text-secondary);
}
.boot .mark {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-primary);
}
.boot-bar {
  width: 120px;
  height: 3px;
  border-radius: 999px;
  background: var(--surface-active);
  overflow: hidden;
}
.boot-bar::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: var(--purple);
  animation: boot-slide 1.1s var(--ease) infinite;
}
@keyframes boot-slide {
  from { transform: translateX(-100%); }
  to   { transform: translateX(300%); }
}

/* ============ Администрирование → Пользователи (батч 2) ============ */
.admin-users { margin-top: 4px; }
.admin-user-row { width: 100%; }
.admin-sub {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-top: 2px;
}
/* Чипы статуса в строке и карточке */
.admin-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  background: var(--purple-12);
  vertical-align: middle;
}
.admin-chip.danger { color: #fff; background: var(--danger, #B3261E); }
.admin-chips { display: flex; gap: 6px; margin-top: 6px; }
.admin-chips:empty { display: none; }

/* Шапка карточки пользователя */
.admin-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 2px 0 14px;
}
.admin-card-id { min-width: 0; }
.admin-card-id .name { font-size: 1.125rem; font-weight: 700; }
.admin-card-id .nick { color: var(--accent-text); font-size: 0.875rem; font-weight: 600; margin-top: 1px; }
.admin-card-id .role { color: var(--text-secondary); font-size: 0.875rem; margin-top: 2px; }

/* Секции действий */
.admin-section { margin-top: 18px; }
.admin-section .btn.block + .btn.block { margin-top: 8px; }
.admin-field { margin: 8px 0; }
.admin-field-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin: 0 0 3px 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-field select.field { width: 100%; }

/* §6.2 Пометка «не в NiMilex» у локального контакта в «Новом звонке» */
.contact-note {
  flex: none;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
}

/* §17.2 Аудиосообщение — фирменная двухцветная волна */
.audio-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  max-width: 320px;
  margin: 2px 0 4px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--audio-container);
}
/* ТЗ 4.5 §12: компактная кнопка скорости — не фиолетовая заливка, лишь акцент. */
.audio-speed {
  flex: none;
  min-width: 34px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--separator);
  border-radius: 999px;
  background: transparent;
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.audio-speed:hover { background: var(--surface-hover); }
.audio-play {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--audio-btn);
  color: var(--audio-icon);
  transition: background var(--dur-fast) var(--ease);
}
.audio-play:hover { background: var(--ink-dry); }
.audio-play:active { background: var(--ink-fresh); }
.audio-play svg { width: 20px; height: 20px; }
.audio-play-ic { display: flex; }
.audio-wave {
  flex: 1;
  min-width: 0;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  touch-action: none;
}
.audio-bar {
  flex: 1;
  min-width: 2px;
  min-height: 3px;
  border-radius: 999px;
  background: var(--wave-unplayed);
  transition: background 0.08s linear;
}
.audio-bar.played { background: var(--wave-played); }
.audio-time {
  flex: none;
  font-size: 0.75rem;
  color: var(--audio-time);
  font-variant-numeric: tabular-nums;
}

/* §2.1 Профиль: тап по собеседнику в шапке диалога */
.dialog-peer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}
.dialog-peer .dialog-title { flex: 1; min-width: 0; }

/* карточка профиля как кнопка (открывает профиль целиком). Ширину и центрирование
   задаёт основное правило .profile-card выше (§2.2). */
.profile-card { border: 0; cursor: pointer; font: inherit; color: inherit; }

/* §2.1 Профиль. На телефоне — цельная колонка во всю ширину (фото по центру,
   ниже — форма); фото сбоку от формы только на широком экране (десктоп). */
.profile-edit { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.profile-edit-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: none;
}
.profile-edit-photo .avatar.lg { width: 120px; height: 120px; }
.profile-edit-form { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 900px) {
  .profile-edit { flex-direction: row; gap: 24px; align-items: flex-start; }
  .profile-edit-form { flex: 1; min-width: 260px; }
}

/* фото профиля кликабельно (зум) */
.avatar-zoom { background: none; border: 0; padding: 0; cursor: zoom-in; }

/* §2.1 Полноэкранный просмотр фотографии */
.photo-zoom {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 6, 10, 0.92);
  cursor: zoom-out;
  animation: fade-in var(--dur) var(--ease);
}
.photo-zoom-img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.photo-zoom-mono {
  width: min(60vw, 260px);
  height: min(60vw, 260px);
  clip-path: var(--polygon26);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mono-0);
  color: #fff;
  font-size: 4rem;
  font-weight: 600;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   ТЗ 4.6 — профиль «Вы», конфиденциальность и настройки
   ============================================================ */

/* §2: профильная область ниже исходной ровно на 110 CSS px (см. --profile-extra). */
.you-profile { min-height: calc(132px + var(--profile-extra)); }
.you-profile .presence { color: var(--text-tertiary); font-size: 0.8125rem; margin-top: 4px; }

/* §5 Публичный ID: нажатие копирует, поэтому это кнопка, а не текст. */
.profile-id {
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-row);
}
.profile-id:hover { background: var(--purple-08); }

/* §5 «Мой QR». Код рисуется своим SVG — сторонних скриптов не подключаем. */
.qr-box { display: flex; justify-content: center; margin: 8px 0 14px; }
.qr-svg { border-radius: var(--r-card); }
.qr-bg { fill: #FFFFFF; }        /* сканеру нужен светлый фон в обеих темах */
.qr-fg { fill: #0D0F13; }
.qr-handle { display: block; margin: 0 auto 8px; cursor: pointer; }

/* §13 Одноразовые коды восстановления — показываются один раз. */
.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 14px;
}
.recovery-codes code {
  padding: 8px 10px;
  border-radius: var(--r-row);
  background: var(--surface-sunken);
  font-size: 0.9375rem;
  letter-spacing: 0.04em;
  text-align: center;
}

/* §8 Строка приватности: подпись сверху, три варианта под ней. */
.privacy-group { padding: 4px 0; }
.privacy-row { padding: 10px 14px; border-bottom: 1px solid var(--separator); }
.privacy-row:last-child { border-bottom: 0; }
.privacy-label { font-size: 0.9375rem; margin-bottom: 8px; }
.segmented.small button { font-size: 0.8125rem; padding: 6px 8px; }

/* §11 Активные устройства. */
.session-row { align-items: flex-start; }
.session-main { flex: 1; min-width: 0; }
.session-sub { font-size: 0.8125rem; color: var(--text-secondary); margin-top: 2px; }

/* §15 Шкала медиакэша: точки 1 / 5 / 10 / 20 ГБ и «∞ Никогда».
   Заполненная часть и выбранная точка — фирменный активный цвет #542366,
   неактивная часть — #A7ADB7, недоступное состояние — #777E89. */
.cache-scale-box { padding: 18px 22px 10px; }
.cache-scale {
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: var(--silver-secondary);
  margin-bottom: 16px;
}
.cache-scale-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--ink-core);
  transition: width var(--dur) var(--ease);
}
.cache-dot {
  position: absolute;
  top: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--silver-secondary);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.cache-dot[aria-selected="true"] {
  border-color: var(--ink-core);
  background: var(--ink-violet);
}
.cache-dot:disabled { border-color: var(--silver-disabled); cursor: default; }
.cache-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* §12 Экран кода приложения. */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg-top);
  padding: 24px;
}
.lock-mark { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.06em; color: var(--ink-violet); }
.lock-title { color: var(--text-secondary); }
.lock-dots { display: flex; gap: 12px; margin: 6px 0 2px; }
.lock-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--silver-secondary);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.lock-dot.on { background: var(--ink-core); border-color: var(--ink-core); }
.lock-error { min-height: 20px; color: var(--danger); font-size: 0.875rem; }
.lock-keys {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 14px;
}
.lock-key {
  height: 64px;
  display: grid; place-items: center;
  border: 0;
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 1.5rem;
  cursor: pointer;
}
.lock-key:hover { background: var(--surface-hover); }
.lock-key:active { background: var(--surface-active); }
.lock-key.empty { background: transparent; cursor: default; }
.lock-key svg { width: 22px; height: 22px; color: var(--icon); }

/* Компактная кнопка внутри строк и карточек. */
.btn.small {
  padding: 6px 12px;
  font-size: 0.8125rem;
  min-height: 0;
  width: auto;
}
