/* ================================================================
   reset + theme
   ================================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow: hidden;
  color: var(--fg);
  background: var(--bg);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* iOS safe-area */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
svg { display: block; flex-shrink: 0; }

:root, [data-theme="dark"] {
  --bg:            #0f1115;
  --bg-2:          #14171d;
  --bg-3:          #1a1d24;
  --bg-4:          #22252d;
  --fg:            #e4e6eb;
  --fg-2:          #9aa5b8;
  --fg-3:          #6a7186;
  --accent:        #7aa2f7;
  --accent-fg:     #0b0d12;
  --danger:        #ff6b6b;
  --success:       #7ac97a;
  --border:        #22252d;
  --shadow:        0 8px 40px rgba(0,0,0,0.4);
  --bubble-in:     #1e2129;
  --bubble-out:    #2a4a7a;
  --bubble-out-fg: #ffffff;
  --input-bg:      #11141a;
  --radius:        8px;
  --radius-bubble: 14px;
  --radius-card:   14px;
  --transition:    0.12s;
}

[data-theme="light"] {
  --bg:            #f5f6fa;
  --bg-2:          #ffffff;
  --bg-3:          #ffffff;
  --bg-4:          #e9ecf2;
  --fg:            #1a1d24;
  --fg-2:          #6a7186;
  --fg-3:          #99a2b8;
  --accent:        #4a7de8;
  --accent-fg:     #ffffff;
  --danger:        #e04a4a;
  --success:       #3aa83a;
  --border:        #e1e4eb;
  --shadow:        0 4px 20px rgba(0,0,0,0.1);
  --bubble-in:     #e9ecf2;
  --bubble-out:    #4a7de8;
  --bubble-out-fg: #ffffff;
  --input-bg:      #eef1f6;
}

/* --- Midnight — глубокий синий с мягкими ночными тонами --- */
[data-theme="midnight"] {
  --bg:            #0a0f1e;
  --bg-2:          #0f1628;
  --bg-3:          #131d35;
  --bg-4:          #1c2849;
  --fg:            #dfe6ff;
  --fg-2:          #8c9bc9;
  --fg-3:          #5a6a99;
  --accent:        #8b5cf6;
  --accent-fg:     #ffffff;
  --danger:        #ff7a7a;
  --success:       #7ad1b6;
  --border:        #1c2849;
  --shadow:        0 12px 48px rgba(0,0,30,0.55);
  --bubble-in:     #182342;
  --bubble-out:    #5b3ca3;
  --bubble-out-fg: #ffffff;
  --input-bg:      #0e1730;
}

/* --- Sunset — тёплая тема, персик/янтарь --- */
[data-theme="sunset"] {
  --bg:            #1b1318;
  --bg-2:          #251a20;
  --bg-3:          #30212a;
  --bg-4:          #3e2d38;
  --fg:            #ffe8d8;
  --fg-2:          #e0b59a;
  --fg-3:          #9f7d6d;
  --accent:        #ff8a5b;
  --accent-fg:     #1b1318;
  --danger:        #ff5d6c;
  --success:       #ffcf70;
  --border:        #3e2d38;
  --shadow:        0 10px 42px rgba(90,20,0,0.45);
  --bubble-in:     #2b1d27;
  --bubble-out:    #a64428;
  --bubble-out-fg: #fff4e6;
  --input-bg:      #1f1519;
}

/* --- Forest — спокойный зелёный, чуть графитовый --- */
[data-theme="forest"] {
  --bg:            #0e1512;
  --bg-2:          #131d18;
  --bg-3:          #182720;
  --bg-4:          #20342a;
  --fg:            #dfefe4;
  --fg-2:          #9bb6a6;
  --fg-3:          #647b71;
  --accent:        #6ccf8c;
  --accent-fg:     #0a1b12;
  --danger:        #e77373;
  --success:       #92d9a0;
  --border:        #20342a;
  --shadow:        0 8px 36px rgba(0,20,10,0.45);
  --bubble-in:     #1a2b22;
  --bubble-out:    #2f6b48;
  --bubble-out-fg: #f1fff4;
  --input-bg:      #101916;
}

/* --- Rose — розовая лёгкая тема --- */
[data-theme="rose"] {
  --bg:            #fdf6f7;
  --bg-2:          #ffffff;
  --bg-3:          #ffffff;
  --bg-4:          #f9e3e8;
  --fg:            #301824;
  --fg-2:          #76546a;
  --fg-3:          #ab8aa0;
  --accent:        #e0477e;
  --accent-fg:     #ffffff;
  --danger:        #d83a3a;
  --success:       #4aa373;
  --border:        #f1d6dd;
  --shadow:        0 6px 26px rgba(200,60,110,0.18);
  --bubble-in:     #f9e3e8;
  --bubble-out:    #e0477e;
  --bubble-out-fg: #ffffff;
  --input-bg:      #fbeef2;
}

/* --- Nord — холодный северный, арктический --- */
[data-theme="nord"] {
  --bg:            #2e3440;
  --bg-2:          #343b48;
  --bg-3:          #3b4252;
  --bg-4:          #434c5e;
  --fg:            #eceff4;
  --fg-2:          #d8dee9;
  --fg-3:          #8b96ab;
  --accent:        #88c0d0;
  --accent-fg:     #2e3440;
  --danger:        #bf616a;
  --success:       #a3be8c;
  --border:        #434c5e;
  --shadow:        0 8px 32px rgba(10,14,24,0.5);
  --bubble-in:     #3b4252;
  --bubble-out:    #5e81ac;
  --bubble-out-fg: #eceff4;
  --input-bg:      #333a47;
}

/* --- Aurora — живой фон с плавающими световыми пятнами --- */
[data-theme="aurora"] {
  --bg:            #0a0d1a;
  --bg-2:          rgba(16,20,38,0.72);
  --bg-3:          rgba(24,28,50,0.82);
  --bg-4:          rgba(40,48,80,0.72);
  --fg:            #e8efff;
  --fg-2:          #a0aecd;
  --fg-3:          #6b7999;
  --accent:        #64d9ff;
  --accent-fg:     #06101f;
  --danger:        #ff7aa2;
  --success:       #8effc9;
  --border:        rgba(120,160,230,0.22);
  --shadow:        0 18px 48px rgba(20,40,100,0.5);
  --bubble-in:     rgba(25,32,58,0.82);
  --bubble-out:    linear-gradient(135deg, #4dbdff 0%, #a16bff 100%);
  --bubble-out-fg: #ffffff;
  --input-bg:      rgba(20,25,46,0.75);
}
body[data-theme="aurora"] {
  background:
    radial-gradient(40% 50% at 20% 20%, rgba(77,189,255,0.35), transparent 70%),
    radial-gradient(45% 45% at 80% 30%, rgba(161,107,255,0.32), transparent 70%),
    radial-gradient(50% 55% at 50% 100%, rgba(142,255,201,0.22), transparent 70%),
    linear-gradient(135deg, #070a18 0%, #0a0d1a 100%);
  background-size: 200% 200%, 180% 180%, 180% 180%, 100% 100%;
  animation: aurora-shift 24s ease-in-out infinite;
}
@keyframes aurora-shift {
  0%, 100% { background-position: 0% 0%, 100% 0%, 50% 100%, 0 0; }
  33%      { background-position: 100% 60%, 20% 40%, 80% 70%, 0 0; }
  66%      { background-position: 40% 100%, 60% 100%, 20% 30%, 0 0; }
}
body[data-theme="aurora"] .sidebar,
body[data-theme="aurora"] .chat-header,
body[data-theme="aurora"] .composer,
body[data-theme="aurora"] .modal-card {
  backdrop-filter: blur(16px) saturate(130%);
  background-color: rgba(10,13,26,0.55);
}
body[data-theme="aurora"] .msg.in { backdrop-filter: blur(6px); }

/* --- Neon — киберпанк, сканлайны и неоновая обводка --- */
[data-theme="neon"] {
  --bg:            #05060a;
  --bg-2:          #0a0b13;
  --bg-3:          #0e1020;
  --bg-4:          #151830;
  --fg:            #e0f7ff;
  --fg-2:          #8dd3ff;
  --fg-3:          #5a6a99;
  --accent:        #00f0ff;
  --accent-fg:     #00141a;
  --danger:        #ff2d75;
  --success:       #8dff88;
  --border:        rgba(0,240,255,0.25);
  --shadow:        0 0 30px rgba(0,240,255,0.25), 0 8px 40px rgba(0,0,0,0.7);
  --bubble-in:     #0e1020;
  --bubble-out:    linear-gradient(135deg, #00f0ff 0%, #ff2d75 100%);
  --bubble-out-fg: #001018;
  --input-bg:      #0a0b13;
}
body[data-theme="neon"] {
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0, transparent 2px,
      rgba(0,240,255,0.035) 2px, rgba(0,240,255,0.035) 3px
    ),
    radial-gradient(50% 40% at 15% 25%, rgba(0,240,255,0.15), transparent 70%),
    radial-gradient(50% 40% at 85% 75%, rgba(255,45,117,0.12), transparent 70%),
    #05060a;
  background-attachment: fixed;
  animation: neon-flicker 7s linear infinite;
}
@keyframes neon-flicker {
  0%, 92%, 100% { filter: none; }
  93%, 95%      { filter: brightness(1.2) hue-rotate(6deg); }
  94%           { filter: brightness(0.9); }
}
body[data-theme="neon"] .msg.out {
  box-shadow: 0 0 20px rgba(0,240,255,0.35), 0 6px 24px rgba(255,45,117,0.18);
}
body[data-theme="neon"] .chat-item.active {
  background: rgba(0,240,255,0.08);
  box-shadow: inset 2px 0 0 var(--accent);
}
body[data-theme="neon"] .me-bar,
body[data-theme="neon"] .chat-header,
body[data-theme="neon"] .composer {
  border-color: rgba(0,240,255,0.18);
}
body[data-theme="neon"] input:focus,
body[data-theme="neon"] textarea:focus,
body[data-theme="neon"] select:focus {
  box-shadow: 0 0 0 2px rgba(0,240,255,0.35), 0 0 20px rgba(0,240,255,0.25);
}
body[data-theme="neon"] .send-btn {
  background: linear-gradient(135deg, #00f0ff, #ff2d75);
  color: #001018;
  box-shadow: 0 0 18px rgba(0,240,255,0.5);
  animation: neon-pulse 2.6s ease-in-out infinite;
}
@keyframes neon-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(0,240,255,0.5); }
  50%      { box-shadow: 0 0 32px rgba(255,45,117,0.6); }
}
body[data-theme="neon"] h1,
body[data-theme="neon"] .me-name,
body[data-theme="neon"] .chat-peer-name {
  text-shadow: 0 0 8px rgba(0,240,255,0.45);
}

/* --- Mono — чистый монохром, строгий --- */
[data-theme="mono"] {
  --bg:            #000000;
  --bg-2:          #0c0c0c;
  --bg-3:          #131313;
  --bg-4:          #1c1c1c;
  --fg:            #f5f5f5;
  --fg-2:          #a8a8a8;
  --fg-3:          #6c6c6c;
  --accent:        #ffffff;
  --accent-fg:     #000000;
  --danger:        #ff5a5a;
  --success:       #c0c0c0;
  --border:        #1c1c1c;
  --shadow:        0 6px 28px rgba(0,0,0,0.6);
  --bubble-in:     #141414;
  --bubble-out:    #2a2a2a;
  --bubble-out-fg: #ffffff;
  --input-bg:      #0c0c0c;
}

/* ================================================================
   base controls
   ================================================================ */
.view { height: 100vh; display: flex; }
.view.center { align-items: center; justify-content: center; }
.hidden { display: none !important; }

.muted { color: var(--fg-3); font-size: 12px; line-height: 1.4; }
.error {
  color: var(--danger); min-height: 0;
  font-size: 13px; white-space: pre-wrap;
  line-height: 1.4;
}
.error:not(:empty) {
  margin-top: 4px;
  padding: 10px 12px 10px 36px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  position: relative;
  animation: error-shake 0.4s cubic-bezier(.36,.07,.19,.97);
}
.error:not(:empty)::before {
  content: "!";
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff;
  font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: "Inter", sans-serif;
}
@keyframes error-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  35% { transform: translateX(5px); }
  55% { transform: translateX(-3px); }
  75% { transform: translateX(2px); }
}
.row { display: flex; gap: 6px; flex-wrap: wrap; }

input, textarea, select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 11px 14px;
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
textarea { resize: vertical; min-height: 40px; }

button {
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  padding: 11px 18px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  transition: filter 0.12s, background 0.12s, transform 0.12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
/* min-height только на "обычные" кнопки — на круглые/маленькие не навешиваем */
button.primary, button.secondary, button.danger,
button:not([class]) {
  min-height: 44px;
}
button:hover { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-fg); }
button.primary.big { padding: 14px 22px; font-size: 16px; font-weight: 700; }
button.secondary {
  background: var(--bg-4); color: var(--fg);
}
button.secondary:hover { background: var(--border); }
button.small {
  padding: 8px 12px; font-size: 13px; font-weight: 500;
  background: var(--bg-4); color: var(--fg);
  min-height: 36px;
}
button.small:hover { background: var(--border); }
button.danger { background: var(--danger); color: #fff; }
button.btn-like { display: inline-flex; align-items: center; gap: 6px; }
label.btn-like {
  background: var(--bg-4); color: var(--fg);
  padding: 8px 12px; font-size: 13px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px;
}
label.btn-like:hover { background: var(--border); }

.icon-btn {
  background: transparent; color: var(--fg-2);
  padding: 0;                          /* фикс: иначе svg съезжает */
  border-radius: 10px;
  width: 40px; height: 40px;
  min-width: 40px; min-height: 40px;   /* не даём global min-height сделать вытянутым */
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg-4); color: var(--fg); }
.icon-btn svg { width: 20px; height: 20px; pointer-events: none; }
.icon-btn[data-icon] > svg { pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-size: 12px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding-left: 2px;
}

a { color: var(--accent); text-decoration: none; text-align: center; font-size: 13px; }
a:hover { text-decoration: underline; }

/* ================================================================
   auth card — login + register
   ================================================================ */
.auth-bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(40% 40% at 15% 20%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
    radial-gradient(50% 50% at 85% 80%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--bg);
}
.auth-bg::before, .auth-bg::after {
  content: ""; position: absolute;
  border-radius: 50%; filter: blur(60px); opacity: 0.55;
  animation: auth-float 12s ease-in-out infinite alternate;
}
.auth-bg::before {
  width: 420px; height: 420px; left: -100px; top: -120px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
}
.auth-bg::after {
  width: 380px; height: 380px; right: -80px; bottom: -120px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 50%, #ff6b9d) 0%, transparent 70%);
  animation-delay: -6s;
}
@keyframes auth-float {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(40px, -30px) scale(1.07); }
  100% { transform: translate(-20px, 40px) scale(0.95); }
}

.auth-card {
  background: var(--bg-3);
  padding: 36px 32px; border-radius: 18px; width: min(400px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: card-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
  /* чтобы ошибка и ссылка никогда не уезжали за экран */
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}
/* .error в auth — всегда над ссылкой и сразу под кнопкой */
.auth-card .error:not(:empty) { order: 2; }
.auth-card a { order: 3; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.brand-lockup {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.brand-mark {
  color: var(--accent);
  animation: brand-pop 0.7s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes brand-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.auth-card h1 {
  font-family: "Unbounded", "Inter", sans-serif;
  font-size: 26px; color: var(--fg); font-weight: 800;
  letter-spacing: -0.02em;
}
.auth-card h2 {
  font-size: 13px; font-weight: 500; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.12em;
}
.auth-card .tight { font-size: 12px; margin-top: -4px; }
.auth-card a { margin-top: 6px; }
.auth-card .error { margin-top: 0; }
.auth-card .primary.big { width: 100%; margin-top: 8px; }

/* loading spinner */
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--bg-4);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin: 6px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   app layout
   ================================================================ */
#view-app { flex-direction: row; }

.sidebar {
  width: 300px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0;
}
.me-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.me-bar .me-info { flex: 1; min-width: 0; }
.me-name { font-weight: 600; color: var(--fg); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-username { color: var(--fg-3); font-size: 12px; }
.me-avatar { width: 36px; height: 36px; cursor: pointer; }

.sidebar-search {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  position: relative;
}
.sidebar-search .search-icon {
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  color: var(--fg-3); pointer-events: none;
  display: inline-flex;
}
.sidebar-search input {
  padding: 9px 12px 9px 38px;
  border-radius: 10px;
}

.sidebar-bottom-btn {
  margin: 10px 12px;
  padding: 10px 12px;
  background: var(--bg-4);
  color: var(--fg);
  border-radius: 12px;
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 14px;
  justify-content: flex-start;
  min-height: 44px;
}
.sidebar-bottom-btn:hover { background: var(--border); }
.sidebar-bottom-btn .icon { color: var(--accent); display: inline-flex; }

.list { display: flex; flex-direction: column; }
.chat-list { flex: 1; overflow-y: auto; padding: 4px; }

.sidebar-tabs {
  display: flex; gap: 4px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--border);
}
.side-tab {
  background: transparent; color: var(--fg-2);
  padding: 8px 12px; border-radius: 10px 10px 0 0;
  font-size: 13px; font-weight: 500; min-height: 36px;
  flex: 1;
}
.side-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  background: var(--bg-3);
}
.rooms-toolbar { padding: 8px 10px; border-bottom: 1px solid var(--border); }
#rooms-pane { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#sidebar-rooms { flex: 1; overflow-y: auto; padding: 4px; }

.radio-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 9999px;
  background: var(--bg-4); color: var(--fg);
  cursor: pointer; font-size: 13px;
}
.radio-chip input { width: auto; }

.search-results { max-height: 40%; overflow-y: auto; padding: 4px; border-bottom: 1px solid var(--border); }

/* legacy — оставляем на случай старой разметки */
.admin-block { display: none; }

/* admin modal content */
.modal-title {
  font-family: "Unbounded", "Inter", sans-serif;
  font-size: 20px; font-weight: 700; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px;
  color: var(--fg);
  margin-bottom: 6px;
}
.modal-title svg { color: var(--accent); }

.admin-card { width: 720px; max-width: min(720px, calc(100vw - 32px)); padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 10px; }
.admin-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.admin-tabs .tab {
  background: transparent; color: var(--fg-2);
  padding: 8px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  min-height: 36px;
  display: inline-flex; align-items: center; gap: 6px;
  position: relative;
}
.admin-tabs .tab:hover { background: var(--bg-4); color: var(--fg); }
.admin-tabs .tab.active { background: var(--accent); color: var(--accent-fg); }
.admin-body { max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.admin-pane { display: flex; flex-direction: column; gap: 10px; }
.admin-section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}

.invites-list {
  max-height: 340px; overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
}

.admin-users-list, .admin-activity-list, .admin-alerts-list { display: flex; flex-direction: column; gap: 6px; }
.admin-user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
}
.admin-user-body { flex: 1; min-width: 0; }
.admin-user-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-user-sub { color: var(--fg-3); font-size: 12px; margin-top: 2px; }
.admin-user-actions .small { padding: 6px 10px; }
.role-chip {
  font-size: 10px; padding: 2px 6px; border-radius: 6px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}
.role-chip.admin    { background: var(--accent); color: var(--accent-fg); }
.role-chip.banned   { background: var(--danger); color: #fff; }
.role-chip.verified { background: #1d9bf0; color: #fff; padding: 1px 6px; font-size: 12px; }

.verified-mark {
  display: inline-flex; align-items: center; vertical-align: middle;
  color: #1d9bf0;
  margin-left: 4px;
  filter: drop-shadow(0 0 2px rgba(29,155,240,0.4));
}
.chat-item.active .verified-mark { color: #fff; }
.msg.out .verified-mark { color: rgba(255,255,255,0.9); }

.admin-activity-row {
  padding: 6px 8px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.admin-activity-row:last-child { border-bottom: none; }
.activity-time { font-size: 11px; color: var(--fg-3); }
.activity-main { margin-top: 2px; }

.alerts-toolbar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 10px;
}
.alerts-toolbar input[type="search"] { flex: 1; }
.alert-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.admin-alert-row {
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 10%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  display: flex; flex-direction: column; gap: 6px;
}
.admin-alert-row.seen { opacity: 0.55; background: var(--bg-2); border-color: var(--border); }
.alert-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.alert-match {
  font-weight: 700; color: var(--danger);
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  padding: 2px 8px; border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace;
}
.alert-ctx { font-size: 12px; }
.alert-snippet { font-style: italic; color: var(--fg); font-size: 14px; }

.alert-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  display: inline-block; margin-left: 4px;
  animation: pulse-dot 1.6s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,80,80,0.6); }
  50%      { box-shadow: 0 0 0 8px rgba(255,80,80,0); }
}
#btn-admin.has-alerts { position: relative; }
#btn-admin.has-alerts::after {
  content: ""; position: absolute; top: 10px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.pad { padding: 16px; }

.section-title {
  color: var(--fg-3); font-size: 11px; text-transform: uppercase;
  margin: 8px 0 4px; letter-spacing: 0.6px;
}

/* ================================================================
   avatar
   ================================================================ */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-4); color: var(--fg-2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px;
  overflow: hidden; flex-shrink: 0;
  background-size: cover; background-position: center;
  position: relative;
  border: 0;
}
.avatar.big  { width: 96px;  height: 96px;  font-size: 40px; }
.avatar.huge { width: 140px; height: 140px; font-size: 60px; }

/* ================================================================
   chat list item
   ================================================================ */
.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
  min-width: 0;
  transition: background 0.12s;
}
.chat-item:hover { background: var(--bg-3); }
.chat-item.active { background: var(--bubble-out); color: var(--bubble-out-fg); }
.chat-item.active .chat-preview,
.chat-item.active .chat-ts { color: rgba(255,255,255,0.75); }
.chat-item .online-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--success); border: 2px solid var(--bg-2);
}
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.chat-name { font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-ts { color: var(--fg-3); font-size: 11px; flex-shrink: 0; }
.chat-preview {
  color: var(--fg-2); font-size: 12px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.unread-badge {
  background: var(--accent); color: var(--accent-fg);
  padding: 1px 6px; border-radius: 10px;
  font-size: 11px; font-weight: 700; min-width: 18px; text-align: center;
  margin-left: 4px;
}
.chat-item.blocked { opacity: 0.45; }

/* ================================================================
   chat area
   ================================================================ */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.no-chat {
  margin: auto; padding: 24px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.welcome-card {
  max-width: 460px; width: 100%;
  display: flex; flex-direction: column; gap: 18px;
  align-items: center; text-align: center;
}
.welcome-hero {
  position: relative;
  width: 160px; height: 160px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  animation: hero-in 0.6s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes hero-in {
  from { opacity: 0; transform: scale(0.9) rotate(-5deg); }
  to   { opacity: 1; transform: none; }
}
.hero-shape {
  position: absolute; border-radius: 50%;
  filter: blur(18px); opacity: 0.45;
  animation: hero-bob 8s ease-in-out infinite alternate;
}
.shape-1 {
  width: 110px; height: 110px;
  top: 10px; left: -10px;
  background: var(--accent);
}
.shape-2 {
  width: 90px; height: 90px;
  bottom: 0; right: -10px;
  background: color-mix(in srgb, var(--accent) 60%, #ff6b9d);
  animation-delay: -3s;
}
.shape-3 {
  width: 80px; height: 80px;
  bottom: 20px; left: 40px;
  background: color-mix(in srgb, var(--accent) 40%, var(--success));
  animation-delay: -6s;
}
@keyframes hero-bob {
  0% { transform: translate(0,0) scale(1); }
  50% { transform: translate(8px,-10px) scale(1.05); }
  100% { transform: translate(-6px,6px) scale(0.96); }
}
.hero-lock {
  position: relative; z-index: 2;
  background: var(--bg-3);
  border-radius: 26px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: inline-flex;
}
.welcome-title {
  font-family: "Unbounded", "Inter", sans-serif;
  font-size: 30px; font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.welcome-sub {
  color: var(--fg-2); font-size: 15px; line-height: 1.55;
  max-width: 400px;
}
.welcome-actions {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  margin-top: 6px;
}
.welcome-tips {
  margin-top: 18px; padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
  width: 100%;
}
.welcome-tips .tip {
  display: flex; align-items: center; gap: 10px;
  color: var(--fg-2); font-size: 13px;
  background: var(--bg-3);
  padding: 10px 14px; border-radius: 12px;
  text-align: left;
}
.welcome-tips .tip svg { color: var(--accent); }
.welcome-tips .tip b { color: var(--fg); font-weight: 600; }

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

.chat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.chat-peer {
  background: transparent; padding: 4px 6px; border-radius: 8px;
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 400;
  justify-content: flex-start;
}
.chat-peer:hover { background: var(--bg-4); }
.chat-peer-info { flex: 1; min-width: 0; text-align: left; }
.chat-peer-name { font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-peer-status { font-size: 11px; color: var(--fg-3);
  display: flex; align-items: center; gap: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-peer-status .lock-icon { font-size: 10px; }
.chat-peer-status .online-text { color: var(--success); }

.chat-actions { display: flex; align-items: center; gap: 2px; position: relative; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: 100%; right: 0;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px;
  min-width: 200px;
  box-shadow: var(--shadow);
  z-index: 30;
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 4px;
}
.dropdown-menu button {
  background: transparent; color: var(--fg);
  text-align: left; padding: 8px 10px; font-weight: 400; font-size: 13px;
  border-radius: 6px;
}
.dropdown-menu button:hover { background: var(--bg-4); }
.dropdown-menu button.danger { color: var(--danger); }
.dropdown-menu button.danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }

.typing-indicator {
  padding: 4px 20px; color: var(--fg-3); font-size: 12px;
  font-style: italic; min-height: 18px;
}

/* ================================================================
   messages
   ================================================================ */
.messages {
  flex: 1; overflow-y: auto;
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: smooth;
}

.msg-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }

.msg {
  max-width: 65%;
  padding: 7px 12px;
  border-radius: 14px;
  background: var(--bubble-in);
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  cursor: default;
}
.msg.out { align-self: flex-end; background: var(--bubble-out); color: var(--bubble-out-fg); }
.msg.in  { align-self: flex-start; }
.msg.out  + .msg.out { border-top-right-radius: 4px; }
.msg.out:has(+ .msg.out) { border-bottom-right-radius: 4px; }
.msg.in  + .msg.in  { border-top-left-radius: 4px; }
.msg.in:has(+ .msg.in) { border-bottom-left-radius: 4px; }

.msg .body { white-space: pre-wrap; }
.msg .body a { color: inherit; text-decoration: underline; }
.msg .meta-row {
  display: inline-flex; align-items: center; gap: 4px;
  float: right; margin-left: 10px; margin-top: 4px;
  font-size: 10px; opacity: 0.65;
}
.msg.out .meta-row { color: rgba(255,255,255,0.8); }
.msg .ticks {
  display: inline-flex; align-items: center;
  color: currentColor; opacity: 0.8;
  margin-left: 2px;
}
.msg .ticks.read { color: #4dbdff; opacity: 1; }
.msg.out .ticks.read { color: #b6e8ff; }

.msg .sticker-img { max-width: 160px; max-height: 160px; display: block; }
.msg.sticker, .msg.gif { background: transparent; padding: 0; }
.msg.sticker .meta-row, .msg.gif .meta-row {
  position: absolute; bottom: 4px; right: 6px;
  background: rgba(0,0,0,0.35); padding: 1px 6px; border-radius: 8px;
  float: none; margin: 0; color: #fff;
}
.msg.gif img, .msg.gif video {
  max-width: 260px; max-height: 260px;
  display: block; border-radius: 10px;
  cursor: pointer;
}

.msg.file .file-card {
  display: flex; align-items: center; gap: 10px;
  min-width: 180px;
}
.msg.file .file-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.msg.file .file-name { font-weight: 500; word-break: break-all; }
.msg.file .file-size { font-size: 11px; opacity: 0.7; }
.msg.file .file-download { margin-left: 8px; }

.msg.is-gift { background: transparent !important; padding: 0 !important; max-width: 280px !important; }
.gift-card {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 18%, var(--bg-3)),
    color-mix(in srgb, var(--danger) 14%, var(--bg-3)));
  border-radius: 20px;
  padding: 18px 20px 14px;
  text-align: center;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.gift-emoji {
  font-size: 56px; line-height: 1;
  animation: gift-bob 2.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}
@keyframes gift-bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-4px) rotate(3deg); }
}
.gift-title {
  font-family: "Unbounded", "Inter", sans-serif;
  font-size: 16px; font-weight: 700;
  margin-top: 6px; color: var(--fg);
}
.gift-note {
  font-size: 14px; color: var(--fg-2);
  margin-top: 6px; font-style: italic;
}
.gift-label {
  font-size: 11px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-top: 8px;
}

.msg.voice .voice-card {
  display: flex; align-items: center; gap: 10px; min-width: 180px;
}
.msg.voice button.play { width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; padding: 0;
  font-size: 14px; }

.msg.circle_video video {
  width: 240px; height: 240px; border-radius: 50%;
  object-fit: cover; display: block; background: #000;
}
.msg.circle_video { background: transparent; padding: 0; }

.msg.image img {
  max-width: 320px; max-height: 420px;
  border-radius: 10px; display: block; cursor: pointer;
}
.msg.image { background: transparent; padding: 0; }

.msg .body a, .msg-link {
  color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  word-break: break-all;
}
.msg .body a:hover { text-decoration-color: currentColor; }

.link-preview {
  display: flex; flex-direction: column;
  margin-top: 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-3) 70%, transparent);
  border: 1px solid var(--border);
  overflow: hidden;
  text-decoration: none;
  color: var(--fg);
  max-width: 400px;
  transition: background 0.15s;
}
.link-preview:hover { background: var(--bg-3); }
.msg.out .link-preview {
  background: rgba(0,0,0,0.14);
  border-color: rgba(255,255,255,0.16);
  color: inherit;
}
.link-preview-img {
  width: 100%; max-height: 220px; object-fit: cover;
  background: var(--bg-4);
}
.link-preview-body {
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.link-preview-host {
  font-size: 11px; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.link-preview-title {
  font-weight: 600; font-size: 14px;
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.link-preview-desc {
  font-size: 13px; color: var(--fg-2);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.msg .reactions {
  margin-top: 4px;
  display: flex; flex-wrap: wrap; gap: 4px;
}
.msg .reaction-chip {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 12px;
  padding: 1px 6px;
  font-size: 11px;
  display: inline-flex; align-items: center; gap: 3px;
  cursor: pointer;
  user-select: none;
}
.msg.in .reaction-chip { background: var(--bg-4); border-color: var(--border); color: var(--fg); }
.msg .reaction-chip.mine { outline: 1.5px solid var(--accent); }

.msg .react-btn {
  position: absolute;
  top: -8px; right: -8px;
  opacity: 0;
  width: 26px; height: 26px;
  min-width: 26px; min-height: 26px;
  border-radius: 50%;
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--border); font-size: 12px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.12s;
  line-height: 1;
  flex-shrink: 0;
}
.msg:hover .react-btn,
.msg:hover .msg-menu-btn { opacity: 1; }
.msg.out .react-btn   { left: -8px; right: auto; }

.msg .msg-menu-btn {
  position: absolute; top: -8px; right: -36px;
  opacity: 0;
  width: 26px; height: 26px;
  min-width: 26px; min-height: 26px;
  border-radius: 50%;
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--border); font-size: 14px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; flex-shrink: 0;
  transition: opacity 0.12s;
}
.msg.out .msg-menu-btn { left: -36px; right: auto; }
@media (max-width: 820px) {
  .msg .msg-menu-btn { opacity: 1; right: -28px; }
  .msg.out .msg-menu-btn { left: -28px; right: auto; }
}

.msg-menu-pop {
  position: absolute; top: 24px; right: -6px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 40;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 160px;
}
.msg.out .msg-menu-pop { left: -6px; right: auto; }
.msg-menu-pop button {
  background: transparent; color: var(--fg);
  text-align: left; padding: 8px 10px; font-weight: 400; font-size: 13px;
  border-radius: 6px; min-height: 36px;
}
.msg-menu-pop button:hover { background: var(--bg-4); }
.msg-menu-pop button.danger { color: var(--danger); }
.msg-menu-pop button.danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }

.day-divider {
  text-align: center; color: var(--fg-3); font-size: 11px;
  padding: 8px 0; text-transform: uppercase;
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 85%, transparent); z-index: 1;
}

/* ================================================================
   reaction picker
   ================================================================ */
.reaction-picker {
  position: fixed; z-index: 45;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 24px; padding: 6px;
  display: flex; gap: 2px;
  box-shadow: var(--shadow);
}
.reaction-picker button {
  background: transparent; padding: 0;
  font-size: 20px; border-radius: 50%;
  width: 36px; height: 36px;
  min-width: 36px; min-height: 36px;
  flex-shrink: 0;
  line-height: 1;
}
.reaction-picker button:hover { background: var(--bg-4); transform: scale(1.25); }
.reaction-picker .more-btn { font-size: 18px; color: var(--fg-2); }

/* ================================================================
   composer
   ================================================================ */
.composer-reply {
  padding: 6px 14px; font-size: 12px; color: var(--fg-2);
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}

.composer {
  display: flex; gap: 6px;
  padding: 8px 10px; border-top: 1px solid var(--border);
  align-items: flex-end;
  background: var(--bg-2);
}
.composer textarea {
  flex: 1; resize: none;
  max-height: 140px; min-height: 40px;
  line-height: 1.4;
  background: var(--input-bg);
}
.send-btn { padding: 0 18px; height: 40px; }

/* ================================================================
   emoji / sticker / gif panel
   ================================================================ */
.emoji-panel {
  position: fixed; bottom: 60px; left: 20px; right: 20px;
  max-width: 420px; margin-left: auto;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 35;
  display: flex; flex-direction: column;
  height: 360px;
  overflow: hidden;
}
.emoji-tabs { display: flex; border-bottom: 1px solid var(--border); }
.emoji-tabs .tab {
  flex: 1; background: transparent; color: var(--fg-2);
  border-radius: 0; padding: 10px; font-weight: 500; font-size: 13px;
}
.emoji-tabs .tab.active {
  color: var(--accent); border-bottom: 2px solid var(--accent); background: transparent;
}
.emoji-tabs .tab:hover { background: var(--bg-4); color: var(--fg); }

.emoji-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.panel-content {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  padding: 0;
}
.emoji-search-row { padding: 8px; border-bottom: 1px solid var(--border); }
.emoji-search-row input { padding: 6px 10px; }

.emoji-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 2px;
  overflow-y: auto;
  padding: 6px;
}
.emoji-grid button {
  background: transparent; padding: 4px;
  font-size: 22px; line-height: 1;
  border-radius: 6px; height: 36px;
}
.emoji-grid button:hover { background: var(--bg-4); }

.emoji-categories {
  display: flex; gap: 2px; padding: 4px 6px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}
.emoji-categories button {
  background: transparent; color: var(--fg-2); font-size: 16px;
  padding: 4px 6px; border-radius: 4px; flex-shrink: 0;
}
.emoji-categories button.active { color: var(--accent); background: var(--bg-4); }

.sticker-header { padding: 8px; border-bottom: 1px solid var(--border);
  display: flex; gap: 6px; align-items: center; }
.sticker-body { flex: 1; overflow-y: auto; padding: 6px; }
.sticker-pack-title {
  font-size: 11px; color: var(--fg-3); text-transform: uppercase;
  padding: 8px 4px 4px;
}
.sticker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
}
.sticker-grid img {
  width: 100%; height: 72px; object-fit: contain;
  background: var(--bg-4); border-radius: 8px; padding: 4px;
  cursor: pointer;
  transition: transform 0.1s;
}
.sticker-grid img:hover { transform: scale(1.08); background: var(--bg-2); }

.gif-grid {
  flex: 1; overflow-y: auto; padding: 6px;
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.gif-grid img {
  width: 100%; height: 120px; object-fit: cover;
  border-radius: 8px; cursor: pointer; background: var(--bg-4);
}

/* ================================================================
   modal
   ================================================================ */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.modal-card {
  background: var(--bg-3); border-radius: 14px;
  width: 100%; max-width: 480px;
  max-height: calc(100vh - 32px);
  position: relative;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-card.small-card { max-width: 380px; padding: 20px; gap: 10px; }
.modal-card.small-card h3 { font-size: 16px; }
.modal-close {
  position: absolute; top: 10px; right: 10px;
  background: transparent; color: var(--fg-2);
  /* фикс: задаём точные размеры, иначе глобальный min-height:44 делает вытянутым */
  width: 36px !important; height: 36px !important;
  min-width: 36px; min-height: 36px;
  padding: 0;
  border-radius: 50%;
  z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--bg-4); color: var(--fg); }
.modal-close svg { width: 18px; height: 18px; pointer-events: none; }

/* ================================================================
   profile modal
   ================================================================ */
/* ИТД-style profile card: banner + overlap avatar + quick-actions */
#modal-profile .modal-card.profile-card {
  padding: 0; gap: 0;
  max-width: 520px;
  display: flex; flex-direction: column;
  max-height: calc(100dvh - 32px);
  /* скроллим внутри: banner + top + поля + actions */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.profile-banner {
  height: 180px;
  background-color: var(--bg-4);
  background-size: cover; background-position: center;
  position: relative;
  flex-shrink: 0;
}
.profile-banner.empty {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #ff6b9d));
}
.profile-banner.empty::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(40% 40% at 20% 30%, rgba(255,255,255,0.15), transparent 70%),
    radial-gradient(40% 40% at 80% 70%, rgba(255,255,255,0.1),  transparent 70%);
}
.profile-top {
  position: relative;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 20px;
  margin-top: -64px;                        /* аватар поверх банера */
  min-height: 64px;
}
.profile-avatar-wrap { position: relative; }
#profile-avatar.huge {
  border: 4px solid var(--bg-3);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.profile-online {
  position: absolute; bottom: 6px; right: 6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--fg-3); border: 3px solid var(--bg-3);
}
.profile-online.online { background: var(--success); }
.profile-quick-actions {
  display: flex; gap: 8px;
  margin-bottom: 8px;
}
.profile-qa-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-4);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 8px 14px;
  font-size: 13px; font-weight: 600;
  min-height: 36px;
  transition: var(--transition, 0.15s);
}
.profile-qa-btn:hover { background: var(--border); transform: translateY(-1px); }
.profile-qa-btn svg { width: 18px; height: 18px; color: var(--accent); }

.profile-names { padding: 14px 20px 4px; }
.profile-display {
  font-family: "Unbounded", "Inter", sans-serif;
  font-size: 22px; font-weight: 700; word-break: break-word;
  letter-spacing: -0.01em;
}
.profile-username { color: var(--fg-3); font-size: 14px; margin-top: 2px; }
.profile-status-line { color: var(--fg-2); font-size: 13px; margin-top: 6px; }

.profile-bio {
  padding: 6px 20px 14px;
  font-size: 15px; line-height: 1.5;
  color: var(--fg);
}
.profile-bio.private { color: var(--fg-3); font-style: italic; }

#profile-fields { padding: 0 20px 14px; display: flex; flex-direction: column; gap: 10px; }
#profile-actions { padding: 0 20px 20px; }

.profile-fields { display: flex; flex-direction: column; gap: 10px; }
.profile-field {
  display: flex; flex-direction: column; gap: 2px;
}
.profile-field .label {
  font-size: 11px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.5px;
}
.profile-field .value { color: var(--fg); word-break: break-word; font-size: 14px; }
.profile-field.hidden-field .value {
  font-style: italic; color: var(--fg-3);
}

.profile-actions {
  display: flex; flex-direction: column; gap: 6px;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.profile-actions button {
  background: var(--bg-4); color: var(--fg); font-weight: 500; text-align: left;
  padding: 10px 12px;
}
.profile-actions button:hover { background: var(--border); }
.profile-actions button.danger { color: var(--danger); }
.profile-actions button.accent { background: var(--accent); color: var(--accent-fg); }

/* ================================================================
   settings modal
   ================================================================ */
.settings-card {
  max-width: 720px; height: 560px; max-height: calc(100vh - 32px);
  flex-direction: row;
}
.settings-tabs {
  background: var(--bg-2); border-right: 1px solid var(--border);
  width: 180px; padding: 12px 8px;
  display: flex; flex-direction: column; gap: 2px;
  flex-shrink: 0;
}
.settings-tabs .tab {
  background: transparent; color: var(--fg-2); text-align: left;
  padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: 13px;
}
.settings-tabs .tab:hover { background: var(--bg-4); color: var(--fg); }
.settings-tabs .tab.active { background: var(--accent); color: var(--accent-fg); }

.settings-body {
  flex: 1; padding: 20px 24px; overflow-y: auto;
}
.settings-pane { display: flex; flex-direction: column; gap: 14px; }
.settings-pane h3 { font-size: 16px; margin-bottom: 4px; }

.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row > label { font-size: 12px; color: var(--fg-2); }
.form-row.checkbox-row {
  flex-direction: row; align-items: center; gap: 10px;
}
.form-row.checkbox-row input[type="checkbox"] { width: auto; }
.form-row.checkbox-row label { margin: 0; }

.photo-picker { display: flex; align-items: center; gap: 16px; }
.banner-picker {
  width: 100%; height: 120px;
  background-color: var(--bg-4);
  background-size: cover; background-position: center;
  border-radius: 14px;
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.banner-picker::before {
  content: "Обложка профиля";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-3); font-size: 13px;
  pointer-events: none;
}
.banner-picker[style*="background-image"]::before { display: none; }

/* ========= privacy — FIXED: grid layout without overlap ========= */
.privacy-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.privacy-row:last-of-type { border-bottom: none; }
.privacy-label {
  font-size: 14px; color: var(--fg);
  min-width: 0; word-wrap: break-word;
}
.privacy-select {
  width: 100%;
}

.accent-row { display: flex; gap: 8px; align-items: center; }
.accent-swatch {
  width: 28px; height: 28px; border-radius: 50%; padding: 0;
  border: 2px solid transparent;
}
.accent-swatch.active { border-color: var(--fg); }

.my-packs { display: flex; flex-direction: column; gap: 12px; }
.pack-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px;
}
.pack-card-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.pack-card-title { font-weight: 600; flex: 1; }
.pack-stickers {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
}
.pack-stickers .sticker-wrap { position: relative; background: var(--bg-4); border-radius: 8px; }
.pack-stickers img { width: 100%; height: 60px; object-fit: contain; padding: 4px; }
.cp-drop {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  color: var(--fg-2);
  cursor: pointer;
  transition: var(--transition, 0.15s);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--bg-2);
}
.cp-drop:hover, .cp-drop.over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-2));
}
.cp-drop u { text-decoration: underline; color: var(--accent); }
.cp-preview {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px; margin-top: 10px;
}
.cp-chip {
  position: relative;
  background: var(--bg-4);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
}
.cp-chip img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.cp-chip-x {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  min-width: 20px; min-height: 20px;
  background: var(--danger); color: #fff;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.cp-chip-x svg { width: 12px; height: 12px; }

.pack-stickers .del {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff;
  padding: 0; font-size: 12px; display: flex; align-items: center; justify-content: center;
}

.invite {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px; color: var(--fg-2);
  cursor: pointer; padding: 6px 8px; border-radius: 6px;
  word-break: break-all;
}
.invite:hover { background: var(--bg-4); }
.invite.used { opacity: 0.5; text-decoration: line-through; cursor: default; }

.blocked-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px; border-bottom: 1px solid var(--border);
}

/* ================================================================
   call UI
   ================================================================ */
.call-card {
  text-align: center; padding: 32px 24px; gap: 16px;
  display: flex; flex-direction: column; align-items: center;
  max-width: 360px;
}
.call-name { font-size: 22px; font-weight: 600; }
.call-sub { color: var(--fg-2); font-size: 13px; }
.call-buttons { display: flex; gap: 16px; margin-top: 16px; }
.call-btn {
  width: 64px; height: 64px; border-radius: 50%;
  min-width: 64px; min-height: 64px;
  padding: 0; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-4); color: var(--fg);
  flex-shrink: 0;
}
.call-btn.accept { background: var(--success); color: #fff; }
.call-btn.reject { background: var(--danger); color: #fff; }

.call-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: #000;
  display: flex; flex-direction: column;
}
.call-remote { flex: 1; position: relative; overflow: hidden; }
.call-remote video { width: 100%; height: 100%; object-fit: cover; background: #111; }
.call-info {
  position: absolute; top: 20px; left: 20px;
  display: flex; align-items: center; gap: 14px;
  background: rgba(0,0,0,0.45); padding: 10px 14px; border-radius: 12px;
  color: #fff;
}
.call-info .call-name { font-size: 16px; color: #fff; }
.call-info .call-sub { color: rgba(255,255,255,0.7); }

.call-self {
  position: absolute; bottom: 120px; right: 20px;
  width: 160px; height: 220px; background: #000;
  border-radius: 12px; overflow: hidden;
  border: 2px solid rgba(255,255,255,0.18);
}
.call-self video { width: 100%; height: 100%; object-fit: cover; }

.call-controls {
  padding: 20px; display: flex; gap: 18px; justify-content: center;
  background: rgba(0,0,0,0.65);
}
.call-controls .call-btn {
  width: 56px; height: 56px; font-size: 22px;
  background: rgba(255,255,255,0.15); color: #fff;
}
.call-controls .call-btn.active { background: var(--accent); }
.call-controls .call-btn.reject { background: var(--danger); }

/* ================================================================
   toast + lightbox
   ================================================================ */
.ban-banner {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(10,0,0,0.94);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(10px);
}
.ban-card {
  background: var(--bg-3);
  border-radius: 20px;
  padding: 36px 30px 28px;
  max-width: 440px; width: 100%;
  text-align: center;
  border: 2px solid var(--danger);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 6px color-mix(in srgb, var(--danger) 20%, transparent);
  animation: ban-in 0.45s cubic-bezier(.2,.9,.3,1);
}
@keyframes ban-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: none; }
}
.ban-icon { font-size: 64px; margin-bottom: 10px; }
.ban-card h2 {
  font-family: "Unbounded", "Inter", sans-serif;
  font-size: 24px; font-weight: 800;
  color: var(--danger);
  margin-bottom: 10px;
}
.ban-reason {
  color: var(--fg);
  font-size: 15px; line-height: 1.5;
  margin-bottom: 8px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  padding: 10px 14px; border-radius: 10px;
}
.ban-card .muted { margin: 12px 0 18px; }
.ban-card .primary { width: 100%; }

.update-banner {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 550;
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(0,0,0,0.4);
  border-radius: 14px;
  padding: 10px 14px;
  width: min(560px, calc(100vw - 24px));
  animation: toast-in 0.25s;
}
.update-banner-body {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px;
}
.update-banner-body > div:first-child { flex: 1; }
.update-banner-body .muted { font-size: 12px; margin-top: 2px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 24px;
  font-size: 13px; z-index: 500;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s;
}
@keyframes toast-in {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to   { transform: translate(-50%, 0);     opacity: 1; }
}

/* ================================================================
   tooltip — кастомные на hover
   ================================================================ */
.tooltip {
  position: fixed; z-index: 600;
  background: var(--bg-4);
  color: var(--fg);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0,0,0,0.32);
  pointer-events: none;
  white-space: nowrap;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis;
  animation: tip-in 0.16s ease-out;
}
.tooltip.hidden { display: none; }
@keyframes tip-in {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@media (max-width: 820px) {
  .tooltip { display: none !important; }
}

.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; }

/* ================================================================
   gift grid
   ================================================================ */
.gift-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin: 10px 0;
}
.gift-grid button {
  background: var(--bg-2); color: var(--fg);
  font-size: 32px; padding: 14px 0;
  border: 2px solid transparent; height: auto;
}
.gift-grid button.selected { border-color: var(--accent); }
.gift-grid button:hover { background: var(--bg-4); }

/* ================================================================
   theme gallery (settings → theme tab)
   ================================================================ */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.theme-card {
  background: var(--bg-2); color: var(--fg);
  padding: 8px; border-radius: 12px;
  border: 2px solid transparent;
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; font-weight: 500;
  text-align: center;
  transition: border-color var(--transition), transform var(--transition);
}
.theme-card:hover { transform: translateY(-2px); background: var(--bg-4); }
.theme-card.active { border-color: var(--accent); }
.theme-name { font-size: 12px; color: var(--fg); }
.theme-badge {
  display: inline-block; margin-left: 2px;
  font-size: 9px; padding: 1px 5px; border-radius: 6px;
  background: var(--accent); color: var(--accent-fg);
  text-transform: uppercase; letter-spacing: 0.4px;
  vertical-align: middle;
}
.theme-preview {
  position: relative; height: 58px; border-radius: 8px;
  background: var(--tp-bg, #222);
  overflow: hidden; border: 1px solid var(--border);
}
.theme-preview::before {
  content: ""; position: absolute; inset: 6px auto 6px 6px;
  width: 32%; border-radius: 5px; background: var(--tp-bg2, #333);
}
.theme-preview::after {
  content: ""; position: absolute; top: 10px; right: 8px; bottom: 26px;
  width: 46%; border-radius: 10px 10px 10px 2px;
  background: var(--tp-acc, #4a7de8);
}
.theme-preview .dot {
  position: absolute; bottom: 10px; right: 8px;
  width: 36%; height: 7px; border-radius: 4px;
  background: var(--tp-fg, #fff); opacity: 0.85;
}
.haip-preview {
  background: #151518;
  border: 1px solid rgba(255,255,255,0.1);
}
.haip-preview::before {
  content: ""; position: absolute; inset: 8px auto 8px 8px;
  width: 28%; border-radius: 6px;
  background: #222222;
}
.haip-preview::after {
  content: "31"; position: absolute; top: 10px; right: 10px;
  padding: 4px 9px; border-radius: 9999px;
  background: #ffffff; color: #000;
  font-family: "Unbounded", "Inter", sans-serif;
  font-weight: 900; font-size: 10px;
  width: auto; height: auto;
}

.aurora-preview {
  background:
    radial-gradient(circle at 20% 30%, rgba(77,189,255,0.55), transparent 55%),
    radial-gradient(circle at 75% 70%, rgba(161,107,255,0.55), transparent 55%),
    linear-gradient(135deg, #070a18 0%, #0a0d1a 100%);
  background-size: 180% 180%;
  animation: aurora-preview-shift 6s ease-in-out infinite;
}
@keyframes aurora-preview-shift {
  0%, 100% { background-position: 0% 0%; }
  50%      { background-position: 100% 100%; }
}
.aurora-preview::before, .aurora-preview::after { display: none; }

.neon-preview {
  background:
    repeating-linear-gradient(180deg,
      transparent 0, transparent 3px,
      rgba(0,240,255,0.12) 3px, rgba(0,240,255,0.12) 4px),
    radial-gradient(circle at 30% 40%, rgba(0,240,255,0.35), transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(255,45,117,0.35), transparent 60%),
    #05060a;
  border: 1px solid rgba(0,240,255,0.35);
  animation: neon-preview-flicker 3.5s linear infinite;
}
@keyframes neon-preview-flicker {
  0%, 90%, 100% { filter: none; }
  91%, 93%      { filter: brightness(1.3); }
  92%           { filter: brightness(0.7); }
}
.neon-preview::before, .neon-preview::after { display: none; }

.theme-badge.anim {
  background: linear-gradient(135deg, #00f0ff, #ff2d75);
  color: #001018;
  font-size: 10px;
  padding: 0 4px;
}

/* ================================================================
   31HAIP theme — admin-only
   Загружается через data-theme="31haip" + data-layout="31haip"
   Источник: xn--d1ah4a.com (реально скопировано с :root vars)
   Ключевое:
     - Inter (400-700) + Unbounded (400/700/900) для заголовков
     - палитра #151518 / #222222 / accent #0080FF
     - primary-кнопка БЕЛАЯ #fff на чёрном тексте
     - glass-элементы rgba(47,47,47,0.5) + blur(16px)
     - радиусы 32px / 20px / 18px / pill
     - transition 0.2s cubic-bezier(0.5, 0, 0, 1) (sharp-out)
   ================================================================ */
[data-theme="31haip"] {
  --bg:            #151518;
  --bg-2:          #1a1a1d;
  --bg-3:          #222222;
  --bg-4:          #2a2a2c;
  --fg:            #f5f5f5;
  --fg-2:          rgba(255,255,255,0.7);
  --fg-3:          rgba(255,255,255,0.5);
  --accent:        #0080FF;
  --accent-fg:     #ffffff;
  --danger:        #f91880;      /* like-pink ИТД */
  --success:       #00ba7c;      /* repost-green ИТД */
  --border:        rgba(255,255,255,0.1);
  --shadow:        0 4px 16px rgba(0,0,0,0.2);
  --bubble-in:     #222222;
  --bubble-out:    #0080FF;
  --bubble-out-fg: #ffffff;
  --input-bg:      #222224;

  --radius:        18px;
  --radius-bubble: 18px;
  --radius-card:   20px;
  --transition:    0.2s cubic-bezier(0.5, 0, 0, 1);

  /* ИТД-specific tokens */
  --haip-glass:    rgba(47,47,47,0.5);
  --haip-hover:    rgba(255,255,255,0.08);
  --haip-active:   rgba(255,255,255,0.12);
  --haip-btn-primary-bg:   #ffffff;
  --haip-btn-primary-text: #000000;
  --haip-nav-gradient: linear-gradient(to bottom, transparent 0%, rgba(21,21,24,0.3) 30%, rgba(21,21,24,0.8) 100%);
}

body[data-theme="31haip"] {
  background: #151518;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-size: 15px;
  letter-spacing: -0.005em;
}

[data-layout="31haip"] h1,
[data-layout="31haip"] h2,
[data-layout="31haip"] h3,
[data-layout="31haip"] .me-name,
[data-layout="31haip"] .profile-display,
[data-layout="31haip"] .chat-peer-name,
[data-layout="31haip"] .auth-card h1,
[data-layout="31haip"] .call-name {
  font-family: "Unbounded", "Inter", sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* --- scrollbars: тонкие, минорный штрих --- */
[data-layout="31haip"] *::-webkit-scrollbar { width: 8px; height: 8px; }
[data-layout="31haip"] *::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 9999px;
}
[data-layout="31haip"] *::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
[data-layout="31haip"] *::-webkit-scrollbar-track { background: transparent; }

/* --- sidebar: 260px, glass, с fade-градиентом сверху --- */
[data-layout="31haip"] .sidebar {
  width: 260px;
  background: var(--bg);
  border-right: 1px solid var(--border);
}
[data-layout="31haip"] .me-bar {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
[data-layout="31haip"] .me-name { font-size: 16px; font-weight: 700; }
[data-layout="31haip"] .me-username { color: var(--fg-3); font-size: 13px; font-family: "Inter"; }

/* --- sidebar-search: pill-капсула с 20px радиусом --- */
[data-layout="31haip"] .sidebar-search input {
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  transition: var(--transition);
}
[data-layout="31haip"] .sidebar-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,128,255,0.15);
}

/* --- chat list items: плоские, hover = белая подложка 8% --- */
[data-layout="31haip"] .chat-item {
  padding: 10px 12px;
  margin: 1px 6px;
  border-radius: 12px;
  transition: background var(--transition);
}
[data-layout="31haip"] .chat-item:hover {
  background: var(--haip-hover);
  transform: none;
}
[data-layout="31haip"] .chat-item.active {
  background: var(--haip-active);
  color: var(--fg);
}
[data-layout="31haip"] .chat-item.active .chat-preview,
[data-layout="31haip"] .chat-item.active .chat-ts { color: var(--fg-3); }

/* --- chat-header: glass с backdrop-filter blur(16px) --- */
[data-layout="31haip"] .chat-header {
  background: rgba(21,21,24,0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
[data-layout="31haip"] .chat-peer {
  background: transparent;
  padding: 4px 8px;
  border-radius: 12px;
  transition: var(--transition);
}
[data-layout="31haip"] .chat-peer:hover { background: var(--haip-hover); }
[data-layout="31haip"] .chat-peer-name { font-weight: 700; letter-spacing: -0.01em; }
[data-layout="31haip"] .chat-peer-status { color: var(--fg-3); }

/* --- chat-actions: круглые 36px glass-кнопки --- */
[data-layout="31haip"] .chat-actions { gap: 4px; }
[data-layout="31haip"] .chat-actions .icon-btn {
  background: var(--haip-glass);
  backdrop-filter: blur(16px);
  border-radius: 50%;
  width: 36px; height: 36px;
  color: var(--fg);
  transition: var(--transition);
  box-shadow: var(--shadow);
}
[data-layout="31haip"] .chat-actions .icon-btn:hover {
  background: rgba(47,47,47,0.8);
  transform: translateY(-1px);
}

/* --- messages area: на ПК используем доступную ширину, но не ультра-широко --- */
[data-layout="31haip"] .messages {
  width: 100%;
  max-width: none;
  padding: 14px 24px 14px;
}
/* На больших экранах — мягкое центрирование (как в ИТД), но только 900+ */
@media (min-width: 1200px) {
  [data-layout="31haip"] .messages { max-width: 900px; margin: 0 auto; }
  [data-layout="31haip"] .composer  { max-width: 900px; margin: 0 auto; }
}

/* --- message bubbles: radius 18px, без тени у входящих --- */
[data-layout="31haip"] .msg {
  border-radius: 18px;
  padding: 9px 14px;
  font-size: 15px;
  font-family: "Inter";
  animation: haip-msg-in 0.22s cubic-bezier(0.5, 0, 0, 1);
}
[data-layout="31haip"] .msg.in {
  background: var(--bg-3);
  color: var(--fg);
}
[data-layout="31haip"] .msg.out {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}
@keyframes haip-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* --- reactions: pill chips с рамкой --- */
[data-layout="31haip"] .msg .reaction-chip {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 2px 8px;
  font-size: 12px;
}
[data-layout="31haip"] .msg .reaction-chip.mine {
  outline: none;
  background: rgba(0,128,255,0.18);
  border-color: var(--accent);
  color: var(--accent);
}

/* --- composer: glass, тонкая верхняя линия --- */
[data-layout="31haip"] .composer {
  background: rgba(21,21,24,0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  gap: 6px;
  width: 100%;
}
[data-layout="31haip"] .composer textarea {
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 10px 16px;
  font-family: "Inter";
  font-size: 15px;
  transition: var(--transition);
}
[data-layout="31haip"] .composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,128,255,0.15);
}
[data-layout="31haip"] .composer .icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: transparent;
  color: var(--fg-2);
  transition: var(--transition);
}
[data-layout="31haip"] .composer .icon-btn:hover {
  background: var(--haip-hover);
  color: var(--fg);
}

/* --- send-btn: БЕЛАЯ с чёрным текстом (фирменная ИТД primary) --- */
[data-layout="31haip"] .send-btn {
  background: var(--haip-btn-primary-bg);
  color: var(--haip-btn-primary-text);
  border-radius: 9999px;
  padding: 0 22px; height: 38px;
  font-family: "Unbounded";
  font-weight: 700;
  font-size: 14px;
  box-shadow: none;
  transition: var(--transition);
  animation: none;
}
[data-layout="31haip"] .send-btn:hover {
  background: rgba(255,255,255,0.9);
  transform: none;
}

/* --- общие primary-кнопки: тоже БЕЛЫЕ на тёмном фоне --- */
[data-layout="31haip"] button:not(.icon-btn):not(.small):not(.theme-card):not(.modal-close):not(.accent-swatch):not(.tab):not(.call-btn):not(.send-btn):not(.danger):not(.reaction-chip) {
  background: var(--haip-btn-primary-bg);
  color: var(--haip-btn-primary-text);
  border-radius: 9999px;
  font-family: "Unbounded";
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  padding: 10px 20px;
  box-shadow: none;
  transition: var(--transition);
}
[data-layout="31haip"] button:not(.icon-btn):not(.small):not(.theme-card):not(.modal-close):not(.accent-swatch):not(.tab):not(.call-btn):not(.send-btn):not(.danger):not(.reaction-chip):hover {
  background: rgba(255,255,255,0.9);
}
[data-layout="31haip"] button.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 9999px;
  font-family: "Unbounded";
  font-weight: 700;
  box-shadow: none;
}
[data-layout="31haip"] button.danger:hover {
  background: rgba(249,24,128,0.12);
}

/* --- small/secondary-кнопки: glass rgba(47,47,47,.5) --- */
[data-layout="31haip"] button.small {
  background: var(--haip-glass);
  backdrop-filter: blur(16px);
  border-radius: 9999px;
  color: var(--fg);
  border: none;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow);
}
[data-layout="31haip"] button.small:hover { background: rgba(47,47,47,0.85); }
[data-layout="31haip"] label.btn-like {
  background: var(--haip-glass);
  backdrop-filter: blur(16px);
  border-radius: 9999px;
  padding: 6px 14px;
  box-shadow: var(--shadow);
}

/* --- inputs в формах/модалках --- */
[data-layout="31haip"] input:not([type="checkbox"]):not([type="file"]),
[data-layout="31haip"] textarea,
[data-layout="31haip"] select {
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 12px 16px;
  font-family: "Inter";
  transition: var(--transition);
}
[data-layout="31haip"] input:focus,
[data-layout="31haip"] textarea:focus,
[data-layout="31haip"] select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,128,255,0.15);
}

/* --- auth-card --- */
[data-layout="31haip"] .auth-card {
  background: var(--bg-3);
  border-radius: 24px;
  border: 1px solid var(--border);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
[data-layout="31haip"] .auth-card h1 {
  font-family: "Unbounded"; font-weight: 900; color: var(--fg);
  font-size: 26px;
}

/* --- модалки: полу-прозрачный слой + solid card --- */
[data-layout="31haip"] .modal {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
}
[data-layout="31haip"] .modal-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* --- reaction picker --- */
[data-layout="31haip"] .reaction-picker {
  background: var(--haip-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 9999px;
  box-shadow: var(--shadow);
}
[data-layout="31haip"] .reaction-picker button:hover {
  background: var(--haip-hover);
  transform: scale(1.25);
}

/* --- settings tabs: активная вкладка — фон accent 20%, текст белый --- */
[data-layout="31haip"] .settings-tabs .tab {
  font-family: "Inter";
  color: var(--fg-2);
  border-radius: 12px;
}
[data-layout="31haip"] .settings-tabs .tab:hover { background: var(--haip-hover); color: var(--fg); }
[data-layout="31haip"] .settings-tabs .tab.active {
  background: rgba(0,128,255,0.18);
  color: var(--accent);
  box-shadow: none;
}

/* --- emoji / sticker / gif tabs --- */
[data-layout="31haip"] .emoji-tabs .tab.active {
  color: var(--fg);
  border-bottom: 2px solid var(--accent);
}

/* --- online-dot + unread badge (используем accent, не градиенты) --- */
[data-layout="31haip"] .chat-item .online-dot {
  background: var(--success);
  box-shadow: 0 0 0 2px var(--bg);
}
[data-layout="31haip"] .unread-badge {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
  font-family: "Inter";
}

/* --- chat-peer-status online --- */
[data-layout="31haip"] .chat-peer-status .online-text { color: var(--success); }

/* --- avatar --- */
[data-layout="31haip"] .avatar {
  transition: transform var(--transition);
}

/* --- fade-in на #view-app переключении в admin-тему --- */
[data-layout="31haip"] #view-app { animation: haip-fade 0.3s cubic-bezier(0.5, 0, 0, 1); }
@keyframes haip-fade {
  from { opacity: 0; transform: scale(0.99); }
  to   { opacity: 1; transform: none; }
}

/* --- admin-panel header внутри sidebar --- */
[data-layout="31haip"] .admin-block .section-title {
  font-family: "Unbounded"; font-weight: 700; letter-spacing: 0.06em;
  color: var(--fg-3);
}

/* --- секция профиля в модалке --- */
[data-layout="31haip"] .profile-display { font-family: "Unbounded"; font-weight: 700; }
[data-layout="31haip"] .profile-field .label {
  font-family: "Inter"; letter-spacing: 0.04em;
}

/* --- callы: круглые, чёткие, без градиентов --- */
[data-layout="31haip"] .call-btn {
  border-radius: 50%;
  box-shadow: var(--shadow);
}
[data-layout="31haip"] .call-btn.accept { background: var(--success); }
[data-layout="31haip"] .call-btn.reject { background: var(--danger); }

/* --- 31HAIP: галочки ярче, исходящие — прозрачный цвет поверх accent --- */
[data-layout="31haip"] .msg.out .ticks       { color: rgba(255,255,255,0.75); }
[data-layout="31haip"] .msg.out .ticks.read  { color: #ffffff; }
[data-layout="31haip"] .msg.in  .ticks.read  { color: var(--accent); }

/* --- 31HAIP фикс: icon-btn в composer светлее --- */
[data-layout="31haip"] .composer .icon-btn { color: var(--fg-2); }
[data-layout="31haip"] .composer .icon-btn:hover { color: var(--fg); background: var(--haip-hover); }

/* --- 31HAIP: chat-actions крупнее видно --- */
[data-layout="31haip"] .chat-actions .icon-btn svg { width: 20px; height: 20px; }

/* --- 31HAIP фикс: theme-card активной подсветить accent-рамкой жирнее --- */
[data-layout="31haip"] .theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,128,255,0.3); }

/* --- 31HAIP фикс: modal-close circle корректный --- */
[data-layout="31haip"] .modal-close { background: var(--haip-glass); backdrop-filter: blur(10px); }
[data-layout="31haip"] .modal-close:hover { background: rgba(255,255,255,0.15); }

/* ================================================================
   31HAIP DOM-overlay: узкий icon-rail + glass-декор
   Активируется, когда JS вставляет #haip-rail и #view-app.haip-mode
   ================================================================ */
.haip-glow {
  position: fixed; inset: 0;
  z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 50% at 10% 30%, rgba(0,128,255,0.10), transparent 70%),
    radial-gradient(50% 40% at 90% 80%, rgba(249,24,128,0.08), transparent 70%);
  filter: blur(40px);
  animation: haip-glow-shift 22s ease-in-out infinite alternate;
}
@keyframes haip-glow-shift {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(20px,-10px) scale(1.05); }
}

#view-app.haip-mode {
  display: grid !important;
  grid-template-columns: 76px 320px 1fr;
  grid-template-rows: 1fr;
  width: 100%; height: 100vh;
}
#view-app.haip-mode .sidebar {
  grid-column: 2; grid-row: 1;
  width: auto;        /* отменяем фиксированную ширину */
  position: static;   /* отменяем мобильный absolute */
  display: flex;      /* восстанавливаем flex column для внутренностей */
  inset: auto;
}
#view-app.haip-mode .chat-area {
  grid-column: 3; grid-row: 1;
  position: static; inset: auto;
  display: flex; flex-direction: column;
  min-width: 0;
}

/* Rail слева */
.haip-rail {
  grid-column: 1;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 12px 0;
}
.haip-rail-head {
  padding: 4px 0 16px;
}
.haip-brand {
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--haip-btn-primary-bg, #fff);
  color: var(--haip-btn-primary-text, #000);
  font-family: "Unbounded", sans-serif;
  font-weight: 900; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow);
}
.haip-rail-nav {
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
  width: 100%;
  align-items: center;
  padding: 12px 0;
}
.haip-rail-item {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: transparent;
  color: var(--fg-2);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition, 0.2s);
  min-height: 48px; padding: 0;
}
.haip-rail-item:hover {
  background: var(--haip-hover, rgba(255,255,255,0.08));
  color: var(--fg);
}
.haip-rail-item.active {
  background: var(--haip-active, rgba(255,255,255,0.12));
  color: var(--accent);
}
.haip-rail-item svg { width: 22px; height: 22px; }

.haip-rail-foot { padding: 8px 0; }
.haip-rail-me {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-3);
  color: var(--fg);
  padding: 0; font-weight: 700;
  background-size: cover; background-position: center;
  transition: transform var(--transition, 0.2s);
}
.haip-rail-me:hover { transform: scale(1.06); }

/* У haip-rail скрываем классический btn-admin и btn-settings в me-bar — они уехали в rail */
#view-app.haip-mode #btn-admin { display: none; }
#view-app.haip-mode .me-bar #btn-settings,
#view-app.haip-mode .me-bar #btn-new-chat { display: none; }

/* rail переключает: чаты ↔ контакты */
#view-app.haip-mode[data-sidebar-tab="contacts"] #chats,
#view-app.haip-mode[data-sidebar-tab="contacts"] #search-results,
#view-app.haip-mode[data-sidebar-tab="contacts"] .sidebar-search { display: none; }
#view-app.haip-mode:not([data-sidebar-tab="contacts"]) #sidebar-contacts { display: none; }

#sidebar-contacts { flex: 1; overflow-y: auto; padding: 4px; }
#sidebar-contacts .pad { padding: 16px; }

/* На мобилке rail превращается в нижний таб-бар */
@media (max-width: 820px) {
  #view-app.haip-mode {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr auto;
  }
  #view-app.haip-mode .sidebar,
  #view-app.haip-mode .chat-area {
    grid-column: 1;
    grid-row: 1;
    position: absolute; inset: 0;
  }
  #view-app.haip-mode.chat-open .sidebar   { display: none; }
  #view-app.haip-mode:not(.chat-open) .chat-area { display: none; }
  .haip-rail {
    grid-column: 1; grid-row: 2;
    width: 100%;
    flex-direction: row;
    padding: 6px 12px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
    justify-content: space-around;
    gap: 4px;
    z-index: 20;
  }
  .haip-rail-head { display: none; }
  .haip-rail-nav {
    flex-direction: row; gap: 4px;
    padding: 0;
    justify-content: space-around;
    width: 100%;
  }
  .haip-rail-foot { padding: 0; }
  .haip-rail-item { width: 52px; height: 52px; }
}

/* ================================================================
   mobile tweaks — touch-size 44+, safe-area, full-screen modals
   ================================================================ */
.mobile-only { display: none; }
@media (max-width: 820px) {
  body { font-size: 16px; }

  /* layout: sidebar ↔ chat-area как две стопки */
  .sidebar { width: 100%; position: absolute; inset: 0; z-index: 2; }
  .chat-area { position: absolute; inset: 0; z-index: 1; }
  #view-app.chat-open .sidebar { display: none; }
  #view-app.chat-open .chat-area { z-index: 5; }
  #view-app:not(.chat-open) .chat-area { display: none; }
  .mobile-only { display: inline-flex; }

  /* touch-friendly */
  .icon-btn { width: 44px; height: 44px; border-radius: 12px; }
  .icon-btn svg { width: 22px; height: 22px; }
  button, .sidebar-bottom-btn { min-height: 46px; }
  button.small { min-height: 40px; padding: 10px 14px; font-size: 14px; }

  /* chat-list: крупнее */
  .chat-item { padding: 12px 12px; }
  .chat-name { font-size: 16px; }
  .chat-preview { font-size: 14px; }
  .avatar { width: 48px; height: 48px; font-size: 18px; }
  .me-avatar { width: 40px; height: 40px; }

  /* chat-header */
  .chat-header { padding: 10px 12px; gap: 6px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .chat-peer-name { font-size: 16px; }
  .chat-peer-status { font-size: 12px; }

  /* messages: шире bubbles, крупный шрифт */
  .messages { padding: 12px 12px; }
  .msg { max-width: 85%; font-size: 16px; padding: 10px 14px; }
  .msg .meta-row { font-size: 11px; }
  .msg .react-btn { opacity: 1; } /* hover на мобилке нет */

  /* composer: широкий с крупным textarea */
  .composer {
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 4px;
  }
  .composer textarea { min-height: 44px; font-size: 16px; /* 16px чтобы iOS не zoom */ }
  .send-btn { padding: 0 16px; height: 44px; width: 44px; padding: 0; }
  .send-btn svg { width: 22px; height: 22px; }

  /* emoji panel: снизу, на всю ширину, выше клавиатуры */
  .emoji-panel {
    left: 0; right: 0; bottom: 0; max-width: none;
    height: 44vh; min-height: 300px;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* модалки: в полный экран */
  .modal { padding: 0; align-items: stretch; backdrop-filter: blur(6px); }
  .modal-card {
    max-width: none !important; max-height: none !important;
    height: 100dvh;          /* dvh учитывает URL-bar браузера */
    min-height: 100dvh;
    border-radius: 0;
    padding-top: 0;
    padding-bottom: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
  }
  .modal-card > .modal-close {
    top: calc(env(safe-area-inset-top) + 8px);
    right: 8px;
    z-index: 10;
  }
  .settings-card { flex-direction: column; }
  .settings-tabs {
    width: 100%; flex-direction: row; overflow-x: auto; padding: 10px 8px;
    /* отступ сверху под safe-area и крестик */
    padding-top: calc(env(safe-area-inset-top) + 10px);
    padding-right: 52px;        /* место для крестика */
    border-right: 0; border-bottom: 1px solid var(--border);
    gap: 4px;
    flex-shrink: 0;
  }
  .settings-tabs .tab { flex-shrink: 0; min-height: 40px; }
  .settings-body {
    flex: 1; overflow-y: auto;
    padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
    -webkit-overflow-scrolling: touch;
  }
  /* admin modal — та же логика */
  .admin-card .admin-tabs { padding-top: calc(env(safe-area-inset-top) + 8px); padding-right: 52px; }
  .admin-card .admin-body { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); -webkit-overflow-scrolling: touch; }

  /* privacy: в одну колонку */
  .privacy-row { grid-template-columns: 1fr; gap: 8px; }

  /* welcome-экран — сужаем */
  .welcome-title { font-size: 24px; }
  .welcome-hero { width: 140px; height: 140px; }

  /* auth-card во всю ширину с отступами */
  .auth-card {
    width: calc(100% - 24px); padding: 28px 22px; margin: 12px;
  }

  /* звонок */
  .call-self { width: 100px; height: 140px; bottom: calc(100px + env(safe-area-inset-bottom)); right: 10px; }
  .call-controls { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .call-controls .call-btn { width: 56px; height: 56px; }

  /* reaction picker — адаптируем под тач */
  .reaction-picker { padding: 8px; }
  .reaction-picker button { width: 44px; height: 44px; font-size: 24px; }

  /* dropdown-menu: от правого края с отступом */
  .dropdown-menu { right: 4px; min-width: 220px; }
  .dropdown-menu button { min-height: 44px; padding: 10px 12px; font-size: 14px; }

  /* theme grid — минимум 3 в ряд */
  .theme-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

/* очень узкие (iPhone SE) */
@media (max-width: 380px) {
  .chat-actions .icon-btn { width: 40px; height: 40px; }
  .msg { max-width: 90%; }
  .welcome-actions { flex-direction: column; width: 100%; }
  .welcome-actions button { width: 100%; }
}

/* reduced-motion — убираем декор-анимации */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
