/* ================================
   Auth / Registration Styles
   ================================ */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  box-sizing: border-box;
  background: var(--bg-app, #0b1220);
  backdrop-filter: blur(20px);
}

.auth-overlay[hidden] {
  display: none !important;
}

.auth-container {
  width: min(420px, 100%);
  max-width: 100%;
  box-sizing: border-box;
  max-height: min(calc(100dvh - 24px), 900px);
  margin: auto 0;
  padding: 28px 24px 32px;
  overflow-y: auto;
  background: var(--panel-bg, #121a2a);
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  animation: authSlideIn 0.4s ease;
}

@media (min-width: 480px) {
  .auth-container {
    padding: 40px 32px;
    margin: auto;
  }

  .auth-overlay {
    align-items: center;
  }
}

@keyframes authSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  margin-bottom: 16px;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  margin: 0 0 8px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--text-secondary, #94a3b8);
  margin: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-form[hidden] {
  display: none !important;
}

.auth-step-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
  margin: 0 0 8px;
  text-align: center;
}

.auth-step-hint {
  font-size: 14px;
  color: var(--text-secondary, #94a3b8);
  margin: 0 0 8px;
  text-align: center;
  line-height: 1.5;
}

.auth-spam-notice {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary, #94a3b8);
  margin: 0;
  padding: 12px 14px;
  text-align: left;
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.28);
  box-sizing: border-box;
}

.auth-spam-notice--compact {
  margin-top: -8px;
}

.auth-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.auth-input {
  height: 52px;
  padding: 0 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary, #f1f5f9);
  background: var(--input-bg, #0b1220);
  border: 1px solid var(--input-border, rgba(148,163,184,0.15));
  border-radius: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input:focus {
  border-color: var(--accent, #34d399);
  box-shadow: 0 0 0 3px rgba(52,211,153,0.15);
}

.auth-input::placeholder {
  color: var(--text-tertiary, #64748b);
}

/* Phone Input */
.auth-phone-input {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  background: var(--input-bg, #0b1220);
  border: 1px solid var(--input-border, rgba(148,163,184,0.15));
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-phone-input:focus-within {
  border-color: var(--accent, #34d399);
  box-shadow: 0 0 0 3px rgba(52,211,153,0.15);
}

.auth-country-code {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent, #34d399);
  user-select: none;
}

.auth-phone-input .auth-input {
  flex: 1;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

/* Code Input */
.auth-code-inputs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 8px 0;
}

.auth-code-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
  background: var(--input-bg, #0b1220);
  border: 2px solid var(--input-border, rgba(148,163,184,0.15));
  border-radius: 12px;
  outline: none;
  transition: all 0.2s;
}

.auth-code-digit:focus {
  border-color: var(--accent, #34d399);
  box-shadow: 0 0 0 4px rgba(52,211,153,0.15);
  transform: scale(1.05);
}

.auth-code-digit.filled {
  border-color: var(--accent, #34d399);
  background: rgba(52,211,153,0.1);
}

/* Avatar Upload */
.auth-avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
}

.auth-avatar-preview {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--input-bg, #0b1220);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  border: 3px dashed var(--input-border, rgba(148,163,184,0.3));
  transition: all 0.2s;
}

.auth-avatar-preview:hover {
  border-color: var(--accent, #34d399);
  background: rgba(52,211,153,0.05);
}

.auth-avatar-preview.has-image {
  border-style: solid;
  border-color: var(--accent, #34d399);
}

.auth-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-avatar-placeholder {
  font-size: 40px;
  opacity: 0.6;
}

.auth-avatar-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 28px;
}

.auth-avatar-preview:hover .auth-avatar-overlay {
  opacity: 1;
}

.auth-avatar-preview.has-image .auth-avatar-overlay {
  opacity: 0;
}

.auth-avatar-preview.has-image:hover .auth-avatar-overlay {
  opacity: 1;
}

/* Tag Input */
.auth-tag-input {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 16px;
  background: var(--input-bg, #0b1220);
  border: 1px solid var(--input-border, rgba(148,163,184,0.15));
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-tag-input:focus-within {
  border-color: var(--accent, #34d399);
  box-shadow: 0 0 0 3px rgba(52,211,153,0.15);
}

.auth-tag-prefix {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent, #34d399);
  user-select: none;
}

.auth-tag-input .auth-input {
  flex: 1;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.auth-hint {
  font-size: 12px;
  color: var(--text-tertiary, #64748b);
  margin-top: 4px;
}

/* Buttons */
.auth-btn {
  height: 52px;
  padding: 0 24px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn--primary {
  background: var(--accent, #34d399);
  color: #0b1220;
}

.auth-btn--primary:hover {
  background: #2bc88a;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(52,211,153,0.3);
}

.auth-btn--primary:active {
  transform: translateY(0);
}

.auth-btn--secondary {
  background: transparent;
  color: var(--text-secondary, #94a3b8);
  border: 1px solid var(--input-border, rgba(148,163,184,0.2));
}

.auth-btn--secondary:hover {
  background: rgba(148,163,184,0.1);
  color: var(--text-primary, #f1f5f9);
}

.auth-link {
  font-size: 14px;
  color: var(--accent, #34d399);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}

.auth-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* Resend timer */
.auth-resend {
  text-align: center;
  font-size: 14px;
  color: var(--text-tertiary, #64748b);
  min-height: 24px;
}

#auth-resend-btn[hidden] {
  display: none !important;
}

/* Light theme adjustments */
html[data-app-theme="light"] .auth-overlay {
  background: #f8fafc;
}

html[data-app-theme="light"] .auth-container {
  background: #fff;
  box-shadow: 0 25px 80px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,0,0,0.05);
}

html[data-app-theme="light"] .auth-title,
html[data-app-theme="light"] .auth-step-title {
  color: #0f172a;
}

html[data-app-theme="light"] .auth-subtitle,
html[data-app-theme="light"] .auth-step-hint {
  color: #64748b;
}

html[data-app-theme="light"] .auth-spam-notice {
  color: #713f12;
  background: rgba(251, 191, 36, 0.16);
  border-color: rgba(180, 83, 9, 0.28);
}

html[data-app-theme="light"] .auth-input,
html[data-app-theme="light"] .auth-phone-input,
html[data-app-theme="light"] .auth-tag-input {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #0f172a;
}

html[data-app-theme="light"] .auth-input::placeholder {
  color: #94a3b8;
}

html[data-app-theme="light"] .auth-code-digit {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #0f172a;
}

html[data-app-theme="light"] .auth-avatar-preview {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

html[data-app-theme="light"] .auth-label {
  color: #64748b;
}

html[data-app-theme="light"] .auth-hint {
  color: #94a3b8;
}

html[data-app-theme="light"] .auth-btn--secondary {
  border-color: #e2e8f0;
  color: #64748b;
}

html[data-app-theme="light"] .auth-resend {
  color: #94a3b8;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .auth-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
    padding: 32px 24px;
  }
  
  .auth-code-digit {
    width: 44px;
    height: 52px;
    font-size: 22px;
  }
  
  .auth-code-inputs {
    gap: 8px;
  }
}
/**
 * Nodum — основной UI мессенджера (сетка, сайдбар, диалог, композер).
 * Восстановлено: ранее эти правила были в styles.css до добавления блока регистрации.
 */

:root {
  --bg-app: #0b1220;
  --panel-bg: #121a2a;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --accent: #34d399;
  --border-subtle: rgba(148, 163, 184, 0.12);
  --sidebar-w: min(360px, 100%);
  --header-h: 56px;
  --composer-h: auto;
  /* Оценка высоты композера: max-height модалки как у ленты сообщений в диалоге */
  --profile-modal-composer-est: 72px;
  --profile-modal-backdrop-pad: 40px;
  /* Список чатов в сайдбаре — как Telegram: имя / превью / время */
  --chat-title-font-size: 0.9375rem;
  --chat-title-font-weight: 600;
  --chat-preview-font-size: 0.8125rem;
  --chat-preview-color: #5288c1;
  --chat-time-font-size: 0.75rem;
  --chat-time-color: #707579;
  /* Пузыри: ориентир — Telegram dark (входящие серо-синие, исходящие зеленоватые) */
  --msg-in-bg: #2b333e;
  --msg-out-bg: #3d8f6a;
  --msg-fg: #f1f5f9;
  --msg-time-fg: rgba(148, 163, 184, 0.72);
  /* Галочки доставки: 1✓ и 2✓ — бледно-серый; прочитано — Tiffany (градиент) */
  --msg-receipt-muted: #d8e4ef;
  --msg-receipt-read-a: #9ef0e8;
  --msg-receipt-read-b: #40d9ce;
  --msg-receipt-read-c: #1db5a6;
  /* Тема чата (chatTheme.js → documentElement); до init — как статическая палитра */
  --app-gradient: linear-gradient(
    165deg,
    hsl(215, 12%, 9%) 0%,
    hsl(220, 10%, 8%) 50%,
    hsl(212, 11%, 9%) 100%
  );
  --theme-sidebar-bg: var(--panel-bg);
  --theme-dialog-bg: var(--bg-app);
  --theme-feed-bg: var(--bg-app);
  --theme-search-bg: rgba(11, 18, 32, 0.6);
  --theme-composer-bg: var(--panel-bg);
  --theme-bubble-in: var(--msg-in-bg);
  --theme-bubble-out: var(--msg-out-bg);
  --theme-border-sidebar: var(--border-subtle);
  --theme-border-subtle: rgba(148, 163, 184, 0.12);
  --theme-accent-dot: var(--accent);
}

html[data-app-theme="light"] {
  --bg-app: #f1f5f9;
  --panel-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --border-subtle: rgba(15, 23, 42, 0.08);
  --msg-in-bg: #e8edf2;
  --msg-out-bg: #b8e0c8;
  --msg-fg: #0f172a;
  --msg-time-fg: rgba(71, 85, 105, 0.65);
  /* Те же роли, но контрастнее на светлом пузыре */
  --msg-receipt-muted: #5a6b7c;
  --msg-receipt-read-a: #5eead4;
  --msg-receipt-read-b: #14b8a6;
  --msg-receipt-read-c: #0d9488;
  --chat-preview-color: #2481cc;
  --chat-time-color: #8e9398;
  --app-gradient: linear-gradient(
    165deg,
    hsl(220, 14%, 97%) 0%,
    hsl(220, 10%, 98.5%) 50%,
    hsl(220, 12%, 97%) 100%
  );
  --theme-sidebar-bg: #ffffff;
  --theme-dialog-bg: #f1f5f9;
  --theme-feed-bg: #f8fafc;
  --theme-search-bg: #f1f5f9;
  --theme-composer-bg: #ffffff;
  --theme-bubble-in: var(--msg-in-bg);
  --theme-bubble-out: var(--msg-out-bg);
  --theme-border-sidebar: rgba(15, 23, 42, 0.1);
  --theme-border-subtle: rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  height: -webkit-fill-available;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
  /* iOS Safari: не раздувать шрифт на узком экране (ломает переносы и ширину). */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html *,
html *::before,
html *::after {
  box-sizing: inherit;
}

html,
body {
  margin: 0;
  height: 100%;
}

@media (max-width: 904px) {
  html {
    overflow: hidden;
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
    overscroll-behavior: none;
  }
}

body.nodum-app {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--app-gradient, var(--bg-app));
  color: var(--text-primary);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overflow-x: clip;
  overscroll-behavior: none;
  min-height: 100%;
  max-height: 100%;
  width: 100%;
  max-width: 100%;
  position: relative;
}

#root {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: clip;
  background: transparent;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

html.vv-polyfill.vv-pinned body.nodum-app {
  min-height: var(--app-vvh, 100%);
  max-height: var(--app-vvh, 100%);
}

html.vv-polyfill.vv-pinned #root {
  height: var(--app-vvh, 100dvh);
  min-height: var(--app-vvh, 100dvh);
  max-height: var(--app-vvh, 100dvh);
}

/*
 * iOS Safari / PWA «на экран домой»: при фокусе в поле ввода visualViewport смещается
 * (offsetTop) и сужается (height). Привязываем #root к видимому прямоугольнику — иначе
 * системная панель над клавиатурой наезжает на композер.
 */
/* Порог 904/905px — см. apps/web/src/layoutBreakpoint.ts */
@media (max-width: 904px) {
  /*
   * Раньше max-height: none на body давал рост документа выше видимой области — при клавиатуре
   * скроллился весь экран. Держим body в рамках visualViewport / 100dvh.
   */
  body.nodum-app {
    overflow: hidden;
    overscroll-behavior: none;
    max-height: 100dvh;
    max-height: 100svh;
  }

  html.vv-polyfill.vv-pinned body.nodum-app {
    min-height: var(--app-vvh, 100dvh);
    max-height: var(--app-vvh, 100dvh);
    height: var(--app-vvh, 100dvh);
  }

  /*
   * Не используем visualViewport.offsetLeft для позиции: на iOS при скролле/клавиатуре
   * он даёт ненулевой left → весь UI съезжает вправо и появляется «белая полоса» / обрез.
   * Только вертикаль: top + height по --app-vvh.
   */
  html.vv-polyfill.vv-pinned #root {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    z-index: 0;
    overflow-x: clip;
  }
}

/* --- Оболочка: баннер + main в одной колонке на всю высоту --- */
.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  overflow-x: hidden;
  background: transparent;
}

.sync-error-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(251, 191, 36, 0.12);
  color: var(--text-primary);
  font-size: 0.875rem;
}

html[data-app-theme="light"] .sync-error-banner {
  background: rgba(245, 158, 11, 0.16);
}

.sync-error-banner__text {
  min-width: 0;
}

.sync-error-banner__retry {
  flex-shrink: 0;
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-primary);
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.sync-error-banner__retry:hover {
  background: rgba(148, 163, 184, 0.2);
}

/* --- Сетка: мобильный 1 колонка; десктоп — сайдбар | ресайзер | диалог --- */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  flex: 1;
  min-height: 0;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  overflow-x: hidden;
  background: transparent;
}

@media (min-width: 905px) {
  .layout {
    grid-template-columns: var(--sidebar-w) 6px minmax(0, 1fr);
  }

  /* iOS Safari: шрифт <16px в input/contenteditable вызывает автозум «к центру». */
  .composer-input,
  .search,
  .search.search--infield {
    font-size: 16px;
  }

  /* Узкий левый rail (как в Telegram): иконки разделов */
  .layout--with-rail {
    grid-template-columns: var(--rail-w, 56px) var(--sidebar-w) 6px minmax(0, 1fr);
  }
}

/* --- Левое боковое меню (разделы) --- */
.app-rail {
  display: none;
}

@media (min-width: 905px) {
  .app-rail {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 12px 6px;
    width: var(--rail-w, 56px);
    box-sizing: border-box;
    flex-shrink: 0;
    min-height: 0;
    background: color-mix(
      in srgb,
      var(--theme-sidebar-bg, var(--panel-bg)) 92%,
      transparent
    );
    border-right: 1px solid var(--theme-border-sidebar, var(--border-subtle));
  }
}

.app-rail__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 48px;
  padding: 8px 4px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  transition:
    background 0.15s,
    color 0.15s;
}

.app-rail__btn:hover {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-primary);
}

.app-rail__btn--active {
  background: rgba(52, 211, 153, 0.14);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.25);
}

.app-rail__icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-rail__badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--accent, #34d399);
  color: #042018;
  font-size: 0.625rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  letter-spacing: -0.02em;
  box-shadow: 0 0 0 2px var(--theme-sidebar-bg, var(--panel-bg));
}

.app-rail__icon {
  font-size: 1.35rem;
  line-height: 1;
}

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

/* Мобильный доступ к разделам rail (узкий экран): кнопка в шапке сайдбара */
.sidebar-head-leading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.sidebar-head-leading .brand-lockup {
  min-width: 0;
}

.btn-mobile-rail {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.btn-mobile-rail:hover {
  background: rgba(148, 163, 184, 0.16);
}

.btn-mobile-rail:focus-visible {
  outline: 2px solid var(--accent, #34d399);
  outline-offset: 2px;
}

.btn-mobile-rail__icon {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

/* Выезжающая панель разделов (аналог левого rail) */
.mobile-rail-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: hidden;
}

.mobile-rail-dialog::backdrop {
  background: rgba(4, 8, 18, 0.52);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

html[data-app-theme="light"] .mobile-rail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.mobile-rail-dialog__panel {
  box-sizing: border-box;
  width: min(320px, calc(100% - 40px));
  height: 100%;
  max-height: 100dvh;
  margin: 0 auto 0 0;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  background: var(--theme-sidebar-bg, var(--panel-bg));
  border-right: 1px solid var(--theme-border-sidebar, var(--border-subtle));
  border-radius: 0 20px 20px 0;
  box-shadow: 12px 0 48px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.mobile-rail-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.mobile-rail-dialog__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.mobile-rail-dialog__close {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mobile-rail-dialog__close:hover {
  color: var(--text-primary);
  background: rgba(148, 163, 184, 0.16);
}

.mobile-rail-dialog__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.mobile-rail-dialog__item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}

.mobile-rail-dialog__item:hover {
  background: rgba(148, 163, 184, 0.1);
}

.mobile-rail-dialog__item--active {
  background: rgba(52, 211, 153, 0.14);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.25);
}

.mobile-rail-dialog__item-icon {
  flex-shrink: 0;
  font-size: 1.35rem;
  line-height: 1;
  width: 2rem;
  text-align: center;
}

.mobile-rail-dialog__item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.mobile-rail-dialog__item-label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.mobile-rail-dialog__item-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.mobile-rail-dialog__item--active .mobile-rail-dialog__item-hint {
  color: color-mix(in srgb, var(--accent) 75%, var(--text-secondary));
}

.mobile-rail-dialog__badge {
  flex-shrink: 0;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--accent, #34d399);
  color: #042018;
  font-size: 0.6875rem;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  letter-spacing: -0.02em;
}

/* Полоса папок под поиском */
.folder-rail-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 4px;
  border-bottom: 1px solid var(--theme-border-sidebar, var(--border-subtle));
  flex-shrink: 0;
}

.folder-rail-bar__chip {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-secondary);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-rail-bar__chip:hover {
  color: var(--text-primary);
  background: rgba(148, 163, 184, 0.14);
}

.folder-rail-bar__chip--active {
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--accent);
  background: rgba(52, 211, 153, 0.1);
}

.folder-rail-bar__add {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px dashed var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.folder-rail-bar__add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rail-list-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Контекстное меню чата (ПКМ / долгое нажатие) */
.chat-context-menu {
  min-width: min(268px, calc(100vw - 24px));
  max-width: min(92vw, 320px);
  padding: 6px 0;
  border-radius: 12px;
  background: rgba(30, 27, 24, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 20px 50px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

html[data-app-theme="light"] .chat-context-menu {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.06),
    0 16px 40px rgba(15, 23, 42, 0.14);
}

/* Без dvi (старый WebView / часть Samsung Internet) остаётся vw выше. */
@supports (width: 1dvi) {
  .chat-context-menu {
    min-width: min(268px, calc(100dvi - 24px));
    max-width: min(92dvi, 320px);
  }
}

.chat-context-menu__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 12px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

html[data-app-theme="light"] .chat-context-menu__item {
  color: var(--text-primary);
}

.chat-context-menu__item:hover,
.chat-context-menu__item:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

html[data-app-theme="light"] .chat-context-menu__item:hover,
html[data-app-theme="light"] .chat-context-menu__item:focus-visible {
  background: rgba(15, 23, 42, 0.06);
}

.chat-context-menu__item--danger {
  color: #f87171;
}

html[data-app-theme="light"] .chat-context-menu__item--danger {
  color: #dc2626;
}

.chat-context-menu__item--danger:hover,
.chat-context-menu__item--danger:focus-visible {
  background: rgba(248, 113, 113, 0.12);
}

.chat-context-menu__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.75);
}

html[data-app-theme="light"] .chat-context-menu__icon {
  color: var(--text-secondary);
}

.chat-context-menu__item--danger .chat-context-menu__icon {
  color: inherit;
}

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

.chat-context-menu__chevron {
  flex-shrink: 0;
  opacity: 0.55;
  display: flex;
}

.chat-context-menu__sep {
  height: 1px;
  margin: 4px 12px;
  background: rgba(255, 255, 255, 0.08);
}

html[data-app-theme="light"] .chat-context-menu__sep {
  background: rgba(15, 23, 42, 0.08);
}

.chat-context-menu__folder-block {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin: 4px 0;
  padding: 2px 0;
}

html[data-app-theme="light"] .chat-context-menu__folder-block {
  border-color: rgba(15, 23, 42, 0.06);
}

.chat-context-menu__item--folder-trigger.chat-context-menu__item--open {
  background: rgba(255, 255, 255, 0.05);
}

.chat-context-menu__sublist {
  padding: 2px 0 6px;
  max-height: 200px;
  overflow-y: auto;
}

.chat-context-menu__subitem {
  display: block;
  width: calc(100% - 16px);
  margin: 0 8px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}

html[data-app-theme="light"] .chat-context-menu__subitem {
  color: var(--text-primary);
}

.chat-context-menu__subitem:hover,
.chat-context-menu__subitem:focus-visible {
  background: rgba(52, 211, 153, 0.12);
  outline: none;
}

.chat-context-menu__subitem--active {
  color: var(--accent, #34d399);
  font-weight: 600;
}

.chat-context-menu__subitem--accent {
  color: var(--accent, #34d399);
  font-weight: 500;
}

/* --- Sidebar --- */
.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--theme-border-sidebar, var(--border-subtle));
  background: var(--theme-sidebar-bg, var(--panel-bg));
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  min-width: 0;
}

.chat-list {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

/* Pull-to-refresh: индикатор над списком чатов (моб.) */
.chat-list-ptr-track {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  transition: height 0.15s ease-out;
}

.chat-list-ptr-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text-secondary) 45%, transparent);
  transform: scale(0.85);
  transition:
    transform 0.12s ease,
    background 0.12s ease;
}

.chat-list-ptr-dot--armed {
  transform: scale(1.15);
  background: var(--accent, #34d399);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #34d399) 25%, transparent);
  animation: chatListPtrPulse 0.85s ease-in-out infinite;
}

@keyframes chatListPtrPulse {
  50% {
    opacity: 0.65;
  }
}

.friend-incoming-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--theme-border-subtle, var(--border-subtle));
  background: rgba(52, 211, 153, 0.06);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.friend-incoming-block__title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent, #34d399);
  margin: 0 0 12px;
  text-align: center;
  width: 100%;
  max-width: 420px;
}

.friend-incoming-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 420px;
  min-width: 0;
}

.friend-incoming-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 14px;
  border-radius: 14px;
  border: 1px solid var(--theme-border-subtle, var(--border-subtle));
  background: rgba(15, 23, 42, 0.45);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

html[data-app-theme="light"] .friend-incoming-row {
  background: rgba(241, 245, 249, 0.9);
}

.friend-incoming-row__main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.friend-incoming-row__avatar {
  width: 40px;
  height: 40px;
  font-size: 1rem;
  flex-shrink: 0;
}

.friend-incoming-row__text {
  min-width: 0;
  flex: 1;
  text-align: center;
  max-width: 100%;
}

.friend-incoming-row__name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-incoming-row__login {
  font-size: 0.8125rem;
  color: var(--accent, #34d399);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-incoming-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

.btn-friend-incoming {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition:
    background 0.15s ease,
    opacity 0.15s ease;
  box-sizing: border-box;
  min-width: 0;
  flex: 0 1 auto;
}

.btn-friend-incoming:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-friend-incoming--accept {
  background: rgba(52, 211, 153, 0.18);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--accent, #34d399);
}

.btn-friend-incoming--accept:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.28);
}

.btn-friend-incoming--decline {
  background: transparent;
  border-color: var(--theme-border-subtle, var(--border-subtle));
  color: var(--text-secondary, #94a3b8);
}

.btn-friend-incoming--decline:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.1);
}

.friend-incoming-block--outgoing {
  background: rgba(251, 191, 36, 0.07);
  border-bottom-color: rgba(251, 191, 36, 0.12);
}

.friend-incoming-block__title--outgoing {
  color: #fbbf24;
}

.friend-incoming-row__hint {
  font-size: 0.75rem;
  color: var(--text-tertiary, #64748b);
  margin-top: 4px;
}

.friend-incoming-row__actions--single {
  justify-content: center;
}

.btn-friend-incoming--cancel {
  background: transparent;
  border-color: rgba(251, 191, 36, 0.45);
  color: #fbbf24;
  max-width: 100%;
}

.btn-friend-incoming--cancel:hover:not(:disabled) {
  background: rgba(251, 191, 36, 0.12);
}

html[data-app-theme="light"] .friend-incoming-block--outgoing {
  background: rgba(254, 243, 199, 0.45);
}

/* Вертикальный разделитель ширины списка чатов */
.layout-resizer {
  display: none;
  width: 6px;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  flex-shrink: 0;
  background: transparent;
  position: relative;
  align-self: stretch;
}

@media (min-width: 905px) {
  .layout-resizer {
    display: block;
  }
}

.layout-resizer::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--theme-border-sidebar, var(--border-subtle));
  opacity: 0.7;
  border-radius: 1px;
}

.layout-resizer:hover::after,
.layout-resizer:focus-visible::after {
  opacity: 1;
  background: var(--accent);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
  min-width: 0;
  flex-wrap: nowrap;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.logo-mark {
  flex-shrink: 0;
}

.brand-wordmark-slot {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-wordmark {
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text-primary);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.wordmark {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sidebar-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex: 0 0 auto;
}

/* Ступени сжатия сайдбара (data-sidebar-tier на aside) */
.sidebar[data-sidebar-tier="1"] .btn-app-theme,
.sidebar[data-sidebar-tier="2"] .btn-app-theme,
.sidebar[data-sidebar-tier="3"] .btn-app-theme,
.sidebar[data-sidebar-tier="4"] .btn-app-theme {
  display: none;
}

.sidebar[data-sidebar-tier="2"] .brand-wordmark-slot,
.sidebar[data-sidebar-tier="3"] .brand-wordmark-slot,
.sidebar[data-sidebar-tier="4"] .brand-wordmark-slot {
  display: none;
}

/* Tier 3–4: колонка — лого, лупа, аватар входа; список — только аватары (класс .sidebar--icons-only) */
.sidebar[data-sidebar-tier="3"] .sidebar-head,
.sidebar[data-sidebar-tier="4"] .sidebar-head {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 6px 12px;
}

.sidebar[data-sidebar-tier="3"] .brand-lockup,
.sidebar[data-sidebar-tier="4"] .brand-lockup {
  width: 100%;
  justify-content: center;
  flex: none;
}

.sidebar[data-sidebar-tier="3"] .logo-mark,
.sidebar[data-sidebar-tier="4"] .logo-mark {
  display: block;
}

.sidebar[data-sidebar-tier="3"] .sidebar-head-actions,
.sidebar[data-sidebar-tier="4"] .sidebar-head-actions {
  width: 100%;
  justify-content: center;
}

/* Компактный аватар входа вместо длинной кнопки */
.btn-sidebar-user-avatar {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--theme-border-subtle, var(--border-subtle));
  background: rgba(148, 163, 184, 0.1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.btn-sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-sidebar-user-avatar--placeholder {
  color: var(--text-secondary);
}

/* Режим только аватаров в списке (tier ≥ 3, без обрезанного текста с «…») */
.sidebar.sidebar--icons-only .chat-item {
  justify-content: center;
  padding: 10px 8px;
  gap: 0;
}

.sidebar.sidebar--icons-only .chat-meta {
  display: none;
}

.sidebar.sidebar--icons-only .chat-item .avatar {
  margin: 0;
  width: 44px;
  height: 44px;
  font-size: 1.05rem;
}

.sidebar.sidebar--icons-only .chat-item.chat-item--unread .avatar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent, #34d399);
  border: 2px solid var(--theme-sidebar-bg, var(--panel-bg));
  box-sizing: border-box;
}

.sidebar.sidebar--icons-only .chat-item.active {
  border-left-width: 2px;
}

/* Входящие заявки: как чаты — по центру колонки, в узком режиме без вылезания за край */
.sidebar.sidebar--icons-only .friend-incoming-block {
  padding: 8px 4px 10px;
  align-items: center;
}

.sidebar.sidebar--icons-only .friend-incoming-block__title {
  font-size: 0.5625rem;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  padding: 0 4px;
  line-height: 1.25;
  max-width: 100%;
}

.sidebar.sidebar--icons-only .friend-incoming-list {
  max-width: 100%;
  gap: 8px;
}

.sidebar.sidebar--icons-only .friend-incoming-row {
  padding: 8px 4px 10px;
  gap: 8px;
  border-radius: 12px;
  border-left: none;
}

.sidebar.sidebar--icons-only .friend-incoming-row__main {
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.sidebar.sidebar--icons-only .friend-incoming-row__avatar {
  width: 44px;
  height: 44px;
  font-size: 1.05rem;
  margin: 0;
}

.sidebar.sidebar--icons-only .friend-incoming-row__text {
  width: 100%;
  max-width: 100%;
}

.sidebar.sidebar--icons-only .friend-incoming-row__name {
  font-size: 0.75rem;
}

.sidebar.sidebar--icons-only .friend-incoming-row__login {
  font-size: 0.6875rem;
}

.sidebar.sidebar--icons-only .friend-incoming-row__actions {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 6px;
  max-width: 100%;
}

.sidebar.sidebar--icons-only .btn-friend-incoming {
  width: 100%;
  max-width: 100%;
  flex: none;
  padding: 6px 8px;
  font-size: 0.6875rem;
}

.btn-app-theme,
.btn-node {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.875rem;
}

.btn-app-theme {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-node {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Тег @login в шапке — как на старом скрине */
.btn-node--login {
  color: var(--accent);
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.09);
  font-weight: 500;
}

.btn-node--login:hover {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.4);
}

.search-wrap {
  position: relative;
  padding: 12px 16px;
  min-width: 0;
}

/* Поле с лупой (та же иконка, что у кнопки в узком сайдбаре) */
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px 0 14px;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid var(--theme-border-subtle, var(--border-subtle));
  background: var(--theme-search-bg, rgba(11, 18, 32, 0.6));
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

html[data-app-theme="light"] .search-field {
  background: var(--theme-search-bg, #f1f5f9);
}

.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
}

.search-field__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary, #64748b);
}

.search-field__icon svg {
  width: 20px;
  height: 20px;
}

.search {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--theme-border-subtle, var(--border-subtle));
  background: var(--theme-search-bg, rgba(11, 18, 32, 0.6));
  color: var(--text-primary);
  font-size: 0.8125rem;
  outline: none;
}

.search.search--infield {
  flex: 1;
  min-width: 0;
  width: auto;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.search.search--infield:focus {
  border: none;
  box-shadow: none;
  outline: none;
}

html[data-app-theme="light"] .search {
  background: var(--theme-search-bg, #f1f5f9);
}

html[data-app-theme="light"] .search.search--infield {
  background: transparent;
}

.search::placeholder {
  color: var(--text-tertiary);
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
}

.search--popover {
  width: 100%;
}

/* Узкий сайдбар: кнопка поиска под логотипом */
.search-wrap--icon-only {
  display: flex;
  justify-content: center;
  width: 100%;
  flex-shrink: 0;
  padding: 0;
}

.btn-sidebar-search {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.18));
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.btn-sidebar-search:hover {
  color: var(--text-primary, #f1f5f9);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}

.btn-sidebar-search:focus-visible {
  outline: 2px solid var(--accent, #34d399);
  outline-offset: 2px;
}

.search-popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10054;
  background: rgba(4, 8, 18, 0.35);
}

.search-popover {
  position: fixed;
  z-index: 10055;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel-bg, #121a2a);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  max-height: min(70dvh, 420px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

html[data-app-theme="light"] .search-popover {
  background: #fff;
  box-shadow:
    0 24px 50px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(15, 23, 42, 0.08);
}

html[data-app-theme="light"] .search-popover-backdrop {
  background: rgba(15, 23, 42, 0.2);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel-bg, #121a2a);
  border-radius: 12px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 100;
  padding: 8px;
}

.search-popover .search-results {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  margin-top: 0;
  flex: 1;
  min-height: 0;
  max-height: min(52dvh, 320px);
  box-shadow: none;
}

.search-results[hidden] {
  display: none !important;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 12px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: inherit;
  background: transparent;
  transition: background 0.2s;
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.search-result-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(11, 18, 32, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.search-result-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-result-avatar span {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent, #34d399);
}

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

.search-result-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-username {
  font-size: 13px;
  color: var(--accent, #34d399);
  margin-top: 2px;
}

.search-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary, #94a3b8);
  font-size: 14px;
}

html[data-app-theme="light"] .search-results {
  background: #fff;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(0, 0, 0, 0.05);
}

html[data-app-theme="light"] .search-popover .search-results {
  box-shadow: none;
}

html[data-app-theme="light"] .search-result-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

html[data-app-theme="light"] .search-result-avatar {
  background: #f1f5f9;
}

html[data-app-theme="light"] .search-result-name {
  color: #0f172a;
}

html[data-app-theme="light"] .search-empty {
  color: #64748b;
}

/* FitWordsText: якорь для абсолютного measure, иначе строки чатов наезжают друг на друга */
.fit-words {
  min-width: 0;
  display: block;
  position: relative;
  overflow: hidden;
}

/* Chat list item (button или div[role="button"], без вложенных <button>) */
.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 12px 16px;
  cursor: pointer;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: background 0.15s;
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.chat-item--muted .chat-item-preview-line {
  opacity: 0.72;
}

.chat-item[role="button"]:focus {
  outline: none;
}

.chat-item[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.chat-item:hover {
  background: rgba(148, 163, 184, 0.06);
}

.chat-item.active {
  border-left-color: var(--accent);
  background: rgba(52, 211, 153, 0.08);
}

/* Закреплённый чат: значок по центру верхней границы строки */
.chat-item--pinned {
  padding-top: 15px;
}

.chat-item-pin-badge {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--theme-sidebar-bg, var(--panel-bg, #121a2a));
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: var(--accent, #34d399);
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.22);
}

.chat-item-pin-icon {
  flex-shrink: 0;
  color: inherit;
}

.chat-item.active .chat-item-pin-badge {
  border-color: rgba(52, 211, 153, 0.5);
}

html[data-app-theme="light"] .chat-item-pin-badge {
  background: var(--theme-sidebar-bg, #f8fafc);
  border-color: rgba(100, 116, 139, 0.35);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.sidebar.sidebar--icons-only .chat-item--pinned {
  padding-top: 13px;
}

.sidebar.sidebar--icons-only .chat-item-pin-badge {
  width: 20px;
  height: 20px;
  transform: translate(-50%, -42%);
}

.sidebar.sidebar--icons-only .chat-item-pin-icon {
  width: 13px;
  height: 13px;
}

.avatar {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.125rem;
  flex-shrink: 0;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  color: var(--accent);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar--assistant {
  background: linear-gradient(145deg, #1e3a5f, #0f172a);
}

.avatar-theme-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--theme-accent-dot, var(--accent));
  border: 2px solid var(--theme-sidebar-bg, var(--panel-bg));
}

/* Тема чата может задавать --theme-accent-dot не зелёным; для статуса «в сети» фиксируем цвет. */
.avatar-theme-dot--online {
  background: #22c55e;
}
.avatar-theme-dot--offline {
  background: #64748b;
}
.avatar--assistant .avatar-theme-dot {
  background: #22c55e;
}

.dialog-header-presence {
  font-size: 0.8125rem;
  color: var(--text-secondary, #94a3b8);
  margin: 4px 0 0;
  line-height: 1.3;
}

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

.chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.chat-item-title {
  min-width: 0;
  flex: 1;
  font-size: var(--chat-title-font-size);
  font-weight: var(--chat-title-font-weight);
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text-primary);
}

.chat-top-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding-top: 1px;
}

/*
 * Строка превью: текст слева на всю ширину, кружок непрочитанных — у правого края
 * (как в Telegram), а не сразу после текста.
 */
.chat-preview-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  width: 100%;
  margin-top: 3px;
}

.chat-preview-row .chat-item-preview-line {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
}

.chat-item-unread {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 6px;
  border-radius: 999px;
  background: #3390ec;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

html[data-app-theme="light"] .chat-item-unread {
  background: #3390ec;
  color: #fff;
}

.chat-item-time {
  font-size: var(--chat-time-font-size);
  font-weight: 400;
  line-height: 1.2;
  color: var(--chat-time-color);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chat-item-avatar-slot {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 0;
}

.chat-item-favorite-star {
  flex-shrink: 0;
  color: #facc15;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.4));
}

.chat-item-time-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 2px;
  flex-shrink: 0;
  min-width: 0;
}

.chat-item-muted-bell {
  flex-shrink: 0;
  color: var(--text-tertiary, #64748b);
  opacity: 0.95;
}

.delete-chat-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.52);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.delete-chat-dialog {
  width: min(400px, 100%);
  max-height: min(90dvh, 520px);
  overflow: auto;
  background: var(--panel-bg, #121a2a);
  color: var(--text-primary);
  border-radius: 18px;
  padding: 22px 20px 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.15));
}

.delete-chat-dialog__title {
  margin: 0 0 10px;
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.delete-chat-dialog__text {
  margin: 0 0 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-secondary, #94a3b8);
}

.delete-chat-dialog__text--warning {
  color: #fca5a5;
}

html[data-app-theme="light"] .delete-chat-dialog__text--warning {
  color: #b91c1c;
}

.delete-chat-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.delete-chat-dialog__btn {
  font: inherit;
  cursor: pointer;
  border-radius: 11px;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.25));
  background: rgba(52, 211, 153, 0.12);
  color: var(--accent, #34d399);
  padding: 9px 14px;
  font-size: 0.875rem;
  font-weight: 500;
}

.delete-chat-dialog__btn:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.2);
}

.delete-chat-dialog__btn--secondary {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-primary);
}

.delete-chat-dialog__btn--secondary:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.16);
}

.delete-chat-dialog__btn--danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.delete-chat-dialog__btn--danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.22);
}

.delete-chat-dialog__btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-item-preview-line,
.chat-meta > p {
  margin: 0;
  font-size: var(--chat-preview-font-size);
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--chat-preview-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Dialog --- */
.dialog {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  min-width: 0;
  overflow: hidden;
  background: var(--theme-dialog-bg, var(--bg-app));
}

.dialog-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
  flex-shrink: 0;
  padding: 8px 12px 8px 8px;
  border-bottom: 1px solid var(--theme-border-subtle, var(--border-subtle));
  background: var(--theme-dialog-bg, var(--panel-bg));
  /* Чуть отличаем шапку от ленты; пресеты чата задают --theme-dialog-bg */
  box-shadow: inset 0 -1px 0 rgba(148, 163, 184, 0.06);
  position: relative;
  z-index: 2;
}

.btn-icon {
  font: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: 10px;
}

.btn-icon:hover {
  background: rgba(148, 163, 184, 0.1);
}

.btn-back {
  display: none;
}

.dialog-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.dialog-header .avatar {
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

.dialog-header-text strong {
  display: block;
  font-size: 0.9375rem;
}

.dialog-header-text p {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.dialog-header-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.dialog-header-text--assistant .dialog-header-title-row strong {
  display: inline;
  font-size: 0.9375rem;
}

.dialog-header-assistant-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  color: var(--accent);
  border: 1px solid rgba(52, 211, 153, 0.28);
  flex-shrink: 0;
  line-height: 1.2;
}

html[data-app-theme="light"] .dialog-header-assistant-badge {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
}

.dialog-header-actions {
  margin-left: auto;
}

.btn-chat-preset {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--theme-border-subtle, var(--border-subtle));
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* --- Feed --- */
.feed-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  isolation: isolate;
  background: var(--theme-feed-bg, var(--bg-app));
}

/* Матовый «атмосферный» слой из chatTheme (--app-gradient), поверх фона ленты */
.feed-pane::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--app-gradient);
  opacity: 0.58;
  mix-blend-mode: soft-light;
}

/* Лёгкий «техно»-переход справа налево поверх темы чата */
.feed-pane::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    270deg,
    rgba(255, 255, 255, 0.055) 0%,
    transparent 42%,
    transparent 100%
  );
  opacity: 0.85;
}

html[data-app-theme="light"] .feed-pane::before {
  opacity: 0.38;
  mix-blend-mode: soft-light;
}

html[data-app-theme="light"] .feed-pane::after {
  background: linear-gradient(
    270deg,
    rgba(15, 23, 42, 0.06) 0%,
    transparent 45%,
    transparent 100%
  );
  opacity: 0.9;
}

.feed-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 32px 24px;
  text-align: center;
  color: var(--text-secondary);
  position: relative;
  z-index: 1;
}

.feed-empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.feed-empty-hint {
  font-size: 0.875rem;
  max-width: 280px;
}

.feed {
  list-style: none;
  margin: 0;
  padding: 12px 14px;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  z-index: 1;
}

/*
 * Строка сообщения на всю ширину ленты, иначе % max-width у пузыря считается от
 * узкого flex-элемента — все пузыри становятся «колонкой слева» и слишком узкими.
 */
.message {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  align-items: flex-start;
}

.message.message--out,
.message.self {
  align-items: flex-end;
}

.message-bubble {
  display: block;
  width: fit-content;
  max-width: min(78%, 520px);
  min-width: 0;
  box-sizing: border-box;
  overflow: visible;
}

/*
 * Как в Telegram: текст с отступом справа под полосу «галочки + время»;
 * мета position:absolute внизу справа (галочки слева от времени, узкий зазор).
 */
.message-line {
  display: block;
  padding: 8px 11px 7px 12px;
  border-radius: 16px;
  background: var(--theme-bubble-in, var(--msg-in-bg));
  color: var(--msg-fg);
  border: 1px solid var(--theme-border-subtle, rgba(148, 163, 184, 0.08));
  position: relative;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
  overflow: visible;
}

.message-text-row {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 1.15em;
}

/* Исходящие: шире под полосу «лоадер / галочки + время» */
.message.message--out .message-text-row--meta-wide .message-text {
  padding-right: 4.5rem;
}

.message.message--out .message-text-row:not(.message-text-row--meta-wide) .message-text {
  padding-right: 3.35rem;
}

.message.message--in .message-text {
  padding-right: 3.35rem;
}

/* «Хвост» у края, как в Telegram */
.message.message--in .message-line,
.message.peer .message-line {
  border-radius: 16px 16px 16px 4px;
}

.message.message--in .message-line::after {
  content: "";
  position: absolute;
  left: -5px;
  bottom: 0;
  width: 10px;
  height: 14px;
  background: var(--theme-bubble-in, var(--msg-in-bg));
  border-radius: 0 0 0 3px;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  z-index: 0;
  pointer-events: none;
}

.message.message--out .message-line,
.message.self .message-line {
  background: var(--theme-bubble-out, var(--msg-out-bg));
  border-color: var(--theme-border-subtle, rgba(148, 163, 184, 0.12));
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.message.message--out .message-line::after,
.message.self .message-line::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: 0;
  width: 10px;
  height: 14px;
  background: var(--theme-bubble-out, var(--msg-out-bg));
  border-radius: 0 0 3px 0;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  z-index: 0;
  pointer-events: none;
}

html[data-app-theme="light"] .message-line {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}

.message-text {
  position: relative;
  z-index: 1;
  font-size: 0.9375rem;
  line-height: 1.45;
  font-weight: 400;
  letter-spacing: 0.01em;
  font-variant-ligatures: common-ligatures;
  word-break: normal;
  overflow-wrap: break-word;
  overflow-wrap: anywhere; /* длинные URL / строки без пробелов — без горизонтального скролла */
  white-space: pre-wrap;
  hyphens: manual;
  min-width: 0;
  max-width: 100%;
}

.message-footer {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: inline-flex;
  flex-direction: row;
  align-items: baseline;
  flex-wrap: nowrap;
  /* Время слева в полосе меты, справа — лоадер или галочки */
  gap: 6px;
  margin: 0;
  padding: 0;
  line-height: 1;
  pointer-events: none;
}

.message-footer time {
  font-size: 0.6875rem;
  line-height: 1.15;
  color: var(--msg-time-fg);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Галочки доставки: цвета из --msg-receipt-* (тёмная/светлая тема в :root) */
.message-status {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.1em;
  user-select: none;
  color: var(--msg-receipt-muted);
  -webkit-text-stroke: 0.45px color-mix(in srgb, var(--msg-receipt-muted) 55%, transparent);
  paint-order: stroke fill;
}

/* Доставлено (1✓) — бледно-серый; прочитано (2✓) — Tiffany ниже */
.message-status--delivered {
  color: var(--msg-receipt-muted);
  -webkit-text-stroke: 0.45px color-mix(in srgb, var(--msg-receipt-muted) 55%, transparent);
}

.message-status--read {
  -webkit-text-stroke: 0;
  background: linear-gradient(
    145deg,
    var(--msg-receipt-read-a) 0%,
    var(--msg-receipt-read-b) 48%,
    var(--msg-receipt-read-c) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

/* Лоадер только на время отправки на сервер (POST) */
.message-send-loader {
  display: inline-block;
  width: 0.8125rem;
  height: 0.8125rem;
  flex-shrink: 0;
  border: 2px solid color-mix(in srgb, var(--msg-receipt-muted) 32%, transparent);
  border-top-color: var(--msg-receipt-muted);
  border-radius: 50%;
  vertical-align: -0.12em;
  opacity: 0.95;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--msg-receipt-muted) 28%, transparent);
  animation:
    message-send-spin 0.7s linear infinite,
    message-send-loader-glow 1.5s ease-in-out infinite;
}

html[data-app-theme="light"] .message-send-loader {
  border-color: color-mix(in srgb, var(--msg-receipt-muted) 40%, transparent);
  border-top-color: var(--msg-receipt-muted);
}

@keyframes message-send-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes message-send-loader-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--msg-receipt-muted) 15%, transparent);
  }
  50% {
    box-shadow: 0 0 8px 1px color-mix(in srgb, var(--msg-receipt-muted) 28%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .message-send-loader {
    animation: none;
    border-color: var(--msg-receipt-muted);
    opacity: 0.88;
    box-shadow: none;
  }
}

/*
 * Появление сообщения: направление от собеседника / от себя,
 * лёгкий blur→sharp, масштаб с коротким «перелётом» (spring-ощущение).
 */
@keyframes message-enter-in {
  0% {
    opacity: 0;
    transform: translate3d(-36px, 16px, 0) scale(0.88) rotate(-0.35deg);
    filter: blur(8px);
  }
  38% {
    opacity: 0.92;
    filter: blur(1px);
  }
  58% {
    opacity: 1;
    transform: translate3d(5px, -4px, 0) scale(1.03) rotate(0deg);
    filter: blur(0);
  }
  78% {
    transform: translate3d(-2px, 2px, 0) scale(0.995);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
    filter: blur(0);
  }
}

@keyframes message-enter-out {
  0% {
    opacity: 0;
    transform: translate3d(36px, 16px, 0) scale(0.88) rotate(0.35deg);
    filter: blur(8px);
  }
  38% {
    opacity: 0.92;
    filter: blur(1px);
  }
  58% {
    opacity: 1;
    transform: translate3d(-5px, -4px, 0) scale(1.03) rotate(0deg);
    filter: blur(0);
  }
  78% {
    transform: translate3d(2px, 2px, 0) scale(0.995);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
    filter: blur(0);
  }
}

@keyframes message-enter-reduced {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .message.message--enter--in .message-bubble {
    transform-origin: left center;
    backface-visibility: hidden;
    animation: message-enter-in 0.68s cubic-bezier(0.22, 0.82, 0.24, 1) both;
  }

  .message.message--enter--out .message-bubble {
    transform-origin: right center;
    backface-visibility: hidden;
    animation: message-enter-out 0.68s cubic-bezier(0.22, 0.82, 0.24, 1) both;
  }
}

@media (prefers-reduced-motion: reduce) {
  .message.message--enter--in .message-bubble,
  .message.message--enter--out .message-bubble {
    animation: message-enter-reduced 0.22s ease-out both;
  }
}

/* Совместимость со старой разметкой */
.message-body {
  padding: 8px 10px 7px 11px;
  border-radius: 10px;
  background: var(--theme-bubble-in, var(--msg-in-bg));
  color: var(--msg-fg);
  font-size: 0.9375rem;
  border: 1px solid var(--theme-border-subtle, rgba(148, 163, 184, 0.06));
}

.message.self .message-body {
  background: var(--theme-bubble-out, var(--msg-out-bg));
  border-color: var(--theme-border-subtle, rgba(148, 163, 184, 0.1));
}

/* --- Composer --- */
.composer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0;
  padding: 12px 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--theme-border-subtle, var(--border-subtle));
  background: var(--theme-composer-bg, var(--panel-bg));
  /* Нижний край = низ видимого окна (visualViewport); без лишнего зазора над клавиатурой */
  transition: padding-bottom 0.22s ease;
}

@media (prefers-reduced-motion: reduce) {
  .composer {
    transition: none;
  }
}

.composer-error {
  font-size: 0.8125rem;
  color: #fca5a5;
  padding: 0 2px;
}

.composer-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
  position: relative;
}

.composer-input-wrap {
  flex: 1;
  min-width: 0;
}

.composer-input {
  width: 100%;
  min-height: 44px;
  max-height: 160px;
  resize: none;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: rgba(11, 18, 32, 0.5);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9375rem;
  outline: none;
  vertical-align: top;
  box-sizing: border-box;
}

html[data-app-theme="light"] .composer-input {
  background: #f1f5f9;
}

.composer-input::placeholder {
  color: var(--text-tertiary);
}

.composer-input:focus {
  border-color: var(--accent);
}

/* Мобильный ввод: без <textarea> — иначе iOS Safari часто показывает панель Prev/Next/Done */
.composer-input--contenteditable {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-height: 44px;
  max-height: 160px;
  overflow-y: auto;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
  /* plaintext-only — меньше «форменного» оформления WebKit у contenteditable */
  -webkit-user-modify: read-write-plaintext-only;
}

.composer-input--contenteditable:empty::before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  pointer-events: none;
}

html[data-app-theme="light"] .composer-input--contenteditable:empty::before {
  color: var(--text-tertiary);
}

.composer-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: var(--theme-btn-send-bg, var(--accent));
  color: var(--theme-btn-send-fg, #0b1220);
  font-size: 1.125rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.composer-send:hover {
  background: var(--theme-btn-send-bg-hover, var(--accent));
  color: var(--theme-btn-send-fg-hover, #0b1220);
  filter: brightness(1.03);
}

.send-actions-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(92vw, 360px);
  padding: 10px;
  border-radius: 5%;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: color-mix(in oklab, var(--panel-bg) 74%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 8px;
  z-index: 40;
  animation: send-actions-fade-in 170ms ease-out;
  overflow: hidden;
}

.send-actions-slider {
  width: 200%;
  display: flex;
  transform: translateX(0);
  transition: transform 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.send-actions-slider--schedule {
  transform: translateX(-50%);
}

.send-actions-page {
  width: 50%;
  display: grid;
  gap: 8px;
  padding-right: 8px;
}

.send-actions-page--schedule {
  padding-left: 8px;
  padding-right: 0;
}

.send-actions-item,
.send-actions-close,
.send-actions-apply {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.36);
  color: var(--text-primary);
  padding: 10px 12px;
  text-align: left;
}

.send-actions-item--schedule {
  display: grid;
  gap: 8px;
}

.send-actions-datetime {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.4);
  color: var(--text-primary);
  padding: 10px 12px;
  min-height: 42px;
}

@keyframes send-actions-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- Mobile: список чатов + диалог — общая ячейка сетки, диалог «выплывает» справа --- */
/* Порог 904/905px — см. apps/web/src/layoutBreakpoint.ts */
@media (max-width: 904px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    position: relative;
    overflow: hidden;
    overflow-x: clip;
    overscroll-behavior-x: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .layout > .sidebar {
    grid-area: 1 / 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    z-index: 1;
    pointer-events: auto;
    overflow-x: hidden;
  }

  .layout > .dialog {
    grid-area: 1 / 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    position: relative;
    z-index: 2;
    transform: translateX(100%);
    transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: none;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18);
    will-change: transform;
    overflow-x: hidden;
  }

  .layout[data-view="dialog"] > .dialog {
    transform: translateX(0);
    pointer-events: auto;
  }

  .layout[data-view="dialog"] > .sidebar {
    pointer-events: none;
  }

  .layout[data-view="sidebar"] > .dialog {
    pointer-events: none;
  }

  /*
   * Открытый чат: колонка на всю высоту #root (--app-vvh). Шапка и композер не сжимаются,
   * сжимается только .feed-pane (лента с прокруткой) — при клавиатуре остаётся «как в Telegram».
   */
  .layout[data-view="dialog"] > .dialog {
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  /* Шапка чата: центр — собеседник, по краям — назад и тема (как в референсе) */
  .layout[data-view="dialog"] .dialog-header {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    min-height: 52px;
    background: color-mix(
      in srgb,
      var(--theme-dialog-bg, var(--panel-bg)) 58%,
      transparent
    );
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
    box-shadow:
      inset 0 -1px 0 rgba(148, 163, 184, 0.08),
      0 4px 24px rgba(0, 0, 0, 0.12);
  }

  html[data-app-theme="light"] .layout[data-view="dialog"] .dialog-header {
    background: color-mix(in srgb, #ffffff 72%, transparent);
  }

  .layout[data-view="dialog"] .dialog-header .btn-back {
    grid-column: 1;
    justify-self: start;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(148, 163, 184, 0.1);
  }

  .layout[data-view="dialog"] .dialog-header .dialog-header-main,
  .layout[data-view="dialog"] .dialog-header .dialog-header-main--peer {
    grid-column: 2;
    justify-self: center;
    margin: 0;
    flex: none;
    max-width: 100%;
    min-width: 0;
  }

  .layout[data-view="dialog"] .dialog-header .dialog-header-main--peer {
    justify-content: center;
    border: none;
    background: transparent;
    width: auto;
  }

  .layout[data-view="dialog"] .dialog-header .dialog-header-title-row {
    justify-content: center;
  }

  .layout[data-view="dialog"] .dialog-header .dialog-header-text {
    text-align: center;
  }

  .layout[data-view="dialog"] .dialog-header .dialog-header-text strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .layout[data-view="dialog"] .dialog-header .dialog-header-text p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .layout[data-view="dialog"] .dialog-header .dialog-header-presence {
    display: none;
  }

  .layout[data-view="dialog"] .dialog-header .dialog-header-actions {
    grid-column: 3;
    margin-left: 0;
    justify-self: end;
  }

  .layout[data-view="dialog"] .btn-chat-preset {
    border-radius: 999px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(148, 163, 184, 0.12);
  }

  /* Композер: стекло + без вылезания за край экрана (safe area + % вместо vw) */
  .layout[data-view="dialog"] .composer {
    padding: 8px max(10px, env(safe-area-inset-left)) 10px
      max(10px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: color-mix(
      in srgb,
      var(--theme-composer-bg, var(--panel-bg)) 62%,
      transparent
    );
    -webkit-backdrop-filter: blur(22px) saturate(165%);
    backdrop-filter: blur(22px) saturate(165%);
    border-top-color: rgba(148, 163, 184, 0.12);
  }

  html[data-app-theme="light"] .layout[data-view="dialog"] .composer {
    background: color-mix(in srgb, #ffffff 78%, transparent);
  }

  html.vv-keyboard .layout[data-view="dialog"] .composer {
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }

  /* Интерактивный свайп: без transition, transform задаётся из JS */
  .layout.layout--narrow-drag > .dialog {
    transition: none !important;
  }

  @media (prefers-reduced-motion: reduce) {
    .layout > .dialog {
      transition: none !important;
    }
  }

  .btn-back {
    display: inline-flex;
  }
}

@media (min-width: 905px) {
  .btn-back {
    display: none;
  }
}

/* --- Тост «тег скопирован» --- */
.tag-copied-toast {
  position: fixed;
  z-index: 10050;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: tagCopiedIn 0.2s ease-out;
}

html[data-app-theme="light"] .tag-copied-toast {
  background: rgba(255, 255, 255, 0.96);
}

@keyframes tagCopiedIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Тост после заявки в друзья / взаимного принятия (выше «Тег скопирован», чтобы не пересекались) */
.friend-action-toast {
  position: fixed;
  z-index: 10050;
  left: 50%;
  bottom: max(88px, calc(env(safe-area-inset-bottom) + 64px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 360px);
  padding: 12px 18px 12px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid color-mix(in srgb, var(--accent, #34d399) 55%, transparent);
  box-shadow:
    0 0 0 1px rgba(52, 211, 153, 0.12),
    0 16px 48px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  animation: friendActionToastIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both,
    friendActionToastGlow 2.2s ease-in-out 0.15s 1 both;
}

html[data-app-theme="light"] .friend-action-toast {
  background: rgba(255, 255, 255, 0.97);
  box-shadow:
    0 0 0 1px rgba(52, 211, 153, 0.2),
    0 16px 40px rgba(15, 23, 42, 0.12);
}

.friend-action-toast__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.95rem;
  font-weight: 700;
  color: #022c22;
  background: var(--accent, #34d399);
  animation: friendActionCheckPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.08s both;
}

.friend-action-toast__text {
  text-align: left;
}

@keyframes friendActionToastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(18px) scale(0.94);
  }
  55% {
    opacity: 1;
    transform: translateX(-50%) translateY(-3px) scale(1.02);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes friendActionCheckPop {
  from {
    opacity: 0;
    transform: scale(0.35);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes friendActionToastGlow {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(52, 211, 153, 0.12),
      0 16px 48px rgba(0, 0, 0, 0.4);
  }
  40% {
    box-shadow:
      0 0 0 1px rgba(52, 211, 153, 0.35),
      0 16px 52px rgba(52, 211, 153, 0.18);
  }
}

/* --- Модалка профиля (ПКМ / долгое нажатие на логин) --- */
.user-profile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.user-profile-modal {
  position: relative;
  /* 100% — внутри паддингов backdrop (flex); без 100vw → меньше горизонтального вылезания */
  width: min(440px, 100%);
  max-width: 100%;
  box-sizing: border-box;
  /* Высота как у блока переписки: вся колонка диалога минус шапка и поле ввода */
  max-height: calc(
    100dvh - var(--header-h) - var(--profile-modal-composer-est) -
      var(--profile-modal-backdrop-pad)
  );
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-radius: 20px;
  background: var(--panel-bg);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(148, 163, 184, 0.12);
}

/* Телефоны: высота окна — 2/3 экрана, с учётом safe-area */
/* Порог 904/905px — см. apps/web/src/layoutBreakpoint.ts */
@media (max-width: 904px) {
  .user-profile-modal {
    max-height: calc(
      (100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * 2 / 3
    );
  }
}

.user-profile-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.45);
}

.user-profile-close:hover {
  color: var(--text-primary);
  background: rgba(148, 163, 184, 0.15);
}

html[data-app-theme="light"] .user-profile-close {
  background: rgba(241, 245, 249, 0.9);
}

.user-profile-header {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 28px 24px 20px;
  background: linear-gradient(
    180deg,
    rgba(52, 211, 153, 0.14) 0%,
    rgba(18, 26, 42, 0.4) 100%
  );
}

html[data-app-theme="light"] .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(52, 211, 153, 0.12) 0%,
    rgba(255, 255, 255, 0.5) 100%
  );
}

/* Темы карточки профиля (свои + чужие) */
.user-profile-modal--theme-forest .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(34, 197, 94, 0.2) 0%,
    rgba(15, 23, 42, 0.55) 100%
  );
}

html[data-app-theme="light"] .user-profile-modal--theme-forest .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(34, 197, 94, 0.18) 0%,
    rgba(255, 255, 255, 0.55) 100%
  );
}

.user-profile-modal--theme-ocean .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(56, 189, 248, 0.22) 0%,
    rgba(15, 23, 42, 0.55) 100%
  );
}

html[data-app-theme="light"] .user-profile-modal--theme-ocean .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(56, 189, 248, 0.16) 0%,
    rgba(255, 255, 255, 0.55) 100%
  );
}

.user-profile-modal--theme-sunset .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(251, 146, 60, 0.22) 0%,
    rgba(15, 23, 42, 0.55) 100%
  );
}

html[data-app-theme="light"] .user-profile-modal--theme-sunset .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(251, 146, 60, 0.18) 0%,
    rgba(255, 255, 255, 0.55) 100%
  );
}

.user-profile-modal--theme-mono .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(148, 163, 184, 0.18) 0%,
    rgba(15, 23, 42, 0.6) 100%
  );
}

html[data-app-theme="light"] .user-profile-modal--theme-mono .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(100, 116, 139, 0.14) 0%,
    rgba(255, 255, 255, 0.55) 100%
  );
}

.user-profile-modal--theme-aurora .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(167, 139, 250, 0.24) 0%,
    rgba(15, 23, 42, 0.55) 100%
  );
}

html[data-app-theme="light"] .user-profile-modal--theme-aurora .user-profile-header {
  background: linear-gradient(
    180deg,
    rgba(167, 139, 250, 0.18) 0%,
    rgba(255, 255, 255, 0.55) 100%
  );
}

.user-profile-theme-block {
  margin: 0 0 14px;
  text-align: left;
}

.user-profile-theme-block__title {
  margin-bottom: 4px;
}

.user-profile-theme-hint {
  margin: 0 0 10px;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-tertiary);
  text-align: center;
}

.user-profile-notify-grid {
  display: grid;
  gap: 8px;
}

.user-profile-notify-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.user-profile-notify-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.user-profile-notify-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-profile-notify-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.user-profile-notify-select {
  min-width: 140px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.42);
  color: var(--text-primary);
  padding: 8px 10px;
}

.user-profile-notify-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-profile-notify-preview {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.45);
  color: var(--text-primary);
  padding: 8px 10px;
  font-size: 0.8125rem;
  cursor: pointer;
}

.user-profile-notify-preview:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.user-profile-notify-time-row input[type="time"] {
  flex: 1;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.42);
  color: var(--text-primary);
  padding: 8px 10px;
}

.user-profile-theme-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  justify-content: stretch;
  width: 100%;
  min-width: 0;
}

.user-profile-theme-chip {
  font: inherit;
  flex: 1 1 0;
  min-width: 0;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 7px 3px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.user-profile-theme-chip:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--text-primary);
}

.user-profile-theme-chip--active {
  background: linear-gradient(
    155deg,
    rgba(52, 211, 153, 0.42) 0%,
    rgba(16, 185, 129, 0.28) 55%,
    rgba(5, 150, 105, 0.22) 100%
  );
  border-color: rgba(52, 211, 153, 0.75);
  color: #ecfdf5;
  font-weight: 700;
  box-shadow:
    0 0 0 1px rgba(52, 211, 153, 0.55),
    0 4px 18px rgba(52, 211, 153, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

html[data-app-theme="light"] .user-profile-theme-chip--active {
  background: linear-gradient(
    155deg,
    rgba(16, 185, 129, 0.38) 0%,
    rgba(52, 211, 153, 0.28) 100%
  );
  border-color: rgba(5, 150, 105, 0.55);
  color: #064e3b;
  text-shadow: none;
  box-shadow:
    0 0 0 1px rgba(16, 185, 129, 0.45),
    0 4px 14px rgba(16, 185, 129, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.user-profile-theme-chip:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.user-profile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Камера привязана к кругу аватара, а не ко всему блоку — не наезжает на «Удалить фото». */
.user-profile-avatar-stack {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-profile-avatar-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.user-profile-avatar-wrap--editable .user-profile-avatar {
  cursor: pointer;
}

.user-profile-avatar-stack .user-profile-avatar-fab {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(15, 23, 42, 0.9);
  background: linear-gradient(145deg, #34d399, #059669);
  color: #022c22;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.user-profile-avatar-stack .user-profile-avatar-fab:hover {
  transform: scale(1.06);
  filter: brightness(1.05);
}

.user-profile-avatar-stack .user-profile-avatar-fab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

html[data-app-theme="light"] .user-profile-avatar-stack .user-profile-avatar-fab {
  border-color: #fff;
}

.user-profile-avatar-remove {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.user-profile-avatar-remove:hover {
  color: var(--accent);
}

.user-profile-avatar-error {
  margin: 0;
  max-width: 260px;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #fecaca;
  text-align: center;
}

html[data-app-theme="light"] .user-profile-avatar-error {
  color: #b91c1c;
}

.user-profile-avatar {
  width: 96px;
  height: 96px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1;
  background: linear-gradient(145deg, #1e3a5f, #0f172a);
  color: var(--accent);
  border: 3px solid rgba(148, 163, 184, 0.2);
}

.user-profile-avatar > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.user-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-profile-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 24px max(28px, calc(16px + env(safe-area-inset-bottom, 0px)));
  text-align: center;
}

.user-profile-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.user-profile-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 4px;
}

.user-profile-name-row .user-profile-name {
  margin: 0;
}

.user-profile-icon-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.user-profile-icon-btn:hover {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent, #34d399);
}

.user-profile-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.user-profile-name-edit {
  width: 100%;
  max-width: 320px;
  margin: 0 auto 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.user-profile-name-edit label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.user-profile-name-edit input {
  font: inherit;
  font-size: 0.9375rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.45);
  color: var(--text-primary);
}

html[data-app-theme="light"] .user-profile-name-edit input {
  background: rgba(255, 255, 255, 0.85);
}

.user-profile-username-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  width: 100%;
}

.user-profile-username-field {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  max-width: min(280px, 100%);
}

.user-profile-username-prefix {
  color: var(--accent);
  font-weight: 600;
  font-size: 1.0625rem;
  flex-shrink: 0;
}

.user-profile-username-input {
  min-width: 0;
  flex: 1;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  text-transform: none;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.5);
  color: var(--accent);
}

html[data-app-theme="light"] .user-profile-username-input {
  background: rgba(255, 255, 255, 0.9);
}

.user-profile-username-hint,
.user-profile-username-error {
  width: 100%;
  margin: 4px 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: center;
}

.user-profile-username-hint {
  color: var(--text-tertiary);
}

.user-profile-username-error {
  color: #fecaca;
}

html[data-app-theme="light"] .user-profile-username-error {
  color: #b91c1c;
}

.user-profile-username {
  margin: 8px 0 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  display: inline-block;
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  width: 100%;
  line-height: 1.35;
  /* Показываем логин так, как сохранён на сервере (AdMin ≠ admin) */
  text-transform: none;
  font-variant: normal;
}

.user-profile-username--in-row {
  margin: 0;
  width: auto;
  flex: 0 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 600;
}

.user-profile-username:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.user-profile-username:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.user-profile-hint {
  margin: 14px 0 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.user-profile-actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-profile-btn {
  width: 100%;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.user-profile-btn--primary {
  border: 1px solid var(--border-subtle);
  background: rgba(52, 211, 153, 0.12);
  color: var(--text-primary);
}

.user-profile-btn--primary:hover {
  background: rgba(52, 211, 153, 0.2);
}

.user-profile-btn--logout {
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: transparent;
  color: var(--text-secondary);
}

.user-profile-btn--logout:hover {
  border-color: rgba(248, 113, 113, 0.55);
  color: var(--text-primary);
  background: rgba(248, 113, 113, 0.08);
}

.user-profile-btn--secondary {
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
}

.user-profile-btn--secondary:hover {
  color: var(--text-primary);
  background: rgba(148, 163, 184, 0.08);
}

.user-profile-bio-label {
  display: block;
  margin: 14px 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  text-align: left;
}

.user-profile-bio-input {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.35);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
  resize: none;
  min-height: 96px;
  max-height: 160px;
  text-align: left;
  vertical-align: top;
}

html[data-app-theme="light"] .user-profile-bio-input {
  background: #f8fafc;
}

.user-profile-bio {
  margin: 14px 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.user-profile-bio--empty {
  font-style: italic;
  opacity: 0.85;
}

.user-profile-bio-actions {
  margin-top: 6px;
  margin-bottom: 2px;
}

.user-profile-btn--save {
  transition:
    background 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.45s ease,
    color 0.45s ease,
    transform 0.4s cubic-bezier(0.34, 1.4, 0.64, 1),
    box-shadow 0.4s ease;
}

.user-profile-btn--save-pending {
  opacity: 0.88;
  pointer-events: none;
}

.user-profile-btn--save-succeeded {
  background: linear-gradient(135deg, #047857, #34d399) !important;
  border-color: rgba(52, 211, 153, 0.45) !important;
  color: #ecfdf5 !important;
  box-shadow: 0 8px 28px rgba(52, 211, 153, 0.25);
  animation: userProfileSaveSuccess 0.55s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

@keyframes userProfileSaveSuccess {
  0% {
    transform: scale(0.94);
    opacity: 0.85;
  }
  55% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.user-profile-save-error {
  margin: 10px 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #fecaca;
  text-align: center;
}

html[data-app-theme="light"] .user-profile-save-error {
  color: #b91c1c;
}

.user-profile-peer-error {
  margin: 18px 0 0;
  padding: 12px 14px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #fecaca;
  text-align: left;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.22);
  border-radius: 12px;
}

.user-profile-bio--empty + .user-profile-peer-error {
  margin-top: 14px;
}

.user-profile-peer-error + .user-profile-actions--friend {
  margin-top: 16px;
}

.user-profile-actions--friend {
  margin-top: 16px;
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.user-profile-actions--friend .user-profile-btn {
  padding: 10px 22px;
  max-width: min(100%, 320px);
  margin-left: auto;
  margin-right: auto;
}

.user-profile-actions--friend .user-profile-btn--secondary {
  max-width: min(100%, 320px);
}

.user-profile-actions--friend .user-profile-btn--remove-friend {
  max-width: none;
  width: auto;
}

.user-profile-friend-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: min(100%, 380px);
  margin-left: auto;
  margin-right: auto;
}

.user-profile-friend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.user-profile-btn--remove-friend {
  width: auto;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(248, 113, 113, 0.75);
  background: rgba(248, 113, 113, 0.05);
  border: 1px solid rgba(248, 113, 113, 0.18);
  border-radius: 999px;
  max-width: none;
  margin: 0;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.user-profile-btn--remove-friend:hover:not(:disabled) {
  color: rgba(248, 113, 113, 0.95);
  background: rgba(248, 113, 113, 0.09);
  border-color: rgba(248, 113, 113, 0.28);
}

.user-profile-btn--remove-friend:focus-visible {
  outline: 2px solid rgba(248, 113, 113, 0.45);
  outline-offset: 2px;
}

.user-profile-btn--remove-friend:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

html[data-app-theme="light"] .user-profile-btn--remove-friend {
  color: rgba(185, 28, 28, 0.85);
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.22);
}

html[data-app-theme="light"] .user-profile-btn--remove-friend:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.32);
}

/* Кликабельная шапка диалога с собеседником */
.dialog-header-main--peer {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 4px 8px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.dialog-header-main--peer:hover {
  background: rgba(148, 163, 184, 0.08);
}

.dialog-header-main--peer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Модалка «Тема этого чата» (раньше стили жили в ios/styles; в бандл идёт app-ui) --- */

.sheet.sheet--chat-theme {
  z-index: 10050;
  margin: auto;
  padding: 0;
  border: none;
  border-radius: 22px;
  width: min(460px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(92dvh, 760px);
  overflow: hidden;
  color: var(--text-primary, #f1f5f9);
  background: linear-gradient(
      155deg,
      color-mix(in srgb, var(--panel-bg, #121a2a) 92%, #34d399) 0%,
      var(--panel-bg, #121a2a) 42%,
      color-mix(in srgb, var(--panel-bg, #121a2a) 88%, #0f172a) 100%
    ),
    var(--panel-bg, #121a2a);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.07),
    0 28px 90px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Без dvi — остаётся vw в блоке .sheet.sheet--chat-theme выше. */
@supports (width: 1dvi) {
  .sheet.sheet--chat-theme {
    width: min(460px, calc(100dvi - 24px));
    max-width: calc(100dvi - 24px);
  }
}

.sheet.sheet--chat-theme::backdrop {
  background: rgba(4, 8, 18, 0.62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

html[data-app-theme="light"] .sheet.sheet--chat-theme {
  background: linear-gradient(
      155deg,
      #ffffff 0%,
      #f8fafc 45%,
      #f1f5f9 100%
    );
  color: #0f172a;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.08),
    0 28px 70px rgba(15, 23, 42, 0.12);
}

.sheet.sheet--chat-theme .sheet__inner {
  max-height: min(92dvh, 760px);
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet.sheet--chat-theme .sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-shrink: 0;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.12));
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03) 0%,
    transparent 100%
  );
}

html[data-app-theme="light"] .sheet.sheet--chat-theme .sheet__head {
  border-bottom-color: rgba(15, 23, 42, 0.08);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.85) 0%,
    transparent 100%
  );
}

.sheet__head-main {
  min-width: 0;
  flex: 1;
}

.sheet__kicker {
  margin: 0 0 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary, #64748b);
}

.sheet.sheet--chat-theme .sheet__title {
  margin: 0;
  font-size: 1.1875rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.sheet__close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.18));
  background: rgba(148, 163, 184, 0.08);
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.12s ease;
}

.sheet__close:hover {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(52, 211, 153, 0.35);
}

.sheet__close:focus-visible {
  outline: 2px solid var(--accent, #34d399);
  outline-offset: 2px;
}

.sheet__close:active {
  transform: scale(0.96);
}

.sheet__lead-box {
  flex-shrink: 0;
  padding: 14px 20px 16px;
}

.sheet__lead {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-secondary, #94a3b8);
}

html[data-app-theme="light"] .sheet__lead {
  color: #64748b;
}

.sheet.sheet--chat-theme .theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  padding: 4px 20px 8px;
  margin: 0;
}

.sheet.sheet--chat-theme .theme-custom-panel {
  border-top: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.12));
  padding: 16px 20px 22px;
  background: rgba(0, 0, 0, 0.12);
}

html[data-app-theme="light"] .sheet.sheet--chat-theme .theme-custom-panel {
  background: rgba(241, 245, 249, 0.65);
  border-top-color: rgba(15, 23, 42, 0.08);
}

.theme-preset {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 118px;
  padding: 14px 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.14));
  background: rgba(148, 163, 184, 0.06);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition:
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    transform 0.15s ease,
    background 0.18s ease;
}

.theme-preset:hover {
  border-color: rgba(52, 211, 153, 0.38);
  background: rgba(52, 211, 153, 0.06);
  transform: translateY(-1px);
}

.theme-preset:focus-visible {
  outline: 2px solid var(--accent, #34d399);
  outline-offset: 2px;
}

.theme-preset.is-active {
  border-color: var(--accent, #34d399);
  box-shadow:
    0 0 0 2px rgba(52, 211, 153, 0.22),
    0 12px 28px rgba(0, 0, 0, 0.25);
  background: rgba(52, 211, 153, 0.08);
}

.theme-preset__ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.42),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 2px 0 rgba(255, 255, 255, 0.22),
    inset 0 -10px 22px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.theme-preset__ring--custom {
  background: conic-gradient(
    from 210deg,
    #34d399,
    #38bdf8,
    #a78bfa,
    #f472b6,
    #fbbf24,
    #34d399
  );
}

.theme-preset__name {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
}

.theme-custom-panel[hidden] {
  display: none !important;
}

.theme-custom-panel__hint {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.45;
}

html[data-app-theme="light"] .theme-custom-panel__hint {
  color: #64748b;
}

.theme-custom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin-bottom: 12px;
}

.theme-custom-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary, #94a3b8);
}

html[data-app-theme="light"] .theme-custom-field {
  color: #64748b;
}

.theme-custom-field input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.22));
  background: rgba(0, 0, 0, 0.22);
  cursor: pointer;
}

html[data-app-theme="light"] .theme-custom-field input[type="color"] {
  background: #e2e8f0;
}

.theme-custom-reset {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.22));
  background: rgba(148, 163, 184, 0.08);
  color: inherit;
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.theme-custom-reset:hover {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.1);
}

@media (prefers-reduced-motion: reduce) {
  .theme-preset {
    transition: none;
  }

  .theme-preset:hover {
    transform: none;
  }
}
