/* ═══════════════════════════════════════════════════════════════════════════
   theme.css — ЕДИНСТВЕННЫЙ слой оформления ChatApp 1.7.0.
   Раньше поверх base/layout/chat лежали ещё два конкурирующих файла правок
   (refined.css и discord-reference.css). Из-за них токены и геометрия спорили
   друг с другом, и интерфейс «разъезжался». Теперь всё оформление здесь.

   Направление: раскладка Discord (рельса → список → чат → участники),
   но палитра теплее и мягче, чтобы в приложении было уютно, а не по-серверному.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ───────────────────────────── 1. Токены ───────────────────────────── */
:root {
  color-scheme: light;

  /* Поверхности: тёплый фиолетовый уголь, от глубокого к приподнятому */
  --bg:            oklch(95.6% .010 75);
  --bg1:           oklch(98.9% .005 75);
  --bg2:           oklch(97.7% .006 75);
  --bg3:           oklch(93.8% .010 75);
  --bg4:           oklch(89.8% .012 72);
  --bg5:           oklch(77% .014 70);
  --bg6:           oklch(63% .014 65);
  --bg7:           oklch(48% .015 60);
  --panel-user:    oklch(96.6% .008 75);
  --bg-floating:   oklch(99.3% .004 75);
  --bg-modal-footer: oklch(96.2% .008 75);

  /* Модификаторы состояния — прозрачные, поэтому работают на любой поверхности */
  --hover:         oklch(93.6% .012 72);
  --active:        oklch(90.6% .016 70);
  --selected:      oklch(93% .035 195);
  --msg-hover:     oklch(96.4% .008 72);
  --border:        oklch(87.6% .013 70);
  --border-subtle: oklch(91.6% .010 70);
  --divider:       oklch(84.6% .014 70);

  /* Акцент: узнаваемый blurple, чуть теплее оригинала */
  --accent:            oklch(50% .098 198);
  --accent-h:          oklch(45.5% .09 200);
  --accent-a:          oklch(41% .082 202);
  --accent-bg:         oklch(50% .098 198 / .11);
  --accent-bg2:        oklch(50% .098 198 / .2);
  --accent-border:     oklch(50% .098 198 / .42);
  --accent-modifier:   var(--accent-bg);
  --accent-gradient:   linear-gradient(155deg, oklch(60% .1 190), oklch(46% .09 205));
  --neutral-avatar-gradient: linear-gradient(155deg, oklch(68% .13 55), oklch(55% .14 38));
  --mention-bg:        oklch(84% .12 80 / .24);
  --mention-fg:        oklch(42% .10 75);

  /* Текст */
  --text-h:      oklch(21% .018 50);
  --text:        oklch(29% .016 50);
  --text2:       oklch(40% .014 55);
  --text3:       oklch(49.5% .013 60);
  --text4:       oklch(60% .012 62);
  --text-active: oklch(18% .02 50);
  --text-brand:  oklch(44% .09 200);

  /* Эти четыре токена достались от прежней тёмной базы и остались светлыми
     после перехода на светлый фон. На --bg они давали 1.6–2.2:1, то есть
     текст ошибки, статус «в сети» и предупреждения практически не читались.
     Значения ниже дают 6.7–7.6:1 (WCAG AA с запасом); тёмная тема
     возвращает исходные светлые варианты у себя. */
  --text-danger:   oklch(48% .19 22);
  --text-positive: oklch(45% .13 152);
  --text-warning:  oklch(45% .11 85);

  /* Статусы */
  --green:       oklch(70% .155 152);
  --green-h:     oklch(63% .145 152);
  --green-btn:   oklch(52% .120 152);
  --green-btn-h: oklch(46% .110 152);
  --green-btn-a: oklch(41% .100 152);
  --green-bg:     oklch(70% .155 152 / .16);
  --green-border: oklch(70% .155 152 / .45);
  --yellow:      oklch(82% .145 85);
  --gold:        oklch(84% .135 85);
  --red:         oklch(63% .195 22);
  --red-h:       oklch(57% .185 22);
  --red-a:       oklch(51% .170 22);
  --red-aa:      oklch(45% .150 22);
  --red-bg:      oklch(63% .195 22 / .14);
  --red-bg2:     oklch(63% .195 22 / .26);
  --red-border:  oklch(63% .195 22 / .45);
  --grey-status: oklch(60% .012 70);

  /* Кольцо фокуса на светлом фоне давало 1.5:1 — клавиатурная навигация была
     вслепую. WCAG требует минимум 3:1 для нетекстовых индикаторов. */
  --link:  oklch(45% .12 235);
  --focus: oklch(50% .11 198);
  --info:  var(--link);

  --scrollbar-thumb: oklch(78% .014 70);
  --scrollbar-track: transparent;

  /* Тени: мягкие, без чёрных обрывов */
  --shadow-stroke: 0 0 0 1px oklch(84% .014 70);
  --shadow-header: 0 1px 0 oklch(88% .012 70);
  --shadow-low:    0 1px 2px oklch(36% .020 70 / .08);
  --shadow-medium: 0 8px 24px oklch(36% .020 70 / .10);
  --shadow:        0 14px 36px oklch(36% .020 70 / .13);
  --shadow-lg:     0 20px 48px oklch(36% .020 70 / .16);
  --shadow-modal:  0 28px 72px oklch(36% .020 70 / .18), 0 0 0 1px var(--border);

  /* Геометрия: одна шкала на всё приложение */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --rail-w: 76px;
  --sidebar-w: 268px;
  --members-w: 240px;
  --header-h: 56px;
  --user-panel-h: 60px;

  --font: 'Inter', 'SF Pro Text', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'SF Pro Display', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --ease:      200ms cubic-bezier(.22, 1, .36, 1);
  --ease-fast: 110ms cubic-bezier(.22, 1, .36, 1);
  --ease-slow: 360ms cubic-bezier(.16, 1, .3, 1);
  --on-accent: oklch(99% .006 195);
  --on-strong: oklch(99% .004 60);
  --bubble-mine: oklch(92.6% .038 192);
  --bubble-mine-border: oklch(85% .05 195);
  --bubble-other: oklch(99.4% .004 75);
  --bubble-other-border: oklch(90% .011 70);
}

html, body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}
h1, h2, h3 { text-wrap: balance; }

::selection { background: var(--accent-bg2); color: var(--text-h); }

:is(button, [role="button"], [tabindex]:not([tabindex="-1"]), a[href],
    .friend-item, .s-item, .gm-item, .picker-item, .me-card):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: none;
}

/* ─────────────────────── 2. Каркас приложения ─────────────────────── */
/* Видимость экранов: раньше это правило жило в удалённом слое правок. */
.screen { display: none; }
.screen.active { display: flex; }
#auth-screen, #app-screen { height: 100vh; height: 100dvh; min-height: 0; width: 100%; }

/* Фальшивая полоса заголовка только съедала место — убрана. */
.app-titlebar { display: none; }
#app-screen { padding-top: 0; flex-direction: row; background: var(--bg); }

.sidebar {
  flex: 0 0 calc(var(--rail-w) + var(--sidebar-w));
  width: calc(var(--rail-w) + var(--sidebar-w));
  min-width: calc(var(--rail-w) + var(--sidebar-w));
  background: var(--bg);
}
.sidebar-inner {
  background: var(--bg1);
  border-radius: 0;
  border: 0;
  box-shadow: 1px 0 0 var(--border-subtle);
}

/* ── Рельса разделов: единственная навигация, текстовые табы скрыты ── */
.guild-rail {
  width: var(--rail-w);
  gap: 10px;
  padding: 14px 0;
  background: var(--bg);
}
.rail-btn {
  width: 48px; height: 48px;
  border-radius: var(--radius-lg);
  background: var(--bg2);
  color: var(--text2);
  transition: border-radius var(--ease), background-color var(--ease), color var(--ease);
}
.rail-btn svg { width: 24px; height: 24px; }
.rail-btn:hover { background: var(--bg4); color: var(--text-h); border-radius: var(--radius-lg); }
.rail-btn:active { transform: none; }
.rail-btn.active,
.sidebar:has(.sidebar-tab[data-stab="dm"].active) .rail-btn[data-rail="dm"],
.sidebar:has(.sidebar-tab[data-stab="groups"].active) .rail-btn[data-rail="groups"] {
  background: var(--accent); color: var(--on-accent); border-radius: var(--radius);
}
.rail-add { background: transparent; color: var(--text-positive); box-shadow: inset 0 0 0 1px var(--border); }
.rail-add:hover { background: var(--green-btn); color: var(--on-strong); box-shadow: none; }
.rail-pill { left: -14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--text-h); }
.rail-divider { width: 32px; height: 1px; background: var(--divider); border-radius: 1px; }

/* ── Поиск ── */
.search-box {
  height: var(--header-h);
  padding: 0 12px;
  background: var(--bg1);
  box-shadow: 0 1px 0 var(--border-subtle);
}
.search-icon { left: 24px; width: 16px; height: 16px; color: var(--text3); }
#search-input {
  height: 36px;
  width: 100%;
  padding: 0 10px 0 34px;
  font-size: 14px; font-weight: 450;
  color: var(--text-h);
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: border-color var(--ease), background-color var(--ease);
}
#search-input:hover { background: oklch(18% .014 70); }
#search-input:focus { border-color: var(--accent-border); background: var(--bg); }
#search-input::placeholder { color: var(--text4); font-weight: 450; }
.search-drop {
  top: calc(100% - 4px); left: 8px; right: 8px;
  padding: 6px;
  background: var(--bg-floating);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: min(420px, 60dvh);
}
.s-item { gap: 10px; min-height: 48px; padding: 8px; border-radius: var(--radius-sm); }
.s-nick { font-size: 15px; font-weight: 550; }
.s-id, .s-empty { color: var(--text3); }
.s-item .btn-add { margin-left: auto; flex-shrink: 0; min-height: 32px; border-radius: var(--radius-xs); }
.s-empty { padding: 18px 10px; font-size: 14px; }

/* Дублирующие текстовые табы: рельса уже переключает раздел */
.sidebar-tabs { display: none; }
@supports not selector(:has(a)) {
  .sidebar-tabs { display: flex; gap: 4px; padding: 10px 10px 2px; }
  .sidebar-tab { min-height: 34px; border-radius: var(--radius-xs); }
}

.sidebar-body { padding: 6px 10px 12px; gap: 1px; }

.section-label {
  height: auto; min-height: 32px;
  padding: 16px 6px 6px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--text3);
}
.section-add { width: 24px; height: 24px; border-radius: var(--radius-xs); opacity: 1; color: var(--text3); }
.section-add:hover { background: var(--hover); color: var(--text-h); }

/* ── Заявки в друзья: отдельный сгруппированный блок, а не строки вперемешку ── */
#requests-section {
  margin: 8px 0 4px;
  padding: 2px 6px 6px;
  background: var(--accent-bg);
  border-radius: var(--radius);
}
#requests-section .section-label { padding: 10px 6px 4px; color: var(--text-brand); }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--red); color: var(--on-strong);
  font-size: 11px; font-weight: 700; line-height: 1;
}
.badge:empty { display: none; }
.req-card { min-height: 52px; padding: 6px 8px; border-radius: var(--radius-sm); gap: 10px; }
.req-card:hover { background: var(--hover); }
.req-nick { font-size: 14px; font-weight: 600; }
.req-id { font-size: 12px; color: var(--text3); }
.req-card .f-av { width: 32px; height: 32px; font-size: 13px; }
.req-card .btn-ok, .req-card .btn-no {
  width: 30px; height: 30px; border-radius: var(--radius-xs);
  background: var(--bg); color: var(--text2);
}
.req-card .btn-ok:hover { background: var(--green-btn); color: var(--on-strong); }
.req-card .btn-no:hover { background: var(--red-h); color: var(--on-strong); }

/* ── Строки бесед ── */
.friend-item {
  min-height: 46px;
  margin: 1px 0;
  padding: 5px 8px;
  gap: 10px;
  border-radius: var(--radius-sm);
}
.friend-item:hover { background: var(--hover); }
.friend-item.active, .friend-item.active:hover { background: var(--selected); }
.f-av { width: 34px; height: 34px; font-size: 14px; }
.f-nick { font-size: 15px; font-weight: 550; color: var(--text2); }
.friend-item:hover .f-nick { color: var(--text); }
.friend-item.active .f-nick, .friend-item.unread .f-nick { color: var(--text-h); }
.f-stat, .f-sub { font-size: 12px; line-height: 16px; color: var(--text3); }
.f-stat.on { color: var(--text-positive); }
.f-unread {
  margin-left: auto; flex-shrink: 0;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
  font-size: 12px; font-weight: 700;
}
.f-dot, .friend-item .f-dot, .gm-item .f-dot {
  position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--bg1);
  border: 0;
}
.group-item { padding-top: 5px; padding-bottom: 5px; }

/* Голосовой канал внутри карточки группы */
.group-voice-channel {
  margin: 4px 0 0 44px;
  padding: 4px 4px 4px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.group-voice-channel:hover { background: oklch(18% .014 70); }
.group-voice-channel-name { font-size: 13px; font-weight: 600; }
.group-voice-channel-count { font-size: 11px; }
.group-voice-channel-members { padding-left: 8px; font-size: 13px; }
.group-voice-member { min-height: 28px; border-radius: var(--radius-xs); }
.group-voice-channel-join {
  min-height: 28px; padding: 0 10px; border-radius: var(--radius-xs);
  background: var(--green-btn); color: var(--on-strong);
  font-size: 12px; font-weight: 650;
}
.group-voice-channel-join:hover:not(:disabled) { background: var(--green-btn-h); }

/* ── Панель пользователя ── */
.sidebar-footer {
  height: auto; min-height: var(--user-panel-h);
  padding: 8px;
  background: var(--panel-user);
  box-shadow: 0 -1px 0 var(--border-subtle);
}
.me-card { height: auto; min-height: 44px; padding: 4px 6px; gap: 10px; margin: 0; border-radius: var(--radius-sm); }
.me-card:hover { background: var(--hover); }
.me-card:hover .me-avatar-wrap, .me-card:hover .me-info { background: transparent; }
.me-avatar-wrap { width: 34px; height: 34px; padding: 0; }
.me-avatar { width: 34px; height: 34px; font-size: 14px; }
.me-info { padding: 0; margin: 0; }
.me-nick { font-size: 14px; font-weight: 650; }
.me-id { font-size: 12px; line-height: 16px; color: var(--text3); }
.sidebar-footer .icon-btn, .me-card .icon-btn { width: 34px; height: 34px; border-radius: var(--radius-xs); color: var(--text2); }
.sidebar-footer .icon-btn:hover { background: var(--hover); color: var(--text-h); }

/* ─────────────────────────── 3. Чат ─────────────────────────── */
.chat-main, .chat-window, .chat-empty, .group-chat-body,
.messages, .group-messages { background: var(--bg2); }
.chat-main { min-width: 0; }

.chat-head {
  height: var(--header-h); min-height: var(--header-h);
  padding: 0 12px 0 18px;
  gap: 12px;
  background: var(--bg2);
  box-shadow: 0 1px 0 var(--border-subtle);
}
.chat-head-avatar { width: 34px; height: 34px; font-size: 14px; }
.chat-head-info { gap: 10px; }
.chat-head-nick { font-size: 16px; font-weight: 650; color: var(--text-h); }
.chat-head-status { font-size: 12px; color: var(--text3); }
.chat-head-status::before {
  width: 8px; height: 8px; background: var(--grey-status); box-shadow: none;
}
.chat-head-status.on { color: var(--text-positive); }
.chat-head-status.on::before { background: var(--green); }
.chat-head-actions { gap: 2px; }
.chat-head .icon-btn { width: 36px; height: 36px; margin: 0; border-radius: var(--radius-xs); color: var(--text2); }
.chat-head .icon-btn svg { width: 22px; height: 22px; }
.chat-head .icon-btn:hover { background: var(--hover); color: var(--text-h); }

.messages, .group-messages { padding: 12px 0 16px; scroll-behavior: smooth; }

/* Приветствие: спокойный блок, а не баннер во весь экран */
.chat-welcome { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 3px 12px; padding: 10px 20px 12px; }
.chat-welcome-av { grid-row: span 2; width: 40px; height: 40px; font-size: 17px; margin: 0; }
.chat-welcome-title { font-size: 17px; font-weight: 750; line-height: 1.2; letter-spacing: -.02em; overflow-wrap: anywhere; }
.chat-welcome-sub { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text2); max-width: 62ch; overflow-wrap: anywhere; }
.chat-welcome-sub b { color: var(--text-h); font-weight: 650; }

/* Сообщения */
.g-msg { padding: 2px 56px 2px 20px; gap: 14px; margin-top: 18px; }
.g-msg.grouped { margin-top: 0; padding-top: 2px; padding-bottom: 2px; }
.g-msg:hover, .g-msg:focus-within { background: var(--msg-hover); }
.g-msg-av { width: 38px; height: 38px; font-size: 15px; margin-top: 1px; }
.g-msg-av-slot { width: 38px; min-width: 38px; height: auto; min-height: 22px; }
.g-msg-head { gap: 8px; }
.g-msg-nick { font-size: 15px; font-weight: 650; color: var(--text-h); }
.g-msg-time, .g-msg-hover-time { font-size: 11px; color: var(--text3); font-variant-numeric: tabular-nums; }
.g-msg-text { font-size: 15px; line-height: 1.55; color: var(--text); max-width: 74ch; }
.g-msg-text.jumbo { font-size: 44px; line-height: 1.1; }
.g-msg.deleted .g-msg-text { color: var(--text3); }
/* Упоминание: подсветка фоном вместо цветной полосы сбоку */
.g-msg.mention { background: var(--mention-bg); box-shadow: none; }
.g-msg.mention:hover { background: oklch(80% .14 85 / .16); }

.msg-del-btn {
  width: 30px; height: 30px;
  top: -14px; right: 18px;
  border-radius: var(--radius-xs);
  background: var(--bg-floating);
  color: var(--text2);
  box-shadow: var(--shadow-low), 0 0 0 1px var(--border);
}
.msg-del-btn:hover { background: var(--red-bg); color: var(--text-danger); }
.msg-del-btn svg { width: 18px; height: 18px; }

.msg-divider { margin: 26px 20px 10px; border-top-color: var(--divider); }
.msg-divider span { background: var(--bg2); color: var(--text3); font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; }
.msg-divider.new { border-top-color: var(--red); }
.msg-divider.new span { background: var(--red); color: var(--on-strong); border-radius: 0 0 var(--radius-xs) var(--radius-xs); }

.msg-system { padding: 2px 56px 2px 20px; margin-top: 12px; font-size: 14px; color: var(--text2); }
.msg-system-icon { color: var(--green); }
.msg-system-time { font-size: 11px; }

/* Markdown */
.md-code { background: var(--bg); border: 1px solid var(--border-subtle); border-radius: var(--radius-xs); font-size: 87%; }
.md-pre {
  margin-top: 8px; padding: 10px 12px;
  max-width: min(100%, 74ch);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px; line-height: 1.5;
}
.md-blockquote { border-left: 0; padding: 8px 12px; margin-top: 6px; background: var(--bg1); border-radius: var(--radius-xs); }
.md-link { color: var(--link); }
.md-spoiler { background: var(--bg); border-radius: var(--radius-xs); }
.md-spoiler:hover { background: oklch(16% .014 70); }
.md-spoiler.revealed { background: var(--hover); }
.message-image {
  margin-top: 8px;
  max-width: min(420px, 100%);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ── Строка ввода ── */
.msg-bar-wrap { padding: 0 20px 14px; }
.msg-bar {
  align-items: flex-end;
  gap: 4px;
  min-height: 48px;
  padding: 0 6px 0 14px;
  background: var(--bg3);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  transition: border-color var(--ease), background-color var(--ease);
}
.msg-bar:focus-within { border-color: var(--accent-border); }
#msg-input, #group-msg-input, .msg-input {
  padding: 12px 0; font-size: 15px; line-height: 22px;
  max-height: min(220px, 32dvh);
}
#msg-input::placeholder, #group-msg-input::placeholder { color: var(--text4); }
.attach-btn, .send-btn {
  flex: 0 0 38px; width: 38px; height: 38px;
  margin-bottom: 5px;
  border-radius: var(--radius-xs);
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  transition: background-color var(--ease), color var(--ease);
}
.attach-btn svg, .send-btn svg { width: 21px; height: 21px; }
.attach-btn:hover { background: var(--hover); color: var(--text-h); }
.send-btn:hover:not(:disabled) { background: var(--accent); color: var(--on-accent); }
.send-btn:disabled { opacity: .4; }
.composer-hint {
  display: flex; gap: 6px; align-items: center;
  padding: 6px 4px 0;
  font-size: 11px; color: var(--text4);
}
.composer-hint kbd {
  font: inherit; padding: 1px 5px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg); color: var(--text3);
}
.attach-preview { display: none; }
.attach-preview.show {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; padding: 8px 8px 8px 12px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text2);
}
.attach-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: var(--radius-xs); }
.attach-preview-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-preview-remove {
  margin-left: auto; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: var(--radius-xs);
  color: var(--text2);
}
.attach-preview-remove:hover { background: var(--red-bg); color: var(--text-danger); }

/* ── Пустой экран ── */
.chat-empty { padding: 40px 24px; gap: 0; }
.chat-empty-icon {
  width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xl);
  background: var(--accent-bg); color: var(--text-brand);
  opacity: 1; margin-bottom: 22px;
}
.chat-empty-icon svg { width: 44px; height: 44px; }
.chat-empty-title { font-size: clamp(22px, 2.6vw, 30px); font-weight: 750; line-height: 1.2; letter-spacing: -.02em; color: var(--text-h); }
.chat-empty-sub { margin-top: 10px; max-width: 44ch; font-size: 15px; line-height: 1.6; color: var(--text2); }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }
.empty-start, .empty-create {
  min-height: 40px; padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 650;
  transition: background-color var(--ease);
}
.empty-start { background: var(--accent); color: var(--on-accent); }
.empty-start:hover { background: var(--accent-h); }
.empty-create { background: var(--bg4); color: var(--text-h); }
.empty-create:hover { background: var(--bg5); }
.empty-shortcut { margin-top: 20px; font-size: 12px; color: var(--text4); }
.empty-shortcut kbd {
  font: inherit; padding: 2px 6px;
  border: 1px solid var(--border); border-radius: 4px; color: var(--text3);
}
.empty-state { padding: 32px 16px; gap: 6px; }
.empty-icon { opacity: .5; color: var(--text4); }
.empty-title { font-size: 14px; font-weight: 650; color: var(--text2); }
.empty-sub { font-size: 13px; color: var(--text3); }

/* ─────────────────── 4. Группы: участники и войс ─────────────────── */
.group-members-panel {
  width: var(--members-w); min-width: var(--members-w);
  background: var(--bg1);
  box-shadow: -1px 0 0 var(--border-subtle);
}
.group-members-panel .section-label { padding: 18px 8px 6px; }
#group-members-list { padding: 0 8px 8px; gap: 1px; }
.gm-section { padding: 16px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .07em; color: var(--text3); }
.gm-item { height: auto; min-height: 42px; padding: 4px 8px; border-radius: var(--radius-sm); gap: 10px; }
.gm-item:hover { background: var(--hover); }
.gm-av { width: 30px; height: 30px; font-size: 12px; }
.gm-name { font-size: 14px; font-weight: 550; color: var(--text2); }
.gm-item:hover .gm-name { color: var(--text-h); }
.gm-item.offline { opacity: .55; }
.gm-item.offline:hover { opacity: 1; }
/* Кнопка приглашения больше не вываливается за панель */
.btn-invite {
  margin: 8px; height: auto; min-height: 40px;
  padding: 8px 12px;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg3); color: var(--text);
  font-size: 13px; font-weight: 600;
  text-align: center;
  white-space: normal;
}
.btn-invite:hover { background: var(--bg4); color: var(--text-h); }

.dm-voice-bar, .group-voice-bar {
  min-height: 0;
  padding: 12px 18px;
  gap: 10px;
  background: var(--bg1);
  box-shadow: 0 1px 0 var(--border-subtle);
}
.dm-voice-bar { display: flex; align-items: center; justify-content: space-between; }
.dm-voice-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; }
.dm-voice-info strong { color: var(--text-positive); font-size: 13px; font-weight: 650; }
.dm-voice-info span { color: var(--text3); font-size: 12px; }
.dm-voice-bar .btn-primary { min-height: 34px; padding: 0 14px; font-size: 13px; }
.group-voice-title { font-size: 14px; color: var(--text-h); }
.group-voice-title small { font-size: 12px; color: var(--text3); }
.group-voice-members { min-height: 40px; gap: 10px; }
.group-voice-member-avatar { width: 40px; height: 40px; font-size: 15px; }
.group-voice-actions { position: static; transform: none; margin-left: auto; }
.group-voice-bar { flex-direction: row; align-items: center; flex-wrap: wrap; }
.group-voice-join { min-height: 34px; padding: 0 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 650; }

/* ─────────────────── 5. Кнопки, поля, примитивы ─────────────────── */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  min-height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color var(--ease), color var(--ease), opacity var(--ease);
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-primary:active:not(:disabled) { background: var(--accent-a); }
.btn-primary:disabled { opacity: .5; }
.btn-secondary { background: var(--bg4); color: var(--text-h); }
.btn-secondary:hover:not(:disabled) { background: var(--bg5); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--hover); color: var(--text-h); }
.btn-danger-outline { background: transparent; color: var(--text-danger); box-shadow: inset 0 0 0 1px var(--red-border); }
.btn-danger-outline:hover { background: var(--red-bg); }
.btn-block { width: 100%; }
.btn-quiet {
  min-height: 32px; padding: 0 10px;
  border-radius: var(--radius-xs);
  background: transparent; color: var(--text2);
  font-size: 13px; font-weight: 550;
  transition: background-color var(--ease), color var(--ease);
}
.btn-quiet:hover { background: var(--hover); color: var(--text-h); }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label {
  font-size: 12px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--text2);
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px;
}
.field .hint { text-transform: none; letter-spacing: 0; font-weight: 450; font-size: 12px; color: var(--text3); }
.field .req { color: var(--text-danger); }
.field input, .field textarea {
  min-height: 44px; padding: 10px 12px;
  font-size: 16px;
  color: var(--text-h);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--ease);
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus { border-color: var(--accent-border); outline: none; }
.field input::placeholder, .field textarea::placeholder { color: var(--text4); }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 48px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
}
.pw-toggle:hover { background: var(--hover); color: var(--text-h); }
.form-stack { display: flex; flex-direction: column; gap: 18px; }

.error-msg:empty { display: none; }
.error-msg:not(:empty) {
  margin-top: 16px; padding: 12px 14px;
  background: var(--red-bg); border: 1px solid var(--red-border);
  border-radius: var(--radius-sm);
  color: var(--text-danger); font-size: 13px; line-height: 1.5;
}

/* ─────────────────────────── 6. Авторизация ─────────────────────────── */
#auth-screen.active {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(32px, 6vw, 96px);
  padding: 48px 32px;
  background: oklch(30% .105 195);
  background-image:
    radial-gradient(105% 85% at 12% 4%, oklch(46% .170 70 / .85), transparent 62%),
    radial-gradient(85% 75% at 92% 96%, oklch(34% .110 195 / .8), transparent 60%);
}
.auth-bg { display: none; }
.auth-story { max-width: 440px; flex: 0 1 440px; color: var(--text-h); }
.auth-wordmark {
  display: flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 750; letter-spacing: -.02em;
}
.auth-wordmark svg { width: 26px; height: 26px; }
.auth-story h2 {
  margin: 36px 0 18px;
  font-size: clamp(38px, 4.4vw, 60px);
  font-weight: 800; line-height: 1.04; letter-spacing: -.04em;
}
.auth-story p { font-size: 16px; line-height: 1.6; color: oklch(94% .020 70 / .82); max-width: 42ch; }
.auth-art { margin-top: 36px; width: 100%; max-width: 320px; }
.auth-logo { display: none; }
.auth-box {
  position: relative; z-index: 1;
  width: 100%; max-width: 424px;
  padding: 32px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: auth-in var(--ease-slow);
}
.auth-heading { text-align: left; margin-bottom: 4px; }
.auth-title { font-size: 24px; font-weight: 750; line-height: 1.25; letter-spacing: -.02em; }
.auth-sub { margin-top: 8px; font-size: 15px; color: var(--text2); }
.tab-content.active { gap: 18px; }
.auth-switch { margin-top: -4px; font-size: 14px; color: var(--text3); }
.auth-link { color: var(--link); font-weight: 600; }
.btn-block.btn-primary { min-height: 44px; }

/* ──────────────────────────── 7. Модалки ──────────────────────────── */
.modal-overlay { background: oklch(8% .010 70 / .72); padding: 20px; }
.modal-box {
  max-width: 480px;
  padding: 24px;
  background: var(--bg2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
}
.modal-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 18px; }
.modal-sub { margin: -10px 0 18px; font-size: 14px; color: var(--text2); }
.modal-close-btn {
  width: 32px; height: 32px; top: 16px; right: 16px;
  border-radius: 50%;
  background: var(--hover); color: var(--text2);
}
.modal-close-btn:hover { background: var(--active); color: var(--text-h); }
.modal-box:not(.modal-profile) .modal-close-btn { background: var(--hover); color: var(--text2); }
.modal-box:not(.modal-profile) .modal-close-btn:hover { background: var(--active); color: var(--text-h); }
.modal-footer {
  margin: 22px -24px -24px;
  padding: 16px 24px;
  background: var(--bg-modal-footer);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  box-shadow: 0 -1px 0 var(--border-subtle);
}
.modal-actions { gap: 10px; margin-top: 16px; }

.modal-profile-header { padding: 64px 0 18px; }
.modal-profile-header::before { height: 108px; background: var(--accent-gradient); }
.modal-profile-header .modal-avatar { border: 5px solid var(--bg2); }
.modal-avatar { width: 88px; height: 88px; font-size: 34px; }
.modal-profile-name { font-size: 20px; font-weight: 700; }
.modal-profile-id { font-size: 14px; color: var(--text2); }
.modal-online-badge { border-radius: var(--radius-xs); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.modal-online-badge.online { background: var(--green-bg); color: var(--text-positive); }
.modal-online-badge.offline { background: var(--hover); color: var(--text3); }
.modal-profile-body { padding: 14px 16px; background: var(--bg1); border-radius: var(--radius); gap: 14px; }
.profile-info-label { font-size: 11px; letter-spacing: .06em; color: var(--text3); }
.profile-info-value { font-size: 14px; line-height: 1.55; }
.profile-info-row + .profile-info-row { border-top-color: var(--border); }

/* Редактирование профиля: аватар и его действия рядом, а не друг под другом */
.edit-avatar-block {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 22px; padding: 14px;
  background: var(--bg1);
  border-radius: var(--radius);
}
.edit-avatar-wrap { margin: 0; flex-shrink: 0; }
.edit-avatar { width: 76px; height: 76px; font-size: 30px; }
.edit-avatar-side { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.edit-avatar-title { font-size: 14px; font-weight: 650; color: var(--text-h); }
.edit-avatar-note { font-size: 12px; line-height: 1.45; color: var(--text3); }
.edit-avatar-actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 0 -10px; }
.edit-avatar-actions:not(:has(button:not([hidden]))) { display: none; }
.avatar-pending-hint { font-size: 12px; line-height: 1.45; color: var(--text-warning); }
.avatar-pending-hint[hidden] { display: none; }
.avatar-upload-btn {
  width: 26px; height: 26px;
  background: var(--accent); border: 3px solid var(--bg1);
}
.avatar-upload-btn:hover { background: var(--accent-h); }
.edit-avatar-wrap:hover .edit-avatar { filter: brightness(.85); }
.edit-profile-actions { justify-content: space-between; }

.btn-link-row {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--bg1); color: var(--text2);
  font-size: 14px; font-weight: 550;
  transition: background-color var(--ease), color var(--ease);
}
.btn-link-row:hover { background: var(--bg3); color: var(--text-h); }
.btn-link-row .chev { margin-left: auto; color: var(--text3); }

.blocked-users-list { margin: 0 -6px; }
.blocked-user-item { min-height: 56px; padding: 8px 6px; border-top-color: var(--border); }
.blocked-user-item:hover { background: var(--hover); border-radius: var(--radius-sm); }
.blocked-user-nick { font-size: 15px; font-weight: 600; }
.btn-unblock { min-height: 32px; padding: 0 12px; border-radius: var(--radius-xs); background: var(--bg4); color: var(--text-h); font-size: 13px; font-weight: 600; }
.btn-unblock:hover { background: var(--bg5); }
.blocked-users-empty { color: var(--text3); font-size: 14px; }

.friends-picker {
  max-height: 260px; margin: 0 -6px; padding: 4px 6px;
  background: var(--bg1); border-radius: var(--radius);
}
.picker-item { min-height: 48px; padding: 6px 8px; border-radius: var(--radius-sm); }
.picker-item.selected { background: var(--accent-bg); }
.picker-check { width: 22px; height: 22px; border-radius: var(--radius-xs); border-color: var(--text4); }
.group-members-list { max-height: 260px; }
.group-member-item { min-height: 48px; border-radius: var(--radius-sm); }

.delete-confirm-popup {
  padding: 12px 14px; gap: 12px;
  background: var(--bg-floating);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
}
.btn-danger-sm, .btn-ghost-sm {
  min-height: 34px; padding: 0 14px;
  border-radius: var(--radius-xs);
  font-size: 13px; font-weight: 650;
}
.btn-danger-sm { background: var(--red-h); color: var(--on-strong); }
.btn-danger-sm:hover { background: var(--red-a); }
.btn-ghost-sm { background: transparent; color: var(--text2); }
.btn-ghost-sm:hover { background: var(--hover); color: var(--text-h); }

.transient-notice {
  padding: 12px 16px;
  background: var(--bg-floating); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
}
.runtime-notice {
  position: fixed; inset: auto 16px 16px auto;
  z-index: calc(var(--z-modal) + 1);
  max-width: min(420px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-floating); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13.5px; line-height: 1.5;
}
.runtime-notice button {
  flex-shrink: 0; min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-xs);
  background: var(--accent); color: var(--on-accent);
  font-size: 13px; font-weight: 650;
}
.conn-banner { background: var(--red-h); font-size: 13px; font-weight: 600; }

/* ─────────────────────────── 8. Звонки ─────────────────────────── */
.call-overlay { background: var(--bg); }
.call-overlay-top, .call-overlay-controls { background: var(--bg1); box-shadow: 0 1px 0 var(--border-subtle); backdrop-filter: none; }
.call-overlay-controls { box-shadow: 0 -1px 0 var(--border-subtle); }
.call-overlay-label { font-size: 11px; letter-spacing: .08em; color: var(--text3); }
.call-overlay-title { font-size: 18px; font-weight: 700; color: var(--text-h); }
.call-overlay-status { font-size: 13px; color: var(--text3); }
.call-tile { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.call-tile-avatar { background: var(--accent-gradient); }
.call-tile-audio { background: var(--bg2); }
.call-overlay-controls .call-round-btn { background: var(--bg4); color: var(--text-h); }
.call-overlay-controls .call-round-btn:hover { background: var(--bg5); }
.call-overlay-controls .call-round-btn.active-off { background: var(--text); color: var(--bg); }
.call-overlay-controls .call-round-btn.call-decline { background: var(--red-h); color: var(--on-strong); }
.call-incoming-box { border-radius: var(--radius-xl); }
.call-incoming-nick { font-size: 20px; font-weight: 700; }
.call-incoming-sub { font-size: 14px; color: var(--text3); }

/* ─────────────────────────── 9. Адаптив ─────────────────────────── */
@media (min-width: 641px) and (max-width: 1100px) {
  :root { --rail-w: 68px; --sidebar-w: 232px; --members-w: 212px; }
  .rail-pill { left: -10px; }
  .chat-head { padding-left: 14px; }
  .g-msg, .msg-system { padding-left: 14px; padding-right: 44px; }
  .msg-bar-wrap { padding-inline: 14px; }
  .msg-divider { margin-inline: 14px; }
  .auth-story { flex-basis: 340px; }
}

@media (max-width: 900px) {
  .auth-story { display: none; }
  .auth-logo { display: flex; margin-bottom: 22px; }
}

@media (max-width: 640px) {
  :root {
    --rail-w: 64px;
    --sidebar-w: calc(100vw - var(--rail-w));
    --header-h: 56px;
  }
  #auth-screen { padding: 24px 16px; background: var(--bg); background-image: none; }
  .auth-box { max-width: 100%; padding: 22px 18px; border-radius: var(--radius-lg); }

  .sidebar { flex-basis: 100%; width: 100%; min-width: 100%; }
  .sidebar-inner { box-shadow: none; }
  .guild-rail { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .rail-btn { width: 44px; height: 44px; }
  .sidebar-top { padding-top: env(safe-area-inset-top, 0px); }
  .sidebar-footer {
    min-height: calc(var(--user-panel-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  #search-input { height: 38px; font-size: 16px; }

  .chat-head {
    height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    min-height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 6px 0 4px;
    gap: 6px;
  }
  .back-btn { display: flex; margin: 0; }
  .chat-head-avatar { width: 30px; height: 30px; font-size: 12px; }
  .chat-head .icon-btn { width: 40px; height: 40px; }

  .g-msg, .msg-system { padding: 2px 40px 2px 12px; gap: 10px; }
  .g-msg-av, .g-msg-av-slot { width: 34px; min-width: 34px; }
  .g-msg-av { height: 34px; }
  .msg-divider { margin-inline: 12px; }
  .chat-welcome { padding-inline: 12px; }
  .msg-bar-wrap { padding: 0 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .composer-hint, .empty-shortcut { display: none; }

  .group-members-panel { width: min(84vw, 300px); min-width: 0; }
  .modal-box { border-radius: var(--radius-lg); padding: 20px; }
  .modal-footer { margin: 20px -20px -20px; padding: 14px 20px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
  .edit-avatar-block { flex-direction: column; align-items: flex-start; }
  .edit-profile-actions { flex-direction: row-reverse; }
  .edit-profile-actions .btn-primary { flex: 1; }
  .group-voice-actions { width: 100%; margin-left: 0; }
  .group-voice-join { width: 100%; }
}

/* Без наведения (тач) кнопка удаления доступна всегда, но не спорит с текстом */
@media (hover: none) {
  .msg-del-btn {
    opacity: 1; pointer-events: auto;
    width: 26px; height: 26px; top: 0; right: 6px;
    background: transparent; box-shadow: none; color: var(--text4);
  }
  .msg-del-btn svg { width: 16px; height: 16px; }
  .g-msg, .msg-system { padding-right: 34px; }
  .section-add { opacity: 1; }
}

/* Этот блок тоже остался от тёмной базы: он осветлял текст, а фон теперь
   светлый, так что включение «увеличить контраст» в системе роняло вторичный
   текст до 1.13:1 — то есть делало его невидимым. Теперь каждая тема
   усиливает контраст в свою сторону. */
@media (prefers-contrast: more) {
  :root {
    --text2: oklch(30% .020 70);
    --text3: oklch(34% .018 70);
    --text4: oklch(38% .016 70);
    --border: oklch(62% .020 70);
    --divider: oklch(55% .022 70);
  }

  :root[data-theme="gray"] {
    --text2: oklch(92% .006 60);
    --text3: oklch(85% .008 60);
    --text4: oklch(80% .010 60);
    --border: oklch(100% 0 0 / .32);
    --divider: oklch(100% 0 0 / .42);
  }
}

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


/* 1.8 usability polish: files, clearer groups, calmer light theme */
.group-item {
  min-height: 58px;
  margin: 4px 2px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
}
.group-item:hover { border-color: var(--border); box-shadow: var(--shadow-low); }
.group-item.active { border-color: var(--accent-border); background: var(--selected); }
.group-item .f-av { width: 40px; height: 40px; }
.group-item .f-nick { color: var(--text-h); font-weight: 700; letter-spacing: -.01em; }
.group-item .f-stat { margin-top: 2px; }
.group-voice-channel { background: var(--bg2); border: 1px solid var(--border-subtle); }
.group-voice-channel:hover { background: var(--bg3); }

.msg-bar-wrap { padding-top: 8px; }
.msg-bar {
  border: 1px solid var(--border);
  background: var(--bg1);
  box-shadow: var(--shadow-low);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast), transform var(--ease-fast);
}
.msg-bar:focus-within { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-bg); }
.msg-bar.is-dragging { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-bg2); transform: translateY(-2px); }
.composer-hint { display: flex; justify-content: space-between; gap: 16px; }

.attach-preview.show {
  min-height: 54px;
  padding: 8px 10px;
  background: var(--bg2);
  border-color: var(--border);
  box-shadow: var(--shadow-low);
}
.attach-preview-label { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; flex: 1; }
.attach-preview-kind {
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--accent-bg);
  color: var(--text-brand);
  font-size: .75rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.attach-preview-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-h); font-weight: 600; }
.attach-preview-size { color: var(--text3); font-variant-numeric: tabular-nums; }

.message-image, .message-video {
  display: block;
  margin-top: 10px;
  width: min(520px, 100%);
  max-height: 440px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg2);
  box-shadow: var(--shadow-low);
}
.message-audio { display: block; width: min(420px, 100%); margin-top: 10px; }
.message-file {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(430px, 100%);
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
  color: var(--text);
  text-decoration: none;
  transition: transform var(--ease-fast), border-color var(--ease-fast), box-shadow var(--ease-fast);
}
.message-file:hover { transform: translateY(-1px); border-color: var(--accent-border); box-shadow: var(--shadow-medium); }
.message-file:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.message-file-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--text-brand);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .05em;
}
.message-file-copy { display: grid; min-width: 0; }
.message-file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-h); }
.message-file-copy small { color: var(--text3); font-variant-numeric: tabular-nums; }
.message-file-download { color: var(--text-brand); font-size: .875rem; font-weight: 700; }

@media (max-width: 640px) {
  .composer-hint span:first-child { display: none; }
  .composer-hint { justify-content: flex-end; }
  .message-file { grid-template-columns: 40px minmax(0, 1fr); }
  .message-file-download { display: none; }
  .message-video { max-height: 56vh; }
}

.group-search-empty { display: grid; gap: 4px; padding: 32px 16px; text-align: center; color: var(--text3); }
.group-search-empty strong { color: var(--text-h); font-size: 1rem; }
.group-search-empty span { font-size: .875rem; }

/* 1.8.1 settings and appearance */
:root[data-theme="gray"] {
  color-scheme: dark;
  --bg: oklch(20% .006 275);
  --bg1: oklch(23% .006 275);
  --bg2: oklch(25% .006 275);
  --bg3: oklch(28% .007 275);
  --bg4: oklch(32% .007 275);
  --bg5: oklch(42% .008 275);
  --bg6: oklch(55% .008 275);
  --bg7: oklch(68% .007 275);
  --panel-user: oklch(21.5% .006 275);
  --bg-floating: oklch(30% .007 275);
  --bg-modal-footer: oklch(22.5% .006 275);
  --hover: oklch(100% .004 60 / .055);
  --active: oklch(100% .004 60 / .09);
  --selected: oklch(74% .105 190 / .16);
  --msg-hover: oklch(100% .004 60 / .03);
  --border: oklch(100% .004 60 / .09);
  --border-subtle: oklch(100% .004 60 / .06);
  --divider: oklch(100% .004 60 / .12);
  --text-h: oklch(96% .005 70);
  --text: oklch(89% .007 70);
  --text2: oklch(78% .009 70);
  --text3: oklch(68% .010 70);
  --text4: oklch(59% .010 70);
  --text-active: oklch(99% .002 60);
  --text-brand: oklch(78% .13 278);

  /* На тёмном фоне работают ровно противоположные значения. */
  --text-danger:   oklch(76% .14 22);
  --text-positive: oklch(78% .15 152);
  --text-warning:  oklch(84% .13 85);
  --mention-bg:    oklch(80% .14 85 / .12);
  --mention-fg:    oklch(86% .12 85);
  --link:          oklch(78% .11 230);
  --focus:         oklch(72% .15 278);

  --scrollbar-thumb: oklch(100% .004 60 / .16);
  --shadow-stroke: 0 0 0 1px oklch(8% .010 60 / .2);
  --shadow-header: 0 1px 0 oklch(8% .010 60 / .24);
  --shadow-low: 0 1px 2px oklch(8% .010 60 / .22);
  --shadow-medium: 0 8px 24px oklch(8% .010 60 / .28);
  --shadow: 0 14px 36px oklch(8% .010 60 / .34);
  --shadow-lg: 0 20px 48px oklch(8% .010 60 / .42);
  --shadow-modal: 0 28px 72px oklch(8% .010 60 / .5), 0 0 0 1px var(--border);
  --accent: oklch(61% .19 278);
  --accent-h: oklch(66% .18 278);
  --accent-a: oklch(55% .18 278);
  --accent-bg: oklch(61% .19 278 / .14);
  --accent-bg2: oklch(61% .19 278 / .24);
  --accent-border: oklch(61% .19 278 / .52);
  --on-accent: oklch(99% .004 275);
  --on-strong: oklch(99% .004 60);
  --bubble-mine: oklch(36% .055 195);
  --bubble-mine-border: oklch(42% .06 195);
  --bubble-other: oklch(29.5% .009 60);
  --bubble-other-border: oklch(33% .01 60);
}

:root[data-theme="gray"] .message-image,
:root[data-theme="gray"] .message-video,
:root[data-theme="gray"] .message-file,
:root[data-theme="gray"] .msg-bar { background: var(--bg1); }
:root[data-theme="gray"] .group-voice-channel:hover { background: var(--bg); }
:root[data-theme="gray"] .modal-overlay { background: oklch(8% .010 60 / .76); }

.me-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.me-info { min-width: 0; }
.settings-btn svg { transition: transform 280ms cubic-bezier(.22, 1, .36, 1); }
.settings-btn:hover svg { transform: rotate(32deg); }
.settings-modal-box { width: min(540px, 100%); max-width: 540px; }
.settings-heading { display: flex; align-items: center; gap: 12px; padding-right: 42px; margin-bottom: 24px; }
.settings-heading-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  background: var(--accent-bg);
  color: var(--text-brand);
}
.settings-heading .modal-title { margin: 0; }
.settings-sub { margin-top: 3px; color: var(--text3); font-size: .875rem; }
.theme-picker { display: grid; gap: 10px; border: 0; padding: 0; margin: 0; }
.theme-picker legend {
  margin-bottom: 10px;
  color: var(--text3);
  font-size: .75rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.theme-option {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg1);
  cursor: pointer;
  transition: transform var(--ease-fast), border-color var(--ease-fast), box-shadow var(--ease-fast), background-color var(--ease-fast);
}
.theme-option:hover { transform: translateY(-1px); border-color: var(--accent-border); box-shadow: var(--shadow-medium); }
.theme-option:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); box-shadow: 0 0 0 3px var(--accent-bg); }
.theme-option:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.theme-option input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.theme-preview {
  position: relative;
  display: block;
  width: 84px;
  height: 58px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow-low);
}
.theme-preview::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 22px; }
.theme-preview i, .theme-preview b, .theme-preview em { position: absolute; display: block; border-radius: 3px; }
.theme-preview i { left: 29px; top: 11px; width: 42px; height: 6px; }
.theme-preview b { left: 29px; top: 23px; width: 32px; height: 5px; }
.theme-preview em { left: 29px; top: 39px; width: 46px; height: 8px; }
.preview-gray { background: oklch(31% .010 60); }
.preview-gray::before { background: oklch(24% .011 60); }
.preview-gray i { background: oklch(75% .010 60); }
.preview-gray b { background: oklch(56% .010 60); }
.preview-gray em { background: oklch(42% .020 195); }
.preview-white { background: oklch(98% .006 70); }
.preview-white::before { background: oklch(93% .011 70); }
.preview-white i { background: oklch(35% .020 70); }
.preview-white b { background: oklch(67% .015 70); }
.preview-white em { background: oklch(91% .035 195); }
.theme-option-copy { display: grid; gap: 3px; min-width: 0; }
.theme-option-copy strong { color: var(--text-h); font-size: 1rem; }
.theme-option-copy small { color: var(--text3); line-height: 1.4; }
.theme-check {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: transparent;
}
.theme-option:has(input:checked) .theme-check { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.settings-status { min-height: 21px; margin-top: 16px; color: var(--text3); font-size: .8125rem; text-align: center; }

@media (max-width: 520px) {
  .theme-option { grid-template-columns: 68px minmax(0, 1fr) 24px; gap: 10px; }
  .theme-preview { width: 68px; }
  .theme-preview i, .theme-preview b, .theme-preview em { left: 27px; max-width: 34px; }
  .theme-option-copy small { font-size: .75rem; }
}
.auth-story, .auth-story h2, .auth-wordmark { color: oklch(97% .006 195); }

/* settings reference layout */
.settings-shell { display: grid; grid-template-columns: 218px minmax(0, 1fr); width: min(920px, calc(100vw - 48px)); height: min(640px, calc(100dvh - 48px)); overflow: hidden; background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); }
.settings-sidebar { display: flex; flex-direction: column; gap: 16px; min-width: 0; padding: 24px 14px 16px; background: var(--bg1); border-right: 1px solid var(--border-subtle); }
.settings-user-mini { display: flex; align-items: center; gap: 10px; padding: 0 8px 4px; }
.settings-user-avatar { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: var(--accent-gradient); }
.settings-user-copy { display: grid; min-width: 0; }
.settings-user-copy strong { overflow: hidden; color: var(--text-h); font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
.settings-user-copy small { color: var(--text3); font-size: .72rem; }
.settings-search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text3); }
.settings-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: .82rem; }
.settings-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.settings-search-empty { margin: 4px 10px; color: var(--text2); font-size: .875rem; }
.settings-nav [hidden], .settings-search-empty[hidden] { display: none !important; }
.settings-search input::placeholder { color: var(--text4); }
.settings-nav { display: grid; gap: 3px; overflow: auto; }
.settings-nav-item, .settings-subitem { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text2); text-align: left; font: inherit; font-size: .82rem; cursor: pointer; }
.settings-nav-item:hover, .settings-subitem:hover { background: var(--hover); color: var(--text-h); }
.settings-nav-item.active { background: var(--selected); color: var(--text-h); font-weight: 700; }
.settings-subnav { display: grid; gap: 3px; margin: 0 0 8px 27px; padding-left: 10px; border-left: 1px solid var(--border); }
.settings-subitem { min-height: 31px; padding: 0 7px; font-size: .77rem; }
.settings-subitem.active { color: var(--text-brand); }
.settings-nav-divider { height: 1px; margin: 12px 6px 4px; background: var(--border-subtle); }
.settings-nav-label { padding: 0 10px 4px; color: var(--text3); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.settings-content { position: relative; overflow: auto; padding: 32px clamp(24px, 4vw, 42px) 28px; background: var(--bg2); }
.settings-close { position: absolute; top: 18px; right: 18px; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--text3); cursor: pointer; }
.settings-close:hover { background: var(--hover); color: var(--text-h); }
.settings-close-mobile { display: none; }
.settings-content-head { margin-bottom: 42px; }
.settings-breadcrumb { margin-bottom: 30px; color: var(--text3); font-size: .8rem; }
.settings-breadcrumb span { padding: 0 7px; color: var(--text4); }
.settings-breadcrumb b { color: var(--text2); font-weight: 600; }
.settings-content-head h2 { color: var(--text-h); font-size: 1.55rem; letter-spacing: -.025em; }
.settings-section { display: none; max-width: 700px; animation: settings-in 220ms cubic-bezier(.16, 1, .3, 1); }
.settings-section.active { display: block; }
.settings-section h3 { margin: 0 0 7px; color: var(--text-h); font-size: 1.2rem; }
.settings-section-note { max-width: 56ch; margin-bottom: 26px; color: var(--text3); font-size: .9rem; }
.settings-info-list { display: grid; gap: 4px; }
.settings-info-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 22px; min-height: 64px; padding: 0 14px; border-radius: 10px; }
.settings-info-row:hover { background: var(--hover); }
.settings-info-row > span { display: grid; gap: 3px; color: var(--text2); font-size: .88rem; }
.settings-info-row > span small { color: var(--text3); font-size: .75rem; }
.settings-info-row strong { overflow: hidden; color: var(--text-h); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.settings-info-row button { min-width: 90px; padding: 8px 13px; border: 0; border-radius: 7px; background: var(--bg4); color: var(--text-h); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; }
.settings-info-row button:hover { background: var(--accent); color: var(--on-accent); }
.settings-divider { height: 1px; margin: 36px 0 32px; background: var(--border-subtle); }
.settings-placeholder { margin-top: 24px; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg1); color: var(--text3); }

/* Переключатель в настройках (звуки уведомлений) */
.settings-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  max-width: 640px; margin-top: 20px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg1); box-shadow: var(--shadow-low);
}
.settings-toggle-copy { display: block; min-width: 0; cursor: pointer; }
.settings-toggle-copy strong { display: block; color: var(--text-h); font-size: .92rem; font-weight: 650; }
.settings-toggle-copy small { display: block; max-width: 52ch; margin-top: 5px; color: var(--text3); font-size: .78rem; line-height: 1.45; }
.settings-switch {
  flex: 0 0 auto; appearance: none; position: relative;
  width: 44px; height: 26px; margin: 0; border-radius: 13px;
  background: var(--bg4); cursor: pointer;
  transition: background var(--ease-fast);
}
.settings-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: oklch(99% .004 195); box-shadow: var(--shadow-low);
  transition: transform var(--ease-fast);
}
.settings-switch:checked { background: var(--accent); }
.settings-switch:checked::after { transform: translateX(18px); }
.settings-switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (max-width: 620px) { .settings-toggle-row { gap: 14px; padding: 14px; } }
 .settings-section .theme-picker { max-width: 600px; }
.voice-threshold-control { padding: 16px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg1); }
.voice-threshold-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.voice-threshold-head strong { display: block; color: var(--text-h); font-size: .92rem; }
.voice-threshold-head small { display: block; max-width: 52ch; margin-top: 5px; color: var(--text3); font-size: .78rem; line-height: 1.45; }
.voice-threshold-head output, #voice-meter-value { flex: 0 0 auto; min-width: 74px; padding: 4px 7px; border-radius: 6px; background: var(--bg3); color: var(--text-brand); font-size: .8rem; font-variant-numeric: tabular-nums; font-weight: 700; text-align: center; }
.voice-meter { position: relative; height: 10px; margin: 16px 0 12px; border-radius: 6px; background: var(--bg5); }
.voice-meter-fill { width: var(--voice-level, 0%); height: 100%; border-radius: inherit; background: var(--accent); transition: width 90ms linear; }
.voice-meter.is-active .voice-meter-fill { background: #38ae73; }
.voice-meter-mark { position: absolute; inset-block: -3px; left: var(--voice-threshold, 31.43%); width: 2px; border-radius: 2px; background: var(--text-h); box-shadow: 0 0 0 1px var(--bg1); }
.voice-check-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.voice-check-actions small { font-size: .78rem; color: var(--text3); }
.voice-threshold-heading { align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
#voice-threshold { width: 100%; height: 24px; margin: 6px 0 2px; accent-color: var(--accent); cursor: pointer; color-scheme: dark; }
:root[data-theme="white"] #voice-threshold { color-scheme: light; }
.voice-threshold-scale { display: flex; justify-content: space-between; gap: 8px; color: var(--text3); font-size: .72rem; }
.voice-threshold-scale span:last-child { text-align: right; }
@media (prefers-reduced-motion: reduce) { .voice-meter-fill { transition: none; } }
@keyframes settings-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 760px) {
  .settings-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); width: calc(100vw - 20px); height: calc(100dvh - 20px); border-radius: 12px; }
  .settings-sidebar { display: flex; padding: 12px 12px 8px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--border-subtle); }
  .settings-user-mini, .settings-nav-divider, .settings-nav-label { display: none; }
  .settings-search { max-width: 320px; min-height: 40px; }
  .settings-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; padding: 2px 0 6px; }
  .settings-subnav { display: contents; }
  .settings-nav-item, .settings-subitem { width: auto; flex: 0 0 auto; min-height: 40px; margin: 0; padding: 0 12px; white-space: nowrap; }
  .settings-content { min-height: 0; padding: 22px 16px 24px; }
  .settings-close-mobile { display: none; }
}

.settings-password-row { margin-top: 4px; }
.settings-password-btn { grid-column: 2; }
.settings-password-card { max-width: 560px; padding: 22px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg1); box-shadow: var(--shadow-low); }
.settings-password-card .form-stack { gap: 16px; }
.settings-field-hint { display: block; margin-top: 6px; color: var(--text3); font-size: .75rem; }
.settings-form-message { min-height: 22px; margin: 4px 0 12px; color: var(--text-danger); font-size: .84rem; }
.settings-form-message.is-good { color: var(--text-positive); }
.settings-save-password { min-height: 44px; width: 100%; }
@media (max-width: 620px) { .settings-info-row { grid-template-columns: 1fr; gap: 9px; padding: 12px 10px; } .settings-password-btn { grid-column: 1; } .settings-password-card { padding: 16px; } }


/* Electron/WebRTC polish */
.call-overlay { min-width: 0; min-height: 0; }
.call-overlay-top, .call-overlay-controls { flex-shrink: 0; }
.call-video-grid { min-width: 0; min-height: 0; overflow: auto; scrollbar-gutter: stable; }
.call-overlay-controls .call-round-btn { min-width: 44px; min-height: 44px; transition: transform var(--ease-fast), background-color var(--ease-fast), color var(--ease-fast); }
.call-overlay-controls .call-round-btn:hover:not(:disabled) { transform: translateY(-1px); }
.call-overlay-controls .call-round-btn:active:not(:disabled) { transform: scale(.95); }
.call-overlay-controls .call-round-btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 700px) {
  .call-overlay-top { padding-inline: 14px; }
  .call-overlay-controls { gap: 8px; padding-inline: 12px; }
  .call-overlay-controls .call-round-btn { min-width: 42px; min-height: 42px; }
}
/* Small interaction and accessibility refinements kept separate from layout. */
:root {
  --ease: 170ms cubic-bezier(0.25, 1, 0.5, 1);
  --ease-fast: 110ms cubic-bezier(0.22, 1, 0.36, 1);
  --ease-slow: 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.skip-link {
  position: fixed;
  z-index: var(--z-modal);
  top: 12px;
  left: 12px;
  min-height: 44px;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--text-h);
  color: var(--bg);
  font-weight: 700;
  box-shadow: var(--shadow);
  transform: translateY(-160%);
  transition: transform var(--ease-fast);
}
.skip-link:focus { transform: translateY(0); text-decoration: none; }

:is(h1, h2, h3, .chat-empty-title, .modal-title) { text-wrap: balance; }
:is(.chat-empty-sub, .settings-section-note, .auth-story p) { text-wrap: pretty; }
:is(.msg-time, .badge, .f-unread, .group-voice-count, .call-time) { font-variant-numeric: tabular-nums; }

:is(button, [role="button"], [tabindex]:not([tabindex="-1"]), a[href]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: none;
}

.send-btn:not(:disabled) { background: var(--accent-bg); color: var(--text-brand); }
.send-btn:active:not(:disabled), .attach-btn:active { transform: scale(.94); }
.friend-item, .group-item, .gm-item, .picker-item {
  transition: background-color var(--ease-fast), border-color var(--ease-fast), color var(--ease-fast), transform var(--ease-fast);
}

@media (hover: hover) {
  .friend-item:hover, .group-item:hover, .picker-item:hover { transform: translateY(-1px); }
}
@media (pointer: coarse) {
  .attach-btn, .send-btn, .icon-btn, .modal-close-btn { min-width: 44px; min-height: 44px; }
}
@media (max-width: 640px) {
  .msg-bar-wrap { padding-inline: 8px; }
  #msg-input, #group-msg-input, .msg-input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .skip-link, .friend-item, .group-item, .gm-item, .picker-item { transition: none; }
}

/* ═══════════════════════ 2.0 · Редизайн: бумага и петроль ═══════════════════════ */
body { -webkit-font-smoothing: antialiased; }
.rail-btn.active,
.sidebar:has(.sidebar-tab[data-stab="dm"].active) .rail-btn[data-rail="dm"],
.sidebar:has(.sidebar-tab[data-stab="groups"].active) .rail-btn[data-rail="groups"] { color: var(--on-accent); border-radius: 14px; }
.friend-item, .group-item { border-radius: 12px; }
.friend-item.active { background: var(--selected); }
.friend-item.is-typing .f-stat { font-size: 0; }
.friend-item.is-typing .f-stat::after { content: 'печатает…'; font-size: 12px; color: var(--text-brand); font-weight: 600; }
.chat-head { background: var(--bg1); }
.chat-head-nick { font-family: var(--font-display); letter-spacing: -.01em; }

/* Legacy bubble rules are neutralized by the flat Discord timeline below. */
.messages .g-msg, .group-messages .g-msg { padding: 1px 20px; gap: 10px; margin-top: 14px; background: transparent; }
.g-msg.grouped { margin-top: 3px; }
.g-msg:hover, .g-msg:focus-within { background: transparent; }
.g-msg-body {
  position: relative; max-width: min(640px, 78%);
  padding: 8px 12px 6px; display: flex; flex-direction: column;
  background: var(--bubble-other); border: 1px solid var(--bubble-other-border);
  border-radius: 18px 18px 18px 6px; box-shadow: var(--shadow-low);
}
.g-msg.grouped .g-msg-body { border-radius: 6px 18px 18px 6px; }
.g-msg.mine { flex-direction: row-reverse; }
.g-msg.mine .g-msg-av, .g-msg.mine .g-msg-av-slot, #messages .g-msg-av-slot, #messages .g-msg-av { display: none; }
.g-msg.mine .g-msg-body { background: var(--bubble-mine); border-color: var(--bubble-mine-border); border-radius: 18px 18px 6px 18px; }
.g-msg.mine.grouped .g-msg-body { border-radius: 18px 6px 6px 18px; }
.g-msg-av { width: 32px; height: 32px; font-size: 13px; align-self: flex-end; }
.g-msg-av-slot { width: 32px; min-width: 32px; }
.g-msg-head { display: contents; }
.g-msg-time, .g-msg-hover-time, #messages .g-msg-nick, .g-msg.mine .g-msg-nick, .g-msg .g-msg-head svg { display: none; }
.g-msg-nick { font-size: 13px; font-weight: 700; color: var(--text-brand); margin-bottom: 2px; }
.g-msg-text { font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.g-msg.deleted .g-msg-body { background: transparent; box-shadow: none; border-style: dashed; }
.g-msg.deleted .g-msg-text { font-style: italic; }
.g-msg .msg-del-btn { display: none; }
.g-msg.flash .g-msg-body { animation: cp-flash 1.4s cubic-bezier(.22,1,.36,1); }
@keyframes cp-flash { 0%, 30% { box-shadow: 0 0 0 3px var(--accent-border); } 100% { box-shadow: var(--shadow-low); } }
.message-image, .message-video { border-radius: 12px; margin-top: 6px; }

.msg-meta { display: none; }
.msg-edited { font-style: italic; }

.msg-reply { all: unset; cursor: pointer; display: grid; gap: 1px; margin: 2px 0 6px; padding: 6px 10px; border-radius: 10px; background: var(--accent-bg); min-width: 0; }
.msg-reply:hover { background: var(--accent-bg2); }
.msg-reply:focus-visible { outline: 2px solid var(--focus); }
.msg-reply-name { font-size: 12px; font-weight: 700; color: var(--text-brand); }
.msg-reply-text { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48ch; }
.msg-reply.is-deleted .msg-reply-text { font-style: italic; }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.msg-reaction { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 13px; border: 1px solid var(--border); background: var(--bg1); color: var(--text2); font-size: 12px; font-weight: 600; cursor: pointer; transition: background-color var(--ease-fast), border-color var(--ease-fast), transform var(--ease-fast); }
.msg-reaction:hover { background: var(--hover); }
.msg-reaction:active { transform: scale(.94); }
.msg-reaction.mine { background: var(--accent-bg); border-color: var(--accent-border); color: var(--text-brand); }
.msg-reaction-emoji { font-size: 15px; }
.msg-reaction.add { opacity: 0; padding: 0 6px; }
.g-msg:hover .msg-reaction.add, .msg-reaction.add:focus-visible { opacity: 1; }

.msg-actions { position: absolute; top: -16px; right: 24px; z-index: 3; display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--bg-floating); border: 1px solid var(--border); box-shadow: var(--shadow-medium); opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity var(--ease-fast), transform var(--ease-fast); }
.g-msg.mine .msg-actions { right: auto; left: 24px; }
.g-msg:hover .msg-actions, .g-msg:focus-within .msg-actions, .g-msg.actions-open .msg-actions, .g-msg.picker-open .msg-actions { opacity: 1; transform: none; pointer-events: auto; }
.g-msg.editing .msg-actions { display: none; }
.msg-action { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--text2); }
.msg-action:focus-visible, .react-picker-item:focus-visible, .msg-reaction:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.msg-action:hover { background: var(--hover); color: var(--text-h); }
.msg-action.danger:hover { background: var(--red-bg); color: var(--text-danger); }

.react-picker { position: fixed; z-index: 2000; display: flex; gap: 2px; padding: 6px; border-radius: 16px; background: var(--bg-floating); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: cp-pop 180ms cubic-bezier(.22,1,.36,1); }
.react-picker[hidden] { display: none; }
.react-picker-item { width: 36px; height: 36px; border-radius: 10px; font-size: 20px; transition: transform var(--ease-fast), background-color var(--ease-fast); }
.react-picker-item:hover, .react-picker-item:focus-visible { background: var(--hover); transform: scale(1.18); }
@keyframes cp-pop { from { opacity: 0; transform: translateY(6px) scale(.96); } }

.msg-editor { display: grid; gap: 4px; min-width: min(420px, 60vw); }
.msg-edit-input { resize: none; width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--accent-border); background: var(--bg1); color: var(--text-h); font: inherit; font-size: 15px; line-height: 1.45; box-shadow: 0 0 0 3px var(--accent-bg); }
.msg-edit-input:focus { outline: none; }
.msg-edit-hint { font-size: 11px; color: var(--text3); }
.msg-edit-link { color: var(--link); font-size: 11px; }
.msg-edit-link.strong { font-weight: 700; }

.msg-bar-wrap { position: relative; }
.composer-context { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; padding: 8px 8px 8px 12px; border-radius: 14px; background: var(--accent-bg); animation: cp-pop 180ms cubic-bezier(.22,1,.36,1); }
.composer-context-icon { color: var(--text-brand); display: flex; }
.composer-context-copy { display: grid; min-width: 0; flex: 1; }
.composer-context-title { font-size: 12px; color: var(--text2); }
.composer-context-title strong { color: var(--text-brand); }
.composer-context-text { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-context-close { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--text2); }
.composer-context-close:hover { background: var(--hover); color: var(--text-h); }

.typing-indicator { height: 0; overflow: hidden; display: flex; align-items: center; gap: 8px; padding: 0 6px; font-size: 12px; color: var(--text3); opacity: 0; transition: opacity var(--ease); }
.typing-indicator.show { height: 22px; opacity: 1; }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-brand); animation: cp-dot 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; } .typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes cp-dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.chat-window, .group-chat-left { position: relative; }
.jump-latest { position: absolute; right: 24px; bottom: 110px; z-index: 4; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-floating); color: var(--text-h); border: 1px solid var(--border); box-shadow: var(--shadow-medium); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity var(--ease), transform var(--ease); }
.jump-latest.show { opacity: 1; transform: none; pointer-events: auto; }
.jump-latest:hover { background: var(--accent); color: var(--on-accent); }
.jump-latest-badge { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }
.jump-latest-badge[hidden] { display: none; }

.msg-bar { border-radius: 20px; }
.send-btn:not(:disabled) { background: var(--accent); color: var(--on-accent); border-radius: 50%; }
.send-btn:hover:not(:disabled) { background: var(--accent-h); }

/* Звонки */
.call-overlay { background: oklch(18% .012 200); color: oklch(96% .006 195); }
.call-overlay-top, .call-overlay-controls { background: transparent; box-shadow: none; }
.call-overlay-title { color: oklch(97% .006 195); font-family: var(--font-display); }
.call-overlay-label, .call-overlay-status { color: oklch(80% .02 195); }
.call-tile { background: oklch(24% .015 200); border: 1px solid oklch(100% 0 0 / .07); border-radius: 20px; overflow: hidden; }
.call-tile.speaking { box-shadow: 0 0 0 3px oklch(78% .13 170), 0 0 24px oklch(78% .13 170 / .35); }
.call-tile-nick { background: oklch(12% .01 200 / .6); color: oklch(97% .005 195); border-radius: 10px; padding: 3px 9px; }
.call-overlay-controls { gap: 12px; }
.call-overlay-controls .call-round-btn { width: 54px; height: 54px; border-radius: 18px; background: oklch(30% .015 200); color: oklch(96% .006 195); }
.call-overlay-controls .call-round-btn:hover { background: oklch(36% .02 200); }
.call-overlay-controls .call-round-btn.active-off { background: oklch(96% .006 195); color: oklch(22% .02 200); }
.call-overlay-controls .call-round-btn.call-decline { background: oklch(58% .19 25); color: oklch(99% .004 60); width: 68px; }
.call-overlay-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.call-tool-btn { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: oklch(90% .01 195); background: oklch(100% 0 0 / .06); }
.call-tool-btn:hover { background: oklch(100% 0 0 / .12); }
.call-quality { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px; background: oklch(100% 0 0 / .07); font-size: 12px; font-variant-numeric: tabular-nums; }
.call-quality[hidden] { display: none; }
.q-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.q-bars i { width: 3px; border-radius: 1px; background: oklch(100% 0 0 / .25); }
.q-bars i:nth-child(1) { height: 5px; } .q-bars i:nth-child(2) { height: 8px; } .q-bars i:nth-child(3) { height: 12px; }
.q-good i { background: oklch(78% .15 150); }
.q-fair i:nth-child(-n+2) { background: oklch(84% .14 85); }
.q-poor i:nth-child(1) { background: oklch(66% .19 25); }
.call-tile-quality { position: absolute; top: 10px; right: 10px; z-index: 2; padding: 5px 7px; border-radius: 9px; background: oklch(12% .01 200 / .55); }
.call-tile-volume { position: absolute; left: 10px; top: 10px; z-index: 2; display: flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 11px; background: oklch(12% .01 200 / .6); color: oklch(95% .006 195); opacity: 0; transition: opacity var(--ease); }
.call-tile:hover .call-tile-volume, .call-tile-volume:focus-within { opacity: 1; }
.call-tile-volume.is-muted { opacity: 1; color: oklch(72% .16 25); }
.call-tile-volume input { width: 92px; accent-color: oklch(78% .12 180); }
.call-overlay.is-deafened .call-overlay-status::after { content: ' · звук выключен'; }
.call-incoming-avatar { animation: cp-ring 1.6s infinite cubic-bezier(.22,1,.36,1); }
@keyframes cp-ring { 0% { box-shadow: 0 0 0 0 var(--accent-border); } 100% { box-shadow: 0 0 0 22px transparent; } }
.call-round-btn.call-accept { background: oklch(62% .15 150); color: oklch(99% .004 60); }

@media (max-width: 640px) {
  .messages .g-msg, .group-messages .g-msg { padding-inline: 10px; }
  .g-msg-body { max-width: 86%; }
  .msg-actions { right: 12px; } .g-msg.mine .msg-actions { left: 12px; }
  .jump-latest { right: 14px; bottom: 96px; }
  .call-overlay-controls .call-round-btn { width: 48px; height: 48px; }
}
@media (pointer: coarse) {
  .msg-action, .react-picker-item, .msg-reaction, .composer-context-close { min-width: 44px; min-height: 44px; }
  .msg-reaction.add { opacity: 1; }
  .msg-actions { max-width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) { .typing-dots i, .call-incoming-avatar { animation: none; } }

/* Discord-style conversation rows: shared timeline, no Telegram chat bubbles. */
.messages .g-msg,
.group-messages .g-msg {
  position: relative;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 4px 16px 4px 20px;
  border-radius: 0;
  background: transparent;
  transition: background-color var(--ease-fast);
}
.messages .g-msg:hover,
.group-messages .g-msg:hover,
.messages .g-msg:focus-within,
.group-messages .g-msg:focus-within {
  background: var(--msg-hover);
}
.messages .g-msg.mine,
.group-messages .g-msg.mine { flex-direction: row; }
.messages,
.group-messages { gap: 0; padding-top: 8px; }
.g-msg-av,
.g-msg-av-slot {
  flex: 0 0 38px;
  width: 38px;
  min-width: 38px;
}
.g-msg-av {
  height: 36px;
  margin-top: 2px;
  align-self: flex-start;
  cursor: default;
}
.g-msg-av.clickable { cursor: pointer; }
.g-msg-body,
.g-msg.mine .g-msg-body,
.g-msg.grouped .g-msg-body,
.g-msg.mine.grouped .g-msg-body {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.g-msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 20px;
  margin: 0 0 1px;
}
.g-msg-nick,
.g-msg.mine .g-msg-nick,
#messages .g-msg-nick {
  display: inline;
  margin: 0;
  color: var(--text-h);
  font-size: 15px;
  font-weight: 650;
  line-height: 20px;
  cursor: pointer;
}
.g-msg-nick:hover { text-decoration: underline; }
.g-msg-time,
.g-msg .g-msg-head svg {
  display: inline;
  color: var(--text3);
  font-size: 11px;
  line-height: 16px;
}
.g-msg-text {
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
.messages .g-msg.grouped, .group-messages .g-msg.grouped { min-height: 0; padding-top: 1px; padding-bottom: 1px; }
.g-msg.grouped .g-msg-hover-time {
  display: block;
  padding-top: 2px;
  color: var(--text3);
  font-size: 10px;
  text-align: center;
  opacity: 0;
  transition: opacity var(--ease-fast);
}
.g-msg.grouped:hover .g-msg-hover-time,
.g-msg.grouped:focus-within .g-msg-hover-time { opacity: 1; }
.g-msg.grouped .g-msg-body { margin-left: 0; }
.g-msg.grouped .g-msg-body::before { content: none; }
.g-msg.grouped .g-msg-text { min-height: 1.45em; }
.messages #messages .g-msg-av,
.messages #messages .g-msg-av-slot,
#messages .g-msg-av,
#messages .g-msg-av-slot,
.g-msg.mine .g-msg-av,
.g-msg.mine .g-msg-av-slot {
  display: flex;
}
.g-msg.deleted .g-msg-body { border: 0; background: transparent; box-shadow: none; }
.g-msg.deleted .g-msg-text { color: var(--text3); }
.msg-actions,
.g-msg.mine .msg-actions {
  top: -34px;
  right: 16px;
  left: auto;
  gap: 0;
  padding: 3px;
  border-radius: 8px;
  background: var(--bg-floating);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-medium);
}
.msg-action {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}
.msg-action.danger { color: var(--text-danger); }
.g-msg.flash .g-msg-body { animation: none; }
.g-msg.flash { box-shadow: inset 0 0 0 1px var(--accent-border); }
.g-msg,
.g-msg.mine,
.g-msg.grouped,
.g-msg.mine.grouped { border-radius: 0; }
.g-msg.grouped .g-msg-body,
.g-msg.mine .g-msg-body,
.g-msg.mine.grouped .g-msg-body {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.messages .g-msg.mine,
.group-messages .g-msg.mine { flex-direction: row; }
.g-msg.grouped .g-msg-hover-time {
  position: relative;
  width: 38px;
  min-width: 38px;
}
.message-image,
.message-video { border-radius: 4px; }
.chat-head {
  background: var(--bg1);
  box-shadow: 0 1px 0 var(--border-subtle);
}
.chat-head-actions { gap: 4px; }
.chat-head .icon-btn { width: 36px; height: 36px; }
.chat-head .icon-btn:hover { color: var(--text-h); background: var(--hover); }
.msg-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 18px 10px;
  border: 0;
  color: var(--text3);
}
.msg-divider::before,
.msg-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--divider);
}
.msg-divider span {
  padding: 0 4px;
  background: transparent;
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}
.msg-bar-wrap {
  padding: 0 16px 12px;
  background: var(--bg2);
}
.msg-bar {
  min-height: 48px;
  padding: 0 8px 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.msg-bar:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-bg);
}
.attach-btn,
.send-btn {
  flex-basis: 36px;
  width: 36px;
  height: 36px;
  color: var(--text3);
}
.send-btn:not(:disabled) {
  background: transparent;
  color: var(--text-brand);
}
.send-btn:hover:not(:disabled) {
  background: var(--accent-bg);
  color: var(--accent-h);
}
.composer-hint {
  padding: 4px 4px 0;
  color: var(--text4);
}
.chat-welcome-av {
  background: var(--accent);
  color: var(--on-accent);
}
.msg-reaction {
  border-radius: 7px;
  background: var(--bg3);
}
@media (max-width: 640px) {
  .messages .g-msg,
  .group-messages .g-msg { gap: 12px; padding-inline: 12px; }
  .g-msg-av,
  .g-msg-av-slot { flex-basis: 34px; width: 34px; min-width: 34px; }
  .msg-actions,
  .g-msg.mine .msg-actions { top: -40px; right: 8px; }
}
@media (pointer: coarse) {
  .msg-action { width: 44px; height: 44px; }
  .msg-actions { top: -48px; }
}

/* ───────────────────── 2.0.9. Полировка (только оформление) ─────────────────────
   Токены и контраст не менялись. Правила ниже мягко уточняют геометрию,
   глубину и состояния; всё безопасно для тёмной темы, потому что цвета
   берутся только из существующих токенов. */

/* Карточка входа: чуть больше воздуха и мягкая обводка */
.auth-box {
  padding: 36px;
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-lg), 0 0 0 1px oklch(100% 0 0 / .35) inset;
}
.auth-title { font-size: 26px; }
.tab-content.active { gap: 20px; }

/* Поля: единый плавный фокус-состояние вместо резкой смены рамки */
.field input, .field textarea {
  transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}
.field input:hover:not(:focus):not(:disabled),
.field textarea:hover:not(:focus):not(:disabled) { border-color: var(--divider); }
.field input:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg2);
  outline: none;
}

/* Кнопки: лёгкая глубина и отклик на нажатие */
.btn-primary, .btn-secondary, .btn-danger { transition: background-color var(--ease), color var(--ease), opacity var(--ease), box-shadow var(--ease), transform var(--ease-fast); }
.btn-primary:not(:disabled) { box-shadow: var(--shadow-low); }
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-medium); }
.btn-primary:active:not(:disabled),
.btn-secondary:active:not(:disabled),
.btn-danger:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn-primary[aria-busy="true"] { cursor: progress; }

/* Модальные окна: мягче углы и появление */
.modal-box { border-radius: var(--radius-xl); animation: auth-in var(--ease-slow); }

/* Уважаем системную настройку «меньше анимации» */
@media (prefers-reduced-motion: reduce) {
  .auth-box, .modal-box { animation: none; }
  .btn-primary, .btn-secondary, .btn-danger { transition: none; }
  .btn-primary:active:not(:disabled), .btn-secondary:active:not(:disabled), .btn-danger:active:not(:disabled) { transform: none; }
}

/* Узкие экраны: карточка входа без лишних отступов */
@media (max-width: 640px) {
  .auth-box { padding: 24px 18px; }
  .auth-title { font-size: 24px; }
}

/* 2.0.10 — surfaces, conversation hierarchy and comfortable controls. */
.sidebar-inner { border-right: 1px solid var(--border-subtle); }
.sidebar-top { padding-bottom: 8px; }
.friend-item, .group-item { min-height: 54px; margin-block: 3px; border: 1px solid transparent; }
.friend-item.active, .group-item.active { border-color: var(--accent-border); box-shadow: inset 3px 0 var(--accent); }
.friend-item.active .f-nick { color: var(--text-h); }
.chat-head { min-height: 56px; border-bottom: 1px solid var(--border-subtle); box-shadow: none; }
.chat-head-nick { font-size: 17px; }
.chat-head .icon-btn { border-radius: 12px; background: var(--bg2); }
.chat-head .icon-btn:hover { background: var(--accent-bg); color: var(--text-brand); }
.msg-bar-wrap { padding: 12px 20px 10px; background: var(--bg1); border-top: 1px solid var(--border-subtle); }
.msg-bar { min-height: 52px; padding: 2px 6px 2px 14px; border-radius: 12px; background: var(--bg2); box-shadow: var(--shadow-low); }
.msg-bar .attach-btn, .msg-bar .send-btn { margin-bottom: 5px; }
.msg-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.send-btn:not(:disabled) { background: var(--accent); color: var(--on-accent); border-radius: 12px; }
.send-btn:hover:not(:disabled) { background: var(--accent-h); color: var(--on-accent); }
.composer-hint { align-items: center; padding: 6px 4px 0; line-height: 16px; color: var(--text3); }
.modal-box { border: 1px solid var(--border); }
.settings-section .settings-toggle-row { gap: 20px; margin-block: 16px 24px; padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg1); }
.settings-toggle-copy { min-width: 0; }
.settings-switch { flex-shrink: 0; }
.privacy-note { padding: 20px; border-radius: 14px; background: var(--accent-bg); color: var(--text2); line-height: 1.65; }
.privacy-note strong { color: var(--text-h); }
.privacy-note p { margin: 8px 0 0; }
.call-overlay { background: radial-gradient(ellipse at 50% 0, oklch(25% .035 200), transparent 65%), oklch(18% .012 200); }
.call-overlay-top { border-bottom: 1px solid oklch(100% 0 0 / .08); }
.call-overlay-controls { padding-block: 20px; background: oklch(14% .01 200 / .7); border-top: 1px solid oklch(100% 0 0 / .08); }
.call-tile { border-radius: 18px; }
.call-overlay-controls .call-round-btn:focus-visible { outline: 3px solid oklch(85% .1 190); outline-offset: 4px; }
@media (max-width: 640px) {
  .chat-head { min-height: 60px; }
  .msg-bar-wrap { padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
  .msg-bar { min-height: 52px; }
  .settings-section .settings-toggle-row { padding: 16px; flex-wrap: wrap; }
  .call-overlay-controls { padding-block: 14px max(14px, env(safe-area-inset-bottom)); }
}

/* Profile customization */
.profile-banner { height: 90px; border-radius: 12px 12px 0 0; flex-shrink: 0; }
.profile-preview { border: 1px solid var(--border, #777); border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.profile-preview-copy { padding: 14px 18px; overflow-wrap: anywhere; }
.profile-preview-copy strong { display: block; font-size: 20px; }
.profile-preview-copy span, .profile-pronouns { font-size: 13px; opacity: .85; }
.profile-preview-copy p { margin: 8px 0 0; white-space: pre-wrap; max-height: 100px; overflow: auto; }
.profile-preview-copy p:empty { display: none; }
.profile-color-fields { display: flex; gap: 16px; }
.profile-color-fields .field { flex: 1; min-width: 0; }
.profile-color-fields input[type=color] { width: 100%; height: 42px; padding: 4px; cursor: pointer; }
#profile-modal .modal-box { overflow-x: hidden; overflow-y: auto; }
#profile-modal-banner { margin: -24px -24px 0; border-radius: 0; height: 108px; }
#edit-profile-modal .modal-box { max-height: calc(100dvh - 32px); overflow-y: auto; }
#edit-profile-modal .modal-title { margin-bottom: 0; padding-right: 36px; }
#edit-profile-modal .settings-section-note { margin: 0 0 6px; line-height: 1.5; }
#edit-profile-modal .form-stack { gap: 16px; }
#edit-profile-modal .profile-preview { margin-bottom: 0; }
#edit-profile-modal .edit-avatar-block { margin: 0; padding: 14px; border: 1px solid var(--border-subtle); border-radius: 12px; }
.settings-nav [hidden], .settings-sidebar [hidden] { display: none !important; }
.settings-info-row strong { overflow-wrap: anywhere; min-width: 0; }

/* 2.0.12: registration, profile editor and unobstructed voice diagnostics */
#auth-screen.active { background: #10132b; background-image: radial-gradient(ellipse at 15% 10%, #3447a6 0, transparent 55%), radial-gradient(ellipse at 90% 95%, #292357 0, transparent 55%); }
#auth-screen .btn-primary { background: #5865f2; color: white; }
#auth-screen .btn-primary:hover { background: #4752c4; }
.profile-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-presets button { padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg2); color: var(--text); cursor: pointer; }
.profile-presets button:hover { border-color: #5865f2; }
.profile-presets button { position: relative; display: flex; align-items: center; gap: 9px; flex: 1 1 120px; padding: 10px 12px; text-align: left; border-radius: 10px; }
.profile-presets button::before { content: ''; width: 24px; height: 24px; flex: none; border-radius: 7px; background: linear-gradient(135deg, #5865f2, #9b59b6); }
.profile-presets button[data-profile-colors="#176b87,#64ccc5"]::before { background: linear-gradient(135deg, #176b87, #64ccc5); }
.profile-presets button[data-profile-colors="#833ab4,#fd746c"]::before { background: linear-gradient(135deg, #833ab4, #fd746c); }
.profile-presets button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--accent); }
.profile-color-fields { padding: 14px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg1); }
.profile-rare-badge { display: inline-flex; align-items: center; gap: 9px; padding: 8px 12px; border: 1px solid rgb(162 131 255 / .35); border-radius: 10px; background: linear-gradient(120deg, rgb(113 78 201 / .22), rgb(68 110 201 / .14)); color: var(--text-h); text-align: left; font-size: 13px; font-weight: 700; }
.profile-rare-badge svg { width: 24px; height: 24px; flex: none; color: #ac94ff; }
.profile-rare-badge small { display: block; margin-top: 2px; color: var(--text2); font-size: 11px; font-weight: 400; }
.profile-preview-joined { display: block; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-subtle); font-size: 12px; line-height: 1.5; color: var(--text3); }
#profile-preview-avatar { margin: -46px 0 12px; border: 0; position: relative; }
.profile-preview { background: var(--bg1); }
#edit-profile-modal .modal-footer { position: sticky; bottom: -24px; background: var(--bg1); padding: 16px 0; z-index: 3; }
.call-tile-quality { display: flex; align-items: center; gap: 5px; font-size: 11px; white-space: nowrap; }
.call-overlay.voice-mode .call-tile-quality { top: -26px; right: auto; left: 50%; transform: translateX(-50%); padding: 3px 6px; pointer-events: none; }
.call-overlay.voice-mode .call-video-grid { padding-top: 36px; }
@media (min-width: 850px) {
 #edit-profile-modal .modal-box { width: 850px; max-width: calc(100vw - 48px); display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px 28px; }
 #edit-profile-title, #edit-profile-modal .settings-section-note, #edit-profile-modal .modal-footer { grid-column: 1 / -1; }
 #edit-profile-modal .profile-preview { grid-column: 2; grid-row: 3 / 5; align-self: start; position: sticky; top: 0; }
 #edit-profile-modal .edit-avatar-block, #edit-profile-modal .form-stack { grid-column: 1; }
}

/* Unified profile and settings geometry */
#profile-modal .modal-profile-header::before { content: none; }
#profile-modal .modal-profile-header { padding: 0 0 20px; margin-top: -40px; }
#profile-modal .modal-profile-header .modal-avatar { box-sizing: border-box; width: 88px; height: 88px; border: 0; }
.modal-profile .modal-profile-name, .modal-profile .modal-profile-id { max-width: 100%; overflow-wrap: anywhere; }
.modal-profile .profile-info-value { white-space: pre-wrap; overflow-wrap: anywhere; }
.modal-profile .modal-close-btn { z-index: 5; background: rgb(20 20 26 / .65); color: white; }
.modal-profile .modal-close-btn:hover { background: rgb(20 20 26 / .85); }
#group-info-modal .modal-profile { padding-top: 0; }
#group-info-modal .modal-profile-header { padding-top: 64px; }
#group-info-modal .modal-profile-header::before { background: linear-gradient(120deg, #5865f2, #8b5fbf); }
#group-info-modal .modal-profile-header .modal-avatar { box-sizing: border-box; }
.settings-user-avatar { display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 15px; font-weight: 700; line-height: 1; color: white; }
.settings-user-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
:is(.me-avatar, .s-mini-av, .f-av, .chat-head-avatar, .modal-avatar, .edit-avatar, .gm-av, .g-msg-av, .group-voice-member-avatar, .call-tile-avatar, .call-incoming-avatar, .chat-welcome-av, .settings-user-avatar):not(:has(> img)) { background: var(--avatar-color, #5865f2); }
.profile-badges { margin-top: 10px; }
.profile-badges[hidden] { display: none; }
.profile-admin-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 7px; background: rgb(237 66 69 / .14); color: #ff777a; font-size: 12px; font-weight: 700; }
.profile-admin-badge svg { width: 16px; height: 16px; flex: none; }
.call-overlay.video-mode:not(.detached):not(.call-compact):not(:fullscreen) { inset: var(--call-top, 56px) 0 auto var(--call-left, 312px); height: min(50dvh, 500px); max-height: 50dvh; }
.call-overlay.screen-share-mini:not(.detached):not(.call-compact):not(:fullscreen) .call-overlay-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 12px;
  padding: 8px 14px;
  text-align: left;
}
.screen-share-mini .call-overlay-heading { grid-row: span 2; }
.screen-share-mini .call-overlay-title, .screen-share-mini .call-overlay-status {
  grid-column: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.screen-share-mini .call-overlay-tools { grid-column: 3; grid-row: 1 / 3; }
@media (max-width: 600px) {
  .call-overlay.screen-share-mini:not(.detached):not(.call-compact):not(:fullscreen) .call-overlay-top {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .screen-share-mini:not(.detached):not(.call-compact) .call-overlay-heading { display: none; }
  .screen-share-mini .call-overlay-title, .screen-share-mini .call-overlay-status { grid-column: 1; }
  .screen-share-mini .call-overlay-tools { grid-column: 2; }
}
.call-overlay.screen-share-mini:not(.detached):not(.call-compact):not(:fullscreen) .call-video-grid { min-height: 0; padding: 6px 14px; }
.call-overlay.screen-share-mini:not(.detached):not(.call-compact):not(:fullscreen) .call-tile { min-height: 0; }
.call-overlay.screen-share-mini:not(.detached):not(.call-compact):not(:fullscreen) .call-overlay-controls { position: static; margin: 2px auto 6px; padding: 4px; }
.call-overlay.screen-share-mini:not(.detached):not(.call-compact):not(:fullscreen) .call-round-btn { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
body:has(.call-overlay.video-mode:not(.detached):not(.call-compact):not(:fullscreen)[style*="display: flex"]) .chat-window .messages,
body:has(.call-overlay.video-mode:not(.detached):not(.call-compact):not(:fullscreen)[style*="display: flex"]) .chat-window .group-messages { margin-top: min(50dvh, 500px); }
.call-overlay.screen-share-mini.detached:not(.call-compact) { inset: auto 16px 16px auto; width: min(300px, calc(100vw - 32px)); height: auto; max-height: 220px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg2); box-shadow: var(--shadow-lg); }
.call-overlay.screen-share-mini.detached:not(.call-compact) .call-video-grid { display: none; }
.call-overlay.screen-share-mini.detached:not(.call-compact) .call-overlay-controls { position: static; width: auto; margin: 4px auto 0; padding: 4px; gap: 4px; }
.call-overlay.screen-share-mini.detached:not(.call-compact) .call-overlay-controls .call-round-btn { width: 34px; height: 34px; min-width: 34px; min-height: 34px; }
@media (max-width: 900px) { .call-overlay.video-mode:not(.detached):not(.call-compact):not(:fullscreen) { left: 0; } }
.call-overlay.screen-share-mini.call-compact { inset: 66px 16px auto auto; width: min(340px, calc(100vw - 24px)); height: min(260px, 42dvh); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.call-overlay.screen-share-mini.call-compact .call-overlay-top { padding: 8px 10px; min-height: 42px; flex-direction: row; text-align: left; gap: 8px; }
.call-overlay.screen-share-mini.call-compact .call-overlay-heading { font-size: 10px; padding: 3px 6px; }
.call-overlay.screen-share-mini.call-compact .call-overlay-title, .call-overlay.screen-share-mini.call-compact .call-overlay-status { display: none; }
.call-overlay.screen-share-mini.call-compact .call-overlay-tools { margin-left: auto; }
.call-overlay.screen-share-mini.call-compact .call-video-grid { min-height: 0; padding: 4px 8px; gap: 4px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); }
.call-overlay.screen-share-mini.video-mode:not(.detached):not(.call-compact) .call-video-grid[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
.call-overlay.screen-share-mini.video-mode:not(.detached):not(.call-compact) .call-video-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) {
  .call-overlay.screen-share-mini.video-mode:not(.detached):not(.call-compact) .call-video-grid[data-count="2"] { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }
}
.call-overlay.screen-share-mini.call-compact .call-tile { min-height: 0; }
.call-overlay.screen-share-mini.call-compact .call-overlay-controls { position: static; transform: none; margin: 0 auto 6px; padding: 3px; gap: 4px; }
.call-overlay.screen-share-mini.call-compact .call-round-btn { width: 36px; height: 36px; min-width: 36px; min-height: 36px; border-radius: 10px; }
#btn-call-compact .compact-expand-icon { display: none; }
.call-overlay.screen-share-mini.call-compact #btn-call-compact .compact-expand-icon { display: block; }
:is(.me-avatar, .s-mini-av, .f-av, .chat-head-avatar, .modal-avatar, .edit-avatar, .gm-av, .g-msg-av, .group-av-cell, .group-voice-member-avatar, .call-tile-avatar, .call-incoming-avatar, .chat-welcome-av, .settings-user-avatar):has(> img) { background: transparent; }
.settings-content-head { margin-bottom: 24px; }
.settings-breadcrumb { margin-bottom: 14px; }
.settings-info-list { padding: 8px; background: var(--bg1); border: 1px solid var(--border-subtle); border-radius: 12px; margin-bottom: 20px; }
.settings-info-list .settings-info-row { grid-template-columns: 140px minmax(0, 1fr); min-height: 58px; }
.settings-info-list .settings-info-row strong { text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; text-overflow: clip; font-size: 14px; }
.settings-info-list .settings-info-row + .settings-info-row { border-top: 1px solid var(--border-subtle); border-radius: 0; }
.settings-password-row { padding: 16px; background: var(--bg1); border: 1px solid var(--border-subtle); }
.settings-password-row > span strong { white-space: normal; }
.settings-password-row > span small { line-height: 1.6; }
.settings-nav-item.active { background: var(--accent-bg); }
.settings-search:focus-within { box-shadow: 0 0 0 2px var(--accent-bg); }
#settings-modal .settings-content { scrollbar-gutter: stable; }
#profile-modal .modal-actions .btn-secondary, #group-info-modal .modal-actions .btn-secondary { border-color: var(--border); }
@media (max-width: 620px) {
 .settings-info-list .settings-info-row { grid-template-columns: 1fr; gap: 6px; padding: 12px; }
 .settings-password-row { grid-template-columns: 1fr; }
}

#profile-modal .modal-profile { padding: 24px; }

.settings-info-list .settings-info-row { align-items: start; padding-block: 16px; }
#settings-account-bio { max-height: 160px; overflow-y: auto; font-weight: 400; line-height: 1.6; }
