/* Темы оформления. Светлая — базовые styles.css; тёмная (по умолчанию)
   переопределяет цвета ниже. Тема и фон выбираются в меню «Оформление» (prefs.js). */
:root:not([data-theme='light']) {
  --blue: #6a8bff;
  --blue-dark: #5675f0;
  --ink: #e4e7f2;
  --muted: #8b92a8;
  --line: #232838;
  --wall: #0c0e15;
  --out: #2c3a72;
  --bg: #12141d;
  --panel: #161925;
  --panel-2: #1c2030;
  --hover: #20253a;
  --soft: #9aa2bb;
  --faint: #6b7390;
  --overlay: #1c2030cc;
  --overlay-strong: #161925f0;
  --active: #3f5bd6;
  --compose-fade: #0c0e15cc;
  color-scheme: dark;
}
:root:not([data-theme='light']) body {
  background: var(--bg);
}
:root:not([data-theme='light']) ::selection {
  background: #6a8bff55;
}
:root:not([data-theme='light']) button:focus-visible,
:root:not([data-theme='light']) a:focus-visible,
:root:not([data-theme='light']) .message-photo:focus-visible {
  outline-color: #8ea6ff;
}

/* Общие элементы */
:root:not([data-theme='light']) .icon-button {
  color: var(--faint);
}
:root:not([data-theme='light']) .icon-button:hover {
  background: var(--hover);
  color: var(--blue);
}
:root:not([data-theme='light']) .secondary {
  background: var(--panel-2);
  color: #b8c3ea;
}
:root:not([data-theme='light']) .danger,
:root:not([data-theme='light']) .profile-remove {
  color: #ff7b84 !important;
}
:root:not([data-theme='light']) .form-error {
  color: #ff7b84;
}
:root:not([data-theme='light']) .check-label,
:root:not([data-theme='light']) label {
  color: var(--soft);
}
:root:not([data-theme='light']) label > input:not([type='checkbox']),
:root:not([data-theme='light']) .field-input {
  background: var(--panel-2);
  border-color: #2a3047;
  color: var(--ink);
}
:root:not([data-theme='light']) input::placeholder,
:root:not([data-theme='light']) textarea::placeholder {
  color: #5f6782;
}

/* Боковая панель */
:root:not([data-theme='light']) .app-shell {
  box-shadow: none;
}
:root:not([data-theme='light']) .sidebar,
:root:not([data-theme='light']) .profile-bar {
  background: var(--panel);
}
:root:not([data-theme='light']) .sidebar {
  border-right-color: var(--line);
}
:root:not([data-theme='light']) .search-wrap {
  background: var(--panel-2);
  color: var(--faint);
}
:root:not([data-theme='light']) .search-wrap:focus-within {
  background: var(--panel-2);
  border-color: #6a8bff88;
}
:root:not([data-theme='light']) .tab {
  color: var(--faint);
}
:root:not([data-theme='light']) .tab span {
  background: var(--panel-2);
  color: var(--soft);
}
:root:not([data-theme='light']) .tab.active span {
  background: #6a8bff26;
}
:root:not([data-theme='light']) .chat-list {
  scrollbar-color: #2c3248 transparent;
}
:root:not([data-theme='light']) .chat-row:hover,
:root:not([data-theme='light']) .profile-bar:hover {
  background: var(--hover);
}
:root:not([data-theme='light']) .chat-row.active {
  background: var(--active);
}
:root:not([data-theme='light']) .chat-time {
  color: var(--faint);
}
:root:not([data-theme='light']) .chat-preview {
  color: #7d849c;
}
:root:not([data-theme='light']) .chat-preview .sender-prefix {
  color: #aab4dc;
}
:root:not([data-theme='light']) .chat-row.active .chat-time,
:root:not([data-theme='light']) .chat-row.active .chat-preview,
:root:not([data-theme='light']) .chat-row.active .sender-prefix,
:root:not([data-theme='light']) .chat-row.active .user-status {
  color: #dfe6ff;
}
:root:not([data-theme='light']) .chat-row.active .badge {
  background: #fff;
  color: var(--active);
}
:root:not([data-theme='light']) .profile-text > span,
:root:not([data-theme='light']) .profile-bar > span:last-child,
:root:not([data-theme='light']) .list-empty {
  color: var(--faint);
}
:root:not([data-theme='light']) .list-empty strong {
  color: var(--soft);
}
:root:not([data-theme='light']) .user-status {
  color: #8f9bc4;
}

/* Переписка */
:root:not([data-theme='light']) .welcome p,
:root:not([data-theme='light']) .welcome-bottom {
  color: var(--faint);
}
:root:not([data-theme='light']) .welcome-button {
  background: #ffffff10;
  color: #b8c6ff;
}
:root:not([data-theme='light']) .welcome-button:hover {
  background: #ffffff1c;
}
:root:not([data-theme='light']) .conversation-header,
:root:not([data-theme='light']) .message-search-bar {
  background: var(--panel);
  border-bottom-color: var(--line);
}
:root:not([data-theme='light']) .chat-heading span span {
  color: var(--faint);
}
:root:not([data-theme='light']) .connection {
  background: #4a5170;
}
:root:not([data-theme='light']) .connection.online {
  background: #4fd1a1;
}
:root:not([data-theme='light']) .connection.offline {
  background: #e3b25c;
}
:root:not([data-theme='light']) .pinned-bar {
  background: var(--overlay-strong);
  border-bottom-color: var(--line);
}
:root:not([data-theme='light']) .pinned-bar > span:last-child {
  border-left-color: var(--blue);
}
:root:not([data-theme='light']) .pinned-bar span span {
  color: var(--soft);
}
:root:not([data-theme='light']) .messages {
  scrollbar-color: #2c3248 transparent;
}
:root:not([data-theme='light']) .date-divider {
  background: var(--overlay);
  color: var(--soft);
}
:root:not([data-theme='light']) .message-bubble {
  background: var(--panel-2);
  box-shadow: 0 1px 2px #00000040;
}
:root:not([data-theme='light']) .message-author {
  color: #8ea6ff;
}
:root:not([data-theme='light']) .message-meta {
  color: #6f7792;
}
:root:not([data-theme='light']) .own .message-meta {
  color: #9fb0ea;
}
:root:not([data-theme='light']) .message-photo {
  background: #0f1119;
}
:root:not([data-theme='light']) .photo-error,
:root:not([data-theme='light']) .message-deleted {
  color: var(--faint);
}
:root:not([data-theme='light']) .message-actions {
  background: var(--overlay-strong);
  color: var(--soft);
}
:root:not([data-theme='light']) .message-row.highlight .message-bubble {
  box-shadow: 0 0 0 3px #6a8bff80;
}
:root:not([data-theme='light']) .load-older,
:root:not([data-theme='light']) .chat-empty {
  background: var(--overlay);
  color: var(--soft);
}
:root:not([data-theme='light']) .chat-empty svg {
  color: #8ea6ff;
}
:root:not([data-theme='light']) .chat-empty strong {
  color: var(--ink);
}
:root:not([data-theme='light']) .compose-area {
  background: linear-gradient(transparent, var(--compose-fade));
}
:root:not([data-theme='light']) .composer,
:root:not([data-theme='light']) .attachment-preview,
:root:not([data-theme='light']) .reply-preview {
  background: var(--panel-2);
  box-shadow: 0 2px 14px #00000040;
}
:root:not([data-theme='light']) .composer textarea {
  color: var(--ink);
}
:root:not([data-theme='light']) .composer .icon-button {
  color: var(--faint);
}
:root:not([data-theme='light']) .compose-hint {
  color: #555d78;
}
:root:not([data-theme='light']) .retry-bar {
  background: #3a2c17;
  color: #f0c07a;
}
:root:not([data-theme='light']) .message-search-bar input {
  background: var(--panel-2);
  color: var(--ink);
}

/* Цитаты, реакции, поиск */
:root:not([data-theme='light']) .reply-preview > span {
  border-left-color: var(--blue);
}
:root:not([data-theme='light']) .reply-preview strong,
:root:not([data-theme='light']) .search-result strong,
:root:not([data-theme='light']) .typing {
  color: #8ea6ff !important;
}
:root:not([data-theme='light']) .reply-preview span span,
:root:not([data-theme='light']) .message-quote span,
:root:not([data-theme='light']) .search-result small {
  color: var(--soft);
}
:root:not([data-theme='light']) .message-quote {
  background: #6a8bff14;
  border-left-color: #8ea6ff;
}
:root:not([data-theme='light']) .message-quote strong {
  color: #a9bbff;
}
:root:not([data-theme='light']) .search-result {
  border-bottom-color: var(--line);
}
:root:not([data-theme='light']) .search-result:hover {
  background: var(--hover);
}

/* Окна и меню */
:root:not([data-theme='light']) dialog,
:root:not([data-theme='light']) .modal-header,
:root:not([data-theme='light']) .context-menu {
  background: var(--panel);
  color: var(--ink);
}
:root:not([data-theme='light']) dialog {
  box-shadow: 0 24px 90px #000000a0;
  border: 1px solid var(--line);
}
:root:not([data-theme='light']) dialog::backdrop {
  background: #05060acc;
}
:root:not([data-theme='light']) .context-menu {
  border-color: var(--line);
  box-shadow: 0 8px 30px #00000080;
}
:root:not([data-theme='light']) .user-option:hover,
:root:not([data-theme='light']) .menu-action:hover,
:root:not([data-theme='light']) .context-menu button:hover,
:root:not([data-theme='light']) .emoji-grid button:hover {
  background: var(--hover);
}
:root:not([data-theme='light']) .modal-description,
:root:not([data-theme='light']) .user-option small,
:root:not([data-theme='light']) .section-label,
:root:not([data-theme='light']) .menu-action svg,
:root:not([data-theme='light']) .menu-action small,
:root:not([data-theme='light']) .profile-info p,
:root:not([data-theme='light']) .member-row small,
:root:not([data-theme='light']) .status-label,
:root:not([data-theme='light']) .modal-note,
:root:not([data-theme='light']) .empty-search,
:root:not([data-theme='light']) .context-menu svg {
  color: var(--faint);
}
:root:not([data-theme='light']) .toast {
  background: #252b40f2;
  box-shadow: 0 6px 25px #00000060;
}
:root:not([data-theme='light']) .photo-viewer {
  background: #07080cf5;
}

/* Векторный узор на экране входа. */
:root {
  --pattern: #5d8a6a24;
  --wall-img: url('/assets/wall-geo.svg');
  --wall-size: 720px;
}
:root:not([data-theme='light']) {
  --pattern: #b9c2ff10;
}
:root[data-wallpaper='stars'] {
  --wall-img: url('/assets/wall-stars.svg');
  --wall-size: 600px;
  --pattern: #4a5a8a55;
}
:root:not([data-theme='light'])[data-wallpaper='stars'] {
  --pattern: #dfe5ff59;
}
/* Фоны переписки и образцы в настройках используют одну палитру. */
:root {
  --chat-geometry: url('/assets/wall-geometry.webp');
  --chat-geometry-2: url('/assets/wall-geometry-2.webp');
  --chat-space: url('/assets/wall-starfield.webp');
  --chat-wallpaper: var(--chat-geometry);
  --chat-geometry-size: 440px;
  --chat-wallpaper-size: var(--chat-geometry-size);
  --chat-wallpaper-filter: none;
  --geometry-opacity: 1;
  --chat-wallpaper-opacity: var(--geometry-opacity);
  --geometry-alt-filter: invert(1) hue-rotate(180deg) saturate(0.75) brightness(0.8);
  --geometry-alt-opacity: 0.85;
  --space-filter: none;
  --space-opacity: 1;
  --wall-sky: #18334d;
  --wall-lime: #293e27;
  --wall-burgundy: #442b39;
  --wall-lavender: #302b49;
  --wall-peach: #49342d;
}
:root[data-theme='light'] {
  --chat-geometry: url('/assets/wall-geometry-light.webp');
  --chat-geometry-size: 560px;
  /* Geometry 1 is 15% dimmer on the light theme. */
  --geometry-opacity: 0.85;
  --geometry-alt-filter: none;
  --geometry-alt-opacity: 1;
  --space-filter: invert(1) hue-rotate(182deg) saturate(0.86) brightness(0.97);
  --space-opacity: 0.93;
  --wall-sky: #dcecf9;
  --wall-lime: #e7f1d5;
  --wall-burgundy: #efdce4;
  --wall-lavender: #e9e0f6;
  --wall-peach: #f7e4d7;
}
:root[data-wallpaper='stars'],
.wall-swatch-stars {
  --chat-wallpaper: var(--chat-space);
  --chat-wallpaper-size: 1800px;
  --chat-wallpaper-filter: var(--space-filter);
  --chat-wallpaper-opacity: var(--space-opacity);
}
@media (max-width: 700px) {
  :root[data-wallpaper='stars'] {
    --chat-wallpaper: url('/assets/wall-starfield-mobile.webp');
    --chat-wallpaper-size: 700px;
  }
}
:root[data-wallpaper='geo2'],
.wall-swatch-geo2 {
  --chat-wallpaper: var(--chat-geometry-2);
  --chat-wallpaper-size: 640px;
  --chat-wallpaper-filter: var(--geometry-alt-filter);
  --chat-wallpaper-opacity: var(--geometry-alt-opacity);
}
:root[data-wallpaper='clean'],
.wall-swatch-clean {
  --chat-wallpaper: none;
}
.wall-swatch-geo {
  --chat-wallpaper: var(--chat-geometry);
  --chat-wallpaper-size: var(--chat-geometry-size);
  --chat-wallpaper-filter: none;
  --chat-wallpaper-opacity: var(--geometry-opacity);
}
:root[data-wall-color='sky'],
.wall-color-sky { --wall-solid: var(--wall-sky); }
:root[data-wall-color='lime'],
.wall-color-lime { --wall-solid: var(--wall-lime); }
:root[data-wall-color='burgundy'],
.wall-color-burgundy { --wall-solid: var(--wall-burgundy); }
:root[data-wall-color='lavender'],
.wall-color-lavender { --wall-solid: var(--wall-lavender); }
:root[data-wall-color='peach'],
.wall-color-peach { --wall-solid: var(--wall-peach); }
.wall-color-theme { --wall-solid: var(--wall); }

:root[data-wallpaper='clean'] .settings-preview,
.wall-swatch-clean,
.wall-color-swatch {
  background-color: var(--wall-solid, var(--wall));
}
.conversation,
.settings-preview,
.wall-swatch:not(.wall-swatch-clean) {
  isolation: isolate;
  background-color: var(--wall);
}
:root:not([data-theme='light']) {
  --wallpaper-strength: calc(1 - 0.65 * var(--color-softness, 0));
}
:root[data-theme='light'] {
  --wallpaper-strength: calc(1 - 0.42 * var(--color-softness, 0));
}
/* Geometry 1 and 2 on the light theme: by default as calm as they used to be at 100%
   softness, and calmer still with the slider. */
:root[data-theme='light'][data-wallpaper='geo'],
:root[data-theme='light'][data-wallpaper='geo2'],
:root[data-theme='light'] .wall-swatch-geo,
:root[data-theme='light'] .wall-swatch-geo2 {
  --wallpaper-strength: calc(0.58 - 0.23 * var(--color-softness, 0));
}
.conversation::before,
.settings-preview::before,
.wall-swatch::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--chat-wallpaper) left top / var(--chat-wallpaper-size) repeat;
  filter: var(--chat-wallpaper-filter);
  opacity: calc(var(--chat-wallpaper-opacity) * var(--wallpaper-strength, 1));
}

/* Окно «Оформление» */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.theme-choices {
  grid-template-columns: repeat(2, 1fr);
}
.choice {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  padding: 8px;
  border-radius: 12px;
  border: 2px solid transparent;
  font-size: 12px;
  text-align: center;
}
.choice:hover {
  background: var(--hover, #f3f7fa);
}
.choice[aria-pressed='true'] {
  border-color: var(--blue);
}
.choice-swatch {
  height: 58px;
  border-radius: 9px;
  border: 1px solid #8884;
  position: relative;
  overflow: hidden;
}
.choice-swatch::before,
.choice-swatch::after {
  content: '';
  position: absolute;
  left: 8px;
  height: 10px;
  border-radius: 5px;
}
.choice-swatch::before {
  top: 12px;
  width: 55%;
  background: var(--sw-in);
}
.choice-swatch::after {
  top: 30px;
  left: auto;
  right: 8px;
  width: 45%;
  background: var(--sw-out);
}
.swatch-dark {
  background: #080d1c;
  --sw-in: #17213a;
  --sw-out: #2d3b70;
}
:root:not([data-theme='light']) .swatch-dark {
  background: var(--tg-wall);
  --sw-in: var(--tg-in);
  --sw-out: var(--tg-out);
}
.swatch-light {
  background: #edf1f8;
  --sw-in: #ffffff;
  --sw-out: #effedd;
}
:root[data-theme='light'] .swatch-light {
  background: var(--tg-wall);
  --sw-in: var(--tg-in);
  --sw-out: var(--tg-out);
}
.wall-swatch::after {
  display: none;
}
.wall-color-swatch {
  height: 30px;
}
.wall-color-swatch::before,
.wall-color-swatch::after {
  display: none;
}
.choice-swatch.wall-swatch::before {
  inset: 0;
  width: auto;
  height: auto;
  border-radius: 0;
  background: var(--chat-wallpaper) center / calc(var(--chat-wallpaper-size) / 4) repeat;
}

/* Возвращаем акценты, которые общие правила тёмных тем перебивают по специфичности. */
:root:not([data-theme='light']) .own .message-bubble {
  background: var(--out);
}
:root:not([data-theme='light']) .tab.active {
  color: var(--blue);
}
:root:not([data-theme='light']) .photo-viewer,
:root:not([data-theme='light']) .photo-viewer .modal-header {
  background: transparent;
}
:root:not([data-theme='light']) .photo-viewer {
  background: #07080cf5;
}

/* Бренд Void: живой тессеракт и надпись, где «O» — гиперкуб. */
.wordmark-svg {
  width: 90px;
  height: 28px;
  stroke-width: 2.6;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.wordmark-svg.big {
  width: 110px;
  height: 34px;
}
/* The Void mark inside the letter O (its own 100x100 coordinate box). */
.wordmark-svg .wm-mark {
  width: 14.8px;
  height: 14.8px;
  overflow: visible;
}
.wordmark-svg .wm-mark path {
  stroke: var(--tg-link);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.welcome-bottom {
  color: var(--soft, #7d8b97);
  opacity: 0.8;
}

/* Закреплённые чаты */
.chat-pin {
  display: inline-flex;
  color: var(--faint, #9aa6af);
}
.chat-pin svg {
  width: 15px;
  height: 15px;
  transform: rotate(45deg);
}
.chat-row.active .chat-pin {
  color: #dfe6ff;
}

/* Размер шрифта: текст интерфейса и текст сообщений настраиваются отдельно.
   Масштабируется только текст — иконки, аватарки и отступы не меняются. */
:root .tab {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .tab span {
  font-size: calc(10px * var(--ui-scale, 1));
}
:root .search-wrap input {
  font-size: calc(14px * var(--ui-scale, 1));
}
:root .chat-name {
  font-size: calc(14px * var(--ui-scale, 1));
}
:root .chat-time {
  font-size: calc(10px * var(--ui-scale, 1));
}
:root .chat-preview {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .chat-row .badge {
  font-size: calc(10px * var(--ui-scale, 1));
}
:root .badge {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .profile-text strong {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .profile-text > span {
  font-size: calc(11px * var(--ui-scale, 1));
}
:root .list-empty {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .list-empty strong {
  font-size: calc(15px * var(--ui-scale, 1));
}
:root .chat-heading strong {
  font-size: calc(15px * var(--ui-scale, 1));
}
:root .chat-heading span span {
  font-size: calc(11px * var(--ui-scale, 1));
}
:root .pinned-bar strong {
  font-size: calc(11px * var(--ui-scale, 1));
}
:root .pinned-bar span span {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .composer textarea {
  font-size: calc(14px * var(--ui-scale, 1));
}
:root .message-search-bar input {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .date-divider {
  font-size: calc(10px * var(--ui-scale, 1));
}
:root .load-older {
  font-size: calc(11px * var(--ui-scale, 1));
}
:root .chat-empty {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .chat-empty strong {
  font-size: calc(15px * var(--ui-scale, 1));
}
:root .welcome p {
  font-size: calc(14px * var(--ui-scale, 1));
}
:root .welcome-button {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .modal-header h2 {
  font-size: calc(19px * var(--ui-scale, 1));
}
:root .modal-description {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .modal-note {
  font-size: calc(11px * var(--ui-scale, 1));
}
:root label {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root label > input:not([type='checkbox']) {
  font-size: calc(15px * var(--ui-scale, 1));
}
:root .field-input {
  font-size: calc(15px * var(--ui-scale, 1));
}
:root .check-label {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .primary {
  font-size: calc(15px * var(--ui-scale, 1));
}
:root .secondary {
  font-size: calc(15px * var(--ui-scale, 1));
}
:root .menu-action {
  font-size: calc(14px * var(--ui-scale, 1));
}
:root .menu-action small {
  font-size: calc(10px * var(--ui-scale, 1));
}
:root .user-option strong {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .user-option small {
  font-size: calc(11px * var(--ui-scale, 1));
}
:root .member-row strong {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .member-row small {
  font-size: calc(11px * var(--ui-scale, 1));
}
:root .section-label {
  font-size: calc(10px * var(--ui-scale, 1));
}
:root .status-label {
  font-size: calc(11px * var(--ui-scale, 1));
}
:root .profile-info strong {
  font-size: calc(17px * var(--ui-scale, 1));
}
:root .profile-info p {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .context-menu button {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .toast {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .empty-search {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .search-result strong {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .search-result small {
  font-size: calc(11px * var(--ui-scale, 1));
}
:root .search-result > span {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .resource-text strong {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .resource-text span {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .resource-status strong {
  font-size: calc(17px * var(--ui-scale, 1));
}
:root .resource-queue-item {
  font-size: calc(14px * var(--ui-scale, 1));
}
:root .choice {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .settings-reset {
  font-size: calc(13px * var(--ui-scale, 1));
}
:root .profile-presence {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .profile-about p {
  font-size: calc(14px * var(--ui-scale, 1));
}
:root .retry-bar {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .attachment-preview strong {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .reply-preview strong {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .reply-preview span span {
  font-size: calc(12px * var(--ui-scale, 1));
}
:root .chat-name .user-status {
  font-size: calc(10px * var(--ui-scale, 1));
}
:root .profile-text .user-status {
  font-size: calc(10px * var(--ui-scale, 1));
}
@media (min-width: 1450px) {
  :root .chat-name {
    font-size: calc(15px * var(--ui-scale, 1));
  }
  :root .chat-preview {
    font-size: calc(13px * var(--ui-scale, 1));
  }
}
@media (max-width: 1000px) {
  :root .chat-name {
    font-size: calc(13px * var(--ui-scale, 1));
  }
}
@media (max-width: 700px) {
  :root .chat-name {
    font-size: calc(15px * var(--ui-scale, 1));
  }
  :root .chat-preview {
    font-size: calc(13px * var(--ui-scale, 1));
  }
  :root .chat-time {
    font-size: calc(11px * var(--ui-scale, 1));
  }
  :root .chat-heading strong {
    font-size: calc(14px * var(--ui-scale, 1));
  }
  :root .chat-heading span span {
    font-size: calc(10px * var(--ui-scale, 1));
  }
  :root .toast {
    font-size: calc(12px * var(--ui-scale, 1));
  }
}
.message-row .message-text,
.settings-preview .message-text {
  font-size: var(--chat-font, 14px);
}
.message-row .message-author,
.message-row .message-quote {
  font-size: calc(var(--chat-font, 14px) * 0.8);
}
.message-row .message-meta {
  font-size: calc(var(--chat-font, 14px) * 0.65);
}
.settings-slider {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 14px;
  font-weight: 500;
}
.settings-slider-head {
  display: flex;
  justify-content: space-between;
}
.settings-slider-value {
  color: var(--blue);
}
.settings-slider input {
  width: 100%;
  accent-color: var(--blue);
}
/* A slider is not a text field: drop the field frame and fill it inherits from `label > input`. */
:root label.settings-slider > input[type='range'] {
  --track: #d5dde3;
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
:root:not([data-theme='light']) label.settings-slider > input[type='range'] {
  --track: #2f3650;
}
/* Own track and thumb: the browser's default track turns black next to a light accent colour. */
.settings-slider input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--blue) var(--fill, 0%),
    var(--track) var(--fill, 0%)
  );
}
.settings-slider input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--blue);
}
.settings-slider input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--track);
}
.settings-slider input[type='range']::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--blue);
}
.settings-slider input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
}
.settings-preview {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  background: var(--wall);
  margin-bottom: 12px;
}
.settings-preview .message-bubble {
  align-self: flex-start;
  min-width: 0;
}
.settings-preview .own-preview {
  align-self: flex-end;
  background: var(--out);
}
.bubble-color-row, .bubble-color-field {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bubble-color-row {
  padding: 6px 0;
  justify-content: space-between;
}
.bubble-color-field {
  min-width: 0;
}
.bubble-color-field input[type='color'] {
  width: 40px;
  height: 32px;
  flex: none;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}
.bubble-color-row .settings-reset {
  flex: none;
  padding: 4px 0;
}
.settings-reset {
  color: var(--blue);
  font-size: 13px;
  padding: 4px 0 8px;
}
@media (max-width: 700px) {
  /* iOS zooms into inputs under 16px; keep the composer at 16px whatever the scale. */
  :root .composer textarea {
    font-size: max(16px, calc(16px * var(--ui-scale, 1)));
  }
}

/* Очередь на ресурс (принтер): плашка над списком чатов и окно. */
:root {
  --res-free: #2fb57c;
  --res-busy: #e5484d;
}
.resource-bar {
  padding: 8px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
@media (max-width: 700px) {
  .resource-bar {
    padding-inline: 12px;
  }
}
.resource-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  text-align: left;
  background: var(--panel-2, #f1f5f8);
  border: 1px solid transparent;
}
.resource-row:hover {
  background: var(--hover, #e8eef3);
}
.resource-row.free {
  border-color: color-mix(in srgb, var(--res-free) 45%, transparent);
}
.resource-row.busy {
  border-color: color-mix(in srgb, var(--res-busy) 45%, transparent);
}
.resource-row > svg {
  width: 22px;
  height: 22px;
  color: var(--soft, #7d8b97);
}
.resource-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
.resource-text strong {
  font-size: 13px;
  font-weight: 600;
}
.resource-text span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.resource-mine {
  font-size: 11px;
  color: var(--blue);
  font-weight: 600;
}
.resource-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--res-free);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--res-free) 22%, transparent);
}
.busy .resource-dot {
  background: var(--res-busy);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--res-busy) 22%, transparent);
}
.resource-status {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  background: var(--panel-2, #f1f5f8);
  margin-bottom: 14px;
}
.resource-status .resource-dot {
  width: 14px;
  height: 14px;
}
.resource-status div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.resource-status strong {
  font-size: 17px;
}
.resource-status span:not(.resource-dot) {
  font-size: 12px;
  color: var(--muted);
}
.resource-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}
.resource-actions button {
  width: 100%;
}
.resource-queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.resource-queue-item span {
  flex: 1;
}
.resource-queue-item small {
  color: var(--res-free);
  font-size: 11px;
}
.resource-queue-item .icon-button {
  width: 30px;
  height: 30px;
}
.resource-queue-item .icon-button svg {
  width: 16px;
  height: 16px;
}

/* Профиль пользователя: фон, аватар поверх края фона, имя и действия. */
.profile-modal #modal-content {
  padding-top: 0;
}
.profile-card {
  display: grid;
  gap: 14px;
}
.profile-identity,
.profile-about {
  min-width: 0;
  border-radius: 14px;
  background: var(--tg-card);
}
.profile-cover {
  position: relative;
  aspect-ratio: 3 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, #24306a, #4d2763 60%, #1d1f2c);
}
.profile-cover > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.profile-identity > .profile-cover {
  aspect-ratio: 2.5 / 1;
  border-radius: 14px 14px 0 0;
}
.profile-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 0 14px 12px;
  margin-top: -25px;
  position: relative;
}
.avatar.profile-avatar {
  width: 76px;
  height: 76px;
  font-size: 28px;
  border: 3px solid var(--tg-card);
  flex-shrink: 0;
}
.profile-names {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  /* Starts just below the cover; only the avatar overlaps its edge. */
  margin-top: 32px;
}
.profile-name {
  margin: 0;
  font-size: calc(20px * var(--ui-scale, 1));
  font-weight: 650;
  overflow-wrap: anywhere;
}
.profile-username {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 0;
  color: var(--tg-link);
  font-size: calc(14px * var(--ui-scale, 1));
  overflow-wrap: anywhere;
}
button.profile-username {
  min-height: 44px;
  text-align: left;
  background: transparent;
}
button.profile-username:hover {
  color: var(--tg-accent);
}
.profile-username svg {
  flex: none;
  width: 15px;
  height: 15px;
}
.profile-details {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.profile-role {
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--tg-hover);
  color: var(--tg-hint);
  font-size: calc(12px * var(--ui-scale, 1));
}
.profile-status {
  margin: 0;
  padding: 8px 12px 9px;
  border-top: 1px solid var(--tg-sep);
  color: var(--tg-text);
  font-size: calc(14px * var(--ui-scale, 1));
  overflow-wrap: anywhere;
}
.profile-presence {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.profile-presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint, #a0aab2);
}
.profile-presence.online .profile-presence-dot {
  background: #2fb57c;
}
.profile-about {
  padding: 12px 14px;
}
.profile-group-title {
  margin: 0 0 6px;
  color: var(--tg-hint);
  font-size: calc(13px * var(--ui-scale, 1));
  font-weight: 600;
}
.profile-about p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.profile-admin {
  padding-top: 10px;
  border-top: 1px solid var(--tg-sep);
}
.profile-actions {
  display: grid;
  gap: 10px;
}
.profile-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.profile-actions button svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.profile-actions button,
.profile-admin button {
  width: 100%;
}
.profile-photo-actions.row {
  flex-direction: row;
  align-items: center;
}
.profile-bio {
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
  line-height: 1.5;
}
.member-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0;
}
.member-link > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.clickable {
  cursor: pointer;
}

/* Ссылки, упоминания и предпросмотр ссылок в сообщениях. */
.message-link {
  color: var(--blue);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.message-link:hover {
  text-decoration: underline;
}
.mention {
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
}
.mention.me {
  background: color-mix(in srgb, var(--blue) 22%, transparent);
  border-radius: 5px;
  padding: 0 3px;
}
.link-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--blue);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--blue) 9%, transparent);
  color: inherit;
  text-decoration: none;
  max-width: 420px;
}
.link-preview-image img {
  display: block;
  width: 100%;
  max-height: 170px;
  object-fit: cover;
  border-radius: 6px;
}
.link-preview-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.link-preview-site {
  color: var(--blue);
  font-size: calc(var(--chat-font, 14px) * 0.8);
  font-weight: 600;
}
.link-preview-text strong {
  font-size: calc(var(--chat-font, 14px) * 0.95);
}
.link-preview-desc {
  font-size: calc(var(--chat-font, 14px) * 0.85);
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Подсказка @имя над полем ввода. */
.mention-popup {
  max-width: 920px;
  margin: 0 auto 8px;
  padding: 6px;
  border-radius: 12px;
  background: var(--panel, #fff);
  border: 1px solid var(--line);
  box-shadow: 0 8px 30px #00000033;
  display: flex;
  flex-direction: column;
}
.mention-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  text-align: left;
}
.mention-option.active,
.mention-option:hover {
  background: var(--hover, #f1f6fa);
}
.mention-option > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mention-option small {
  color: var(--muted);
  font-size: 11px;
}

/* Без звука, упоминания и каналы в списке чатов. */
.chat-muted {
  display: inline-flex;
  color: var(--faint, #9aa6af);
}
.chat-muted svg {
  width: 14px;
  height: 14px;
}
.badge.muted {
  background: var(--faint, #a0aab2);
}
.badge.mention-badge {
  margin-right: 4px;
}
.chat-row.active .badge.muted {
  background: #ffffffaa;
}
.compose-area.read-only .composer,
.compose-area.read-only .reply-preview,
.compose-area.read-only .attachment-preview {
  display: none !important;
}
.channel-note {
  max-width: 920px;
  margin: 0 auto 8px;
  padding: 12px 14px;
  border-radius: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel-2, #f1f5f8);
}
