/* ═══════════════════════════════════════════════════════
   Mauris Messenger — Soft Dark Theme
   Design System v4.2 (Pastel + Inter + Lucide Icons)
   ═══════════════════════════════════════════════════════ */

:root {
  /* ── Палитра фонов (Мягкая тёмная тема) ── */
  --bg-primary: #0D0D12;
  --bg-secondary: #16161D;
  --bg-tertiary: #1E1E28;
  --bg-input: #1E1E28;
  --bg-hover: #282833;
  --bg-message-own: linear-gradient(135deg, #6B8CFF, #5A78E6);
  --bg-message-own-solid: #6B8CFF;
  --bg-message-other: rgba(255,255,255,0.06);
  --bg-elevated: #1A1A24;

  /* ── Текст ── */
  --text-primary: #E8E8ED;
  --text-secondary: rgba(232,232,237,0.6);
  --text-muted: rgba(232,232,237,0.35);
  --text-tertiary: rgba(232,232,237,0.50);  /* третичный (должности, подписи) */
  --text-label: rgba(232,232,237,0.9);

  /* ── Акцентные цвета (Пастельная палитра) ── */
  --accent: #7C9AFF;           /* Приглушённый синий */
  --accent-hover: #9DB3FF;
  --accent-green: #7DD89A;     /* Мягкий зелёный */
  --accent-red: #F08A84;       /* Пастельный красный/коралл */
  --accent-yellow: #F5D77A;    /* Тёплый жёлтый */
  --accent-orange: #F5B27A;    /* Мягкий оранжевый */
  --accent-purple: #C9A8F5;    /* Лавандовый */

  /* ── Семантические цвета ── */
  --danger: #F08A84;
  --success: #7DD89A;
  --warning: #F5D77A;
  --border: rgba(255,255,255,0.08);

  /* ── Glass / Glassmorphism ── */
  --glass-bg: rgba(255,255,255,0.05);
  --glass-bg-hover: rgba(255,255,255,0.08);
  --glass-bg-active: rgba(255,255,255,0.12);
  --glass-border: rgba(255,255,255,0.08);
  /* Блюр — ЧИСЛОМ (использовать как blur(var(--glass-blur)) saturate(…)).
     Раньше токен содержал blur() и давал blur(blur()) → невалидно. Фикс в источнике. */
  --glass-blur: 40px;
  --glass-blur-thin: 20px;
  --glass-blur-thick: 60px;
  --overlay: rgba(0,0,0,0.5);

  /* ── Тени (Более мягкие) ── */
  --shadow: rgba(0,0,0,0.25);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);

  /* ── Радиусы (iOS-style) ── */
  /* Скругления уменьшены ~вдвое (было 8/12/16/22/38) — карточки/модалки были
     слишком круглыми. --radius-md ДОБАВЛЕН: раньше он не был задан, поэтому
     border-radius: var(--radius-md) у листа действий и др. давал 0 → квадрат. */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius: 11px;
  --radius-lg: 13px;
  --radius-xl: 20px;

  /* ── Типографика ── */
  --font-hero: 600 34px/1.2 'SF Pro Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-title: 700 28px/1.2 'SF Pro Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-headline: 600 17px/1.3 'SF Pro Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 400 17px/1.5 'SF Pro Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-callout: 400 16px/1.4 'SF Pro Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-subhead: 400 15px/1.4 'SF Pro Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-footnote: 400 13px/1.4 'SF Pro Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-caption: 400 12px/1.3 'SF Pro Display', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --tracking-hero: -0.4px;
  --tracking-title: 0.34px;
  --tracking-headline: -0.41px;
  --tracking-body: -0.41px;
  --tracking-callout: -0.32px;
  --tracking-subhead: -0.24px;
  --tracking-footnote: -0.08px;
  --tracking-caption: 0px;

  /* ── Анимации ── */
  --transition: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-fast: 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-slow: 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --spring: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition: 0.01ms linear;
    --transition-fast: 0.01ms linear;
    --transition-slow: 0.01ms linear;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ─── Lucide Icons ─────────────────────────────────── */

/* Базовые стили для Lucide SVG иконок */
[data-lucide] {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: middle;
  display: inline-block;
  flex-shrink: 0;
}

/* Иконки в кнопках */
.icon-btn [data-lucide] {
  width: 20px;
  height: 20px;
}

/* Маленькие иконки в настройках */
.setting-label [data-lucide],
.download-hint [data-lucide],
h3 [data-lucide],
h4 [data-lucide] {
  width: 18px;
  height: 18px;
  margin-right: 6px;
}

/* Иконки в админ-табах */
.admin-tab [data-lucide] {
  width: 16px;
  height: 16px;
  margin-right: 4px;
}

/* Иконки в download buttons */
.dl-icon [data-lucide] {
  width: 24px;
  height: 24px;
}

/* ─── Glass-утилиты (4.2) ─────────────────────────── */

/* B-026.03: фикс мерцания glass-эффекта на iOS/Safari/мобилках.
   Без `transform: translateZ(0)` элементы с backdrop-filter иногда «прыгают»
   между CPU- и GPU-композитингом при скролле/анимации → визуальное мерцание.
   `will-change: backdrop-filter` явно даёт браузеру понять, что для этих
   элементов нужно создать постоянный composite layer. */
.glass,
.glass-thin,
.glass-thick,
.glass-colored {
  transform: translateZ(0);
  will-change: backdrop-filter;
  -webkit-transform: translateZ(0);
}

/* .glass / .glass-thin / .glass-thick — перенесены в glass.css (R2/R4),
   там «живая» версия (rim-блик + перелив). Здесь удалены как перекрытые. */

.glass-colored {
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  background: rgba(10, 132, 255, 0.12);
  border: 1px solid rgba(10, 132, 255, 0.2);
}

/* ─── Анимации @keyframes (4.3) ───────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes scaleOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.95); }
}

@keyframes backdropFadeIn {
  from { background: rgba(0, 0, 0, 0); }
  to   { background: rgba(0, 0, 0, 0.4); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(10, 132, 255, 0.4); }
  50%      { box-shadow: 0 0 12px 4px rgba(10, 132, 255, 0.15); }
}

@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1); }
}

@keyframes onlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.4); }
  50%      { box-shadow: 0 0 0 4px rgba(48, 209, 88, 0); }
}

@keyframes badgeBounce {
  0%, 100% { transform: scale(1); }
  30%      { transform: scale(1.25); }
  60%      { transform: scale(0.9); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes messageAppear {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Анимационные утилиты ─────────────────────────── */

.animate-fade-in     { animation: fadeIn 0.3s var(--spring) both; }
.animate-slide-up    { animation: slideInUp 0.35s var(--spring) both; }
.animate-slide-down  { animation: slideInDown 0.35s var(--spring) both; }
.animate-slide-left  { animation: slideInLeft 0.35s var(--spring) both; }
.animate-slide-right { animation: slideInRight 0.35s var(--spring) both; }
.animate-scale-in    { animation: scaleIn 0.25s var(--spring) both; }

html, body {
  /* Высота видимого вьюпорта. Каскад «снизу вверх»: берётся последнее
     валидное значение, которое поддержал движок.
     1) 100% — древний фолбэк.
     2) 100dvh — динамическая высота (чёлка/тулбар/home-indicator).
     3) var(--app-height) — ТОЧНУЮ высоту пинит JS из visualViewport/innerHeight.
        Это лечит баг iOS standalone PWA, где 100dvh иногда не включает нижнюю
        safe-зону → контент «уезжает вверх», снизу провал. */
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  /* P-05: блокируем pull-to-refresh браузера и rubber-band на iOS,
     иначе вертикальный свайп в чате уводит вверх и ломает жест */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body {
  font: var(--font-body);
  letter-spacing: var(--tracking-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Экраны ───────────────────────────────────────── */

.screen {
  display: none;
  /* iOS standalone+cover баг: innerHeight/100dvh/проценты высоты занижены на
     статус-бар → снизу провал. position:fixed;inset:0 прибивает экран к РЕАЛЬНОЙ
     рамке webview (полный экран), в обход вранья высоты. */
  position: fixed;
  inset: 0;
}

.screen.active {
  display: flex;
}

/* ─── Экраны авторизации ───────────────────────────── */

#key-screen,
#register-screen {
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  animation: fadeIn 0.5s var(--spring) both;
}

.auth-container,
.login-container {
  text-align: center;
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.4s var(--spring) both;
}

/* Регистрация: 3 поля (Имя / Фамилия / Должность) вертикально */
.register-fields {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.75rem 0 0.25rem;
}
.register-fields input { width: 100%; margin: 0; }

/* Поля профиля в настройках */
.profile-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.profile-fields input {
  width: 100%;
  padding: 0.7rem 1rem;
  font: var(--font-body);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}
.profile-fields input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.25);
}

.auth-container h1 {
  font: var(--font-title);
  letter-spacing: var(--tracking-title);
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-container h2 {
  font: var(--font-headline);
  letter-spacing: var(--tracking-headline);
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.auth-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font: var(--font-subhead);
  letter-spacing: var(--tracking-subhead);
}

#key-input {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1.4rem;
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  letter-spacing: 3px;
  text-align: center;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  margin-bottom: 1rem;
}

#key-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.25);
}

#key-input::placeholder {
  letter-spacing: 2px;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.auth-error {
  color: var(--accent-red);
  font: var(--font-footnote);
  letter-spacing: var(--tracking-footnote);
  margin-bottom: 0.75rem;
  padding: 0.625rem 0.75rem;
  background: rgba(255, 69, 58, 0.12);
  border: 1px solid rgba(255, 69, 58, 0.2);
  border-radius: var(--radius-sm);
  animation: slideInUp 0.3s var(--spring) both;
}

.auth-error.hidden {
  display: none;
}

.login-logo,
.auth-logo {
  font-size: 5rem;
  margin-bottom: 0.5rem;
  animation: float 3s ease-in-out infinite;
}

/* Крупные Lucide-иконки в логотипах и плейсхолдерах */
.login-logo [data-lucide],
.auth-logo [data-lucide],
.placeholder-icon [data-lucide] {
  width: 80px;
  height: 80px;
  stroke-width: 1.5;
  color: var(--accent);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.login-container h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.login-avatar-pick,
.avatar-pick {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.avatar-btn {
  font-size: 1.8rem;
  width: 50px;
  height: 50px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  background: var(--glass-bg);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-btn:hover {
  border-color: var(--accent);
  transform: scale(1.1);
  background: var(--glass-bg-hover);
}

.avatar-btn.selected {
  border-color: var(--accent);
  background: rgba(10, 132, 255, 0.15);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.25);
}

#nickname-input,
.register-fields input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  font: var(--font-body);
  letter-spacing: var(--tracking-body);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  text-align: center;
}

#nickname-input:focus,
.register-fields input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.25);
}

.color-picker {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.color-btn {
  width: 36px;
  height: 36px;
  border: 3px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
}

.color-btn:hover {
  transform: scale(1.15);
}

.color-btn.selected {
  border-color: white;
  box-shadow: 0 0 10px var(--shadow);
}

.btn-primary {
  width: 100%;
  padding: 0.875rem;
  font: var(--font-headline);
  letter-spacing: var(--tracking-headline);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(10, 132, 255, 0.35);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: none;
}

.btn-secondary {
  padding: 0.625rem 1.25rem;
  font: var(--font-callout);
  letter-spacing: var(--tracking-callout);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
}

/* ─── Главный экран ────────────────────────────────── */

#main-screen {
  flex-direction: row;
}

/* ─── Сайдбар ──────────────────────────────────────── */

#sidebar {
  width: 320px;
  min-width: 320px;
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  background: var(--glass-bg);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden; /* Предотвращает выход контента за границы */
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  flex-shrink: 0; /* Не сжимается */
  padding: 0.75rem 1rem;
  /* Шапка списка чатов — ниже «чёлки»/Dynamic Island и не под скруглённые углы
     (status-bar: black-translucent → контент уходит под вырез без этих отступов). */
  padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--glass-border);
  gap: 0.5rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.sidebar-avatar {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.sidebar-nickname {
  font: var(--font-callout);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sidebar-actions {
  display: flex;
  gap: 0.15rem;
  flex-wrap: wrap;
  width: 100%;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-xs);
  transition: var(--transition);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--glass-bg-hover);
}

/* ═══ [B-013] Liquid Glass — тестовая порция: иконки в шапке боковой панели ═══ */
/* Если эффект понравится — раскатываем на остальные кнопки. Откат: удалить этот блок. */

.sidebar-actions .icon-btn {
  position: relative;
  isolation: isolate;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0.02) 100%
  );
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.45rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15),
    0 4px 12px rgba(0, 0, 0, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.25s ease,
              box-shadow 0.25s ease,
              border-color 0.25s ease;
}

/* Верхний блик — имитация преломления света на стекле */
.sidebar-actions .icon-btn::before {
  content: '';
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 45%;
  border-radius: 9px 9px 0 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.22) 0%,
    rgba(255, 255, 255, 0.04) 100%
  );
  pointer-events: none;
  z-index: -1;
}

.sidebar-actions .icon-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.22) 0%,
    rgba(255, 255, 255, 0.10) 50%,
    rgba(255, 255, 255, 0.04) 100%
  );
  border-color: rgba(255, 255, 255, 0.20);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 6px 18px rgba(0, 0, 0, 0.22),
    0 2px 4px rgba(0, 0, 0, 0.14);
}

.sidebar-actions .icon-btn:active {
  transform: translateY(0) scale(0.96);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.20),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Активный режим админа — синий glass */
.sidebar-actions #btn-admin-panel.admin-active {
  background: linear-gradient(
    135deg,
    rgba(10, 132, 255, 0.45) 0%,
    rgba(10, 132, 255, 0.25) 100%
  );
  border-color: rgba(120, 180, 255, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.40),
    0 4px 14px rgba(10, 132, 255, 0.35),
    0 0 12px rgba(10, 132, 255, 0.25);
}

.sidebar-rooms {
  flex: 1;
  min-height: 0; /* Критично для flex overflow */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* P-09 (v2): табы в стиле B-013 Liquid Glass — как кнопочки в шапке сайдбара */
.sidebar-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1;
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0.02) 100%
  );
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15),
    0 4px 12px rgba(0, 0, 0, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.25s ease,
              box-shadow 0.25s ease,
              border-color 0.25s ease,
              color 0.2s ease;
}
/* Верхний блик — преломление света на стекле (как у icon-btn) */
.sidebar-tab::before {
  content: '';
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 45%;
  border-radius: 11px 11px 0 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.22) 0%,
    rgba(255, 255, 255, 0.04) 100%
  );
  pointer-events: none;
  z-index: -1;
}
.sidebar-tab:hover {
  color: var(--text);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.22) 0%,
    rgba(255, 255, 255, 0.10) 50%,
    rgba(255, 255, 255, 0.04) 100%
  );
  border-color: rgba(255, 255, 255, 0.20);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 6px 18px rgba(0, 0, 0, 0.22),
    0 2px 4px rgba(0, 0, 0, 0.14);
}
.sidebar-tab:active {
  transform: translateY(0) scale(0.97);
}
.sidebar-tab.active {
  color: #ffffff;
  background: linear-gradient(
    135deg,
    rgba(10, 132, 255, 0.45) 0%,
    rgba(10, 132, 255, 0.25) 100%
  );
  border-color: rgba(120, 180, 255, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.40),
    0 4px 14px rgba(10, 132, 255, 0.35),
    0 0 12px rgba(10, 132, 255, 0.25);
}

/* P-09 (refine): glass-кружочек вокруг глобуса публичных комнат — B-013 Liquid Glass */
.room-public-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 3px;
  margin-right: 4px;
  vertical-align: middle;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0.02) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.30),
    inset 0 -1px 0 rgba(0, 0, 0, 0.10),
    0 2px 6px rgba(0, 0, 0, 0.18);
  opacity: 1;
  font-size: inherit;
}
.room-public-icon i,
.room-public-icon svg {
  width: 12px;
  height: 12px;
  color: rgba(255, 255, 255, 0.85);
}
.sidebar-tab i { width: 14px; height: 14px; }
.dm-tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  background: var(--accent, #0a84ff);
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  font-weight: 700;
  margin-left: 4px;
}
.dm-tab-badge.hidden { display: none; }

/* P-09 (refine): кнопка "Новый диалог" — B-013 Liquid Glass, квадратно-прямоугольная */
.new-dm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 16px);
  margin: 8px;
  padding: 10px 14px;
  position: relative;
  isolation: isolate;
  color: #fff;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0.02) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.30),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 4px 12px rgba(0, 0, 0, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.new-dm-btn::before {
  content: '';
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 45%;
  border-radius: 11px 11px 0 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.20) 0%,
    rgba(255, 255, 255, 0.02) 100%
  );
  pointer-events: none;
  z-index: -1;
}
.new-dm-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.18) 0%,
    rgba(255, 255, 255, 0.09) 50%,
    rgba(255, 255, 255, 0.04) 100%
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 6px 16px rgba(0, 0, 0, 0.22),
    0 2px 4px rgba(0, 0, 0, 0.14);
}
.new-dm-btn:active { transform: scale(0.97); }
.new-dm-btn i { width: 16px; height: 16px; }

/* Пикер пользователей в модалке */
.dm-user-search {
  width: 100%;
  margin: 0.5rem 0 0.75rem;
  padding: 10px 12px;
  background: var(--bg-elev, #1c1c1e);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 10px;
  color: var(--text, #fff);
  font-size: 0.95rem;
  box-sizing: border-box;
}
.dm-user-list {
  max-height: 50vh;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
}
.dm-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.dm-user-row:hover { background: rgba(255,255,255,0.05); }
.dm-user-row .dm-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}
.dm-user-row .dm-user-name {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  color: var(--text, #fff);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dm-user-row .dm-user-status {
  font-size: 0.78rem;
  color: var(--text-muted, #888);
}
.dm-user-row .dm-user-status.online { color: #4caf50; }

/* Элемент списка личных диалогов (структурно похож на .room-item) */
.dm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border, #2a2a2a);
  transition: background 0.15s;
  /* long-press → меню мута: гасим iOS-callout/выделение текста */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.dm-item:hover { background: rgba(255, 255, 255, 0.04); }
.dm-item.active { background: rgba(10, 132, 255, 0.12); }
.dm-item .dm-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: var(--bg-secondary, #1f1f1f);
  overflow: hidden;
}
.dm-item .dm-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.dm-item .dm-info { flex: 1; min-width: 0; }
.dm-item .dm-name { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-item .dm-last { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.dm-item .dm-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.dm-item .dm-time { font-size: 11px; color: var(--text-muted); }
.dm-item .dm-unread {
  min-width: 20px;
  padding: 0 6px;
  background: var(--accent, #0a84ff);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
}

.empty-rooms {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-rooms .hint {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  /* long-press → меню мута: гасим iOS-callout/выделение текста, чтобы жест не перехватывался */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.room-item:hover {
  background: var(--glass-bg-hover);
}

.room-item.active {
  background: rgba(10, 132, 255, 0.12);
  border-left: 3px solid var(--accent);
}

.room-icon {
  font-size: 1.5rem;
  width: 42px;
  height: 42px;
  background: var(--glass-bg);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.room-info {
  flex: 1;
  min-width: 0;
}

.room-name {
  font: var(--font-callout);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-last-msg {
  font: var(--font-caption);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.room-meta {
  text-align: right;
  flex-shrink: 0;
}

.room-time {
  font: var(--font-caption);
  color: var(--text-muted);
}

