/* ══════════════════════════ ШРИФТЫ ══════════════════════════ */
@font-face {
  font-family: 'Gilroy';
  src: url('/fonts/Gilroy-ExtraBold.otf') format('opentype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:      #0a0616;
  --bg-1:    #110a24;
  --bg-2:    #18102e;
  --bg-3:    #221644;
  --line:    #2c1f5c;
  --line-2:  #3a2a72;
  --fg:      #ece9f8;
  --fg-dim:  #a79ec4;
  --fg-mute: #6d6490;

  --purple:  #8b5cf6;
  --violet:  #a855f7;
  --blue:    #6366f1;
  --pink:    #ec4899;
  --danger:  #ef4444;

  --accent:   #8b5cf6;
  --accent-2: #ec4899;

  --mine-bg: #1e1247;
  --mine-br: #8b5cf6;
  --shadow:  #050110;
  --sidebar-w: 320px;

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;

  --font: 'Gilroy', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body.light {
  --bg:      #f6f4fb;
  --bg-1:    #ede9f7;
  --bg-2:    #ffffff;
  --bg-3:    #ffffff;
  --line:    #d9d0ef;
  --line-2:  #bbacdf;
  --fg:      #1a1230;
  --fg-dim:  #5b4d7e;
  --fg-mute: #9286b5;
  --mine-bg: #e8dcff;
  --mine-br: #8b5cf6;
  --shadow:  #bbacdf;
}

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

html, body {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  overscroll-behavior: none;
  overscroll-behavior-x: none;
}

body {
  font-family: var(--font);
  font-weight: 700;
  font-size: 14px;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
  background: var(--bg);
}

button, input, textarea, select { font: inherit; font-family: var(--font); font-weight: 700; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, textarea { outline: none; }
input, textarea, select, button { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: var(--r-sm); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); }
[hidden] { display: none !important; }

.sidebar, .side-top, .chat-top, .composer, .mobile-nav,
.filter-tabs, .me-card, .chat-item, .tabs,
button, .btn, .icon-btn, .filter-tab, .swatch, .avatar,
.badge, .story-bubble, .row-card, .create-btn, .join-mode,
.modal-head, .pinned-bar, .channel-notice, .day-sep,
.msg, .bubble, .msg-avatar, .msg-author, .msg-meta,
.reactions, .reaction, .msg-tools, .msg-reply,
.att-photo, .att-grid, .file-att, .voice-wrap,
.people-list, .rooms-list, .admin-user-card, .stats-grid,
.gc-window, .call-banner, .conn-banner, .gc-banner, .feed,
.post-card, .post-head, .feed-head, .msg-text, .post-text,
.post-carousel, .post-carousel-item, .post-comment-item,
.post-comment-body, .post-comments-preview {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
input, textarea,
#editTextarea, #postTextarea,
.modal-search, .search-wrap input, .inchat-search input,
.field input, .code-input, #themeShareInput, #aliasInput,
.profile-description, .md-preview, .md-preview *,
.md-code, .md-pre, .md-pre code {
  -webkit-user-select: text; user-select: text;
  -webkit-touch-callout: default;
}

.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line-2);
  border-top-color: var(--accent-2);
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════ БАННЕР ЗВОНКА ═══════════════ */
.call-banner {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 10px;
  background: linear-gradient(135deg, #1a0d3a, #2c1f5c);
  border: 1px solid var(--accent);
  border-radius: 40px;
  color: #fff;
  font-family: var(--font);
  z-index: 380;
  box-shadow: 0 8px 30px rgba(139, 92, 246, .5);
  animation: dropIn .22s ease;
  cursor: pointer;
  max-width: min(420px, calc(100vw - 24px));
}
.call-banner:active { transform: translate(-50%, 1px); }
.call-banner-pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .7);
  animation: callPulse 1.4s infinite;
  flex-shrink: 0;
}
@keyframes callPulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .7); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.call-banner-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font); font-weight: 900; font-size: 13px;
  color: #fff; background: var(--accent);
  flex-shrink: 0;
  background-size: cover; background-position: center;
}
.call-banner-avatar.emoji { font-size: 18px; font-family: 'Segoe UI Emoji', sans-serif; }
.call-banner-avatar.image { color: transparent; }
.call-banner-info { display: flex; flex-direction: column; min-width: 0; text-align: left; flex: 1; }
.call-banner-info b { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .3px; }
.call-banner-info span { font-size: 11px; font-weight: 600; color: #c7bfe8; margin-top: 1px; }
.call-banner-open {
  padding: 6px 12px;
  background: var(--accent-2); color: #fff;
  font-family: var(--font); font-weight: 800; font-size: 11px;
  letter-spacing: .5px; border-radius: 20px;
  white-space: nowrap; flex-shrink: 0;
}
@keyframes dropIn { from { opacity: 0; transform: translate(-50%, -20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ═══════════════ ИКОНКИ ═══════════════ */
.icon-btn svg, .btn-with-icon .ico, .attach-menu button svg,
.call-btn svg, .rec-cancel svg, .rec-send svg, .rec-send-big svg,
.btn-send svg, .verify-icon svg, .lb-close svg, .lb-nav svg,
.channel-notice svg, .pinned-bar svg, .gc-btn svg,
.post-actions button svg, .post-comment-form button svg,
.post-media-btn svg, .post-carousel-item .play-badge svg {
  width: 18px; height: 18px; display: block; stroke-width: 2; flex-shrink: 0;
}
.icon-btn svg { width: 17px; height: 17px; }
.btn-send svg { width: 20px; height: 20px; }
.call-btn svg { width: 22px; height: 22px; }
.rec-send-big svg { width: 26px; height: 26px; }
.verify-icon svg { width: 44px; height: 44px; stroke-width: 1.5; }
.lb-nav svg { width: 26px; height: 26px; stroke-width: 2.2; }
.lb-close svg { width: 20px; height: 20px; }
.gc-btn svg { width: 22px; height: 22px; }
.btn-with-icon { display: flex !important; align-items: center; justify-content: center; gap: 8px; }
.btn-with-icon .ico { width: 16px; height: 16px; }
.attach-menu button { display: flex; align-items: center; gap: 10px; }
.attach-menu button svg { width: 18px; height: 18px; color: var(--accent); }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--bg-1);
  color: var(--fg-dim);
  flex-shrink: 0; border-radius: var(--r-md);
  transition: .15s;
}
.icon-btn:hover { border-color: var(--purple); color: var(--purple); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn.active { border-color: var(--accent); color: var(--accent); background: var(--bg-2); }

.btn {
  padding: 11px 18px;
  font-family: var(--font); font-weight: 800;
  font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  transition: .15s;
}
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { filter: brightness(.92); }
.btn-ghost { background: var(--bg-1); color: var(--fg-dim); border-color: var(--line); text-transform: none; letter-spacing: .3px; }
.btn-ghost:hover { border-color: var(--purple); color: var(--purple); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); text-transform: none; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; display: block; }
.link-btn {
  background: none; border: none;
  color: var(--accent-2);
  font-family: var(--font); font-weight: 700; font-size: 12px;
  padding: 8px 4px; cursor: pointer; letter-spacing: .3px;
  border-radius: var(--r-sm); transition: .15s;
}
.link-btn:hover { color: var(--accent); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font); font-weight: 900; font-size: 15px;
  color: #fff; border: 1px solid var(--shadow);
  flex-shrink: 0; user-select: none; overflow: hidden;
  background-size: cover; background-position: center;
}
.avatar.emoji { font-size: 22px; font-family: 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif; }
.avatar.image { background-size: cover; background-position: center; color: transparent; }
.avatar-xl { width: 84px; height: 84px; font-size: 30px; border-width: 2px; }
.avatar-xl.emoji { font-size: 44px; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-size: 10px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--fg-mute);
  font-weight: 800; margin-bottom: 6px;
}
.field input {
  width: 100%; padding: 12px 14px;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--fg); font-size: 14px; font-family: var(--font);
  font-weight: 700; border-radius: var(--r-md);
}
.field input:focus { border-color: var(--accent-2); }

/* ═══════════════ ЭКРАН ВХОДА ═══════════════ */
.auth { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.auth-box {
  width: 100%; max-width: 400px;
  background: var(--bg-2); border: 1px solid var(--line-2);
  padding: 36px 28px; border-radius: var(--r-xl);
  max-height: 92vh; overflow-y: auto;
}
.brand { font-family: var(--font); font-weight: 900; font-size: 32px; letter-spacing: 5px; text-align: center; color: var(--accent); }
.auth-sub { text-align: center; color: var(--fg-mute); font-size: 11px; letter-spacing: 2px; margin: 6px 0 26px; }
.auth-note { margin-top: 12px; text-align: center; font-size: 11px; color: var(--fg-mute); letter-spacing: .5px; }
.auth-links { display: flex; justify-content: center; margin-top: 8px; }
.tabs { display: flex; margin-bottom: 22px; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.tabs .tab {
  flex: 1; padding: 11px;
  font-family: var(--font); font-weight: 800; font-size: 11px;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--fg-mute); background: var(--bg-1); transition: .15s;
}
.tabs .tab.active { background: var(--accent); color: #fff; }
.auth-error { min-height: 18px; margin-bottom: 12px; font-size: 12px; font-weight: 800; color: var(--accent-2); text-align: center; }
.auth-status { margin-top: 18px; text-align: center; font-size: 10px; letter-spacing: 1px; color: var(--fg-mute); }
.auth-status.ok { color: var(--accent); }
.auth-status.err { color: var(--danger); }

.verify-header { text-align: center; margin-bottom: 22px; }
.verify-icon { display: flex; justify-content: center; color: var(--accent-2); margin-bottom: 12px; }
.verify-title { font-family: var(--font); font-weight: 800; font-size: 17px; letter-spacing: 1px; margin-bottom: 6px; }
.verify-sub { font-size: 12px; color: var(--fg-dim); }
.verify-sub b { color: var(--accent-2); }
.code-input {
  font-size: 26px !important; letter-spacing: 8px !important;
  text-align: center !important; font-family: var(--font) !important;
  font-weight: 900 !important; padding: 16px !important;
  color: var(--accent-2) !important;
}
.code-input::placeholder { color: var(--line-2) !important; letter-spacing: 8px; }
.verify-actions { display: flex; justify-content: space-between; margin-top: 14px; }
.verify-timer { text-align: center; font-size: 11px; color: var(--fg-mute); letter-spacing: 1px; margin-top: 10px; min-height: 14px; }

/* ═══════════════ КАРКАС ═══════════════ */
.app { display: flex; height: 100%; min-height: 0; overflow: hidden; overscroll-behavior: none; touch-action: pan-y; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--line);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
  touch-action: pan-y;
}

.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  position: relative;
  height: 100%;
  overflow: hidden;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.side-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  gap: 8px;
  position: sticky; top: 0; z-index: 6;
}
.logo-wrap { display: flex; flex-direction: column; min-width: 0; flex-shrink: 0; }
.side-top .logo {
  font-family: var(--font); font-weight: 900;
  letter-spacing: 1.5px; font-size: 20px;
  color: var(--accent); white-space: nowrap; line-height: 1.1;
}
.conn-status {
  font-family: var(--font); font-weight: 700;
  font-size: 9px; letter-spacing: 1px;
  text-transform: lowercase;
  color: var(--fg-mute);
  margin-top: 2px; transition: color .2s; white-space: nowrap;
}
.conn-status[data-state="ok"] { color: #22c55e; }
.conn-status[data-state="reconnecting"],
.conn-status[data-state="updating"] { color: var(--accent-2); }
.conn-status[data-state="lost"] { color: var(--danger); }
.side-actions { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.side-top .icon-btn {
  background: transparent; color: var(--fg-dim);
  border-color: var(--line);
  width: 30px; height: 30px; border-radius: var(--r-sm);
}
.side-top .icon-btn:hover { background: var(--bg-2); color: var(--accent); border-color: var(--accent); }
.side-top .icon-btn.active { background: var(--bg-2); color: var(--accent); border-color: var(--accent); }
.side-top .icon-btn svg { width: 15px; height: 15px; }

.me-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  text-align: left; width: 100%;
  flex-shrink: 0; transition: .15s; border-radius: 0;
}
.me-card:hover { background: var(--bg-3); }
.me-info { flex: 1; min-width: 0; }
.me-nick {
  display: block; font-family: var(--font); font-weight: 800; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.me-status {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.conn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex-shrink: 0; }
.conn-dot.on { background: #22c55e; }

.search-wrap { padding: 10px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.search-wrap input {
  width: 100%; padding: 10px 12px;
  background: var(--bg-1); border: 1px solid var(--line);
  font-size: 12px; font-family: var(--font); font-weight: 600;
  border-radius: var(--r-md);
}
.search-wrap input:focus { border-color: var(--accent-2); }

.filter-tabs { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.filter-tab {
  flex: 1; padding: 7px 6px;
  font-family: var(--font); font-weight: 800; font-size: 11px;
  letter-spacing: .5px; border-radius: var(--r-sm);
  color: var(--fg-mute); background: transparent;
  border: 1px solid transparent; transition: .15s;
}
.filter-tab:hover { color: var(--purple); }
.filter-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.chat-list { flex: 1; overflow-y: auto; min-height: 0; padding: 4px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }

.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 2px;
  cursor: pointer; transition: .1s;
  position: relative; border-radius: var(--r-md);
}
.chat-item:hover { background: var(--bg-2); }
.chat-item.active { background: var(--bg-3); }
.chat-item.active::before {
  content: ''; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; background: var(--accent); border-radius: 2px;
}
.chat-item.system { background: var(--bg-1); border: 1px solid var(--line); }
.chat-item.system.active { border-color: var(--accent); }
.chat-item.saved .name { color: var(--accent-2); }
.chat-body { flex: 1; min-width: 0; }
.chat-name-row { display: flex; align-items: baseline; gap: 6px; }
.chat-item .name {
  flex: 1; font-family: var(--font); font-weight: 800; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item .time { font-size: 10px; color: var(--fg-mute); flex-shrink: 0; font-weight: 600; }
.chat-item .preview {
  font-size: 11px; font-weight: 600; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 3px;
}
.chat-item .preview .who { color: var(--fg-mute); }
.badge {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 800;
  min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.empty-side { padding: 32px 16px; text-align: center; font-size: 12px; color: var(--fg-mute); }

.chat-top {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  background: var(--bg-1); border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.back-btn { display: none; }
.chat-head-main {
  display: flex; align-items: center; gap: 12px;
  flex: 1; min-width: 0; text-align: left; padding: 4px 6px;
  border: 1px solid transparent; transition: .15s;
  cursor: pointer; border-radius: var(--r-md); background: transparent;
}
.chat-head-main:hover { border-color: var(--line); background: var(--bg-2); }
.chat-title { flex: 1; min-width: 0; }
.chat-name {
  font-family: var(--font); font-weight: 800; font-size: 15px;
  letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-sub {
  font-size: 11px; font-weight: 600; color: var(--fg-dim); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-sub.typing { color: var(--accent-2); }
.chat-actions { display: flex; gap: 6px; }

.inchat-search { display: flex; gap: 8px; align-items: center; padding: 8px 16px; background: var(--bg-1); border-bottom: 1px solid var(--line); }
.inchat-search input {
  flex: 1; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--line);
  font-size: 12px; font-family: var(--font); font-weight: 600;
  border-radius: var(--r-md);
}
.inchat-search input:focus { border-color: var(--accent-2); }

/* ═══════════ ПЛАШКА ГРУППОВОГО ЗВОНКА В ЧАТЕ ═══════════ */
.gc-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(139,92,246,.15), rgba(236,72,153,.1));
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--accent-2);
  flex-shrink: 0;
}
.gc-banner-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.gc-banner-avatars { display: flex; align-items: center; min-width: 40px; flex-shrink: 0; }
.gc-banner-avatars .avatar {
  width: 30px; height: 30px; font-size: 11px;
  border: 2px solid var(--bg-1); margin-left: -8px;
}
.gc-banner-avatars .avatar:first-child { margin-left: 0; }
.gc-banner-avatars .avatar.emoji { font-size: 14px; }
.gc-banner-info { flex: 1; min-width: 0; }
.gc-banner-info b {
  display: block; font-family: var(--font); font-weight: 800; font-size: 13px;
  color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gc-banner-info span { display: block; font-size: 11px; font-weight: 600; color: var(--fg-dim); margin-top: 2px; }
.gc-banner-info .gc-live-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #22c55e; margin-right: 4px; animation: callPulse 1.4s infinite;
}
#gcBannerJoin { padding: 8px 14px; font-size: 11px; }

.pinned-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--bg-1); border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  cursor: pointer; transition: .15s; flex-shrink: 0;
}
.pinned-bar:hover { background: var(--bg-2); }
.pinned-ico { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; }
.pinned-ico svg { width: 16px; height: 16px; }
.pinned-body { flex: 1; min-width: 0; }
.pinned-body b { display: block; font-size: 10px; color: var(--accent); letter-spacing: 1px; text-transform: uppercase; font-weight: 800; }
.pinned-body span { display: block; font-size: 12px; color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.pinned-unpin { width: 26px; height: 26px; flex-shrink: 0; }
.pinned-unpin svg { width: 12px; height: 12px; }

.channel-notice {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--bg-1); border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--fg-dim); letter-spacing: .3px;
}
.channel-notice svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }

.messages {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  overflow-anchor: none;
}
body.compact .messages { padding: 10px 12px 4px; gap: 1px; }

.day-sep {
  align-self: center; margin: 16px 0 10px;
  padding: 4px 12px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--fg-mute);
  border: 1px solid var(--line); background: var(--bg-1);
  border-radius: 12px;
}

.msg {
  display: flex; gap: 9px; align-items: flex-end;
  max-width: min(680px, 78%);
  animation: msgIn .18s ease;
  position: relative;
  transition: transform .2s cubic-bezier(.2,.7,.3,1);
  touch-action: pan-y;
  will-change: transform;
}
.msg.swiping { transition: none; }
@keyframes msgIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.grouped { margin-top: -1px; }
.msg.grouped .msg-avatar { visibility: hidden; }
.msg.mine .msg-avatar { display: none !important; }

.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font); font-weight: 900; font-size: 13px;
  color: #fff; border: 1px solid var(--shadow); flex-shrink: 0;
  background-size: cover; background-position: center;
}
.msg-avatar.emoji { font-size: 18px; font-family: 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif; }
.msg-avatar.image { color: transparent; }

.bubble {
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 8px 12px 6px;
  font-family: var(--font); font-weight: 700;
  font-size: 13px; line-height: 1.45;
  word-break: break-word;
  max-width: 100%; position: relative;
  border-radius: var(--r-lg);
}
.msg.mine .bubble { background: var(--bg-2); border-color: var(--accent); color: var(--fg); }
body.light .msg.mine .bubble { background: #e8dcff; }

.msg-author {
  font-family: var(--font); font-weight: 900; font-size: 10px;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 3px;
}
.msg-author.channel { color: var(--pink); display: flex; align-items: center; gap: 4px; }
.msg-author.channel::before {
  content: ''; display: inline-block; width: 10px; height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ec4899' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 11l18-8v18l-18-8z'/%3E%3C/svg%3E");
  background-size: contain; background-repeat: no-repeat;
}
.msg-text { white-space: pre-wrap; }
.msg-text.deleted { color: var(--fg-mute); font-style: italic; }
.msg-text mark { background: var(--accent-2); color: #fff; padding: 0 2px; border-radius: 2px; }
.msg-text a {
  color: var(--accent-2); text-decoration: underline;
  text-underline-offset: 2px; text-decoration-thickness: 1px;
  word-break: break-all;
}
.msg-text a:hover { color: var(--accent); }
.msg.mine .msg-text a { color: #d8b4fe; }
body.light .msg.mine .msg-text a { color: #6d28d9; }

.msg-meta {
  display: flex; align-items: center; gap: 6px;
  justify-content: flex-end; margin-top: 3px;
  font-family: var(--font); font-weight: 600;
  font-size: 9px; color: var(--fg-mute); opacity: .85;
}

.msg-reply {
  border-left: 2px solid var(--accent);
  padding: 3px 0 3px 8px; margin-bottom: 6px;
  font-size: 11px; opacity: .85;
  cursor: pointer; max-width: 100%; overflow: hidden;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--bg-1);
}
.msg-reply b {
  display: block; font-family: var(--font); font-weight: 800;
  color: var(--accent-2); font-size: 10px; letter-spacing: .5px;
}
.msg-reply span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border: 1px solid var(--line-2); background: var(--bg-1);
  font-family: var(--font); font-weight: 700; font-size: 12px;
  line-height: 1.4; color: var(--fg-dim);
  transition: .12s; border-radius: 12px;
}
.reaction:hover { border-color: var(--purple); }
.reaction.mine { border-color: var(--accent-2); color: var(--accent-2); background: var(--bg-2); }

.msg-tools {
  position: absolute; top: -12px; display: flex; gap: 2px;
  opacity: 0; pointer-events: none;
  transition: .12s; z-index: 5;
}
.msg:not(.mine) .msg-tools { right: 0; transform: translateX(100%); padding-left: 6px; }
.msg.mine .msg-tools { left: 0; transform: translateX(-100%); padding-right: 6px; }
.msg:hover .msg-tools { opacity: 1; pointer-events: auto; }
.msg-tools button {
  width: 28px; height: 28px;
  background: var(--bg-3); border: 1px solid var(--line);
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--fg-dim);
  transition: .12s;
}
.msg-tools button svg { width: 14px; height: 14px; }
.msg-tools button:hover { border-color: var(--accent); background: var(--accent); color: #fff; }

.empty-chat { margin: auto; text-align: center; color: var(--fg-mute); font-size: 13px; letter-spacing: 1px; padding: 40px; }
.empty-chat .big { font-size: 40px; display: block; margin-bottom: 12px; opacity: .4; }

.attachments { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.attachments:last-child { margin-bottom: 0; }
.att-photo {
  display: block; max-width: 100%;
  border-radius: var(--r-md); cursor: pointer;
  overflow: hidden; background: var(--bg);
  border: 1px solid var(--line);
  position: relative;
}
.att-photo img { display: block; max-width: 100%; max-height: 420px; width: auto; height: auto; object-fit: contain; border-radius: var(--r-md); }
.media-loader {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5); z-index: 2;
}
.media-loader .spinner { border-color: rgba(255,255,255,.2); border-top-color: #fff; }

.att-grid { display: grid; gap: 3px; border-radius: var(--r-md); overflow: hidden; max-width: 420px; }
.att-grid.grid-2 { grid-template-columns: 1fr 1fr; }
.att-grid.grid-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.att-grid.grid-3 > :first-child { grid-row: 1 / 3; }
.att-grid.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.att-grid.grid-more { grid-template-columns: 1fr 1fr 1fr; }
.att-grid .cell { position: relative; aspect-ratio: 1; background: #000; cursor: pointer; overflow: hidden; }
.att-grid .cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-grid .cell .more-overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .6); color: #fff;
  font-family: var(--font); font-weight: 900; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}

.video-wrap { position: relative; border-radius: var(--r-md); overflow: hidden; background: #000; max-width: 420px; border: 1px solid var(--line); }
.video-wrap video { display: block; width: 100%; max-height: 480px; background: #000; object-fit: contain; }
.video-msg-wrap {
  position: relative; width: 240px; max-width: 100%;
  aspect-ratio: 1; border-radius: 50%;
  overflow: hidden; background: #000;
  cursor: pointer; border: 2px solid var(--accent);
}
.video-msg-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-msg-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .35); color: #fff;
  pointer-events: none; transition: opacity .2s;
}
.video-msg-play svg { width: 48px; height: 48px; }
.video-msg-wrap.playing .video-msg-play { opacity: 0; }

.voice-wrap { display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 320px; padding: 4px 0; }
.voice-play {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; transition: .15s;
}
.voice-play svg { width: 16px; height: 16px; }
.voice-play:hover { filter: brightness(1.1); }
.voice-play.playing { background: var(--accent-2); }
.voice-body { flex: 1; min-width: 0; }
.voice-wave { height: 24px; display: flex; align-items: center; gap: 2px; cursor: pointer; user-select: none; }
.voice-wave .bar { width: 3px; background: var(--line-2); border-radius: 2px; transition: background .1s; min-height: 4px; }
.voice-wave .bar.on { background: var(--accent-2); }
.voice-meta { display: flex; justify-content: space-between; font-size: 10px; font-family: var(--font); font-weight: 700; color: var(--fg-mute); margin-top: 3px; }
.voice-speed {
  background: none; border: 1px solid var(--line-2);
  color: var(--fg-dim);
  font-family: var(--font); font-weight: 800; font-size: 10px;
  padding: 2px 6px; border-radius: 8px; cursor: pointer; flex-shrink: 0;
}
.voice-speed:hover { border-color: var(--accent-2); color: var(--accent-2); }

.file-att {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-md); text-decoration: none;
  color: inherit; max-width: 320px; transition: .15s;
}
.file-att:hover { border-color: var(--accent); }
.file-att .ico {
  width: 38px; height: 38px;
  background: var(--accent); color: #fff;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.file-att .ico svg { width: 18px; height: 18px; }
.file-att .info { flex: 1; min-width: 0; }
.file-att .info b { display: block; font-family: var(--font); font-weight: 800; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-att .info span { display: block; font-size: 10px; font-family: var(--font); font-weight: 600; color: var(--fg-mute); margin-top: 2px; }

.composer { border-top: 1px solid var(--line); background: var(--bg-1); padding: 10px 14px 12px; flex-shrink: 0; }
.reply-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 8px;
  border-left: 2px solid var(--accent-2);
  background: var(--bg-2); font-size: 12px;
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.reply-info { flex: 1; min-width: 0; }
.reply-info b { display: block; font-family: var(--font); font-weight: 800; color: var(--accent-2); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }
.reply-info span { display: block; color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.attach-preview { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--bg-1); }
.attach-chip {
  position: relative; width: 76px; height: 76px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; background: var(--bg-1);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.attach-chip img, .attach-chip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-chip .icon { font-size: 26px; opacity: .8; }
.attach-chip .name {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 3px 5px; background: rgba(0, 0, 0, .6); color: #fff;
  font-size: 9px; font-family: var(--font); font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-chip .rm {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0, 0, 0, .7); color: #fff;
  font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; z-index: 2;
}
.attach-chip .rm:hover { background: var(--danger); }

.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-row .icon-btn, #btnEmoji, #btnAttach, #btnVoice, #btnSend {
  flex-shrink: 0 !important; flex-grow: 0 !important;
}
#btnEmoji, #btnAttach { width: 34px !important; min-width: 34px !important; }
#btnVoice { width: 42px !important; min-width: 42px !important; height: 42px !important; }
#btnSend  { width: 46px !important; min-width: 46px !important; height: 42px !important; }
#msgInput {
  flex: 1 1 auto; min-width: 0; width: 100%;
  padding: 11px 12px;
  background: var(--bg); border: 1px solid var(--line);
  font-family: var(--font); font-weight: 700; font-size: 13px;
  resize: none; min-height: 42px; max-height: 140px;
  line-height: 1.4; border-radius: var(--r-md);
  overflow-y: auto;
}
#msgInput:focus { border-color: var(--accent-2); }
#msgInput:disabled { opacity: .45; cursor: not-allowed; }

.btn-send {
  background: var(--accent); color: #fff;
  border: none; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
}
.btn-send:hover:not(:disabled) { filter: brightness(1.08); }
.btn-send:disabled { background: var(--line); color: var(--fg-mute); cursor: not-allowed; }
.btn-voice { background: var(--accent-2); color: #fff; }
.btn-voice:hover:not(:disabled) { filter: brightness(1.1); color: #fff; }
.btn-voice:disabled { background: var(--line); color: var(--fg-mute); cursor: not-allowed; }

.rec-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg-2); border: 1px solid var(--accent-2); border-radius: var(--r-md); margin-bottom: 10px; }
.rec-cancel {
  width: 34px; height: 34px; border-radius: 50%;
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rec-cancel:hover { background: var(--danger); color: #fff; }
.rec-info { flex: 1; display: flex; align-items: center; gap: 10px; font-family: var(--font); font-weight: 800; font-size: 13px; color: var(--fg); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: recPulse 1s infinite; flex-shrink: 0; }
@keyframes recPulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.85); } }
.rec-mode { font-size: 11px; color: var(--accent-2); letter-spacing: 1px; text-transform: uppercase; margin-left: auto; }
.rec-send {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-2); color: #fff; border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rec-send:hover { filter: brightness(1.1); }
.rec-send svg { width: 16px; height: 16px; }

.rec-overlay {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(5, 1, 22, .92);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 24px; padding: 20px;
  animation: fadeIn .15s;
}
.rec-circle {
  width: min(70vw, 340px); aspect-ratio: 1;
  border-radius: 50%; overflow: hidden;
  background: #000; border: 3px solid var(--accent-2);
  position: relative;
}
.rec-circle video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.rec-overlay .rec-cancel { position: absolute; top: 24px; left: 24px; width: 48px; height: 48px; }
.rec-info-big { display: flex; align-items: center; gap: 12px; color: #fff; font-family: var(--font); font-weight: 800; font-size: 20px; }
.rec-send-big {
  width: 70px; height: 70px; border-radius: 50%;
  background: var(--accent-2); color: #fff; border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.rec-send-big:hover { filter: brightness(1.1); }

.emoji-pop {
  position: fixed; z-index: 90;
  width: 300px; max-height: 260px;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--accent);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  border-radius: var(--r-md);
}
.emoji-pop button { font-size: 18px; line-height: 1; padding: 5px 0; transition: .1s; border-radius: var(--r-sm); }
.emoji-pop button:hover { background: var(--bg-3); transform: scale(1.2); }

.ctx-menu {
  position: fixed; z-index: 120;
  min-width: 220px;
  background: var(--bg-2); border: 1px solid var(--accent);
  overflow: hidden; border-radius: var(--r-md);
  animation: ctxPop .12s ease;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
@keyframes ctxPop {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.ctx-menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 14px; text-align: left;
  font-family: var(--font); font-weight: 700; font-size: 13px;
  border-bottom: 1px solid var(--line);
  transition: .1s;
  color: var(--fg);
}
.ctx-menu button svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); }
.ctx-menu button:last-child { border-bottom: none; }
.ctx-menu button:hover { background: var(--accent); color: #fff; }
.ctx-menu button:hover svg { color: #fff; }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu button.danger svg { color: var(--danger); }
.ctx-menu button.danger:hover { background: var(--danger); color: #fff; }
.ctx-menu button.danger:hover svg { color: #fff; }

.attach-menu {
  position: fixed; z-index: 130;
  min-width: 180px;
  background: var(--bg-2); border: 1px solid var(--accent);
  border-radius: var(--r-md); overflow: hidden;
}
.attach-menu button {
  width: 100%; padding: 11px 14px; text-align: left;
  font-family: var(--font); font-weight: 700; font-size: 13px;
  color: var(--fg); border-bottom: 1px solid var(--line);
  transition: .1s;
}
.attach-menu button:last-child { border-bottom: none; }
.attach-menu button:hover { background: var(--accent); color: #fff; }
.attach-menu button:hover svg { color: #fff; }

.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, .95);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .15s;
  touch-action: none;
}
.lb-content {
  max-width: 95vw; max-height: 92vh;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
  user-select: none;
  transition: transform .2s cubic-bezier(.2,.7,.3,1);
  will-change: transform;
}
.lb-content.dragging { transition: none; }
.lb-content img, .lb-content video {
  max-width: 95vw; max-height: 92vh;
  object-fit: contain; border-radius: var(--r-md);
  -webkit-user-drag: none;
}
.lb-close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: .15s; z-index: 10;
}
.lb-close:hover { background: rgba(255,255,255,.3); }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.12); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: .15s; z-index: 10;
}
.lb-nav:hover { background: rgba(255,255,255,.28); }
.lb-prev { left: 20px; }
.lb-next { right: 20px; }
.lb-counter {
  position: absolute; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(255,255,255,.15); color: #fff;
  border-radius: 14px;
  font-family: var(--font); font-weight: 800; font-size: 12px;
  letter-spacing: 1px;
}
.lb-loader { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }

.modal {
  position: fixed; inset: 0; z-index: 110;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .55);
  animation: fadeIn .14s;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal-box {
  width: 100%; max-width: 430px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  animation: popIn .16s cubic-bezier(.2,.9,.3,1.3);
  border-radius: var(--r-xl);
  overflow: hidden;
}
@keyframes popIn { from { transform: scale(.96); opacity: 0 } to { transform: scale(1); opacity: 1 } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px;
  background: var(--bg-1); color: var(--fg);
  font-family: var(--font); font-weight: 800; font-size: 13px;
  letter-spacing: 1.5px; text-transform: uppercase;
  flex-shrink: 0; border-bottom: 1px solid var(--line);
}
.modal-head .icon-btn {
  background: transparent; color: var(--fg-dim); border-color: var(--line);
  width: 28px; height: 28px; border-radius: var(--r-sm);
}
.modal-head .icon-btn:hover { background: var(--bg-2); color: var(--accent); border-color: var(--accent); }
.modal-head .icon-btn svg { width: 14px; height: 14px; }
.modal-body { padding: 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

.modal-search {
  width: 100%; padding: 10px 12px; margin-bottom: 12px;
  background: var(--bg); border: 1px solid var(--line);
  font-size: 12px; font-family: var(--font); font-weight: 600;
  border-radius: var(--r-md);
}
.modal-search:focus { border-color: var(--accent-2); }

.profile-preview { text-align: center; margin-bottom: 12px; }
.profile-nick { text-align: center; font-family: var(--font); font-weight: 900; font-size: 20px; letter-spacing: .5px; margin-bottom: 4px; }
.profile-status { text-align: center; font-size: 12px; font-weight: 600; color: var(--fg-dim); margin-top: 8px; }
.profile-description {
  text-align: center; font-size: 12px; font-weight: 600;
  color: var(--fg-dim); margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-1); border-radius: var(--r-md);
  border: 1px solid var(--line);
  line-height: 1.5; white-space: pre-wrap;
}
.profile-meta { text-align: center; font-size: 11px; font-weight: 600; color: var(--fg-mute); margin-top: 10px; letter-spacing: .5px; }
.profile-username { text-align: center; color: var(--accent-2); font-family: var(--font); font-weight: 800; font-size: 13px; letter-spacing: .5px; margin-bottom: 4px; }
.profile-email { display: block; color: var(--fg-mute); font-size: 11px; font-weight: 600; margin-top: 2px; }

.ci-subscribers-hint {
  margin-top: 16px; padding: 14px;
  background: var(--bg-1); border: 1px dashed var(--line-2);
  border-radius: var(--r-md); font-size: 12px;
  color: var(--fg-mute); text-align: center;
  letter-spacing: .3px; line-height: 1.5;
}

.color-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 38px; height: 38px;
  border: 2px solid var(--line);
  cursor: pointer; transition: .14s;
  border-radius: var(--r-md);
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--fg); box-shadow: 0 0 0 2px var(--accent-2); }

.avatar-tabs { display: flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; flex-wrap: wrap; }
.avatar-tabs .avatar-tab {
  flex: 1; min-width: 60px; padding: 9px;
  font-family: var(--font); font-weight: 800; font-size: 11px;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--fg-mute); background: var(--bg-1);
  transition: .15s;
  border-right: 1px solid var(--line);
}
.avatar-tabs .avatar-tab:last-child { border-right: none; }
.avatar-tabs .avatar-tab.active { background: var(--accent); color: #fff; }

.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 3px; max-height: 180px; overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--r-md);
}
.emoji-grid button { font-size: 20px; line-height: 1; padding: 5px 0; transition: .1s; border-radius: var(--r-sm); }
.emoji-grid button:hover { background: var(--bg-3); transform: scale(1.15); }
.emoji-grid button.active { background: var(--accent); color: #fff; }

.avatar-upload { display: flex; flex-direction: column; gap: 4px; }
.room-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.room-preview-name { font-family: var(--font); font-weight: 800; font-size: 15px; color: var(--fg-dim); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-of-type { border-bottom: none; }
.t-label { font-size: 13px; font-weight: 700; }
.t-desc { font-size: 11px; font-weight: 600; color: var(--fg-mute); margin-top: 2px; }
.switch {
  width: 46px; height: 25px; border-radius: 13px;
  background: var(--line); position: relative;
  cursor: pointer; flex-shrink: 0; transition: .2s;
}
.switch::after {
  content: ''; position: absolute;
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: .2s;
}
.switch.on { background: var(--accent); }
.switch.on::after { left: 24px; }

.settings-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.section-title { font-family: var(--font); font-weight: 800; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--fg-mute); margin-bottom: 10px; }
.theme-presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.theme-preset {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--bg-1); border: 2px solid var(--line);
  border-radius: var(--r-md); cursor: pointer; transition: .12s;
  font-family: var(--font); font-weight: 700; font-size: 12px;
  color: var(--fg); text-align: left;
}
.theme-preset:hover { border-color: var(--accent); }
.theme-preset.active { border-color: var(--accent-2); }
.theme-preset .dots { display: flex; gap: 2px; }
.theme-preset .dots span { width: 12px; height: 12px; border-radius: 50%; }
.theme-custom { margin-bottom: 12px; }
.theme-custom-row { display: flex; gap: 8px; align-items: center; }
.theme-custom-row input[type="color"] { width: 44px; height: 38px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg); padding: 2px; cursor: pointer; }
.theme-custom-row input[type="text"] {
  flex: 1; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--font); font-weight: 700; font-size: 13px;
}
.theme-share-row { display: flex; gap: 8px; margin-bottom: 10px; }
.theme-share-row .btn { flex: 1; padding: 9px 6px; font-size: 11px; text-transform: none; }
.theme-share-field { display: flex; gap: 8px; align-items: center; }
.theme-share-field .modal-search { margin-bottom: 0; }

.version { margin-top: 18px; text-align: center; font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--fg-mute); }

.rooms-list, .people-list { display: flex; flex-direction: column; gap: 6px; }
.row-card {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  background: var(--bg-1); border: 1px solid var(--line);
  transition: .12s; border-radius: var(--r-md);
}
.row-card:hover { border-color: var(--line-2); }
.row-card .info { flex: 1; min-width: 0; }
.row-card .info b { display: block; font-family: var(--font); font-weight: 800; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-card .info span { display: block; font-size: 11px; font-weight: 600; color: var(--fg-mute); margin-top: 2px; }
.row-card .btn { padding: 7px 12px; font-size: 10px; }
.row-card .avatar { width: 36px; height: 36px; font-size: 14px; border-radius: 50%; }
.row-card .avatar.emoji { font-size: 18px; }
.row-card .avatar.image { color: transparent; }

.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-mute); flex-shrink: 0; }
.online-dot.on { background: #22c55e; }

.info-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.info-actions .btn { padding: 10px 8px; font-size: 11px; }

.badge-inline {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent-2); color: #fff;
  font-family: var(--font); font-weight: 800; font-size: 10px;
  border-radius: 9px; margin-left: 4px;
}
.badge-inline[data-zero="1"] { display: none; }

.qr-frame {
  display: inline-block; padding: 14px;
  background: #fff;
  border: 1px solid var(--accent);
  margin-bottom: 14px;
  border-radius: var(--r-md);
  position: relative;
  min-width: 248px; min-height: 248px;
}
.qr-box {
  width: 220px; height: 220px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.qr-box canvas, .qr-box img { display: block; width: 220px; height: 220px; image-rendering: pixelated; border-radius: var(--r-xs); }
.qr-box .qr-fallback { font-family: monospace; word-break: break-all; font-size: 11px; color: #000; padding: 10px; }
.qr-loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; background: #fff;
  color: #6d6490; font-size: 11px; font-weight: 700;
  border-radius: var(--r-md);
}
.qr-loader .spinner { border-color: #d9d0ef; border-top-color: #8b5cf6; }

.qr-hint { font-family: var(--font); font-weight: 600; font-size: 12px; color: var(--fg-dim); margin-bottom: 12px; letter-spacing: .3px; }
.qr-code-label { font-family: var(--font); font-weight: 800; font-size: 11px; color: var(--fg-mute); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 12px; }
.qr-status { font-family: var(--font); font-weight: 700; font-size: 12px; color: var(--fg-dim); letter-spacing: .5px; margin: 8px 0 4px; min-height: 18px; }
.qr-status.pending { color: var(--accent-2); }
.qr-status.confirmed { color: var(--accent); }
.qr-status.expired { color: var(--danger); }

#loginQrBtn { border-color: var(--line-2); color: var(--fg-dim); }
#loginQrBtn:hover { border-color: var(--purple); color: var(--purple); }

.scan-frame { position: relative; width: 100%; max-width: 320px; aspect-ratio: 1; margin: 0 auto 14px; background: #000; border: 1px solid var(--accent); overflow: hidden; border-radius: var(--r-md); }
.scan-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-overlay {
  position: absolute; inset: 15%;
  border: 2px solid var(--accent-2);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45);
  pointer-events: none; border-radius: var(--r-sm);
}
.scan-overlay::before, .scan-overlay::after {
  content: ''; position: absolute;
  width: 24px; height: 24px;
  border: 2px solid var(--accent-2);
}
.scan-overlay::before { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.scan-overlay::after  { bottom: -2px; right: -2px; border-left: none; border-top: none; }

.join-modes { display: grid; grid-template-columns: 1fr; gap: 6px; }
.join-mode {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg); border: 1px solid var(--line);
  text-align: left; transition: .15s; cursor: pointer;
  border-radius: var(--r-md);
}
.join-mode:hover { border-color: var(--line-2); }
.join-mode.active { border-color: var(--accent); background: var(--bg-2); }
.join-mode b { font-family: var(--font); font-weight: 800; font-size: 13px; display: block; }
.join-mode small { font-size: 11px; font-weight: 600; color: var(--fg-mute); display: block; margin-top: 2px; }

.invite-link-row { display: flex; gap: 8px; margin-bottom: 6px; }
.invite-link-row .modal-search { margin-bottom: 0; font-size: 12px; color: var(--accent-2); }
.invite-link-row .btn { padding: 10px 14px; text-transform: none; }

.call-box { max-width: 360px; }
.call-box .modal-body { padding: 34px 24px !important; }
.call-pulse { width: 120px; height: 120px; margin: 0 auto 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; position: relative; }
.call-name { font-family: var(--font); font-weight: 900; font-size: 20px; letter-spacing: .5px; margin-bottom: 6px; }
.call-sub { font-size: 12px; font-weight: 600; color: var(--fg-dim); letter-spacing: .5px; }
.call-timer { font-family: var(--font); font-weight: 900; font-size: 26px; color: var(--accent-2); letter-spacing: 3px; margin-top: 16px; min-height: 34px; }
.call-actions { display: flex; justify-content: center; gap: 22px; margin-top: 26px; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; border: none; color: #fff; display: flex; align-items: center; justify-content: center; transition: .15s; }
.call-btn:active { transform: scale(.94); }
.call-btn-accept { background: #22c55e; }
.call-btn-accept:hover { filter: brightness(1.1); }
.call-btn-reject { background: var(--danger); }
.call-btn-reject:hover { background: #ff5757; }
.call-btn-mute { background: var(--fg-dim); }
.call-btn-mute.muted { background: var(--accent-2); }
.call-btn-mute:hover { filter: brightness(1.1); }
.call-hint { margin-top: 20px; font-size: 11px; font-weight: 600; color: var(--fg-mute); letter-spacing: .4px; }

.gc-window {
  position: fixed; inset: 0; z-index: 260;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  animation: fadeIn .18s ease;
}
.gc-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
  color: var(--fg); flex-shrink: 0;
}
.gc-head-info { flex: 1; min-width: 0; }
.gc-head-info b {
  display: block; font-size: 16px; font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .3px;
}
.gc-head-info span { display: block; font-size: 12px; color: var(--fg-mute); margin-top: 2px; font-weight: 600; }
.gc-head-actions { display: flex; gap: 6px; flex-shrink: 0; }

.gc-participants {
  flex: 1;
  display: grid;
  gap: 10px;
  padding: 16px 0;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-content: start;
  overflow-y: auto;
  min-height: 0;
}
.gc-tile {
  aspect-ratio: 1;
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; position: relative; overflow: hidden;
  transition: border-color .2s;
}
.gc-tile.me { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2) inset; }
.gc-tile .avatar { width: 72px; height: 72px; font-size: 26px; border-width: 2px; }
.gc-tile .gc-name { color: var(--fg); font-size: 13px; font-weight: 700; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.gc-tile .gc-muted {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(239, 68, 68, .9); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

.gc-actions {
  display: flex; gap: 14px; justify-content: center;
  padding-top: 14px; border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.gc-btn {
  width: 58px; height: 58px; border-radius: 50%; border: none;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: .15s;
}
.gc-btn:active { transform: scale(.94); }
.gc-btn.danger { background: var(--danger); }
.gc-btn.danger:hover { filter: brightness(1.1); }
.gc-btn.mute { background: var(--fg-dim); }
.gc-btn.mute.on { background: var(--accent-2); }
.gc-btn.mute:hover { filter: brightness(1.1); }
.gc-btn.speaker { background: var(--fg-dim); }
.gc-btn.speaker.on { background: #22c55e; }
.gc-btn.speaker:hover { filter: brightness(1.1); }

.toasts {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 11px 16px;
  background: var(--bg-2); border: 1px solid var(--accent);
  font-family: var(--font); font-weight: 700; font-size: 12px;
  max-width: 320px;
  animation: toastIn .2s;
  border-radius: var(--r-md);
}
.toast.err { border-color: var(--danger); }
.toast.ok  { border-color: var(--accent-2); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px) } to { opacity: 1; transform: none } }

/* ═══════════ СВАЙП СООБЩЕНИЙ ═══════════ */
.msg-swipe-bg {
  position: absolute; top: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  width: 60px; pointer-events: none;
  opacity: 0; transition: opacity .12s;
  border-radius: var(--r-lg);
}
.msg-swipe-bg svg { width: 22px; height: 22px; }
.msg:not(.mine) .msg-swipe-bg.left { left: -68px; color: var(--accent); background: rgba(139,92,246,.15); }
.msg.mine .msg-swipe-bg.left { right: -68px; color: var(--accent); background: rgba(139,92,246,.15); }
.msg:not(.mine) .msg-swipe-bg.right { right: -68px; color: var(--danger); background: rgba(239,68,68,.15); }
.msg.mine .msg-swipe-bg.right { left: -68px; color: var(--danger); background: rgba(239,68,68,.15); }
.msg.swipe-left .msg-swipe-bg.left { opacity: 1; }
.msg.swipe-right .msg-swipe-bg.right { opacity: 1; }
.msg.swipe-left.swipe-ready .msg-swipe-bg.left { background: var(--accent); color: #fff; }
.msg.swipe-right.swipe-ready .msg-swipe-bg.right { background: var(--danger); color: #fff; }
.msg.swiping { transition: none; user-select: none; }
.msg.long-press .bubble { background: var(--bg-3); border-color: var(--accent-2); animation: longPressPulse .18s ease; }
@keyframes longPressPulse { 0% { transform: scale(1); } 50% { transform: scale(.97); } 100% { transform: scale(1); } }

.scroll-bottom-btn {
  position: absolute; right: 18px; bottom: 90px;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--line-2);
  display: none; align-items: center; justify-content: center;
  z-index: 8; cursor: pointer;
}
.scroll-bottom-btn.show { display: flex; }
.scroll-bottom-btn svg { width: 20px; height: 20px; }
.scroll-bottom-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.resizer {
  width: 5px; cursor: col-resize; background: transparent;
  flex-shrink: 0; z-index: 40; transition: background .15s;
  margin-left: -3px; margin-right: -3px;
  position: relative;
}
.resizer:hover, .resizer.dragging { background: var(--accent); }
@media (max-width: 760px) { .resizer { display: none !important; } }

.stories-bar {
  display: flex; gap: 10px; padding: 10px 12px;
  overflow-x: auto; background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0; scrollbar-width: none;
}
.stories-bar::-webkit-scrollbar { display: none; }
.story-bubble {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
  gap: 4px; cursor: pointer; width: 68px;
}
.story-bubble .ring {
  width: 56px; height: 56px; border-radius: 50%; padding: 2px;
  background: var(--line-2); position: relative;
}
.story-bubble .ring:not(.viewed):not(.mine) { background: var(--accent); }
.story-bubble .ring.viewed { background: var(--line); }
.story-bubble .ring.mine { background: var(--accent-2); }
.story-bubble .ring.add::after {
  content: '+'; position: absolute; bottom: -2px; right: -2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-2); color: #fff; font-weight: 900; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.story-bubble .ring .avatar { width: 100%; height: 100%; border: none; font-size: 18px; }
.story-bubble .name { font-size: 10px; color: var(--fg-dim); font-weight: 600; max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }

.story-viewer {
  position: fixed; inset: 0; z-index: 300;
  background: #000;
  display: flex; flex-direction: column;
  touch-action: none;
  user-select: none;
  transition: transform .2s ease, opacity .2s ease;
}
.story-viewer.dragging { transition: none; }
.story-viewer.closing { pointer-events: none; }
.story-viewer .sv-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,.7), transparent);
}
.story-viewer .sv-avatar { width: 34px; height: 34px; border-radius: 50%; }
.story-viewer .sv-meta { flex: 1; color: #fff; min-width: 0; }
.story-viewer .sv-meta b { display: block; font-size: 14px; }
.story-viewer .sv-meta span { font-size: 11px; opacity: .7; }
.story-viewer .sv-close {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.story-viewer .sv-close svg { width: 18px; height: 18px; }
.story-viewer .sv-progress {
  position: absolute; top: max(6px, env(safe-area-inset-top));
  left: 8px; right: 8px; height: 3px;
  background: rgba(255,255,255,.2); border-radius: 2px;
  display: flex; gap: 3px; z-index: 4;
}
.story-viewer .sv-progress div { flex: 1; background: rgba(255,255,255,.4); border-radius: 2px; overflow: hidden; }
.story-viewer .sv-progress div > i { display: block; height: 100%; width: 0; background: #fff; }
.story-viewer .sv-body { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.story-viewer .sv-body img, .story-viewer .sv-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.story-viewer .sv-body .sv-text {
  padding: 40px; color: #fff; font-size: 28px; font-weight: 800;
  text-align: center; line-height: 1.3; max-width: 90%;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  word-break: break-word;
}
.story-viewer .sv-nav { position: absolute; top: 0; bottom: 0; width: 30%; z-index: 2; cursor: pointer; }
.story-viewer .sv-nav.left { left: 0; }
.story-viewer .sv-nav.right { right: 0; }
.story-viewer .sv-foot {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
  z-index: 3;
}
.story-viewer .sv-reactions { display: flex; gap: 8px; }
.story-viewer .sv-reactions button {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.15); border: none;
  font-size: 20px; cursor: pointer;
}
.story-viewer .sv-views { margin-left: auto; color: #fff; font-size: 12px; display: flex; align-items: center; gap: 4px; }
.story-viewer .sv-delete { background: rgba(239,68,68,.3); color: #fff; border: none; padding: 8px 12px; border-radius: 20px; font-size: 12px; cursor: pointer; }

.poll-bubble { min-width: 260px; }
.poll-q { font-weight: 800; font-size: 14px; margin-bottom: 10px; }
.poll-opt {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; margin-bottom: 6px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; font-family: var(--font);
  color: var(--fg); font-size: 13px; font-weight: 600;
  position: relative; overflow: hidden;
  transition: border-color .12s;
}
.poll-opt:hover { border-color: var(--accent); }
.poll-opt.voted { border-color: var(--accent); background: var(--bg-2); }
.poll-opt .poll-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bg-3); pointer-events: none; transition: width .25s; }
.poll-opt .poll-row { position: relative; display: flex; justify-content: space-between; align-items: center; }
.poll-opt .poll-cnt { color: var(--fg-mute); font-size: 11px; font-weight: 700; }
.poll-meta { font-size: 11px; color: var(--fg-mute); margin-top: 6px; }

.poll-options-list { display: flex; flex-direction: column; gap: 6px; }
.poll-option-row { display: flex; gap: 6px; align-items: center; }
.poll-option-row input {
  flex: 1; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--font); font-weight: 600; font-size: 13px;
  color: var(--fg);
}
.poll-option-row input:focus { border-color: var(--accent-2); }
.poll-option-row .rm {
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; padding: 0;
}
.poll-option-row .rm:hover { background: var(--danger); color: #fff; }

.forward-item { display: flex; align-items: center; gap: 10px; padding: 10px; cursor: pointer; border-radius: 8px; }
.forward-item:hover { background: var(--bg-2); }
.forward-item input { width: 18px; height: 18px; accent-color: var(--accent); }

.create-list { display: flex; flex-direction: column; gap: 8px; }
.create-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-md); text-align: left; color: var(--fg);
  font-family: var(--font); font-weight: 700; font-size: 14px;
  cursor: pointer; transition: .15s; width: 100%;
}
.create-btn:hover { border-color: var(--accent); background: var(--bg-2); }
.create-btn .ico {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.create-btn .ico svg { width: 20px; height: 20px; }
.create-btn .body { flex: 1; min-width: 0; }
.create-btn .body b { display: block; font-size: 14px; }
.create-btn .body span { display: block; font-size: 11px; color: var(--fg-mute); margin-top: 2px; font-weight: 600; }

.story-preview {
  width: 100%; height: 160px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; margin-bottom: 14px;
  font-size: 18px; font-weight: 800; color: #fff;
  text-align: center; word-break: break-word;
  background: #8b5cf6; transition: background .2s; overflow: hidden;
}
.story-preview span { line-height: 1.3; }

.admin-box { max-width: 520px; }
.admin-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 4px;
  background: var(--bg-1);
}
.admin-tab {
  flex: 1; padding: 9px 8px;
  font-family: var(--font); font-weight: 800; font-size: 12px;
  letter-spacing: .5px; border-radius: var(--r-sm);
  color: var(--fg-mute); background: transparent;
  border: 1px solid transparent; transition: .15s;
}
.admin-tab:hover { color: var(--purple); }
.admin-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 8px; }
.stat-card { padding: 14px 10px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-md); text-align: center; transition: .15s; }
.stat-card:hover { border-color: var(--accent); }
.stat-num { font-family: var(--font); font-weight: 900; font-size: 22px; color: var(--fg); line-height: 1.1; margin-bottom: 4px; }
.stat-lbl { font-size: 10px; font-weight: 700; color: var(--fg-mute); letter-spacing: .5px; text-transform: uppercase; line-height: 1.2; }

.admin-users { max-height: 400px; overflow-y: auto; }
.admin-user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r-md); transition: .15s;
}
.admin-user-card:hover { border-color: var(--line-2); }
.admin-user-card.banned { background: rgba(239, 68, 68, .08); border-color: rgba(239, 68, 68, .3); }
.admin-user-card.system { background: rgba(139, 92, 246, .08); border-color: rgba(139, 92, 246, .3); }
.admin-user-card .avatar { width: 38px; height: 38px; font-size: 14px; flex-shrink: 0; }
.admin-user-card .avatar.image { color: transparent; }
.admin-user-card .admin-user-body { flex: 1; min-width: 0; }
.admin-user-card .admin-user-name {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font); font-weight: 800; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-user-card .admin-user-name .ban-chip {
  display: inline-block; padding: 1px 6px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 800;
  border-radius: 6px; letter-spacing: .5px; flex-shrink: 0;
}
.admin-user-card .admin-user-sub { font-size: 11px; color: var(--fg-mute); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-user-card .admin-user-sub b { color: var(--accent-2); font-weight: 700; }
.admin-user-card .admin-user-date { font-size: 10px; color: var(--fg-mute); margin-top: 3px; letter-spacing: .3px; }
.admin-user-card .ban-btn {
  padding: 7px 12px;
  font-family: var(--font); font-weight: 800; font-size: 10px;
  letter-spacing: .5px; border-radius: var(--r-sm);
  border: 1px solid var(--danger);
  background: transparent; color: var(--danger);
  flex-shrink: 0; transition: .15s; white-space: nowrap;
}
.admin-user-card .ban-btn:hover { background: var(--danger); color: #fff; }
.admin-user-card .ban-btn.unban { border-color: var(--accent); color: var(--accent); }
.admin-user-card .ban-btn.unban:hover { background: var(--accent); color: #fff; }

#btnAdmin { background: transparent; color: #ffcc00; border-color: rgba(255, 200, 0, .4); }
#btnAdmin:hover { background: rgba(255, 200, 0, .15); color: #fff; border-color: #ffcc00; }
#browseSearch { margin-bottom: 12px; }
#adminUserSearch { margin-bottom: 12px; }

.msg-reads { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; color: var(--fg-mute); margin-left: 4px; }

/* ═══════════════ MARKDOWN ═══════════════ */
.msg-text b, .msg-text strong, .post-text b, .post-text strong, .md-preview b { font-weight: 900; }
.msg-text i, .msg-text em, .post-text i, .post-text em, .md-preview i { font-style: italic; }
.msg-text u, .post-text u, .md-preview u { text-decoration: underline; text-underline-offset: 2px; }
.msg-text s, .msg-text del, .post-text s, .post-text del, .md-preview s { text-decoration: line-through; opacity: .7; }
.msg-text blockquote, .post-text blockquote, .md-preview blockquote {
  display: block;
  border-left: 3px solid var(--accent-2);
  padding: 2px 10px;
  margin: 4px 0;
  background: var(--bg-1);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--fg-dim);
  font-style: italic;
}
.md-code {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  background: var(--bg-3);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.md-pre {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin: 6px 0;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.4;
}
.md-pre code {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  color: var(--fg);
  font-weight: 600;
  white-space: pre;
}
.md-spoiler {
  background: var(--fg);
  color: transparent !important;
  border-radius: 4px;
  padding: 0 4px;
  cursor: pointer;
  user-select: none;
  transition: .15s;
}
.md-spoiler.revealed {
  background: var(--bg-3);
  color: var(--fg) !important;
  user-select: text;
}

/* ═══════════════ ТУЛБАР РЕДАКТИРОВАНИЯ ═══════════════ */
.md-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 10px; padding: 6px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.md-toolbar button {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--fg-dim);
  font-family: var(--font); font-size: 14px;
  cursor: pointer; transition: .15s; padding: 0;
}
.md-toolbar button:hover { background: var(--bg-3); border-color: var(--accent); color: var(--accent); }

#editTextarea, #postTextarea {
  width: 100%; padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg);
  font-family: var(--font); font-weight: 700; font-size: 14px;
  border-radius: var(--r-md);
  resize: vertical; min-height: 100px;
  outline: none; line-height: 1.5;
}
#editTextarea:focus, #postTextarea:focus { border-color: var(--accent-2); }

.md-preview {
  margin-top: 10px; padding: 12px;
  background: var(--bg-1);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  font-size: 13px; line-height: 1.5; min-height: 40px;
  color: var(--fg); word-break: break-word; white-space: pre-wrap;
}
.md-preview:empty::before { content: 'Предпросмотр…'; color: var(--fg-mute); }

/* ═══════════════ ЛЕНТА ПОСТОВ ═══════════════ */
.feed {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
}
.feed-head {
  display: flex; align-items: center; justify-content: center;
  padding: 14px 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  position: relative;
}
.feed-head h2 { font-family: var(--font); font-weight: 900; font-size: 20px; letter-spacing: 1px; color: var(--fg); }
.feed-body {
  flex: 1; overflow-y: auto;
  padding: 20px 14px;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-anchor: none;
  overscroll-behavior: contain;
}
.feed-empty {
  text-align: center; padding: 60px 20px;
  color: var(--fg-mute); font-size: 13px;
  max-width: 560px; width: 100%;
}
.feed-empty .big { font-size: 42px; display: block; margin-bottom: 14px; opacity: .5; }

.post-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  margin-bottom: 14px;
  transition: .15s;
  width: 100%;
  max-width: 560px;
  flex-shrink: 0;
}
.post-card:hover { border-color: var(--line-2); }
.post-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post-head .avatar { width: 40px; height: 40px; cursor: pointer; }
.post-head-info { flex: 1; min-width: 0; }
.post-head-info b { display: block; font-family: var(--font); font-weight: 800; font-size: 14px; cursor: pointer; }
.post-head-info span { display: block; font-size: 11px; color: var(--fg-mute); margin-top: 2px; font-weight: 600; }
.post-text {
  font-size: 14px; font-weight: 700; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap; margin-bottom: 10px;
}
.post-actions { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.post-actions button {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--fg-dim);
  font-family: var(--font); font-weight: 700; font-size: 12px;
  cursor: pointer; transition: .15s;
}
.post-actions button:hover { border-color: var(--accent); color: var(--accent); }
.post-actions button.liked { border-color: var(--accent-2); color: var(--accent-2); background: rgba(236,72,153,.1); }
.post-actions button svg { width: 14px; height: 14px; }
.post-actions .post-delete { margin-left: auto; color: var(--danger); border-color: transparent; }
.post-actions .post-delete:hover { border-color: var(--danger); }

.feed-fab {
  position: absolute; right: 20px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-2); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(236,72,153,.4);
  cursor: pointer; transition: .15s; z-index: 16;
}
.feed-fab:hover { filter: brightness(1.1); transform: translateY(-2px); }
.feed-fab svg { width: 26px; height: 26px; }

/* ═══════════════ КАРУСЕЛЬ В ПОСТАХ ═══════════════ */
.post-carousel-wrap { position: relative; }
.post-carousel {
  display: flex; gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 10px -18px 8px;
  padding: 0 18px;
  touch-action: pan-x pan-y;
}
.post-carousel::-webkit-scrollbar { display: none; }
.post-carousel-item {
  flex: 0 0 78%;
  max-width: 420px;
  scroll-snap-align: center;
  aspect-ratio: 4 / 5;
  max-height: 480px;
  background: #000;
  border-radius: var(--r-md);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--line);
}
.post-carousel-item img,
.post-carousel-item video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.post-carousel-item .play-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.6); color: #fff;
  border-radius: 50%; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
}
.post-carousel-item .play-badge svg { width: 16px; height: 16px; }
.post-carousel-dots {
  display: flex; gap: 4px; justify-content: center; margin-bottom: 8px;
}
.post-carousel-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--line-2); transition: .15s;
}
.post-carousel-dots span.active { background: var(--accent); }

/* ═══════════════ КОММЕНТАРИИ К ПОСТАМ ═══════════════ */
.post-comments-preview {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.post-comment-item {
  display: flex; gap: 8px; align-items: flex-start;
}
.post-comment-item .avatar {
  width: 28px; height: 28px; font-size: 11px;
  flex-shrink: 0;
}
.post-comment-body {
  flex: 1; min-width: 0;
  background: var(--bg-1);
  padding: 6px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}
.post-comment-author {
  font-family: var(--font); font-weight: 800; font-size: 12px;
  color: var(--accent); cursor: pointer;
}
.post-comment-text {
  font-size: 12px; line-height: 1.4;
  margin-top: 2px;
  word-break: break-word;
  white-space: pre-wrap;
}
.post-comment-meta {
  font-size: 10px; color: var(--fg-mute);
  margin-top: 3px; display: flex;
  justify-content: space-between;
}
.post-comment-delete {
  background: none; border: none;
  color: var(--danger); font-size: 11px;
  cursor: pointer; padding: 0;
}
.post-comment-form {
  display: flex; gap: 6px; align-items: center;
  margin-top: 8px;
}
.post-comment-form input {
  flex: 1; padding: 8px 12px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 20px;
  font-family: var(--font); font-weight: 600;
  font-size: 13px; color: var(--fg);
}
.post-comment-form input:focus { border-color: var(--accent-2); }
.post-comment-form button {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; flex-shrink: 0;
}
.post-comment-form button svg { width: 16px; height: 16px; }
.post-comment-form button:disabled { background: var(--line); cursor: not-allowed; }

.comments-list {
  max-height: 50vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 12px;
}

.post-media-preview {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px;
}
.post-media-preview .attach-chip { width: 68px; height: 68px; }
.post-media-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 20px; color: var(--fg-dim);
  font-family: var(--font); font-weight: 700; font-size: 12px;
  cursor: pointer; transition: .15s;
  margin-top: 10px;
}
.post-media-btn:hover { border-color: var(--accent); color: var(--accent); }
.post-media-btn svg { width: 14px; height: 14px; }

/* ═══════════════ МОБИЛЬНАЯ НАВИГАЦИЯ ═══════════════ */
.mobile-nav {
  display: none; position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(58px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-1);
  border-top: 1px solid var(--line);
  z-index: 35;
  align-items: stretch;
}
.mobile-nav button {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; color: var(--fg-mute);
  font-family: var(--font); font-weight: 700; font-size: 10px;
  letter-spacing: .3px; background: none; border: none;
  transition: color .15s; position: relative;
  padding: 6px 4px; cursor: pointer;
}
.mobile-nav button svg { width: 22px; height: 22px; }
.mobile-nav button.active { color: var(--accent); }
.mobile-nav button.active::before {
  content: ''; position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px;
  background: var(--accent); border-radius: 0 0 3px 3px;
}
.mobile-nav button .nav-badge {
  position: absolute; top: 2px; left: calc(50% + 8px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--accent-2); color: #fff;
  font-size: 9px; font-weight: 800; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.mobile-nav button .nav-badge[data-zero="1"] { display: none; }

/* ═══════════════ DESKTOP (лeнтa нe пoкрывaет sidebar) ═══════════════ */
@media (min-width: 761px) {
  .feed {
    left: var(--sidebar-w);
    border-left: 1px solid var(--line);
  }
}

/* ═══════════════ МОБИЛЬНАЯ ═══════════════ */
@media (max-width: 760px) {
  :root { --sidebar-w: 100%; }

  .sidebar {
    position: absolute; inset: 0;
    z-index: 20; width: 100%;
    transition: transform .22s ease;
    border-right: none;
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
    padding-top: 0 !important;
    transform: translateZ(0);
    will-change: transform;
  }
  .app.chat-open .sidebar { transform: translate3d(-100%, 0, 0); }
  .chat-pane { width: 100%; padding-top: 0 !important; padding-bottom: 0 !important; }
  .back-btn { display: inline-flex; }

  .mobile-nav { display: flex; }
  body.chat-open .mobile-nav { display: none !important; }
  .me-card { display: none !important; }

  .side-top { padding-top: calc(14px + env(safe-area-inset-top, 0px)) !important; }
  .chat-top { padding-top: calc(11px + env(safe-area-inset-top, 0px)) !important; }
  .inchat-search { padding-top: calc(8px + env(safe-area-inset-top, 0px)) !important; }
  .composer { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important; }

  .side-top .logo { font-size: 17px !important; letter-spacing: 1px !important; }
  .conn-status { font-size: 8px; }

  .msg { max-width: 88%; }

  .emoji-pop { width: calc(100vw - 24px); grid-template-columns: repeat(7, 1fr); }

  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }

  .modal { padding: 12px; align-items: flex-end; }
  .modal-box { max-width: 100%; max-height: 88vh; }

  input, textarea, select, .modal-search, #msgInput, #peopleSearch,
  #inchatSearchInput, #chatSearch, .field input,
  #editTextarea, #postTextarea, #aliasInput,
  #commentsInput, .post-comment-form input { font-size: 16px !important; }
  .code-input { letter-spacing: 6px !important; font-size: 22px !important; }
  #msgInput { min-height: 44px; padding: 12px; }

  .video-wrap { max-width: 100%; }
  .video-msg-wrap { width: 200px; }
  .att-grid { max-width: 100%; }
  .voice-wrap { min-width: 180px; }

  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat-card { padding: 10px 6px; }
  .stat-num { font-size: 18px; }
  .stat-lbl { font-size: 9px; }
  .admin-box { max-width: 100%; }
  .admin-user-card .admin-user-date { display: none; }

  .gc-participants { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .gc-tile .avatar { width: 56px; height: 56px; font-size: 20px; }

  .call-banner {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    padding: 6px 12px 6px 8px;
    max-width: calc(100vw - 16px);
  }
  .call-banner-avatar { width: 30px; height: 30px; }
  .call-banner-info b { font-size: 12px; }
  .call-banner-open { padding: 5px 10px; font-size: 10px; }

  .feed-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .feed-fab { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }

  .feed-body {
    padding: 14px 10px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .post-card { padding: 14px; max-width: 100%; }
  .post-carousel-item { flex: 0 0 86%; max-width: none; max-height: none; }
}

body.kb-open .mobile-nav { display: none !important; }
body.kb-open .toasts { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}