/* ============================================================
   Чат — основные стили
   Светлая тема по умолчанию; тёмная: html[data-theme="dark"]
   JS задаёт: --accent, --accent-soft, --accent-strong,
              --msg-font, --sidebar-w, --skin-glow
   ============================================================ */

/* ---------- 0. Сброс, база, утилиты ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #b8860b;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

img,
video {
  max-width: 100%;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
  touch-action: manipulation;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent, #8e6cf5);
  text-decoration: none;
  word-break: break-word;
}
a:hover {
  text-decoration: underline;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 3px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 400;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#chat-wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
html.has-wallpaper body {
  background: transparent;
}

.hp-field {
  position: absolute !important;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

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

mark,
.find-mark {
  background: rgba(255, 214, 0, 0.45);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* ---------- 0.1. Тема ---------- */
:root {
  --accent: #8e6cf5;
  --accent-soft: rgba(142, 108, 245, 0.15);
  --accent-strong: rgba(142, 108, 245, 0.45);
  --msg-font: 14px;
  --skin-glow: transparent;
  --sidebar-w: 330px;

  --bg-header: #ffffff;
  --panel: #ffffff;
  --panel-2: #f5f6fa;
  --input-bg: #f0f1f5;
  --text: #b8860b;
  --text-dim: #6b7280;
  --border: #e3e6ee;
  --hover: rgba(0, 0, 0, 0.045);
  --bubble-own: var(--accent);
  --bubble-other: #ffffff;
  --shadow: 0 2px 12px rgba(20, 24, 60, 0.1);
  --shadow-lg: 0 10px 44px rgba(20, 24, 60, 0.22);
  --overlay: rgba(10, 12, 30, 0.5);
  --danger: #e5484d;
  --ok: #22b573;
  --warn: #ffa41d;
}

html[data-theme='dark'] {
  --bg-header: #171a2e;
  --panel: #171a2e;
  --panel-2: #1d2138;
  --input-bg: #232742;
  --text: #ffd700;
  --text-dim: #8f95b5;
  --border: #2a2f4d;
  --hover: rgba(255, 255, 255, 0.055);
  --bubble-other: #1d2138;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 44px rgba(0, 0, 0, 0.55);
  --overlay: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

html.density-1 {
  font-size: 13px;
}
html.density-3 {
  font-size: 15px;
}

/* ---------- 0.3. Кнопки ---------- */
.btn,
.btn-primary,
.btn-secondary,
.btn-cancel,
.btn-danger,
.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  transition:
    background 0.15s,
    border-color 0.15s,
    opacity 0.15s,
    transform 0.1s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-secondary {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--hover);
}

.btn-cancel {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-cancel:hover {
  background: var(--hover);
  color: var(--text);
}

.btn-danger,
.acct-delete-btn {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  opacity: 0.88;
}

.btn-small,
.member-btn.btn-small {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn.ghost,
.btn-secondary.ghost {
  background: transparent;
}

.clickable {
  cursor: pointer;
}
.export-link {
  display: none;
}
body.dragging-user {
  cursor: grabbing;
  user-select: none;
}

.member-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}
.member-btn:hover {
  background: var(--hover);
}
.member-btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.member-btn.danger,
.member-btn.sel-delete {
  color: var(--danger);
}

/* ---------- 1. Экран входа ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent 60%), radial-gradient(900px 500px at 100% 100%, rgba(46, 157, 255, 0.1), transparent 55%);
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 32px 28px 24px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  text-align: center;
}

.login-card > p {
  margin: 0 0 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo svg {
  width: 30px;
  height: 30px;
}

.login-tabs {
  display: flex;
  gap: 4px;
  background: var(--input-bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}

.login-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dim);
  transition:
    background 0.15s,
    color 0.15s;
}
.login-tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

#login-account-pane input[type='text'],
#login-account-pane input[type='password'],
#login-account-pane input[type='email'],
#login-account-pane input[type='date'],
#login-forgot-pane input,
#login-reset-pane input,
.pw-wrap input {
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  outline: none;
  transition: border-color 0.15s;
}
#login-account-pane input:focus,
#login-forgot-pane input:focus,
#login-reset-pane input:focus,
.pw-wrap input:focus {
  border-color: var(--accent);
}

.pw-wrap {
  position: relative;
}

.pw-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(calc(-50% - 5px));
  padding: 6px;
  font-size: 15px;
  opacity: 0.55;
}
.pw-eye:hover {
  opacity: 1;
}

.pw-hint {
  min-height: 1em;
  margin: -4px 0 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.pw-strength {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.pw-strength-bar {
  flex: 1;
  height: 4px;
  background: var(--input-bg);
  border-radius: 2px;
  overflow: hidden;
}
.pw-strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--danger);
  transition:
    width 0.25s,
    background 0.25s;
}

.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.captcha-question {
  font-weight: 600;
}
.captcha-row input {
  flex: 1;
  margin: 0 !important;
}

.login-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  transition:
    opacity 0.15s,
    background 0.15s;
}
.login-btn:hover {
  opacity: 0.9;
}

.login-btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-weight: 500;
}
.login-btn.ghost:hover {
  background: var(--hover);
  color: var(--text);
}

.login-link {
  display: block;
  width: 100%;
  text-align: center;
  padding: 4px;
  color: var(--accent);
  font-size: 13px;
}

.login-error {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.login-note {
  min-height: 1.2em;
  margin: 6px 0 0;
  color: var(--ok);
  font-size: 13px;
  text-align: center;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--text-dim);
  font-size: 12px;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.pane-note {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 14px;
}

/* ---------- 2. Каркас ---------- */
.chat-screen {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100%;
}

/* ---------- 3. Сайдбар ---------- */
.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w, 330px);
  min-width: 240px;
  max-width: 70vw;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar.collapsed {
  display: none;
}

.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 5;
}
.sidebar-resizer:hover,
body.resizing-sidebar .sidebar-resizer {
  background: var(--accent-soft);
}

.sidebar-show-btn {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
}
.sidebar.collapsed .sidebar-show-btn {
  display: block;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 10px 10px 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  position: relative;
  flex: 1;
  padding: 10px 6px 11px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s,
    border-color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-create-row {
  display: flex;
  gap: 6px;
  padding: 10px 12px 0;
}

.create-group-btn {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.create-group-btn:hover {
  opacity: 0.88;
}

.create-group-btn.ghost {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.create-group-btn.ghost:hover {
  background: var(--hover);
}

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

.ptr-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  color: var(--text-dim);
  font-size: 12px;
}

.ptr-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.chat-filter,
.user-filter {
  display: flex;
  gap: 4px;
  padding: 8px 6px 6px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  transition:
    background 0.15s,
    color 0.15s;
}
.filter-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.folder-filter {
  margin: 0 8px 6px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  width: calc(100% - 16px);
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.chat-item:hover {
  background: var(--hover);
}
.chat-item.active {
  background: var(--accent-soft);
}

.chat-item.pinned::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 2px;
  background: var(--accent);
}

.chat-item.archived {
  opacity: 0.6;
}
.chat-item.dragging {
  opacity: 0.45;
}
.chat-item.drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.chat-item.swipe-right {
  background: var(--accent-soft);
}
.chat-item.swipe-armed {
  background: var(--accent-soft);
}

.chat-cat {
  font-size: 13px;
  flex-shrink: 0;
}
.forum-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  vertical-align: middle;
}
.chat-preview.preview-draft {
  color: var(--accent);
  font-style: italic;
}

.chat-avatar,
.user-avatar,
.common-avatar,
.header-avatar,
.me-avatar,
.story-avatar,
.story-header-avatar,
.profile-avatar,
.call-avatar,
.msg-avatar,
.user-hover-avatar,
.voice-chip-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.chat-avatar img,
.user-avatar img,
.header-avatar img,
.me-avatar img,
.msg-avatar img,
.story-avatar img,
.profile-avatar img,
.user-hover-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.common-avatar {
  background: linear-gradient(135deg, var(--accent), #2e9dff);
}

.chat-info {
  flex: 1;
  min-width: 0;
}

.chat-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 3D-надпись названия группы в списке слева: слои text-shadow дают «торец»
   букв и мягкую тень, светлая линия сверху — блик. Цвет берётся из темы,
   тёмному режиму нужны свои тени: светлый блик там слишком ярок. */
.chat-name.chat-name-3d {
  color: var(--text);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45),
    1px 1px 0 rgba(0, 0, 0, 0.1),
    2px 2px 0 rgba(0, 0, 0, 0.09),
    2px 3px 4px rgba(0, 0, 0, 0.22);
  transition: text-shadow 0.18s ease;
}

.chat-item:hover .chat-name-3d {
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55),
    1px 1px 0 rgba(0, 0, 0, 0.12),
    2px 2px 0 rgba(0, 0, 0, 0.11),
    3px 3px 0 rgba(0, 0, 0, 0.1),
    3px 4px 6px rgba(0, 0, 0, 0.26);
}

html[data-theme='dark'] .chat-name.chat-name-3d {
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18),
    1px 1px 0 rgba(0, 0, 0, 0.35),
    2px 2px 0 rgba(0, 0, 0, 0.32),
    2px 3px 5px rgba(0, 0, 0, 0.45);
}

html[data-theme='dark'] .chat-item:hover .chat-name-3d {
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22),
    1px 1px 0 rgba(0, 0, 0, 0.4),
    2px 2px 0 rgba(0, 0, 0, 0.36),
    3px 3px 0 rgba(0, 0, 0, 0.32),
    4px 5px 8px rgba(0, 0, 0, 0.5);
}

/* Название группы в шапке чата — крупнее, поэтому объём глубже */
.chat-title-wrap h1.is-3d {
  color: var(--text);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45),
    1px 1px 0 rgba(0, 0, 0, 0.12),
    2px 2px 0 rgba(0, 0, 0, 0.11),
    3px 3px 0 rgba(0, 0, 0, 0.1),
    4px 4px 0 rgba(0, 0, 0, 0.1),
    4px 6px 10px rgba(0, 0, 0, 0.28);
}

html[data-theme='dark'] .chat-title-wrap h1.is-3d {
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18),
    1px 1px 0 rgba(0, 0, 0, 0.38),
    2px 2px 0 rgba(0, 0, 0, 0.34),
    3px 3px 0 rgba(0, 0, 0, 0.3),
    4px 4px 0 rgba(0, 0, 0, 0.26),
    5px 7px 12px rgba(0, 0, 0, 0.5);
}

.chat-preview {
  color: var(--text-dim);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-offline {
  font-size: 11px;
  color: var(--text-dim);
}
.chat-imported {
  font-size: 11px;
  color: var(--warn);
}

.chat-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.chat-time {
  font-size: 11px;
  color: var(--text-dim);
}

.chat-call-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  opacity: 0.75;
  transition:
    background 0.12s,
    opacity 0.12s,
    color 0.12s;
  flex-shrink: 0;
}
.chat-call-btn:hover {
  background: var(--hover);
  opacity: 1;
  color: var(--accent);
}
.chat-call-btn .ico {
  width: 16px;
  height: 16px;
}

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

.chat-sep,
.unread-divider {
  text-align: center;
  padding: 8px 0 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.chat-sep-text,
.unread-divider-text {
  display: inline-block;
  padding: 2px 10px;
  background: var(--panel-2);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.unread-divider {
  color: var(--accent);
}

/* Блок «я» */
.me {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

.me-avatar {
  width: 38px;
  height: 38px;
  font-size: 14px;
  cursor: pointer;
}
.me-info {
  flex: 1;
  min-width: 0;
}

.me-name {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.me-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.me-status-select {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.me-change-avatar {
  font-size: 16px;
  padding: 6px;
  border-radius: 8px;
  opacity: 0.6;
}
.me-change-avatar:hover {
  opacity: 1;
  background: var(--hover);
}

.user-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
}
.user-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.user-status.st-ok::before,
.user-hover-status.st-ok::before {
  background: var(--ok);
}
.user-status.st-busy::before,
.user-hover-status.st-busy::before {
  background: var(--danger);
}
.user-status.st-away::before,
.user-hover-status.st-away::before {
  background: var(--warn);
}
.user-status.st-offline::before,
.user-hover-status.st-offline::before {
  background: var(--text-dim);
}
.st-offline {
  color: var(--text-dim);
}

.new-chat-fab {
  position: absolute;
  right: 14px;
  bottom: 78px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px var(--accent-strong);
  z-index: 4;
  transition: transform 0.15s;
}
.new-chat-fab:hover {
  transform: scale(1.06);
}

/* Мобильная навигация */
.mobile-nav {
  display: none;
  align-items: stretch;
  border-top: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-btn {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  color: var(--text-dim);
  font-size: 11px;
  transition: color 0.15s;
}
.mobile-nav-btn.active {
  color: var(--accent);
}

.mobile-nav-ico {
  font-size: 20px;
  line-height: 1;
}

.mobile-nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Участники / друзья */
.users-count {
  padding: 10px 14px 0;
  font-size: 12px;
  color: var(--text-dim);
}
.user-search {
  padding: 10px 12px 0;
}

.user-search input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  outline: none;
}
.user-search input:focus {
  border-color: var(--accent);
}

.users-list,
.friends-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px 12px;
}

.users-section-head,
.friends-section {
  padding: 10px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.user-item,
.friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.user-item:hover,
.friend-item:hover {
  background: var(--hover);
}

.user-info {
  flex: 1;
  min-width: 0;
}
.user-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-name {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-hl {
  background: rgba(255, 214, 0, 0.35);
  border-radius: 3px;
  color: inherit;
}

.friend-actions,
.friend-btn-row {
  display: flex;
  gap: 5px;
}

.friend-btn {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
}
.friend-btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

/* Hover-card */
.user-hover-card {
  position: fixed;
  z-index: 220;
  width: 240px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 14px;
}
.user-hover-top {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.user-hover-avatar {
  width: 48px;
  height: 48px;
}
.user-hover-meta {
  min-width: 0;
}

.user-hover-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-hover-bio {
  font-size: 12px;
  color: var(--text-dim);
  margin: 4px 0 8px;
}
.user-hover-actions {
  display: flex;
  gap: 6px;
}

.user-hover-btn {
  flex: 1;
  padding: 7px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- 4. Область чата ---------- */
.chat-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 56px;
  z-index: 6;
}

.back-btn,
.hdr-action,
.burger-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--text);
  flex-shrink: 0;
  transition: background 0.12s;
}
.back-btn:hover,
.hdr-action:hover,
.burger-btn:hover {
  background: var(--hover);
}

#back-btn {
  display: none;
}
#menu-btn {
  display: none;
}

.header-avatar {
  width: 38px;
  height: 38px;
  font-size: 14px;
  cursor: pointer;
}

.chat-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chat-title-wrap h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-subtitle,
.typing-status {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.typing-status {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.ico {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico-off {
  display: none;
}

/* Вкладки открытых чатов (широкий экран) */
.chat-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  z-index: 5;
}
.chat-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  max-width: 220px;
  flex-shrink: 0;
  transition:
    background 0.12s,
    color 0.12s,
    border-color 0.12s;
}
.chat-tab:hover {
  background: var(--hover);
  color: var(--text);
}
.chat-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chat-tab-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-tab-close {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  opacity: 0.7;
  flex-shrink: 0;
}
.chat-tab-close:hover {
  background: rgba(0, 0, 0, 0.12);
  opacity: 1;
}
.chat-tab.active .chat-tab-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Меню чата / бургер */
.chat-menu,
.burger-menu {
  position: absolute;
  top: 54px;
  right: 10px;
  z-index: 60;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
}

.chat-menu-item,
.burger-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: #b8860b;
  transition: background 0.12s;
}
html[data-theme='dark'] .chat-menu-item,
html[data-theme='dark'] .burger-menu-item {
  color: #ffd700;
}
.chat-menu-item:hover,
.burger-menu-item:hover {
  background: var(--hover);
}
.burger-ico {
  width: 18px;
  text-align: center;
}
.mi-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Служебные полосы */
.conn-bar,
.update-bar,
.announce-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13px;
  flex-shrink: 0;
}
.conn-bar {
  background: var(--warn);
  color: #1a1d2e;
}
.conn-bar.is-error {
  background: #e5484d;
  color: #fff;
}
.update-bar {
  background: var(--warn);
  color: #1a1d2e;
}
.announce-bar {
  background: var(--accent-soft);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.announce-bar-icon {
  flex-shrink: 0;
}

/* Закреп */
.pin-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 13px;
}
.pin-banner-title {
  flex-shrink: 0;
}
.pin-banner-text {
  flex: 1;
  min-width: 0;
  text-align: left;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pin-banner-close {
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-dim);
}
.pin-banner-close:hover {
  background: var(--hover);
  color: var(--text);
}

/* Выбор сообщений */
.select-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.select-count {
  font-weight: 600;
  font-size: 13px;
}

/* Темы форума */
.topics-screen {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.topics-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topics-title {
  font-weight: 700;
  flex: 1;
}

.topics-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
}

.topic-item,
.chat-item.topic-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s;
}
.topic-item:hover {
  background: var(--hover);
}
.topic-icon {
  font-size: 20px;
}
.topic-actions {
  display: flex;
  gap: 4px;
}
.topic-act {
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 13px;
}
.topic-act:hover {
  background: var(--hover);
}
.topic-act.danger {
  color: var(--danger);
}

/* ---------- 5. Сообщения ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 720px;
  width: fit-content;
  position: relative;
  padding: 1px 0;
}
.message.own {
  margin-left: auto;
  flex-direction: row-reverse;
}
.message.grouped {
  margin-top: 0;
}
.message:not(.grouped):not(.group-start) {
  margin-top: 8px;
}
.message.system {
  align-self: center;
  max-width: 90%;
}
.message.selected {
  background: var(--accent-soft);
  border-radius: 12px;
}

.messages.select-mode .message {
  cursor: pointer;
}
.messages.select-mode .message:hover {
  background: var(--accent-soft);
  border-radius: 12px;
}

.message.nav-focus,
.message.kb-focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

.message.highlight .msg-bubble {
  animation: msg-flash 1.6s ease;
}
@keyframes msg-flash {
  0%,
  40% {
    background: rgba(255, 214, 0, 0.25);
  }
  100% {
    background: transparent;
  }
}

.msg-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.message.grouped .msg-avatar {
  visibility: hidden;
  height: 0;
  margin: 0;
}

/* Рамки аватаров */
.msg-avatar.frame-gold {
  box-shadow: 0 0 0 2px #f5c542;
}
.msg-avatar.frame-silver {
  box-shadow: 0 0 0 2px #c0c6d4;
}
.msg-avatar.frame-bronze {
  box-shadow: 0 0 0 2px #cd7f32;
}
.msg-avatar.frame-neon {
  box-shadow:
    0 0 0 2px #22d3ee,
    0 0 10px rgba(34, 211, 238, 0.7);
}
.msg-avatar.frame-pulse {
  box-shadow: 0 0 0 2px var(--accent);
  animation: frame-pulse 2s ease-in-out infinite;
}
.msg-avatar.frame-aurora {
  box-shadow:
    0 0 0 2px #a78bfa,
    0 0 12px rgba(167, 139, 250, 0.6);
  background: linear-gradient(135deg, #a78bfa, #22d3ee);
}
@keyframes frame-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 2px var(--accent);
  }
  50% {
    box-shadow:
      0 0 0 4px var(--accent-strong),
      0 0 14px var(--accent-soft);
  }
}

.msg-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1px;
}

.msg-name {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--accent);
  cursor: pointer;
  text-shadow:
    1px 1px 0 #000,
    2px 2px 0 rgba(0, 0, 0, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.55);
}
.msg-name.vip {
  background: linear-gradient(90deg, #f5c542, #ff8a00, #ffe680, #f5c542);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.35),
    0 0 8px rgba(245, 197, 66, 0.45);
  animation: vip-nick-shimmer 3.5s linear infinite;
}
@keyframes vip-nick-shimmer {
  from {
    background-position: 0% 0;
  }
  to {
    background-position: 300% 0;
  }
}

.msg-auto-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--warn);
  color: #1a1d2e;
  font-weight: 600;
}

.role-badge,
.vip-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.role-owner {
  background: #f5c542;
  color: #1a1d2e;
}
.role-admin {
  background: #e5484d;
  color: #fff;
}
.role-moderator {
  background: #2e9dff;
  color: #fff;
}
.vip-badge {
  background: linear-gradient(135deg, #f5c542, #ff8a00);
  color: #1a1d2e;
}
.vip-badge.vip-tier-1 {
  background: linear-gradient(135deg, #cd7f32, #a05a2c);
  color: #fff;
}
.vip-badge.vip-tier-2 {
  background: linear-gradient(135deg, #c0c6d4, #8a93a8);
  color: #1a1d2e;
}
.vip-badge.vip-tier-3 {
  background: linear-gradient(135deg, #f5c542, #ff8a00);
  color: #1a1d2e;
}

.vip-badge-lg {
  display: inline-flex;
  padding: 5px 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f5c542, #ff8a00);
  color: #1a1d2e;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.msg-bubble {
  position: relative;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--bubble-other);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  font-size: var(--msg-font);
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  text-shadow:
    1px 1px 0 #8a6e18,
    2px 2px 0 #755c14,
    3px 3px 0 #5e4a10,
    0 4px 6px rgba(0, 0, 0, 0.28);
}
.message.own .msg-bubble {
  background: var(--bubble-own);
  color: #fff;
  border-bottom-right-radius: 4px;
  text-shadow:
    1px 1px 0 rgba(0, 0, 0, 0.5),
    2px 2px 0 rgba(0, 0, 0, 0.38),
    3px 3px 0 rgba(0, 0, 0, 0.26),
    0 4px 6px rgba(0, 0, 0, 0.3);
}
.message:not(.own) .msg-bubble {
  border-bottom-left-radius: 4px;
}
.message.grouped.own .msg-bubble {
  border-top-right-radius: 4px;
}
.message.grouped:not(.own) .msg-bubble {
  border-top-left-radius: 4px;
}

.message.deleted .msg-bubble {
  background: transparent;
  box-shadow: none;
  text-shadow: none;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  font-style: italic;
}
.deleted-text {
  color: var(--text-dim);
}

.msg-time {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-dim);
  float: right;
  margin: 6px 0 -2px 10px;
  user-select: none;
}
.message.own .msg-time {
  color: rgba(255, 255, 255, 0.75);
}
.msg-edited {
  opacity: 0.8;
}
.msg-status {
  color: rgba(255, 255, 255, 0.75);
}
.msg-status.read {
  color: #7ef0c0;
}
.message:not(.own) .msg-status {
  display: none;
}

/* Обои на фоне: текст сообщений — белый, пузыри — тёмные полупрозрачные,
   чтобы фото оставалось видимым и текст оставался читаемым. */
html.has-wallpaper .msg-bubble {
  background: rgba(10, 12, 30, 0.62) !important;
  color: #fff;
}
html.has-wallpaper .msg-time,
html.has-wallpaper .message.own .msg-time {
  color: rgba(255, 255, 255, 0.85);
}
html.has-wallpaper .msg-status {
  color: rgba(255, 255, 255, 0.8);
}
html.has-wallpaper .deleted-text {
  color: rgba(255, 255, 255, 0.7);
}

/* Действия над сообщением */
.msg-actions {
  display: none;
  gap: 2px;
  position: absolute;
  top: -14px;
  right: 6px;
  z-index: 2;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 5px;
  box-shadow: var(--shadow);
}
.message.show-actions .msg-actions,
.message:hover .msg-actions {
  display: flex;
}

.act {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.12s;
}
.act:hover {
  background: var(--hover);
}
.act.danger {
  color: var(--danger);
}
.act.fav {
  color: var(--warn);
}

.more-btn {
  align-self: flex-start;
  margin-top: 2px;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}
.more-btn:hover {
  background: var(--accent-soft);
}

/* Быстрые реакции */
.quick-react {
  display: none;
  gap: 2px;
  position: absolute;
  top: -14px;
  left: 6px;
  z-index: 2;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 5px;
  box-shadow: var(--shadow);
}
.message:hover .quick-react {
  display: flex;
}
.message.own .quick-react {
  left: auto;
  right: 6px;
}

.qr-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.1s,
    background 0.12s;
}
.qr-btn:hover {
  background: var(--hover);
  transform: scale(1.15);
}

/* Реакции */
.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s;
}
.reaction-chip:hover {
  background: var(--hover);
}
.reaction-chip.mine {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.message.own .reaction-chip {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
}
.message.own .reaction-chip.mine {
  background: rgba(255, 255, 255, 0.32);
}

/* VIP-реакции: золотое свечение чипа, если отреагировал VIP */
.reaction-chip.vip-react {
  border-color: #f5c542;
  background: linear-gradient(135deg, rgba(245, 197, 66, 0.22), rgba(255, 138, 0, 0.18));
  animation: vip-react-glow 1.6s ease-in-out infinite alternate;
}
.message.own .reaction-chip.vip-react {
  background: rgba(255, 255, 255, 0.28);
  border-color: #ffe680;
}
@keyframes vip-react-glow {
  from {
    box-shadow: 0 0 2px rgba(245, 197, 66, 0.45);
  }
  to {
    box-shadow: 0 0 10px rgba(245, 197, 66, 0.95);
  }
}
@media (prefers-reduced-motion: reduce) {
  .msg-name.vip,
  .reaction-chip.vip-react {
    animation: none;
  }
}

/* Ответ / пересылка */
.reply-quote,
.forward-context {
  display: block;
  padding: 5px 10px;
  margin-bottom: 5px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  max-width: 340px;
}
.message.own .reply-quote,
.message.own .forward-context {
  background: rgba(255, 255, 255, 0.14);
  border-left-color: rgba(255, 255, 255, 0.6);
}
.reply-quote-name,
.forward-src {
  display: block;
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 1px;
}
.message.own .reply-quote-name,
.message.own .forward-src {
  color: rgba(255, 255, 255, 0.9);
}
.reply-quote-text {
  display: block;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message.own .reply-quote-text {
  color: rgba(255, 255, 255, 0.75);
}

/* Медиа */
.msg-media {
  border-radius: 10px;
  overflow: hidden;
  margin: 3px 0;
  max-width: 420px;
}
.msg-media img,
.msg-media video {
  display: block;
  max-height: 400px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.04);
}
.msg-media.sticker {
  font-size: 72px;
  line-height: 1;
  text-align: center;
  padding: 6px 10px;
  background: transparent !important;
  box-shadow: none !important;
}
.msg-caption {
  margin-top: 4px;
  font-size: var(--msg-font);
}

.media-saver-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px;
  margin-top: 4px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.12s;
}
.media-saver-btn:hover {
  background: rgba(0, 0, 0, 0.68);
}
.media-saver-ico {
  font-size: 15px;
}

/* Файлы */
.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  margin: 3px 0;
  cursor: pointer;
}
.message.own .msg-file {
  background: rgba(255, 255, 255, 0.16);
}
.file-icon {
  font-size: 26px;
}
.file-info {
  min-width: 0;
}
.file-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-size {
  font-size: 11px;
  color: var(--text-dim);
}
.message.own .file-size {
  color: rgba(255, 255, 255, 0.7);
}

/* Голосовое */
.voice-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  padding: 4px 0;
}

.voice-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.message.own .voice-play {
  background: rgba(255, 255, 255, 0.25);
}

.voice-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  z-index: auto;
  min-width: 0;
  display: block;
}
.message.own .voice-bar {
  background: rgba(255, 255, 255, 0.25);
}

.voice-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
}
.message.own .voice-fill {
  background: #fff;
}

.voice-time {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 36px;
  text-align: right;
}
.message.own .voice-time {
  color: rgba(255, 255, 255, 0.75);
}

.voice-speed {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text-dim);
  flex-shrink: 0;
}
.message.own .voice-speed {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Markdown / код */
.markdown {
  white-space: pre-wrap;
}
.markdown.e2e-msg {
  border-left: 3px solid var(--ok);
  padding-left: 8px;
}
.long-msg {
  max-height: 250px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
}

.code-block {
  background: #1e1e2e;
  color: #d4d4e4;
  border-radius: 10px;
  margin: 6px 0;
  overflow: hidden;
  font-size: 12.5px;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: #9aa0b8;
}
.code-lang {
  font-weight: 600;
}
.code-copy,
.code-toggle {
  padding: 2px 8px;
  border-radius: 5px;
  color: #9aa0b8;
  font-size: 11px;
}
.code-copy:hover,
.code-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.code-block pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  line-height: 1.5;
}
.code-collapsed pre {
  max-height: 180px;
  overflow: hidden;
}
.tok-key {
  color: #c792ea;
}
.tok-str {
  color: #c3e88d;
}
.tok-com {
  color: #7f848e;
  font-style: italic;
}
.tok-num {
  color: #f78c6c;
}

.mention {
  padding: 0 4px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.message.own .mention {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.mention.mention-all {
  background: rgba(229, 72, 77, 0.18);
  color: #e5484d;
}
.mention-mark {
  background: rgba(255, 214, 0, 0.35);
  border-radius: 3px;
}

/* Превью ссылок */
.link-preview {
  display: flex;
  gap: 10px;
  margin: 6px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  cursor: pointer;
}
.message.own .link-preview {
  background: rgba(255, 255, 255, 0.14);
  border-left-color: rgba(255, 255, 255, 0.6);
}
.link-preview-img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.link-preview-txt {
  min-width: 0;
}
.link-preview-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}
.link-preview-desc {
  font-size: 12px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.message.own .link-preview-desc {
  color: rgba(255, 255, 255, 0.75);
}
.link-preview-host {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
.link-hint {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.8;
}

/* Перевод */
.translation-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}
.message.own .translation-head {
  border-top-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
}
.translation-hide {
  margin-left: auto;
  color: var(--accent);
  font-size: 11px;
}
.translation-text {
  font-size: 13px;
  margin-top: 3px;
  opacity: 0.9;
}
.msg-translation {
  margin-top: 4px;
}
.translation-label {
  font-weight: 700;
  color: var(--accent);
}
.translation-from {
  color: var(--text-dim);
}
.message.own .translation-label {
  color: rgba(255, 255, 255, 0.95);
}
.message.own .translation-from {
  color: rgba(255, 255, 255, 0.7);
}

/* Опрос: подложка тёмная в обеих темах, текст белый — иначе на светлом
   пузыре белый текст опроса нечитаем (регрессия закреплена тестом) */
.poll-msg {
  min-width: 240px;
  margin: 2px 0;
  background: #2a3040;
  border-radius: 10px;
  padding: 8px 10px;
}
.poll-msg.closed {
  opacity: 0.75;
}
.poll-question {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
  color: #fff;
}
.poll-options-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.poll-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  cursor: pointer;
  overflow: hidden;
  transition:
    border-color 0.12s,
    background 0.12s;
}
.poll-option:hover {
  border-color: rgba(255, 255, 255, 0.5);
}
.poll-option.voted {
  border-color: var(--accent);
  background: rgba(142, 108, 245, 0.3);
}
.message.own .poll-option {
  border-color: rgba(255, 255, 255, 0.3);
}
.message.own .poll-option.voted {
  background: rgba(255, 255, 255, 0.22);
  border-color: #fff;
}

.poll-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(142, 108, 245, 0.42);
  border-radius: 10px;
  transition: width 0.3s;
  pointer-events: none;
}

.poll-opt-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 1;
}
.poll-remove {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
  flex-shrink: 0;
}
.poll-remove:hover {
  background: rgba(229, 72, 77, 0.15);
  color: var(--danger);
}
.poll-text {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
}
.poll-pct {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.message.own .poll-pct {
  color: rgba(255, 255, 255, 0.85);
}
.poll-text {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.poll-pct {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.poll-meta {
  margin-top: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
}
.poll-closed {
  font-size: 11px;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.7);
}
.poll-error {
  font-size: 11px;
  margin-top: 4px;
  color: var(--danger);
}
.poll-close {
  margin-top: 8px;
  padding: 5px 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.poll-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Событие */
.event-msg {
  min-width: 240px;
}
.event-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}
.event-desc,
.event-when,
.event-place {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}
.message.own .event-desc,
.message.own .event-when,
.message.own .event-place {
  color: rgba(255, 255, 255, 0.8);
}

.event-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.event-choice {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s;
}
.event-choice:hover {
  border-color: var(--accent);
}
.event-choice.mine {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.event-updated {
  font-size: 11px;
  color: var(--ok);
  margin-top: 4px;
}
.event-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
}
.event-delete {
  margin-top: 8px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid rgba(229, 72, 77, 0.5);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}
.event-delete:hover {
  background: rgba(229, 72, 77, 0.12);
}

/* Игра */
.game-msg {
  min-width: 260px;
}
.game-head {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.message.own .game-head {
  color: rgba(255, 255, 255, 0.75);
}
.game-word {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 22px;
  letter-spacing: 0.25em;
  font-weight: 700;
  margin: 8px 0;
}
.game-input-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.game-input {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  min-width: 0;
}
.game-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.game-key {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.game-key.used {
  opacity: 0.4;
}
.game-key.wrong {
  background: rgba(229, 72, 77, 0.2);
  color: var(--danger);
}
.game-status {
  font-size: 12px;
  margin-top: 6px;
}
.game-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}
.game-wrong {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.game-guess-btn {
  margin-top: 6px;
}
.game-start,
.game-stop {
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

/* Разделители / системные */
.date-separator {
  align-self: center;
  margin: 12px 0 6px;
}
.date-separator-text {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
}
.system-message,
.system-bubble {
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 4px 12px;
  align-self: center;
}
.system-bubble {
  background: var(--panel-2);
  border-radius: 999px;
  padding: 4px 14px;
}

/* Скелет / пусто */
.msg-skeleton {
  width: 180px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--hover) 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.2s infinite;
  margin: 4px 0;
}
@keyframes skeleton {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
.msg-empty {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  padding: 30px;
}
.msg-empty-ico {
  font-size: 44px;
  margin-bottom: 10px;
}
.msg-empty-text {
  font-size: 13.5px;
  margin-top: 4px;
}

.msg-copied {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.msg-copied.show {
  opacity: 1;
}

.fav-label {
  display: inline-block;
  align-self: flex-start;
  margin-top: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(245, 197, 66, 0.18);
  border: 1px solid rgba(245, 197, 66, 0.5);
  font-size: 11px;
  font-weight: 600;
  color: var(--warn);
}

/* Эффекты */
.effect-rainbow .msg-bubble {
  background: linear-gradient(120deg, #ff5d5d, #ffa41d, #22b573, #2e9dff, #8e6cf5, #ff66c4);
  background-size: 200% 200%;
  animation: rainbow-bg 4s ease infinite;
  color: #fff;
}
.effect-neon .msg-bubble {
  box-shadow:
    0 0 8px var(--accent-strong),
    0 0 22px var(--accent-soft);
  border: 1px solid var(--accent);
}
.effect-sparkle .msg-bubble::after {
  content: '\2728';
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 14px;
  animation: sparkle 1.6s ease-in-out infinite;
}
.effect-glow .msg-bubble {
  box-shadow: 0 0 16px var(--skin-glow, var(--accent-soft));
}

@keyframes rainbow-bg {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}
@keyframes sparkle {
  0%,
  100% {
    opacity: 0.5;
    transform: scale(0.8) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.2) rotate(20deg);
  }
}

/* Bottom-sheet действий */
.msg-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 250;
}
.msg-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  z-index: 251;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0));
  box-shadow: var(--shadow-lg);
  animation: sheet-up 0.2s ease;
}
@keyframes sheet-up {
  from {
    transform: translate(-50%, 30px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}
.msg-sheet-grab {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 4px auto 10px;
}
.msg-sheet-title {
  font-weight: 700;
  font-size: 14px;
  padding: 0 6px 8px;
}
.msg-sheet-list {
  display: flex;
  flex-direction: column;
}

.msg-sheet-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 10px;
  font-size: 14px;
  text-align: left;
  width: 100%;
}
.msg-sheet-item:hover {
  background: var(--hover);
}
.msg-sheet-item.danger {
  color: var(--danger);
}
.msg-sheet-react {
  display: flex;
  gap: 6px;
  padding: 8px 6px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.msg-sheet-reactions {
  font-size: 22px;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 8px;
  transition: transform 0.1s;
}
.msg-sheet-reactions:hover {
  transform: scale(1.15);
  background: var(--hover);
}
.msg-sheet-panel {
  display: flex;
  flex-direction: column;
}

/* ---------- 6. Композер ---------- */

/* Панель ответа / редактирования над композером */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  flex-shrink: 0;
}
.reply-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.reply-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}
.reply-preview {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
  flex-shrink: 0;
}
.reply-close:hover {
  background: var(--hover);
  color: var(--text);
}

.input-area {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0));
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.composer-quickbar {
  display: flex;
  gap: 2px;
  padding-bottom: 4px;
}

.cq-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition:
    background 0.12s,
    color 0.12s;
  flex-shrink: 0;
}
.cq-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.input-media {
  position: relative;
  padding-bottom: 4px;
}

.attach-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition:
    background 0.12s,
    color 0.12s;
  flex-shrink: 0;
}
.attach-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.attach-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.input-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 60;
  min-width: 230px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.input-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  transition: background 0.12s;
}
.input-menu-item:hover {
  background: var(--hover);
}
.voice-btn.rec {
  color: var(--danger);
  background: rgba(229, 72, 77, 0.12);
}
.video-record-btn.recording {
  color: var(--danger);
  font-weight: 600;
}
.video-record-btn.recording::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1s step-end infinite;
  margin-left: auto;
}

.input-row {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 6px 4px 10px;
  transition: border-color 0.15s;
  min-width: 0;
}
.input-row:focus-within {
  border-color: var(--accent);
}

#message-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  padding: 7px 4px;
  max-height: 160px;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--text);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    opacity 0.15s,
    transform 0.1s;
}
.send-btn:hover {
  opacity: 0.88;
  transform: scale(1.05);
}

.composer-count {
  position: absolute;
  right: 60px;
  bottom: 2px;
  font-size: 10px;
  color: var(--text-dim);
}
.composer-count.over {
  color: var(--danger);
  font-weight: 700;
}

.composer-format {
  display: flex;
  gap: 2px;
  padding: 0 0 4px;
}

.caption-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.caption-bar input {
  flex: 1;
  min-width: 160px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
}

/* Запись голосового (строка композера) */
#voice-bar.voice-bar {
  position: static;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: auto;
  min-width: 0;
  height: auto;
  flex: 1;
  cursor: default;
}
#voice-bar .voice-fill {
  display: none;
}

.voice-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink 1s step-end infinite;
  flex-shrink: 0;
}
@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

.voice-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
}
.voice-hint {
  flex: 1;
  color: var(--text-dim);
  font-size: 12.5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-cancel,
.voice-stop {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.voice-cancel {
  color: var(--danger);
}
.voice-cancel:hover {
  background: rgba(229, 72, 77, 0.12);
}
.voice-stop {
  background: var(--danger);
  color: #fff;
}

.voice-draft-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.voice-draft-label {
  font-weight: 600;
  font-size: 13px;
}
.voice-draft-audio {
  flex: 1;
  min-width: 140px;
  height: 34px;
}

.undo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
}
.undo-btn {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
}
.undo-btn:hover {
  background: var(--accent-soft);
}

.upload-bar {
  padding: 8px 14px;
  background: var(--bg-header);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.upload-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}
.upload-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-error {
  color: var(--danger);
  font-size: 12px;
}

.progress {
  height: 4px;
  background: var(--input-bg);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.2s;
}
.compress-progress {
  font-size: 11px;
  color: var(--text-dim);
}

.jump-bottom,
.jump-top {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition:
    bottom 0.2s,
    top 0.2s;
}
.jump-bottom {
  bottom: 86px;
}
.jump-top {
  top: 70px;
}
.jump-bottom:hover,
.jump-top:hover {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.date-jump {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 240px;
}
.date-jump-input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
}
.date-jump-quick {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.date-jump-chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
}

.date-scrubber {
  position: absolute;
  right: 8px;
  top: 70px;
  bottom: 100px;
  width: 26px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
}
.date-scrubber-inner {
  position: relative;
  width: 5px;
  height: 100%;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
}
.date-scrubber-bubble {
  position: absolute;
  right: 12px;
  top: 0;
  transform: translateY(-50%);
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
}
.date-scrubber-tick {
  position: absolute;
  left: -3px;
  width: 11px;
  height: 2px;
  background: var(--text-dim);
  border-radius: 1px;
}

.attach-tray {
  padding: 8px 12px 0;
}
.attach-tray-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.attach-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  max-width: 220px;
}
.attach-item img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.attach-ico {
  font-size: 17px;
  line-height: 1;
  flex-shrink: 0;
}
.attach-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-rm {
  color: var(--danger);
  font-weight: 700;
  padding: 0 2px;
}
.attach-tray-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
.attach-tray-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  padding-top: 6px;
}

.desk-smart-replies {
  position: absolute;
  left: 12px;
  right: 70px;
  bottom: calc(100% + 8px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 40;
}

/* ---------- 7. Эмодзи / стикеры ---------- */
.emoji-panel,
.sticker-panel {
  background: var(--panel);
  border-top: 1px solid var(--border);
  max-height: 280px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.emoji-panel:not([hidden]),
.sticker-panel:not([hidden]) {
  display: flex;
}
.sticker-panel {
  overflow-y: auto;
}

.emoji-cats {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}
.emoji-cats button {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 17px;
  flex-shrink: 0;
}
.emoji-cats button:hover,
.emoji-cats button.active {
  background: var(--hover);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
}
.emoji-grid button {
  height: 38px;
  font-size: 22px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.1s,
    transform 0.1s;
}
.emoji-grid button:hover {
  background: var(--hover);
  transform: scale(1.12);
}

.emoji-auto-menu,
.mention-menu {
  position: absolute;
  z-index: 80;
  min-width: 220px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
}
.emoji-auto-glyph {
  font-size: 18px;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.mention-item.active,
.mention-item:hover {
  background: var(--accent-soft);
}
.mention-item-name {
  font-weight: 600;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
}
.sticker-pack {
  margin-bottom: 12px;
}
.sticker-pack-head {
  font-weight: 700;
  font-size: 13px;
  padding: 6px 10px;
  color: var(--text-dim);
}

.sticker-btn {
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  transition:
    transform 0.1s,
    background 0.12s;
  position: relative;
}
.sticker-btn:hover {
  transform: scale(1.05);
  background: var(--hover);
}
.sticker-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.sticker-add {
  margin: 0 10px 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 0.12s;
}
.sticker-add:hover {
  filter: brightness(1.1);
}
.sticker-added {
  background: var(--ok) !important;
}
.sticker-hbtn {
  font-size: 16px;
  padding: 6px;
  border-radius: 8px;
}
.sticker-error {
  color: var(--danger);
  font-size: 12px;
  padding: 4px 10px;
}

.group-sticker-cell {
  position: relative;
}
.group-sticker-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Личный стикер: ячейка сетки с кнопкой удаления только у владельца */
.sticker-cell {
  position: relative;
}
.sticker-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.sticker-cell:hover .sticker-del {
  opacity: 1;
}

/* ---------- 8. Модалки ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: min(86vh, 720px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: modal-up 0.2s ease;
}
@keyframes modal-up {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.modal h3 {
  margin: 0 0 4px;
  font-size: 17px;
}
.modal-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-dim);
}
.modal-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.modal-actions.group-actions,
.modal-actions.export-actions,
.modal-actions.profile-actions,
.modal-actions.call-settings-actions {
  justify-content: flex-start;
}

.search-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus {
  border-color: var(--accent);
}
textarea.search-input {
  resize: vertical;
  min-height: 60px;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-size: 13.5px;
  flex-wrap: wrap;
}
.setting-row input[type='checkbox'] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.setting-row-slider {
  flex-direction: column;
  align-items: stretch;
}
.set-label {
  flex: 1;
  min-width: 120px;
  color: var(--text);
}
.settings-range {
  width: 100%;
  accent-color: var(--accent);
}

.gs-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.gs-input {
  flex: 1;
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  outline: none;
}
.gs-input:focus {
  border-color: var(--accent);
}
.gs-totp-setup:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  margin-top: 6px;
}

.accent-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.accent-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition:
    transform 0.12s,
    border-color 0.12s;
}
.accent-dot:hover {
  transform: scale(1.12);
}
.accent-dot.active {
  border-color: var(--text);
  transform: scale(1.1);
}
.accent-8e6cf5 {
  background: #8e6cf5;
}
.accent-2e9dff {
  background: #2e9dff;
}
.accent-22b573 {
  background: #22b573;
}
.accent-ff5d5d {
  background: #ff5d5d;
}
.accent-ffa41d {
  background: #ffa41d;
}
.accent-ff66c4 {
  background: #ff66c4;
}

.wallpaper-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
}
.wp-preset {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid transparent;
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--panel-2);
  background-size: cover;
  background-position: center;
  transition:
    border-color 0.12s,
    transform 0.12s;
  overflow: hidden;
}
.wp-preset:hover {
  transform: scale(1.05);
}
.wp-preset.active {
  border-color: var(--accent);
}
.wp-photo {
  background-image: url('../img/orizg.png');
}
.wp-photo2 {
  background-image: url('../img/c_3.jpg');
}
.wp-photo3 {
  background-image: url('../img/wallpaper.jpg');
}
.wp-defaults {
  background-image: linear-gradient(160deg, #ffe9a8, #ffd24a);
}
.wp-night {
  background-image: linear-gradient(160deg, #0f1220, #2a2f4d);
}
.wp-sunset {
  background-image: linear-gradient(160deg, #ff8a5b, #ff5d5d);
}
.wp-lavender {
  background-image: linear-gradient(160deg, #c4b5fd, #8e6cf5);
}
.wp-mint {
  background-image: linear-gradient(160deg, #a7f3d0, #22b573);
}
.nick-grad-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin: 2px 0 6px;
}
.nick-grad-sw {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}
.nick-grad-sw.none {
  background: #e3e6ee;
  color: #1a1d2e;
  text-shadow: none;
}
.nick-grad-sw.active {
  border-color: var(--text);
  transform: scale(1.12);
  box-shadow: 0 0 0 2px var(--border);
}
.wp-photo4 {
  background-image: url('../img/i.jpg');
}

.quiet-time {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
}
.quiet-dash {
  color: var(--text-dim);
}
.quiet-hint,
.qr-info {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
}

.account-result-msg {
  font-size: 12.5px;
  min-height: 1em;
  padding: 4px 0;
}
.account-result-msg.ok {
  color: var(--ok);
}
.account-result-msg.err {
  color: var(--danger);
}
.account-result-msg.warn {
  color: var(--warn);
}

.totp-secret {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 8px 12px;
  background: var(--panel-2);
  border-radius: 8px;
  word-break: break-all;
  user-select: all;
}

/* VIP-карточка */
.vip-card {
  background: linear-gradient(145deg, rgba(245, 197, 66, 0.1), rgba(255, 138, 0, 0.06));
  border: 1px solid rgba(245, 197, 66, 0.35);
  border-radius: 14px;
  padding: 14px;
}
.vip-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.vip-card-title {
  font-weight: 700;
  font-size: 15px;
}
.vip-card-sub {
  font-size: 12.5px;
  color: var(--text-dim);
}
.vip-card-txt {
  flex: 1;
  min-width: 0;
}
.vip-perks {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 13px;
}
.vip-perks li {
  margin-bottom: 3px;
}
.vip-note-line {
  font-size: 12px;
  color: var(--text-dim);
  margin: 4px 0;
}

.warn-text {
  color: var(--warn);
}

.vip-tariff {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.12s;
  min-width: 110px;
  text-align: center;
}
.vip-tariff:hover {
  border-color: var(--accent);
}
.vip-tariff.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.vip-tariff-d {
  font-weight: 700;
  font-size: 13px;
}
.vip-tariff-p {
  font-size: 11px;
  color: var(--text-dim);
}

.swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform 0.12s;
}
.swatch:hover {
  transform: scale(1.12);
}
.swatch.active {
  border-color: var(--text);
}
.swatch-none {
  background: var(--panel-2);
  position: relative;
}
.swatch-none::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 2px solid var(--danger);
}

/* Поиск */
.search-modal {
  max-width: 560px;
}
.search-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.search-filter {
  flex: 1;
  min-width: 110px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  font-size: 12.5px;
}
.search-results {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.search-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  transition: background 0.12s;
}
.search-item:hover {
  background: var(--hover);
}
.search-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.search-item-ch {
  font-weight: 700;
  color: var(--accent);
}
.search-item-time {
  margin-left: auto;
}
.search-item-preview {
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Пересылка / цели */
.forward-targets {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}
.forward-target,
.invite-target,
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.forward-target:hover,
.invite-target:hover,
.member-row:hover {
  background: var(--hover);
}
.forward-target.selected,
.member-row.selected {
  background: var(--accent-soft);
}
.forward-target-meta {
  flex: 1;
  min-width: 0;
}
.forward-target-name {
  font-weight: 600;
  font-size: 13.5px;
}
.forward-target-note,
.forward-row {
  font-size: 12px;
  color: var(--text-dim);
}
.forward-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 16px;
  font-size: 13px;
}
.forward-banner {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 0;
}

.invite-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.invite-code {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  user-select: all;
}
.invite-check {
  color: var(--ok);
  font-size: 16px;
}

.member-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.pass-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 12.5px;
  flex-wrap: wrap;
}
.pass-text {
  flex: 1;
  min-width: 120px;
}
.invite-selected-btn {
  width: 100%;
  margin-top: 6px;
}

/* Профиль */
.profile-modal {
  max-width: 420px;
}
.profile-top {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile-avatar-box {
  flex-shrink: 0;
}
.profile-avatar {
  width: 72px;
  height: 72px;
  font-size: 26px;
}
.profile-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-name {
  font-weight: 800;
  font-size: 18px;
}
.profile-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.profile-status {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}
.profile-info,
.profile-contact,
.profile-stats {
  font-size: 13px;
}
.profile-contact-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.profile-stats-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.profile-calls-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}
.profile-call-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}
.profile-call-missed {
  color: var(--danger);
}
.profile-call-rec {
  font-size: 11px;
  color: var(--accent);
}
.profile-call-transcript {
  font-size: 11.5px;
  color: var(--text-dim);
  padding-left: 20px;
}

/* Галерея */
.gallery-modal {
  max-width: 640px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
}
.gallery-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--panel-2);
}
.gallery-cell img,
.gallery-cell video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-video-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
}

/* Статистика */
.stats-modal {
  max-width: 520px;
}
.stats-wrap,
.stats-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stats-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stats-top-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.stats-top-title {
  font-weight: 700;
}
.stats-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.stats-col {
  height: 8px;
  border-radius: 4px;
  background: var(--accent);
  min-width: 2px;
}
.stats-day {
  width: 70px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.stats-meta {
  flex: 1;
  color: var(--text-dim);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stats-val {
  font-weight: 700;
  flex-shrink: 0;
}

.hm-grid {
  display: grid;
  grid-template-columns: 22px repeat(7, 14px);
  gap: 3px;
  font-size: 9px;
}
.hm-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--input-bg);
}
.hm-corner,
.hm-hlab,
.hm-dlab {
  color: var(--text-dim);
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Найти людей */
.find-modal {
  max-width: 440px;
}
.find-results {
  max-height: 40vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.find-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--panel-2);
}
.find-status {
  font-size: 12px;
  color: var(--text-dim);
}

/* Звонки-список */
.calls-modal {
  max-width: 420px;
}
.calls-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 46vh;
  overflow-y: auto;
}
.calls-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 24px;
  font-size: 13px;
}
.call-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
}
.call-row:hover {
  background: var(--hover);
}
.call-row.missed .call-row-name {
  color: var(--danger);
}
.call-row-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.call-row-main {
  flex: 1;
  min-width: 0;
}
.call-row-name {
  font-weight: 600;
  font-size: 13.5px;
}
.call-row-sub {
  font-size: 12px;
  color: var(--text-dim);
}

/* Предпросмотр */
.preview-modal {
  max-width: 520px;
}
.preview-stage {
  max-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--input-bg);
  border-radius: 10px;
  overflow: hidden;
}
.preview-stage img,
.preview-stage video {
  max-height: 50vh;
  max-width: 100%;
  object-fit: contain;
}

/* Подсказки */
.hints-modal {
  max-width: 440px;
}
.hints-list {
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Сторис — создание */
.story-compose-modal {
  max-width: 420px;
}
.story-compose-stage {
  min-height: 160px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--accent), #2e9dff);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  padding: 20px;
  overflow: hidden;
}
.story-compose-stage img,
.story-compose-stage video {
  max-height: 240px;
  max-width: 100%;
  border-radius: 8px;
}
.story-text-input {
  min-height: 70px;
  resize: vertical;
}
.story-bg-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.story-bg-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform 0.12s;
}
.story-bg-swatch:hover {
  transform: scale(1.1);
}
.story-bg-swatch.active {
  border-color: var(--text);
}

.poll-modal {
  max-width: 440px;
}
.poll-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.secret-modal {
  max-width: 380px;
}
.event-modal {
  max-width: 440px;
}

/* Правила / папки / боты */
.rules-text {
  font-size: 13.5px;
  white-space: pre-wrap;
  padding: 10px 12px;
  background: var(--panel-2);
  border-radius: 10px;
  max-height: 300px;
  overflow-y: auto;
}
.rules-edit {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  resize: vertical;
  font-family: inherit;
}
.folder-target-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.folder-target-name {
  font-weight: 600;
  font-size: 13px;
}
.folder-set {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
}
.folders-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}
.folder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
}
.folder-row input {
  flex: 1;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  min-width: 0;
}
.folders-saved {
  color: var(--ok);
  font-size: 12.5px;
}

.qr-title {
  font-weight: 700;
  font-size: 13px;
  margin: 6px 0 2px;
}
.qr-form {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.qr-list,
.bots-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.qr-row,
.bot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 13px;
  flex-wrap: wrap;
}
.qr-text,
.bot-token {
  flex: 1;
  min-width: 100px;
  word-break: break-all;
  font-size: 12.5px;
}
.qr-del,
.bot-del {
  color: var(--danger);
  padding: 3px 6px;
  border-radius: 6px;
  font-weight: 700;
}
.qr-del:hover,
.bot-del:hover {
  background: rgba(229, 72, 77, 0.12);
}

.group-settings {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}
.group-members-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 8px;
}
.group-members-header {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-top: 8px;
}
.gs-auto-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.gs-auto-form {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.set-hint {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 2px 0;
}
.group-call-btn {
  width: 100%;
  margin-top: 8px;
}

.auto-rule {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 12.5px;
  flex-wrap: wrap;
}
.auto-rule.off {
  opacity: 0.55;
}
.auto-rule-trigger,
.auto-rule-cooldown {
  color: var(--text-dim);
  font-size: 11.5px;
}
.auto-rule-main {
  flex: 1;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.auto-rule-reply {
  font-weight: 600;
}
.auto-rule-stat {
  font-size: 11px;
  color: var(--text-dim);
}

.acct-sessions-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 200px;
  overflow-y: auto;
}
.acct-session-info {
  font-size: 12px;
  color: var(--text-dim);
}
.acct-session-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 12px;
  color: var(--text-dim);
}

.vip-stat-total {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  padding: 8px;
}
.vip-stats-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 80px;
  padding: 0 4px;
}
.vip-stats-bars .stats-col {
  flex: 1;
  min-width: 8px;
  border-radius: 4px 4px 0 0;
  align-self: flex-end;
}
.vip-stats-sub {
  font-weight: 700;
  font-size: 13px;
  margin-top: 8px;
}
.vip-stats-channels,
.vip-stats-msg {
  font-size: 12.5px;
  color: var(--text-dim);
}

/* Настройки — поиск / вкладки */
.settings-layout {
  display: flex;
  gap: 14px;
  min-height: 0;
}
.settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 150px;
  flex-shrink: 0;
}
.settings-tab {
  text-align: left;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  transition:
    background 0.12s,
    color 0.12s;
}
.settings-tab:hover {
  background: var(--hover);
  color: var(--text);
}
.settings-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.settings-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 4px;
}
.settings-section {
  margin-bottom: 14px;
}
.settings-search-row {
  position: sticky;
  top: 0;
  background: var(--panel);
  padding: 2px 0 8px;
  z-index: 2;
}
.settings-search {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
}
.settings-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 24px 10px;
  font-size: 13px;
}
.settings-danger {
  color: var(--danger);
  font-weight: 700;
}
.settings-close {
  align-self: flex-end;
}
.settings-sheet-handle {
  display: none;
}

.search-hidden {
  display: none;
}
.search-active {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 8px;
}
.settings-searching .settings-search-row {
  border-bottom: 1px solid var(--accent);
}
.modal.settings-wide {
  max-width: 860px;
}
.settings-close.has-unsaved {
  border-color: var(--warn);
  color: var(--warn);
}

/* Текст в настройках — gold */
.settings-panel {
  color: #b8860b;
}
.settings-panel .set-label,
.settings-panel .settings-section {
  color: #b8860b;
}
html[data-theme='dark'] .settings-panel,
html[data-theme='dark'] .settings-panel .set-label,
html[data-theme='dark'] .settings-panel .settings-section {
  color: #ffd700;
}

/* ---------- 9. Звонки ---------- */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(10, 12, 30, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  color: #e8eaf2;
}
.call-card {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.call-videos {
  width: 100%;
}
.call-grid {
  display: grid;
  gap: 8px;
  width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.call-grid-solo {
  grid-template-columns: 1fr;
  max-width: 480px;
  margin: 0 auto;
}
.call-grid-many {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  max-height: 50vh;
  overflow-y: auto;
}
.call-avatar {
  width: 90px;
  height: 90px;
  font-size: 32px;
  margin: 0 auto;
}
.call-name {
  font-size: 22px;
  font-weight: 800;
}
.call-state {
  font-size: 14px;
  color: #8f95b5;
}

.call-quality {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #8f95b5;
}
.call-quality-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.call-quality-bars i {
  width: 4px;
  border-radius: 1px;
  background: #8f95b5;
}
.call-quality-bars i:nth-child(1) {
  height: 5px;
}
.call-quality-bars i:nth-child(2) {
  height: 8px;
}
.call-quality-bars i:nth-child(3) {
  height: 11px;
}
.call-quality-bars i:nth-child(4) {
  height: 14px;
}

.call-timer {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
  color: #8f95b5;
}

.call-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

.call-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 22px;
  position: relative;
  transition:
    background 0.15s,
    transform 0.12s;
}
.call-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.05);
}
.call-btn.call-mini {
  width: 46px;
  height: 46px;
  font-size: 18px;
}
.call-btn.call-accept {
  background: #22b573;
}
.call-btn.call-accept:hover {
  background: #1d9d63;
}
.call-btn.call-hangup,
.call-btn.call-decline {
  background: #e5484d;
}
.call-btn.call-hangup:hover,
.call-btn.call-decline:hover {
  background: #d13b40;
}

.call-mini-off {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(229, 72, 77, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-mini-off::after {
  content: '';
  position: absolute;
  width: 60%;
  height: 2px;
  background: #fff;
  transform: rotate(-45deg);
}
.call-btn.is-on .ico-on {
  display: none;
}
.call-btn.is-on .ico-off {
  display: block;
}
.call-btn.is-off {
  background: rgba(229, 72, 77, 0.4);
}
.call-btn.is-off:hover {
  background: rgba(229, 72, 77, 0.55);
}

.call-devices {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.call-device {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.call-device .search-input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #e8eaf2;
}

.call-tile {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #171a2e;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-tile video,
.call-tile audio {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0f1220;
}
.call-tile-local video {
  transform: scaleX(-1);
}
.call-tile-audio {
  aspect-ratio: 16/9;
}
.call-tile.call-tile-video {
  aspect-ratio: 16/9;
}
/* аудио-дорожка без видео: звук играет, элемент визуально скрыт,
   чтобы не закрывать аватар в тайле */
.call-tile .call-audio-track {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}
.call-tile.speaking {
  outline: 3px solid #22b573;
}
.call-tile-name {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.call-tile-quality {
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 10px;
  color: #8f95b5;
  background: rgba(0, 0, 0, 0.45);
  padding: 2px 6px;
  border-radius: 5px;
}
.call-tile-muted {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(229, 72, 77, 0.8);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rec-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e5484d;
  animation: blink 1.2s step-end infinite;
}
.call-btn.recording {
  background: rgba(229, 72, 77, 0.4);
}

.voice-room-bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 24px);
}
.voice-room-head {
  display: flex;
  flex-direction: column;
}
.voice-room-title {
  font-size: 11px;
  color: var(--text-dim);
}
.voice-room-name {
  font-weight: 700;
  font-size: 13px;
}
.voice-room-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 280px;
  overflow: hidden;
}

.voice-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
  max-width: 130px;
}
.voice-chip-avatar {
  width: 22px;
  height: 22px;
  font-size: 10px;
}
.voice-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-chip.muted {
  opacity: 0.6;
}
.voice-chip-muted {
  font-size: 11px;
}
.voice-room-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.voice-leave-btn {
  background: #e5484d;
}

/* ---------- 10. Сторис ---------- */
.stories-bar {
  display: flex;
  gap: 8px;
  padding: 10px 8px 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}
.story-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  cursor: pointer;
  width: 62px;
}
.story-avatar {
  width: 52px;
  height: 52px;
  padding: 2px;
  background: conic-gradient(from 180deg, #ff66c4, #8e6cf5, #2e9dff, #22b573, #ffa41d, #ff66c4);
}
.story-cell.viewed .story-avatar,
.story-cell:not(.unseen):not(.story-mine) .story-avatar {
  background: var(--border);
}

.story-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--panel);
  object-fit: cover;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  overflow: hidden;
}
.story-plus {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--panel);
}
.story-name {
  font-size: 10.5px;
  color: var(--text-dim);
  max-width: 60px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.story-add {
  font-size: 11px;
  color: var(--text-dim);
}
.story-view,
.story-viewed {
  font-size: 10px;
  color: var(--text-dim);
}

.story-viewer.modal-overlay {
  background: rgba(5, 6, 15, 0.96);
  padding: 0;
}

.story-stage {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: min(92vh, 780px);
  border-radius: 18px;
  overflow: hidden;
  background: #111;
  display: flex;
  flex-direction: column;
}
.story-progress {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  z-index: 3;
}
.story-progress-bar {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
  overflow: hidden;
}
.story-progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 2px;
}
.story-progress-fill.done {
  width: 100%;
}

.story-header {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  z-index: 3;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
  color: #fff;
}
.story-header-avatar {
  width: 34px;
  height: 34px;
  font-size: 13px;
}
.story-header-user {
  flex: 1;
  min-width: 0;
}
.story-header-name {
  font-weight: 700;
  font-size: 13.5px;
}
.story-header-time {
  font-size: 11.5px;
  opacity: 0.8;
}

.story-viewer-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.story-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.story-media,
.story-text {
  max-width: 100%;
  max-height: 100%;
}
.story-media img,
.story-media video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.story-text-body {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  padding: 30px;
  white-space: pre-wrap;
}
.story-caption {
  padding: 12px 16px 20px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.story-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: background 0.15s;
}
.story-nav:hover {
  background: rgba(255, 255, 255, 0.3);
}
.story-nav-left {
  left: 8px;
}
.story-nav-right {
  right: 8px;
}
.story-viewers {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  font-size: 12.5px;
  z-index: 3;
}
.story-viewers-info {
  font-weight: 700;
  margin-bottom: 4px;
}
.story-delete {
  position: absolute;
  top: 18px;
  right: 54px;
  z-index: 4;
}
.story-delete-btn {
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(229, 72, 77, 0.85);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.story-result {
  font-size: 12.5px;
  color: var(--ok);
  min-height: 1em;
}

/* ---------- 11. Тред ---------- */
.thread-pane {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 100vw);
  z-index: 140;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.thread-pane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.thread-pane-title {
  font-weight: 700;
  flex: 1;
}
.thread-pane-typing {
  font-size: 12px;
  color: var(--accent);
}
.thread-pane-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.thread-pane-close:hover {
  background: var(--hover);
}
.thread-pane-parent {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 13px;
  max-height: 140px;
  overflow-y: auto;
}
.thread-pane-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.thread-pane-input {
  display: flex;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.thread-history {
  padding: 8px 14px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.thread-history-result {
  font-size: 13px;
  padding: 6px 0;
}

/* Блок посетителей профиля */
.profile-visitors {
  margin-top: 12px;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}
.profile-visitors-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}
.profile-visitors-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
}
.profile-visitors-sum {
  font-size: 12px;
  opacity: 0.7;
}
.profile-visitor-when {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.6;
}

/* Журнал группы */
.group-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---------- 12. AI-панель ---------- */
.cards-panel {
  background: var(--panel);
  border-top: 1px solid var(--border);
  max-height: 300px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.ai-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 0;
}
.ai-title {
  flex: 1;
  font-weight: 700;
  font-size: 13.5px;
}
.ai-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  border-bottom: 1px solid var(--border);
}
.ai-tab {
  padding: 7px 12px;
  border-radius: 8px 8px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
}
.ai-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}
.ai-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-out {
  font-size: 13px;
  color: var(--text);
  min-height: 1em;
  white-space: pre-wrap;
}
.ai-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-reply {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  font-size: 12.5px;
  cursor: pointer;
}
.ai-reply:hover {
  background: var(--accent);
  color: #fff;
}
.ai-point {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}
.ai-point-who {
  font-weight: 700;
  color: var(--accent);
}
.ai-keyword {
  background: rgba(255, 214, 0, 0.3);
  border-radius: 3px;
}
.ai-rewrite-modes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ai-mode {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
}
.ai-mode:hover {
  border-color: var(--accent);
}
.dsr-chip {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  font-size: 12px;
  margin: 3px 4px 0 0;
  cursor: pointer;
}
.dsr-label {
  font-size: 11px;
  color: var(--text-dim);
}

.ai-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0;
}
.ai-point-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- 13. Панель поиска в чате ---------- */
.find-bar {
  position: absolute;
  top: 64px;
  right: 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 7px 9px;
  flex-wrap: wrap;
  max-width: calc(100% - 28px);
}
.find-bar .search-input {
  width: 200px;
  padding: 6px 10px;
  font-size: 13px;
}
.find-bar .find-input {
  width: 220px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  font-size: 13px;
  transition: border-color 0.15s;
}
.find-bar .find-input:focus {
  border-color: var(--accent);
}
.find-count {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 54px;
}
.find-current {
  color: var(--accent);
  font-weight: 700;
}
.find-hit {
  background: rgba(255, 214, 0, 0.45);
  border-radius: 3px;
}
.find-hit.current {
  background: var(--accent);
  color: #fff;
}
.find-nav,
.find-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.find-nav:hover,
.find-close:hover {
  background: var(--hover);
}
.find-close {
  color: var(--text-dim);
  font-size: 14px;
}
.find-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.find-btn:hover {
  background: var(--hover);
}

/* ---------- 14. Контекстное меню / снекбар ---------- */
.context-menu {
  position: fixed;
  z-index: 260;
  min-width: 190px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 5px;
}
.cmi {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13.5px;
  transition: background 0.12s;
}
.cmi:hover {
  background: var(--hover);
}
.cmi.danger {
  color: var(--danger);
}

.snackbar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 320;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  background: #232742;
  color: #e8eaf2;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  max-width: calc(100vw - 32px);
  animation: snackbar-in 0.2s ease;
}
@keyframes snackbar-in {
  from {
    transform: translate(-50%, 16px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}
.snackbar-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.snackbar-btn {
  color: #8e6cf5;
  font-weight: 700;
  font-size: 13.5px;
  flex-shrink: 0;
}

.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 340;
  background: rgba(142, 108, 245, 0.12);
  border: 3px dashed var(--accent);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  pointer-events: none;
}
.drag-overlay.visible {
  display: flex;
}

.install-banner {
  position: fixed;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  z-index: 330;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: calc(100vw - 24px);
}
.install-ico {
  line-height: 1;
  flex-shrink: 0;
}
.install-text {
  flex: 1;
  min-width: 0;
}
.install-close {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}
.install-close:hover {
  background: var(--hover);
}

/* ---------- 15. Палитра реакций ---------- */
.reaction-palette {
  position: fixed;
  z-index: 255;
  display: flex;
  gap: 4px;
  padding: 7px 9px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
}
.reaction-palette button {
  font-size: 21px;
  padding: 3px;
  border-radius: 50%;
  transition: transform 0.1s;
}
.reaction-palette button:hover {
  transform: scale(1.2);
  background: var(--hover);
}

/* ---------- 16. Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.15s ease;
}
.lightbox img,
.lightbox video {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
}
.lb-close,
.lb-download {
  position: absolute;
  top: 14px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-close {
  right: 14px;
}
.lb-download {
  right: 64px;
}
.lb-close:hover,
.lb-download:hover {
  background: rgba(255, 255, 255, 0.25);
}
.lb-counter {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.4);
  padding: 5px 12px;
  border-radius: 999px;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}
.lb-nav.prev {
  left: 14px;
}
.lb-nav.next {
  right: 14px;
}
.zoom-in {
  cursor: zoom-in;
}

/* ---------- 17. Command palette ---------- */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: var(--overlay);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}
.cmdk-input {
  width: 100%;
  max-width: 520px;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  font-size: 15px;
}
.cmdk-list {
  width: 100%;
  max-width: 520px;
  margin-top: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 5px;
  max-height: 46vh;
  overflow-y: auto;
}
.cmdk-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.cmdk-row.active {
  background: var(--accent-soft);
}
.cmdk-group {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.cmdk-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}
.cmdk-label {
  font-weight: 600;
}
.cmdk-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Предпросмотр markdown / история правок */
.md-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 355;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fade-in 0.15s ease;
}
.md-preview-card {
  width: 100%;
  max-width: 560px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.md-preview-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.md-preview-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
}
.md-preview-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}
.md-preview-close:hover {
  background: var(--hover);
  color: var(--text);
}
.md-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  min-height: 120px;
  font-size: 14px;
}
.md-preview-hint {
  padding: 10px 16px 14px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.edit-hist {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.edit-rev {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--panel-2);
}
.edit-rev.current {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.edit-rev-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.edit-rev.current .edit-rev-label {
  color: var(--accent);
}
.edit-rev-text {
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 18. Горячие клавиши ---------- */
.shortcuts-overlay {
  position: fixed;
  inset: 0;
  z-index: 360;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fade-in 0.15s ease;
}
.shortcuts-overlay .shortcuts-card {
  max-height: 84vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 18px;
}
.shortcuts-card {
  max-width: 460px;
}
.shortcuts-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shortcuts-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
}
.shortcuts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.hk-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  padding: 6px 0;
}
.hk-label {
  color: var(--text);
}
.hk-combo,
.shortcuts-key {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.shortcuts-desc {
  color: var(--text-dim);
  font-size: 12.5px;
}
.shortcuts-close {
  margin-left: auto;
}

/* ---------- 19. Desk-панели (широкий экран) ---------- */
.desk-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 320px;
  flex-shrink: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
  height: 100%;
  min-width: 0;
}
.desk-pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.desk-pane-title {
  flex: 1;
  font-weight: 700;
  font-size: 14px;
}
.desk-pane-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}
.desk-pane-close:hover {
  background: var(--hover);
  color: var(--text);
}
.desk-pane-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  min-height: 0;
}
.desk-pane-resizer {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
}
.desk-pane-resizer:hover {
  background: var(--accent-soft);
}

.desk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 9px;
  font-size: 13px;
}
.desk-row:hover {
  background: var(--hover);
}
.desk-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.desk-row-btn,
.desk-btn,
.desk-pin {
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
  flex-shrink: 0;
}
.desk-row-btn:hover,
.desk-btn:hover {
  background: var(--hover);
}
.desk-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding: 8px 0;
}
.desk-sec {
  margin-bottom: 14px;
}
.desk-sec-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.desk-full-btn {
  width: 100%;
  margin-top: 6px;
}
.desk-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 22px 8px;
  font-size: 13px;
}
.desk-online {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.desk-online::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}
.desk-online.on {
  color: var(--ok);
}
.desk-online.on::before {
  background: var(--ok);
}

.inbox-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fav-label-chip {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
.feed-chip {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  transition:
    background 0.12s,
    color 0.12s,
    border-color 0.12s;
}
.feed-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.zen-exit {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 120;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.zen-exit:hover {
  background: var(--hover);
}
.desk-split-head {
  font-weight: 700;
  font-size: 13.5px;
  padding: 8px 0 4px;
}
.desk-split-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.desk-split-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
}
.desk-split-row:hover,
.desk-split-row.hl {
  background: var(--accent-soft);
}
.desk-split-name {
  font-weight: 600;
  flex-shrink: 0;
}
.desk-split-text {
  flex: 1;
  min-width: 0;
  color: var(--text-dim);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.desk-split-img {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
}
.desk-split-time {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.desk-feed-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.desk-media {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 5px;
}
.desk-media img {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  width: 100%;
  cursor: pointer;
}
.desk-topic {
  font-size: 13px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.desk-topic:hover {
  background: var(--hover);
}
.desk-resizing {
  user-select: none;
  cursor: col-resize;
}
.desk-mic-btn {
  margin-top: 6px;
  width: 100%;
}

.desk-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.desk-modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 84vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 18px;
}
.desk-modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.desk-modal-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
}
.desk-modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.desk-modal-close:hover {
  background: var(--hover);
}
.desk-modal-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
}
.desk-settings-block {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

/* Секретные строки */
.sk-line {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  word-break: break-all;
  margin-bottom: 4px;
  user-select: all;
}
.sk-line.sk-own {
  border-color: var(--accent);
}

/* E2E */
.e2e-btn,
.e2e-set,
.e2e-publish {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.e2e-key {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--panel-2);
  border-radius: 8px;
  word-break: break-all;
  user-select: all;
  display: block;
  margin: 4px 0;
}
.e2e-state {
  font-size: 12.5px;
  color: var(--text-dim);
}
.e2e-error {
  font-size: 12.5px;
  color: var(--danger);
}

/* ---------- 20. Density / zen / misc ---------- */
html.density-1 .chat-item {
  padding: 6px 10px;
}
html.density-1 .chat-avatar,
html.density-1 .chat-item .chat-avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
}
html.density-1 .messages {
  gap: 1px;
}
html.density-3 .messages {
  gap: 5px;
}

body.compact .chat-item {
  padding: 5px 10px;
}
body.compact .chat-avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
}
body.compact .messages {
  gap: 1px;
}
body.compact .msg-bubble {
  padding: 7px 11px;
}
body.compact .chat-preview {
  margin-top: 0;
}

html.zen-mode .sidebar,
html.zen-mode .mobile-nav,
html.zen-mode .new-chat-fab {
  display: none !important;
}

body.mobile-in-chat .sidebar {
  display: none;
}
body.mobile-in-chat #back-btn {
  display: inline-flex;
}
body.mobile-in-chat #menu-btn {
  display: none;
}

/* ---------- 21. Адаптив ---------- */
@media (max-width: 900px) {
  .desk-pane {
    display: none;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    max-width: none;
    border-right: none;
  }
  .sidebar.collapsed {
    display: flex;
  }
  body.mobile-in-chat .sidebar {
    display: none;
  }

  .chat-main {
    display: none;
  }
  body.mobile-in-chat .chat-main {
    display: flex;
  }

  .mobile-nav {
    display: flex;
  }
  .new-chat-fab {
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }

  /* iOS не масштабирует страницу при фокусе в полях ввода */
  input,
  textarea,
  select {
    font-size: 16px;
  }
  #message-input {
    font-size: 16px;
  }

  /* удобные размеры тапов */
  .back-btn,
  .hdr-action,
  .burger-btn {
    width: 44px;
    height: 44px;
  }
  .cq-btn,
  .attach-btn,
  .send-btn {
    width: 42px;
    height: 42px;
  }
  .mobile-nav-btn {
    padding: 10px 4px 8px;
  }
  .msg-sheet-item {
    padding: 14px 10px;
  }
  .emoji-cats button {
    padding: 8px 12px;
  }

  /* высота вьюпорта без панели адреса Safari */
  body {
    height: 100dvh;
  }

  .header-actions .hdr-action {
    display: none;
  }
  .header-actions #chat-menu-btn,
  .header-actions #search-btn,
  .header-actions #settings-btn,
  .header-actions #theme-btn,
  .header-actions #burger-btn {
    display: inline-flex;
  }

  .messages {
    padding: 10px 8px 8px;
  }
  .message {
    max-width: 100%;
  }
  .msg-actions,
  .quick-react {
    display: none !important;
  }
  .msg-sheet {
    display: flex;
    flex-direction: column;
  }

  .modal {
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
  }
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .settings-layout {
    flex-direction: column;
  }
  .settings-tabs {
    flex-direction: row;
    overflow-x: auto;
    min-width: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
  }
  .settings-tab {
    white-space: nowrap;
    border-radius: 999px;
  }
  .settings-tab.active {
    background: var(--accent);
    color: #fff;
  }
  .settings-main {
    max-height: 62vh;
  }

  .call-overlay {
    padding: 0;
  }
  .call-card {
    padding: 20px 14px calc(20px + env(safe-area-inset-bottom, 0));
  }

  .find-bar {
    top: auto;
    bottom: 74px;
    left: 8px;
    right: 8px;
  }
  .date-scrubber {
    display: none;
  }
  .jump-bottom {
    bottom: 78px;
  }

  .voice-room-bar {
    bottom: 74px;
    left: 8px;
    right: 8px;
    transform: none;
    max-width: none;
  }
  .voice-room-list {
    max-width: none;
    flex: 1;
  }

  .composer-quickbar {
    display: none;
  }

  .story-stage {
    height: 100dvh;
    max-width: none;
    border-radius: 0;
  }
}

@media (max-width: 420px) {
  .chat-create-row {
    flex-wrap: wrap;
  }
  .create-group-btn {
    min-width: calc(50% - 3px);
  }
  .search-filters {
    flex-direction: column;
  }
  .select-bar {
    gap: 6px;
  }
  .modal-actions .btn,
  .modal-actions .btn-primary,
  .modal-actions .btn-secondary,
  .modal-actions .btn-cancel,
  .modal-actions .btn-danger {
    flex: 1;
  }
}

@media (hover: none) {
  .msg-actions,
  .quick-react {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Анимации интерфейса: сообщения, статусы, бейджи, кнопка «вниз», смена темы ===== */
@keyframes msg-pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.msg-appear {
  animation: msg-pop 0.18s ease-out;
}

@keyframes dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 181, 115, 0.5);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 181, 115, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 181, 115, 0);
  }
}
.user-status.st-ok::before,
.user-hover-status.st-ok::before,
.desk-online.on::before {
  animation: dot-pulse 2.4s ease-out infinite;
}

@keyframes badge-beat {
  0%,
  84%,
  100% {
    transform: scale(1);
  }
  88% {
    transform: scale(1.16);
  }
  94% {
    transform: scale(1);
  }
}
@keyframes badge-pop {
  from {
    transform: scale(0.6);
  }
  60% {
    transform: scale(1.22);
  }
  to {
    transform: scale(1);
  }
}
.unread-badge {
  animation: badge-beat 6s ease-in-out infinite;
}
.unread-badge.badge-pop {
  animation:
    badge-pop 0.32s ease-out,
    badge-beat 6s ease-in-out infinite;
}

@keyframes jump-in {
  from {
    transform: translateX(-50%) translateY(10px) scale(0.92);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}
.jump-bottom:not([hidden]),
.jump-top:not([hidden]) {
  animation: jump-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.35);
}

/* плавная смена темы: класс ставится в applyTheme() на время перехода */
html.theme-anim,
html.theme-anim body,
html.theme-anim body * {
  transition:
    background-color 0.28s ease,
    color 0.28s ease,
    border-color 0.28s ease,
    box-shadow 0.28s ease !important;
}

/* ---------- Стрим: режим стримера и алерты ---------- */
/* Значения не подменяются, а размываются: раскладка полей не съезжает, страница
   остаётся рабочей, а в кадр вместо токена, ссылки-приглашения и почты попадает
   нечитаемое пятно. Список сессий и адреса вебхуков попадают сюда же — по ним
   видно устройства и чужие адреса получателей. */
body.streamer #invite-code,
body.streamer .totp-secret,
body.streamer #acct-mail-new,
body.streamer #overlay-url-input,
body.streamer #acct-sessions-list,
body.streamer #bots-list,
body.streamer #webhooks-list,
body.streamer #webhook-url-input,
body.streamer #webhook-channel-input {
  filter: blur(5px);
}

/* Индикатор эфира висит поверх шапки и кликается: если режим забыли выключить,
   это заметно, и возврат к обычному виду не требует поиска тумблера */
#streamer-badge {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4000;
  padding: 5px 12px;
  border: 1px solid rgba(255, 82, 82, 0.7);
  border-radius: 999px;
  background: rgba(20, 20, 24, 0.82);
  color: #ff8a80;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  animation: streamer-pulse 2s ease-in-out infinite;
}

@keyframes streamer-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Баннер стрим-алерта: по центру сверху и поверх интерфейса, чтобы упоминание
   или подарок были видны, даже когда экран занят перепиской */
#stream-alert {
  position: fixed;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4001;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(520px, 92vw);
  padding: 12px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, #b8860b, #ffd700);
  color: #241c00;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#stream-alert-icon {
  font-size: 26px;
  line-height: 1;
}

#stream-alert-title {
  font-weight: 700;
}

#stream-alert-text {
  font-size: 14px;
  opacity: 0.88;
  overflow-wrap: anywhere;
}

.stream-alert-in {
  animation: stream-alert-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes stream-alert-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-18px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  #streamer-badge,
  .stream-alert-in {
    animation: none;
  }
}
