/* ========================================
   CSS VARIABLES
======================================== */
:root {
  --bg-primary: #080810;
  --bg-secondary: #0f0f1a;
  --glass-bg: rgba(255,255,255,0.05);
  --glass-border: rgba(255,255,255,0.13);
  --glass-hover: rgba(255,255,255,0.1);
  --glass-shine: rgba(255,255,255,0.18);
  --text-primary: #ffffff;
  --text-secondary: rgba(255,255,255,0.65);
  --text-muted: rgba(255,255,255,0.32);
  --accent: #ffffff;
  --accent-soft: rgba(255,255,255,0.12);
  --danger: #ff4444;
  --success: #44ff88;
  --warning: #ffaa00;
  --blur: blur(28px) saturate(160%);
  --blur-heavy: blur(40px) saturate(180%);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --transition: 0.3s ease;
  --navbar-height: 60px;
  --sidebar-width: 64px;
  --glow-white: 0 0 20px rgba(255,255,255,0.08);
  --shadow-glass: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
  --inset-shine: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -1px 0 rgba(0,0,0,0.12);
}

/* ── Dark theme (AMOLED black) ── */
.dark-theme {
  --bg-primary: #000000;
  --bg-secondary: #050505;
  --glass-bg: rgba(255,255,255,0.03);
  --glass-border: rgba(255,255,255,0.07);
  --glass-hover: rgba(255,255,255,0.05);
  --glass-shine: rgba(255,255,255,0.08);
  --text-primary: #e8e8e8;
  --text-secondary: rgba(255,255,255,0.5);
  --text-muted: rgba(255,255,255,0.22);
  --accent: #e8e8e8;
  --accent-soft: rgba(255,255,255,0.07);
  --glow-white: none;
  --shadow-glass: 0 4px 20px rgba(0,0,0,0.9);
  --inset-shine: inset 0 1px 0 rgba(255,255,255,0.07), inset 0 -1px 0 rgba(0,0,0,0.5);
}
body.dark-theme { background: #000 !important; }
body.dark-theme .glass-card,
body.dark-theme .glass-card-sm { background: #0d0d0d; border-color: rgba(255,255,255,0.05); box-shadow: none; }
body.dark-theme .navbar { background: #000; border-bottom: 1px solid rgba(255,255,255,0.05); box-shadow: none; }
body.dark-theme .nav-center { background: #0d0d0d; border-color: rgba(255,255,255,0.06); box-shadow: 0 4px 24px rgba(0,0,0,0.9); }
body.dark-theme .nav-search-circle { background: #0d0d0d; border-color: rgba(255,255,255,0.06); }
body.dark-theme .message-bubble.other { background: #141414; border-color: rgba(255,255,255,0.05); backdrop-filter: none; box-shadow: none; }
body.dark-theme #chat-messages-area { background: #000; }
body.dark-theme input,
body.dark-theme textarea { background: #0d0d0d !important; border-color: rgba(255,255,255,0.08) !important; color: #e8e8e8 !important; }
body.dark-theme .chat-header-name-card { background: #0d0d0d; border-color: rgba(255,255,255,0.05); }
body.dark-theme .profile-menu-item { background: transparent; }
body.dark-theme .profile-menu-item:hover { background: rgba(255,255,255,0.06); }
body.dark-theme .msg-context-menu { background: #111; border-color: rgba(255,255,255,0.07); }
body.dark-theme .post-card { background: #0d0d0d; border-color: rgba(255,255,255,0.04); }
body.dark-theme .contact-item:hover,
body.dark-theme .chat-item:hover { background: rgba(255,255,255,0.04); }
body.dark-theme .chat-input-bar { background: #000; border-top: 1px solid rgba(255,255,255,0.05); }
body.dark-theme .chat-input { background: #0d0d0d !important; border-color: rgba(255,255,255,0.07) !important; }

.light-theme {
  --bg-primary: #e8eaf0;
  --bg-secondary: #d8dae8;
  --glass-bg: rgba(255,255,255,0.45);
  --glass-border: rgba(255,255,255,0.65);
  --glass-hover: rgba(255,255,255,0.7);
  --glass-shine: rgba(255,255,255,0.9);
  --text-primary: #111122;
  --text-secondary: rgba(0,0,10,0.6);
  --text-muted: rgba(0,0,10,0.35);
  --accent: #111122;
  --accent-soft: rgba(0,0,10,0.1);
  --glow-white: 0 0 20px rgba(255,255,255,0.3);
  --shadow-glass: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  --inset-shine: inset 0 1px 0 rgba(255,255,255,0.9), inset 0 -1px 0 rgba(0,0,0,0.04);
}

/* ========================================
   RESET & BASE
======================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  height: 100%;
  /* Prevent text resize on orientation change */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: hidden;
  transition: background var(--transition), color var(--transition);
  /* Prevent callout/selection on long-press for non-text */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a { color: inherit; text-decoration: none; cursor: pointer; }
button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-primary);
  background: transparent;
  /* Remove iOS default styling */
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ========================================
   SCROLLBAR
======================================== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========================================
   BACKGROUND BLOBS
======================================== */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.22;
  pointer-events: none;
  z-index: 0;
  animation: blobFloat 22s infinite ease-in-out;
}
.blob-1 {
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(120,120,255,0.5), rgba(80,60,200,0.2), transparent);
  top: -250px; left: -200px;
  animation-delay: 0s;
}
.blob-2 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(255,100,200,0.35), rgba(180,60,180,0.15), transparent);
  bottom: -150px; right: -150px;
  animation-delay: -6s;
}
.blob-3 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(60,200,255,0.3), rgba(40,140,200,0.1), transparent);
  top: 45%; left: 45%;
  transform: translate(-50%, -50%);
  animation-delay: -12s;
}
.blob-4 {
  width: 450px; height: 450px;
  background: radial-gradient(circle, rgba(100,255,180,0.25), rgba(60,200,120,0.1), transparent);
  top: 25%; right: 5%;
  animation-delay: -18s;
}
.blob-5 {
  width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(255,200,80,0.2), rgba(200,140,40,0.08), transparent);
  bottom: 20%; left: 10%;
  animation-delay: -9s;
}

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  20% { transform: translate(40px, -40px) scale(1.06); }
  40% { transform: translate(-30px, 25px) scale(0.94); }
  60% { transform: translate(25px, 40px) scale(1.03); }
  80% { transform: translate(-20px, -20px) scale(0.97); }
}

/* ========================================
   GLASS CARD
======================================== */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-glass), var(--inset-shine);
}
/* top edge shine */
.glass-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--glass-shine) 40%, var(--glass-shine) 60%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}
/* diagonal light sweep */
.glass-card::after {
  content: '';
  position: absolute;
  top: -60%; left: -60%;
  width: 220%; height: 220%;
  background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.glass-panel {
  background: var(--glass-bg);
  border-right: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--inset-shine);
}

/* ========================================
   NAVBAR
======================================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: rgba(8,8,18,0.7);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: var(--blur-heavy);
  -webkit-backdrop-filter: var(--blur-heavy);
  box-shadow: 0 1px 0 rgba(255,255,255,0.07), 0 4px 24px rgba(0,0,0,0.3);
}

.light-theme .navbar {
  background: rgba(232,234,240,0.75);
  box-shadow: 0 1px 0 rgba(255,255,255,0.8), 0 4px 24px rgba(0,0,0,0.08);
}

.nav-left { display: flex; align-items: center; gap: 1rem; }
.nav-right { display: flex; align-items: center; gap: 1rem; }

/* ── Desktop sidebar nav ── */
.nav-center {
  position: fixed;
  left: 1rem;
  top: calc(var(--navbar-height) + 1.25rem);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem;
  width: var(--sidebar-width);
  border-radius: 20px;
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.08);
}
.light-theme .nav-center {
  background: rgba(255,255,255,0.38);
  border-color: rgba(255,255,255,0.55);
  box-shadow: 0 8px 40px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.6);
}

/* Profile link only shown in bottom mobile bar */
.nav-link-profile-mobile { display: none; }

/* ── Search circle button ── */
.nav-search-circle {
  position: fixed;
  /* центрируем под сайдбаром: 1rem отступ + (64px - 48px)/2 = 8px */
  left: calc(1rem + 8px);
  bottom: 2rem;
  z-index: 90;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: var(--text-secondary);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow:
    0 4px 20px rgba(0,0,0,0.35),
    0 0 0 4px rgba(255,255,255,0.03),
    var(--inset-shine);
}
.nav-search-circle:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.22);
  transform: scale(1.1);
  box-shadow:
    0 6px 28px rgba(120,80,255,0.35),
    0 0 0 4px rgba(120,80,255,0.08),
    var(--inset-shine);
}
.nav-search-circle.active {
  background: var(--accent-soft);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.2);
  box-shadow:
    0 6px 24px rgba(120,80,255,0.4),
    0 0 0 4px rgba(120,80,255,0.1),
    var(--inset-shine);
}
.light-theme .nav-search-circle {
  background: rgba(255,255,255,0.38);
  border-color: rgba(255,255,255,0.55);
}

/* Тонкая разделительная линия между сайдбаром и кружком поиска */
.nav-search-circle::before {
  content: '';
  position: absolute;
  top: -0.65rem;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 0.5rem;
  background: rgba(255,255,255,0.12);
}

/* ── Toggle switch ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-secondary);
  gap: 1rem;
}
.toggle-checkbox { display: none; }
.toggle-slider {
  position: relative;
  width: 42px;
  height: 24px;
  background: rgba(255,255,255,0.12);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  flex-shrink: 0;
  transition: background var(--transition);
  backdrop-filter: blur(8px);
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.toggle-checkbox:checked + .toggle-slider {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.3);
}
.toggle-checkbox:checked + .toggle-slider::after {
  left: 21px;
  background: var(--text-primary);
}

.nav-logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  cursor: pointer;
  color: var(--text-primary);
  transition: opacity var(--transition);
}
.nav-logo:hover { opacity: 0.7; }

.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0.7rem;
  border-radius: 14px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  width: 100%;
  white-space: nowrap;
}
.nav-link span { display: none; }
.nav-link:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  transform: scale(1.08);
}
.nav-link.active {
  background: var(--accent-soft);
  color: var(--text-primary);
}
.nav-link i { font-size: 1.1rem; flex-shrink: 0; }

.mobile-menu-btn {
  display: none; /* hidden — nav is always visible (sidebar/bottom bar) */
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  padding: 0.4rem;
  cursor: pointer;
}

.nav-bell {
  position: relative;
  padding: 0.4rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--transition);
}
.nav-bell:hover { color: var(--text-primary); }
.nav-bell .badge {
  position: absolute;
  top: 0; right: 0;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  position: relative;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.nav-user:hover { background: var(--glass-hover); color: var(--text-primary); }

.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 180px;
  padding: 0.5rem;
  z-index: 200;
  display: none;
  animation: dropdownFade 0.2s ease;
}
.dropdown-menu.open { display: block; }

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all var(--transition);
  cursor: pointer;
}
.dropdown-item:hover { background: var(--glass-hover); color: var(--text-primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: rgba(255,68,68,0.1); }
.dropdown-divider { height: 1px; background: var(--glass-border); margin: 0.3rem 0; }

/* ========================================
   MAIN LAYOUT
======================================== */
.main-content {
  margin-top: var(--navbar-height);
  margin-left: calc(var(--sidebar-width) + 2rem);
  min-height: calc(100vh - var(--navbar-height));
  position: relative;
  z-index: 1;
  transition: margin-left var(--transition);
  overflow-x: hidden;
}

.page {
  display: none !important;
  overflow-x: hidden;
  max-width: 100%;
}
.page.active { display: block !important; }
.page.active.page-split { display: flex !important; }
/* channel-view and profile pages use flex for their inner layout via .page-content */

.page-content {
  padding: 2rem;
  width: 100%;
}

/* Profile-view: match back button position to chat header */
#page-profile-view .page-content {
  padding: 0.875rem 1.25rem 2rem;
}
#page-profile-view #profile-view-back-btn {
  margin-bottom: 0.875rem;
}

.centered-content {
  max-width: 700px;
  margin: 0 auto;
}

.page-split {
  height: calc(100vh - var(--navbar-height));
  overflow: hidden;
}

.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

/* Feed tabs */
/* ── Feed composer ─────────────────────── */
.feed-composer {
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  border-radius: 16px;
}
.feed-composer-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.feed-composer-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}
.feed-composer-input-wrap {
  flex: 1;
}
.feed-composer-textarea {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 0.6rem 0.85rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s, rows 0.2s;
  font-family: inherit;
  line-height: 1.5;
}
.feed-composer-textarea:focus {
  border-color: var(--accent);
}
.feed-composer-textarea::placeholder {
  color: var(--text-muted);
}
.feed-composer-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.75rem;
  padding-left: calc(38px + 0.75rem);
}
.feed-composer-media-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 1rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.feed-composer-media-btn:hover {
  background: rgba(120,80,255,0.18);
  color: var(--accent);
  border-color: var(--accent);
}
.feed-composer-actions .btn-ghost,
.feed-composer-actions .btn-primary {
  padding: 0.55rem 1.3rem;
  font-size: 0.95rem;
  border-radius: 12px;
  height: 40px;
}

/* ── Channel inline composer ─────────────── */
.ch-inline-composer {
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  border-radius: 16px;
}
.ch-composer-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.ch-composer-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}
.ch-composer-input-wrap {
  flex: 1;
}
.ch-composer-textarea {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 0.6rem 0.85rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  line-height: 1.5;
}
.ch-composer-textarea:focus {
  border-color: rgba(120,80,255,0.7);
}
.ch-composer-textarea::placeholder {
  color: var(--text-muted);
}
.ch-composer-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.75rem;
  padding-left: calc(38px + 0.75rem);
}
.ch-composer-media-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 1rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.ch-composer-media-btn:hover {
  background: rgba(120,80,255,0.18);
  color: #7850ff;
  border-color: rgba(120,80,255,0.7);
}
.ch-composer-actions .btn-ghost,
.ch-composer-actions .btn-primary {
  padding: 0.55rem 1.3rem;
  font-size: 0.95rem;
  border-radius: 12px;
  height: 40px;
}

.feed-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 3px;
}
.feed-tab {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border-radius: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.feed-tab.active {
  background: rgba(120, 80, 255, 0.25);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 6px rgba(120,80,255,0.18);
}
.feed-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  padding: 0.42rem 1.1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    0 3px 12px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
  letter-spacing: 0.02em;
}

/* ========================================
   SIDEBAR PANEL
======================================== */
.sidebar-panel {
  width: 320px;
  min-width: 280px;
  height: 100%;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  padding: 0.42rem 1.1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    0 3px 12px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
  letter-spacing: 0.02em;
}

/* ========================================
   CHAT LIST
======================================== */
.chat-list { padding: 0.5rem; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.chat-item:hover { background: var(--glass-hover); }
.chat-item.active { background: var(--accent-soft); }

.chat-item-avatar {
  position: relative;
  flex-shrink: 0;
}
.chat-item-avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
}

.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item-last {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.chat-item-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.chat-item-unread {
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ========================================
   CHAT MAIN
======================================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 1rem;
}
.chat-empty-state i { opacity: 0.3; }

.chat-header {
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: transparent;
  flex-shrink: 0;
}

.chat-back-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}
.chat-back-btn:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.22);
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}
.chat-header-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
  cursor: pointer;
}
.chat-header-info { flex: 1; }
.chat-header-name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}
.chat-header-status { font-size: 0.78rem; color: var(--text-muted); }
.chat-header-status.online { color: var(--success); }

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message-bubble {
  max-width: 65%;
  padding: 0.6rem 0.9rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  transition: all var(--transition);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.message-bubble.own {
  background: linear-gradient(135deg, #7850ff, #5b30e0);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(120,80,255,0.3);
}
.message-bubble.other {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.15);
}

.message-wrap {
  display: flex;
  flex-direction: column;
  position: relative;
}
.message-wrap.own { align-items: flex-end; }
.message-wrap.other { align-items: flex-start; }

/* Swipe-to-reply icon */
.swipe-reply-icon {
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%) scale(0.5);
  opacity: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(120,80,255,0.18);
  border: 1.5px solid rgba(120,80,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a080ff;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 2;
}

.message-sender-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  padding: 0 4px;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}
.message-wrap.own .message-meta { justify-content: flex-end; }

.message-status { display: flex; gap: 1px; }
.message-status i { font-size: 0.65rem; color: rgba(255,255,255,0.6); }
.message-status.delivered i { color: rgba(255,255,255,0.6); }
.message-status.read i { color: rgba(255,255,255,1); }

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding: 0 4px;
}
.reaction-pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2), var(--inset-shine);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
  color: rgba(255,255,255,0.75);
}
.reaction-pill:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.22);
  transform: scale(1.06);
}
.reaction-pill .count { font-size: 0.78rem; color: inherit; }

.message-bubble .react-btn {
  position: absolute;
  opacity: 0;
  transition: opacity var(--transition);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 2px 6px;
  font-size: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-muted);
}
.message-bubble.own .react-btn { left: -50px; }
.message-bubble.other .react-btn { right: -50px; }
.message-bubble:hover .react-btn { opacity: 1; }

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 30px;
  flex-shrink: 0;
}
.typing-dots { display: flex; gap: 3px; }
.typing-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.chat-input-area {
  padding: 0.65rem 0.75rem;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
  background: transparent;
  position: relative;
}

/* Attach button (left circle) */
.chat-attach-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text-muted);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--transition);
}
.chat-attach-btn:hover {
  background: var(--glass-hover);
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.07);
}

/* Center input wrap (pill shape) */
.chat-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
}
.chat-input-wrap textarea {
  flex: 1;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 42px;
  line-height: 1.45;
  color: var(--text-primary);
  width: 100%;
}
.chat-input-wrap textarea:focus {
  outline: none;
  border-color: rgba(120,80,255,0.5);
  box-shadow: 0 0 0 3px rgba(120,80,255,0.1);
}

/* ========================================
   POSTS / FEED
======================================== */
.posts-list { display: flex; flex-direction: column; gap: 1rem; }

.post-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-glass), var(--inset-shine);
}
.post-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
  pointer-events: none;
}
.post-card:hover {
  border-color: rgba(255,255,255,0.22);
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(0,0,0,0.45), var(--inset-shine);
}

.post-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}
.post-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
  cursor: pointer;
  flex-shrink: 0;
}
.post-author-info {
  flex: 1;
  min-width: 0;
}
.post-author-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-author-name:hover { opacity: 0.8; }
.post-author-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.post-menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  cursor: pointer;
  flex-shrink: 0;
}
.post-menu-btn:hover { background: var(--glass-hover); color: var(--text-primary); }

.post-content {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.channel-source {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--accent-soft);
  border-radius: 20px;
  padding: 2px 8px;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
}
.channel-source:hover { color: var(--text-primary); }

.post-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--glass-border);
}

/* Base glass-circle style for post action buttons */
.post-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2), var(--inset-shine);
  color: rgba(255,255,255,0.6);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  white-space: nowrap;
  border-radius: 20px;
  padding: 0.28rem 0.7rem;
  min-width: 38px;
  min-height: 34px;
}
.post-action-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
  color: #fff;
  transform: scale(1.05);
}
.post-action-btn i { font-size: 0.85rem; }
.post-action-btn.reacted { color: var(--text-primary); }

/* react-post-btn: just a circle with smile */
.react-post-btn {
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  min-width: 36px;
  min-height: 36px;
}

/* comments-btn: pill with icon + count */
.comments-btn { border-radius: 20px; }

/* post like button */
.post-like-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2), var(--inset-shine);
  border-radius: 20px;
  padding: 0.28rem 0.7rem;
  min-height: 34px;
  color: rgba(255,255,255,0.6);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.post-like-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
  color: #fff;
  transform: scale(1.05);
}
.post-like-btn.liked {
  background: rgba(255,70,100,0.15);
  border-color: rgba(255,70,100,0.35);
  color: #ff4d6d;
  box-shadow: 0 2px 12px rgba(255,70,100,0.2), var(--inset-shine);
}
.post-like-btn .post-like-count { font-size: 0.8rem; }

.post-views {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-reactions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 0.75rem;
}
.post-reactions-bar:empty { display: none; margin-bottom: 0; }

.comments-section {
  border-top: 1px solid var(--glass-border);
  margin-top: 0.875rem;
  padding-top: 0.875rem;
}
.comment {
  display: flex;
  gap: 0.6rem;
  padding: 0.5rem 0;
  font-size: 0.87rem;
}
.comment-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
  flex-shrink: 0;
  cursor: pointer;
}
.comment-body { flex: 1; }
.comment-author {
  font-weight: 600;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 2px;
}
.comment-text { line-height: 1.4; }
.comment-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.comment-input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  align-items: center;
}
.comment-input-row input {
  flex: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: border-color var(--transition);
}
.comment-input-row input:focus { outline: none; border-color: var(--glass-hover); }
.comment-input-row .submit-comment-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.25), var(--inset-shine);
  color: rgba(255,255,255,0.75);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: all var(--transition);
}
.comment-input-row .submit-comment-btn:hover {
  background: rgba(120,80,255,0.25);
  border-color: rgba(120,80,255,0.5);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(120,80,255,0.35), var(--inset-shine);
}

/* Comment like — right side */
.comment-like-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  flex-shrink: 0;
  min-width: 28px;
}
.comment-like-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 2px 10px rgba(0,0,0,0.25), var(--inset-shine);
  color: rgba(255,255,255,0.7);
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  transition: all var(--transition);
}
.comment-like-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.22);
  color: #fff;
  transform: scale(1.08);
}
.comment-like-btn.liked {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
}
.comment-like-btn .like-count { font-size: 0.62rem; line-height: 1; color: inherit; }

/* Comment actions (reply + delete) */
.comment-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 5px;
}
.comment-reply-btn, .comment-delete-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2), var(--inset-shine);
  color: rgba(255,255,255,0.6);
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all var(--transition);
}
.comment-reply-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.22);
  color: #fff;
  transform: scale(1.08);
}
.comment-delete-btn:hover {
  background: rgba(255,60,60,0.15);
  border-color: rgba(255,60,60,0.3);
  color: var(--danger);
  transform: scale(1.08);
}

/* Nested replies */
.comment-replies {
  margin-top: 0.2rem;
  margin-left: 2.2rem;
  border-left: 2px solid var(--glass-border);
  padding-left: 0.6rem;
}
.comment-replies .comment { padding: 0.3rem 0; font-size: 0.84rem; }
.comment-replies .comment-avatar { width: 22px; height: 22px; }

/* Reply input */
.reply-input-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
  margin-left: 2.2rem;
}
.reply-input-row input {
  flex: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
  color: var(--text-primary);
  transition: border-color var(--transition);
}
.reply-input-row input:focus { outline: none; border-color: var(--glass-hover); }
.reply-cancel-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0 4px;
}

/* Undo delete countdown */
.delete-countdown {
  font-size: 0.78rem;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.undo-btn {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: opacity var(--transition);
}
.undo-btn:hover { opacity: 0.8; }

/* ========================================
   CHANNELS
======================================== */
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.channel-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-glass), var(--inset-shine);
  position: relative;
}
.channel-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
  pointer-events: none;
  z-index: 1;
}
.channel-card:hover {
  border-color: rgba(255,255,255,0.25);
  transform: translateY(-3px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), var(--inset-shine);
}

.channel-card-cover {
  height: 80px;
  background: linear-gradient(135deg, var(--glass-border), var(--glass-hover));
  position: relative;
}
.channel-card-cover img { width: 100%; height: 100%; object-fit: cover; }

.channel-card-body {
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.channel-card-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
  border: 2px solid var(--bg-primary);
  margin-top: -24px;
  flex-shrink: 0;
}
.channel-card-info { flex: 1; min-width: 0; }
.channel-card-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-card-username { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }
.channel-card-desc { font-size: 0.82rem; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.channel-card-subs { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

.search-bar-inline {
  margin-bottom: 1rem;
}
.search-bar-inline input {
  width: 100%;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  transition: border-color var(--transition);
}
.search-bar-inline input:focus { outline: none; border-color: var(--text-muted); }

/* ========================================
   PROFILE
======================================== */
.profile-header {
  margin-bottom: 1.5rem;
  overflow: hidden;
  padding: 0;
}

.profile-cover {
  height: 110px;
  margin: 0.75rem 0.75rem 0;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(120,80,255,0.18), rgba(255,255,255,0.05));
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.08);
}
.profile-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-upload-btn {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.profile-info {
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.profile-avatar-wrap { position: relative; }
.profile-avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
  border: 2px solid rgba(255,255,255,0.18);
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.08),
    0 0 0 6px rgba(120,80,255,0.12),
    0 6px 20px rgba(120,80,255,0.45),
    0 2px 8px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.profile-avatar:hover {
  transform: scale(1.05);
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.12),
    0 0 0 7px rgba(120,80,255,0.18),
    0 8px 28px rgba(120,80,255,0.6),
    0 4px 12px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.3);
}
.profile-avatar.large {
  width: 84px; height: 84px;
  margin-top: -42px;
}

.avatar-upload-btn {
  position: absolute;
  bottom: 0; right: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: 50%;
  width: 26px; height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.profile-details { flex: 1; min-width: 200px; }
.profile-details h2 { font-size: 1.3rem; font-weight: 700; display: flex; align-items: center; gap: 0.4rem; }
.profile-details > p { color: var(--text-secondary); margin-top: 4px; font-size: 0.9rem; }
.profile-actions {
  width: 100%;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.profile-actions .btn {
  width: 100%;
  justify-content: center;
}

/* ── View profile action buttons ────────── */
.view-profile-actions-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  width: fit-content;
  margin: 0 auto 0.05rem;
  padding: 0.75rem 1.25rem;
  border-radius: 22px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.08);
}
.view-action-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.15s;
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.08);
  flex-shrink: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.view-action-circle:active { transform: scale(0.93); }
.vac-primary {
  background: linear-gradient(135deg, rgba(120,80,255,0.6), rgba(90,50,220,0.5));
  color: #fff;
  border-color: rgba(120,80,255,0.45);
  box-shadow: 0 4px 14px rgba(120,80,255,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
}
.vac-primary:hover {
  background: linear-gradient(135deg, rgba(120,80,255,0.8), rgba(90,50,220,0.7));
}
.vac-ghost {
  background: rgba(255,255,255,0.07);
  color: var(--text-secondary);
}
.vac-ghost:hover { background: rgba(255,255,255,0.14); color: var(--text-primary); }
.vac-danger {
  background: rgba(239,68,68,0.12);
  color: #f87171;
  border-color: rgba(239,68,68,0.22);
}
.vac-danger:hover { background: rgba(239,68,68,0.22); }
.vac-disabled {
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  cursor: default;
  opacity: 0.5;
}

.profile-menu {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.08);
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
  font-size: 0.95rem;
}
.profile-menu-item:last-child { border-bottom: none; }
.profile-menu-item:hover { background: rgba(255,255,255,0.06); }
.profile-menu-item:active { background: rgba(255,255,255,0.09); }

.profile-menu-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(120,80,255,0.18);
  border: 1px solid rgba(120,80,255,0.25);
  color: #a07aff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(120,80,255,0.15);
}

.profile-menu-label {
  flex: 1;
  font-weight: 500;
}

.profile-menu-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.profile-menu-item--danger .profile-menu-icon {
  background: rgba(255,68,68,0.15);
  border-color: rgba(255,68,68,0.25);
  color: var(--danger);
  box-shadow: 0 2px 8px rgba(255,68,68,0.12);
}
.profile-menu-item--danger .profile-menu-label { color: var(--danger); }
.profile-menu-item--danger .profile-menu-arrow { color: var(--danger); opacity: 0.5; }

/* ========================================
   CONTACTS
======================================== */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.contact-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: all var(--transition);
  box-shadow: var(--shadow-glass), var(--inset-shine);
  position: relative;
  overflow: hidden;
}
.contact-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
  pointer-events: none;
}
.contact-card:hover {
  border-color: rgba(255,255,255,0.22);
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0,0,0,0.4), var(--inset-shine);
}

.contact-card-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}
.contact-card-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
}
.contact-card-info { flex: 1; min-width: 0; }
.contact-card-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-card-username { font-size: 0.78rem; color: var(--text-muted); }
.contact-card-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── Chat item action button ── */
.chat-item-more {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  opacity: 0.55;
  border-radius: 50%;
  transition: opacity 0.15s, background 0.15s;
  margin-left: 0.15rem;
}
.chat-item-more:active { opacity: 1; background: var(--glass-hover); }
.chat-action-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.25s;
}
.chat-action-sheet-overlay.open {
  opacity: 1;
}
.chat-action-sheet {
  width: 100%;
  background: var(--bg-secondary);
  border-radius: 18px 18px 0 0;
  padding: 0.5rem 0 calc(1rem + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}
.chat-action-sheet-overlay.open .chat-action-sheet {
  transform: translateY(0);
}
.chat-action-sheet-title {
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 0.4rem;
}
.chat-action-sheet-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 0.9rem 1.5rem;
  cursor: pointer;
  text-align: left;
}
.chat-action-sheet-btn:active { background: var(--glass-hover); }
.chat-action-sheet-btn.cas-danger { color: #e74c3c; }
.chat-action-sheet-btn.cas-cancel {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.3rem;
  border-top: 1px solid var(--glass-border);
  justify-content: center;
}
.chat-action-pin,
.chat-action-delete {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 70px;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  transition: filter 0.15s;
}
.chat-action-pin { background: #4a90d9; }
.chat-action-delete { background: #e74c3c; }
.chat-action-pin:active { filter: brightness(0.85); }
.chat-action-delete:active { filter: brightness(0.85); }
.chat-action-pin i,
.chat-action-delete i { font-size: 1.1rem; }

.chat-pin-indicator {
  color: var(--accent);
  font-size: 0.7rem;
  margin-right: 4px;
  opacity: 0.8;
  transform: rotate(45deg);
  display: inline-block;
}

/* Delete chat modal */
#delete-chat-modal.modal-overlay {
  opacity: 0;
  transition: opacity 0.25s;
}
#delete-chat-modal.modal-overlay.open {
  opacity: 1;
}
.btn-danger {
  background: #e74c3c;
  color: #fff;
  border: none;
}
.btn-danger:hover { background: #c0392b; }

.contact-card--clickable {
  flex-direction: row;
  align-items: center;
  cursor: pointer;
  gap: 0.75rem;
}
.contact-card--clickable:active {
  transform: scale(0.98);
}
.contact-card-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: auto;
  flex-shrink: 0;
}

/* ========================================
   SEARCH BAR
======================================== */
.search-bar {
  position: relative;
  margin-bottom: 1.5rem;
}
.search-bar i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-bar input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  font-size: 1rem;
  transition: all var(--transition);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--inset-shine);
}
.search-bar input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.05), var(--inset-shine);
}

/* ========================================
   TABS
======================================== */
.tabs-container {
  position: relative;
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 22px;
  padding: 4px;
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    0 3px 14px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

/* Sliding active pill */
.tabs-container::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.tabs-container.tab-right::before {
  transform: translateX(calc(100% + 0px));
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: color 0.22s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 18px;
  position: relative;
  z-index: 1;
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--text-primary); font-weight: 600; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========================================
   FORMS
======================================== */
.form-group {
  margin-bottom: 1.1rem;
}
.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-weight: 500;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  transition: all var(--transition);
  color: var(--text-primary);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), inset 0 -1px 0 rgba(0,0,0,0.1);
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.05), inset 0 1px 0 rgba(255,255,255,0.1);
}

.form-error {
  color: var(--danger);
  font-size: 0.82rem;
  padding: 0.4rem 0;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.input-with-icon {
  position: relative;
}
.input-with-icon input { padding-right: 2.5rem; }
.input-with-icon .toggle-password {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  transition: color var(--transition);
}
.input-with-icon .toggle-password:hover { color: var(--text-primary); }

/* ========================================
   BUTTONS
======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.4s ease;
}
.btn:hover::before { left: 100%; }

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}
.btn-primary:hover { opacity: 0.85; }

.btn-ghost {
  background: var(--glass-bg);
  color: var(--text-secondary);
  border-color: var(--glass-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--inset-shine);
}
.btn-ghost:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2), var(--inset-shine);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { opacity: 0.85; }

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}
.btn-full { width: 100%; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled::before { display: none; }

/* ========================================
   AUTH PAGE
======================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
/* Auth page shown/hidden by JS via inline style */


.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo h1 {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: -2px;
}
.auth-logo p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.auth-tabs {
  display: flex;
  gap: 0;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  padding: 3px;
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1;
  padding: 0.55rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
}
.auth-tab.active { background: var(--accent); color: var(--bg-primary); }

.auth-step-hint {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
  text-align: center;
}

.auth-back-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.auth-back-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}
.auth-back-btn:hover { background: var(--glass-hover); color: var(--text-primary); }

.auth-user-pill {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 0.3rem 0.85rem;
}

/* ========================================
   MODALS
======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4,4,14,0.6);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: overlayFade 0.2s ease;
}
@keyframes overlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: modalSlide 0.25s ease;
}
.modal-sm { max-width: 360px; }

@keyframes modalSlide {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--glass-hover); color: var(--text-primary); }

.modal-body textarea, .modal-body input {
  width: 100%;
}

.modal-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ========================================
   EMOJI PICKER
======================================== */
.emoji-picker {
  position: fixed;
  z-index: 400;
  background: rgba(12,12,22,0.8);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6), var(--inset-shine);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  animation: dropdownFade 0.15s ease;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  max-height: 200px;
  overflow-y: auto;
}
.emoji-btn {
  font-size: 1.3rem;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  background: none;
  border: none;
  line-height: 1;
}
.emoji-btn:hover { background: var(--glass-hover); transform: scale(1.2); }

/* ========================================
   ADMIN PANEL
======================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  transition: all var(--transition);
  box-shadow: var(--shadow-glass), var(--inset-shine);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
  pointer-events: none;
}
.stat-card:hover {
  border-color: rgba(255,255,255,0.22);
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0,0,0,0.4), var(--inset-shine);
}
.stat-card h3 { font-size: 2rem; font-weight: 800; margin-bottom: 0.25rem; }
.stat-card p { font-size: 0.8rem; color: var(--text-muted); }

.table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th {
  text-align: left;
  padding: 0.7rem 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}
.admin-table td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--glass-border);
  vertical-align: middle;
}
.admin-table tr:hover td { background: var(--glass-hover); }
.admin-table tr:last-child td { border-bottom: none; }

.table-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.table-pagination {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 1rem;
}

/* ========================================
   BADGES
======================================== */
.badge {
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.verified-badge {
  color: var(--accent);
  font-size: 0.9em;
}
.verified-badge i { color: #7850ff; }

.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--success);
}
.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Small online indicator for avatars */
.avatar-online-dot {
  position: absolute;
  bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--bg-primary);
}

/* ========================================
   TOAST NOTIFICATIONS
======================================== */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: rgba(15,15,28,0.75);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 0.8rem 1.1rem;
  font-size: 0.87rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 240px;
  max-width: 360px;
  animation: toastIn 0.3s ease;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), var(--inset-shine);
}
.toast.error { border-color: rgba(255,68,68,0.5); box-shadow: 0 8px 32px rgba(255,68,68,0.15), var(--inset-shine); }
.toast.success { border-color: rgba(68,255,136,0.4); box-shadow: 0 8px 32px rgba(68,255,136,0.1), var(--inset-shine); }
.toast i { font-size: 0.9rem; }
.toast.error i { color: var(--danger); }
.toast.success i { color: var(--success); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========================================
   LOADING SPINNER
======================================== */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 1.5rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; opacity: 0.3; }
.empty-state p { font-size: 0.9rem; }

/* ========================================
   IMG UPLOAD PREVIEW
======================================== */
.img-upload-preview {
  width: 80px; height: 80px;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px dashed var(--glass-border);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.img-upload-preview:hover { border-color: var(--text-muted); }
.img-upload-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ========================================
   MISC UTILITIES
======================================== */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: 0.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ========================================
   @MENTIONS
======================================== */
.mention {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  padding: 0 2px;
  transition: background var(--transition), color var(--transition);
}
.mention:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
  text-decoration: underline;
}

/* ========================================
   USERNAME INPUT
======================================== */
.username-input-wrap {
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}
.username-input-wrap:focus-within {
  border-color: rgba(255,255,255,0.25);
}
.username-at {
  padding: 0 0.55rem;
  font-weight: 700;
  color: var(--accent);
  font-size: 1rem;
  flex-shrink: 0;
  border-right: 1px solid var(--glass-border);
  line-height: 2.4rem;
}
.username-input-wrap input {
  border: none;
  background: transparent;
  padding: 0.55rem 0.75rem;
  flex: 1;
  font-size: 0.92rem;
}
.username-input-wrap input:focus { outline: none; }

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  line-height: 1.4;
}

/* ========================================
   MESSAGE CONTEXT MENU
======================================== */
.msg-context-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.msg-context-menu {
  background: rgba(28,28,40,0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 0.5rem;
  min-width: 220px;
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
  animation: ctx-pop 0.18s ease;
}
.light-theme .msg-context-menu {
  background: rgba(255,255,255,0.88);
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}

@keyframes ctx-pop {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.msg-ctx-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.92rem;
  cursor: pointer;
  transition: background var(--transition);
  text-align: left;
}
.msg-ctx-item i {
  width: 18px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.msg-ctx-item:hover { background: rgba(255,255,255,0.08); }
.light-theme .msg-ctx-item:hover { background: rgba(0,0,0,0.06); }

.msg-ctx-item.ctx-danger { color: #f87171; }
.msg-ctx-item.ctx-danger i { color: #f87171; }
.msg-ctx-item.ctx-danger:hover { background: rgba(239,68,68,0.12); }

.msg-ctx-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 0.3rem 0.5rem;
}
.light-theme .msg-ctx-divider { background: rgba(0,0,0,0.08); }

/* ========================================
   PRIVACY SETTINGS
======================================== */
.privacy-card { padding: 1.5rem; }

.privacy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.privacy-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}
.privacy-header h3 i { color: var(--accent); }

.privacy-section {
  margin-bottom: 1.5rem;
}
.privacy-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.privacy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  transition: background var(--transition);
}
.privacy-row:hover { background: rgba(255,255,255,0.04); }

.privacy-row-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.privacy-row-label i {
  width: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.privacy-select {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(12px);
  transition: all var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.35)'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 1.8rem;
  min-width: 110px;
}
.privacy-select:hover, .privacy-select:focus {
  border-color: rgba(255,255,255,0.22);
  background-color: rgba(255,255,255,0.1);
}
.light-theme .privacy-select {
  background-color: rgba(255,255,255,0.5);
  color: #1a1a2e;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(0,0,0,0.35)'/%3E%3C/svg%3E");
}
.light-theme .privacy-select option { background: #fff; color: #1a1a2e; }
.privacy-select option { background: #1a1a2e; color: var(--text-primary); }

/* Blocked list */
.blocked-list { display: flex; flex-direction: column; gap: 0.5rem; }

.blocked-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  transition: background var(--transition);
}
.blocked-item:hover { background: rgba(255,255,255,0.07); }

.blocked-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid var(--glass-border);
}
.blocked-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.blocked-name { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.blocked-username { font-size: 0.78rem; color: var(--text-muted); }

.privacy-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
}

/* Danger ghost button */
.btn-danger-ghost {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  color: #f87171;
}
.btn-danger-ghost:hover {
  background: rgba(239,68,68,0.16);
  border-color: rgba(239,68,68,0.4);
  color: #fca5a5;
}

/* ========================================
   RESPONSIVE — MOBILE
======================================== */
@media (max-width: 768px) {

  /* ── Bottom pill nav bar ── */
  .nav-center {
    position: fixed;
    bottom: max(1.1rem, env(safe-area-inset-bottom, 1.1rem));
    left: 50%;
    top: auto;
    transform: translateX(calc(-50% - 2rem));
    flex-direction: row;
    gap: 0;
    padding: 0.4rem 0.5rem;
    min-width: auto;
    width: auto;
    max-width: calc(100vw - 5.5rem);
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
    box-shadow: 0 6px 32px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.1);
    z-index: 90;
    display: flex !important;
  }
  .light-theme .nav-center {
    background: rgba(255,255,255,0.5);
    border-color: rgba(255,255,255,0.65);
    box-shadow: 0 6px 28px rgba(0,0,0,0.14), inset 0 1px 0 rgba(255,255,255,0.7);
  }

  /* Hide top navbar */
  .navbar { display: none; }

  /* Main content — full width, pad for bottom nav + top safe area (notch/Dynamic Island) */
  .main-content {
    margin-top: 0;
    margin-left: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    height: 100dvh;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Nav links — icons only */
  .nav-link span { display: none; }
  .nav-link {
    padding: 0.7rem 1.05rem;
    width: auto;
    justify-content: center;
    align-items: center;
    transform: none !important;
    border-radius: 999px;
    display: flex;
  }
  .nav-link:hover { transform: none !important; }
  .nav-link i { font-size: 1.35rem; }

  /* Profile avatar in bottom bar */
  .nav-link-profile-mobile .nav-avatar-mini {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
  }
  .mobile-menu-btn { display: none; }
  .nav-link-profile-mobile { display: flex; }

  /* Search circle — bottom right, same level as nav pill */
  .nav-search-circle {
    left: auto;
    right: 1rem;
    bottom: max(1.1rem, env(safe-area-inset-bottom, 1.1rem));
    width: 56px;
    height: 56px;
    font-size: 1.3rem;
  }
  .nav-search-circle::before { display: none; }

  /* ── Split layout (chats / channels) ── */
  .page-split {
    flex-direction: row;
    height: calc(100vh - 80px);
    height: calc(100dvh - 80px);
    overflow: hidden;
    position: relative;
  }
  .sidebar-panel {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(0);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }
  .chat-main {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    pointer-events: none;
  }

  /* Chat open — slide in */
  #page-chats.chat-open .sidebar-panel {
    transform: translateX(-100%);
    pointer-events: none;
  }
  #page-chats.chat-open .chat-main {
    transform: translateX(0);
    pointer-events: auto;
  }
  body.chat-is-open .nav-center,
  body.chat-is-open .nav-search-circle { display: none !important; }

  /*
   * iOS fix: body position:fixed prevents Safari from scrolling the layout
   * viewport when the keyboard opens, which would push fixed elements off-screen.
   */
  body.chat-is-open {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  /* Chat fullscreen container — JS syncs top+height via visualViewport */
  body.chat-is-open #page-chats {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100vh;   /* fallback */
    height: 100dvh;  /* modern browsers */
    overflow: hidden;
  }

  /* Push chat header below status bar / Dynamic Island on iOS */
  body.chat-is-open .chat-header {
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
  }

  /* Profile-view — back button fixed at exact same coords as chat back btn */
  body.profile-view-is-open .nav-center,
  body.profile-view-is-open .nav-search-circle { display: none !important; }

  body.profile-view-is-open {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    overflow: hidden;
  }

  body.profile-view-is-open #page-profile-view {
    position: fixed;
    top: 0; left: 0; right: 0;
    width: 100%;
    height: 100dvh; height: 100vh;
    overflow-y: auto;
  }

  #profile-view-back-btn {
    position: fixed;
    top: calc(0.65rem + env(safe-area-inset-top, 0px));
    left: 1.25rem;
    z-index: 50;
  }

  body.profile-view-is-open #page-profile-view .page-content {
    padding-top: calc(38px + 1.3rem + env(safe-area-inset-top, 0px));
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  /* Channels open — fullscreen */
  body.channel-is-open .nav-center,
  body.channel-is-open .nav-search-circle { display: none !important; }
  body.channel-is-open .channel-header-bar {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(56px + env(safe-area-inset-top, 0px));
  }
  body.channel-is-open #page-channels {
    position: fixed;
    inset: 0;
    height: auto;
  }

  /* Modals — slide up from bottom on mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* stay fixed when keyboard opens */
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: modalSlideUp 0.28s cubic-bezier(0.4,0,0.2,1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* scroll internally so content doesn't escape when keyboard opens */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-sm { max-width: 100%; }
  @keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Profile */
  .profile-info { flex-direction: column; }
  .profile-avatar.large { margin-top: -42px; }
  .channels-grid, .contacts-grid { grid-template-columns: 1fr; }
  .page-content { padding: 0.75rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  #nav-username { display: none; }
  .nav-user { padding: 0.3rem; }

  /* Prevent horizontal overflow on pages */
  .page {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* Prevent iOS Safari auto-zoom on input focus (triggers when font-size < 16px) */
  input, textarea, select {
    font-size: 16px !important;
  }

  /* Chat input area — pinned at bottom, never hidden by keyboard */
  .chat-input-area {
    flex-shrink: 0;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
    touch-action: pan-x pan-y; /* allow normal touch input */
  }

  /* Allow scrolling inside messages/lists, contain overscroll */
  .chat-messages {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .channel-posts-area,
  .channel-slim-list,
  .chat-list {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Channel info panel — full screen on mobile */
  .channel-info-panel { width: 100%; }
}

@media (max-width: 480px) {
  .post-action-btn span:not(.comment-count) { display: none; }
  .post-action-btn .comment-count { display: inline !important; }

  /* Smaller padding on tight screens */
  .post-card { padding: 0.9rem; }
  .glass-card { padding: 1rem; }

  /* Smaller channel/chat headers */
  .channel-header-bar { height: 52px; }
  .chat-header { min-height: 64px; height: auto; }
}

/* Landscape on small phones */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
  .nav-center { display: none !important; }
  .nav-search-circle { display: none !important; }
  .main-content {
    padding-bottom: 0;
    height: 100dvh;
    height: 100vh;
  }
  .page-split {
    height: 100dvh;
    height: 100vh;
  }
}

/* ========================================
   CHAT HEADER REDESIGN
======================================== */
.chat-header {
  padding: 0.65rem 1rem;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: relative;
  z-index: 10;
}

.chat-header-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-header-avatar-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
  border: 2px solid rgba(255,255,255,0.18);
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.08),
    0 0 0 6px rgba(120,80,255,0.12),
    0 6px 20px rgba(120,80,255,0.45),
    0 2px 8px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.25);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
/* Purple story ring */
.chat-header-avatar-wrap.has-story .chat-header-avatar-circle {
  box-shadow: 0 0 0 2px #080810, 0 0 0 4px #7850ff;
}
.chat-header-avatar-wrap.has-story:hover .chat-header-avatar-circle {
  box-shadow: 0 0 0 2px #080810, 0 0 0 4px #9b70ff;
}

.chat-header-avatar-circle:hover {
  transform: scale(1.07);
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.12),
    0 0 0 7px rgba(120,80,255,0.18),
    0 8px 28px rgba(120,80,255,0.6),
    0 4px 12px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.3);
}

.chat-header-name-card {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 55%;
  text-align: center;
  margin: 0 0.3rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 14px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
}
.chat-header-name-card:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}
.light-theme .chat-header {
  background: transparent;
}
.light-theme .chat-header-name-card {
  background: rgba(255,255,255,0.45);
  border-color: rgba(255,255,255,0.6);
}

.chat-header-name {
  font-weight: 600;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}
.chat-header-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.chat-header-status.online { color: var(--success); }

/* ========================================
   MESSAGE ACTIONS
======================================== */
.message-wrap {
  position: relative;
}
.msg-actions {
  position: absolute;
  top: 0;
  display: flex;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
  z-index: 2;
}
.message-wrap.own .msg-actions  { left: -110px; flex-direction: row-reverse; }
.message-wrap.other .msg-actions { right: -110px; }
.message-wrap:hover .msg-actions {
  opacity: 1;
  pointer-events: all;
}
.msg-action-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
  color: var(--text-muted);
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.msg-action-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.2);
  transform: scale(1.1);
}

/* ========================================
   REPLY PREVIEW BAR
======================================== */
.reply-preview-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  background: rgba(255,255,255,0.04);
  border-top: 1px solid var(--glass-border);
  border-left: 3px solid rgba(255,255,255,0.4);
  font-size: 0.82rem;
  flex-shrink: 0;
}
.reply-preview-bar.edit-bar { border-left-color: var(--warning); }
.reply-preview-inner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
}
.reply-preview-inner i { flex-shrink: 0; font-size: 0.8rem; opacity: 0.7; }
.reply-preview-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.reply-cancel-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: color var(--transition);
}
.reply-cancel-btn:hover { color: var(--text-primary); }

/* ========================================
   REPLY QUOTE IN MESSAGE
======================================== */
.reply-quote {
  background: rgba(255,255,255,0.06);
  border-left: 3px solid rgba(255,255,255,0.3);
  border-radius: 0 8px 8px 0;
  padding: 0.3rem 0.6rem;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
}
.message-bubble.own .reply-quote { background: rgba(0,0,0,0.18); border-left-color: rgba(255,255,255,0.4); }
.reply-quote-author { font-weight: 600; margin-bottom: 1px; font-size: 0.75rem; }
.reply-quote-text {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message-bubble.own .reply-quote-text { color: rgba(255,255,255,0.65); }

/* Forwarded label */
.forwarded-label {
  font-size: 0.72rem;
  opacity: 0.6;
  font-style: italic;
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Edited tag */
.edited-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ========================================
   VOICE MESSAGE
======================================== */
.voice-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text-muted);
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  position: relative;
  z-index: 5;
}
.voice-btn:hover {
  background: var(--glass-hover);
  color: var(--accent);
  border-color: rgba(120,80,255,0.4);
}
.voice-btn.send-mode {
  background: linear-gradient(135deg, #7850ff, #5b30e0);
  border-color: #7850ff;
  color: #fff;
  transform: scale(1.05);
}
.voice-btn.send-mode:hover { opacity: 0.88; }
.voice-btn.recording {
  background: rgba(255,68,68,0.2);
  border-color: rgba(255,68,68,0.6);
  color: var(--danger);
  animation: mic-pulse 0.9s infinite;
  box-shadow: 0 0 0 0 rgba(255,68,68,0.4);
}
@keyframes mic-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(255,68,68,0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(255,68,68,0); }
  100% { box-shadow: 0 0 0 0   rgba(255,68,68,0); }
}

/* Video-note mode button */
.voice-btn.video-note-mode {
  background: rgba(120,80,255,0.18);
  border-color: rgba(120,80,255,0.6);
  color: #a87eff;
  animation: mic-pulse-purple 1s infinite;
}
@keyframes mic-pulse-purple {
  0%   { box-shadow: 0 0 0 0   rgba(120,80,255,0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(120,80,255,0); }
  100% { box-shadow: 0 0 0 0   rgba(120,80,255,0); }
}

/* ── Video-note recording overlay ─────────────────────── */
.vn-record-overlay {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
  animation: fadeInUp 0.2s ease;
}
.vn-record-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  border: 3px solid rgba(255,68,68,0.8);
  box-shadow: 0 0 0 0 rgba(255,68,68,0.4);
  animation: vn-ring-pulse 1.2s infinite;
}
@keyframes vn-ring-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(255,68,68,0.5); }
  70%  { box-shadow: 0 0 0 12px rgba(255,68,68,0); }
  100% { box-shadow: 0 0 0 0   rgba(255,68,68,0); }
}
.vn-record-circle video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror selfie */
}
.vn-rec-badge {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.55);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.75rem;
  color: #fff;
  white-space: nowrap;
}
.vn-rec-dot {
  width: 7px; height: 7px;
  background: #ff4444;
  border-radius: 50%;
  animation: blink 1s infinite;
}

/* ── Video-note message bubble ────────────────────────── */
.message-bubble.vn-bubble {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}
.message-bubble.vn-bubble .react-btn { bottom: 8px; }

.vn-msg {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.vn-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.vn-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.38);
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
  transition: opacity 0.2s;
  pointer-events: none;
}

/* ── Video-note in-dialog expand ─────────────────────── */
.vn-expand-modal {
  position: absolute;
  inset: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  pointer-events: auto;
  animation: vn-expand-in 0.28s cubic-bezier(0.34,1.3,0.64,1) forwards;
}
.vn-expand-modal.vn-expand-closing {
  animation: vn-expand-out 0.22s ease-in forwards;
}
@keyframes vn-expand-in {
  from { opacity: 0; transform: scale(0.15); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes vn-expand-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.15); }
}
/* Outer container: holds svg ring + circle + pause icon */
.vn-expand-outer {
  position: relative;
  width: min(72vw, 72vh, 400px);
  height: min(72vw, 72vh, 400px);
  cursor: pointer;
}
/* SVG progress ring — sits on top of circle */
.vn-expand-svg {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  transform: rotate(-90deg);
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(120,80,255,0.7));
}
.vn-progress-track {
  fill: none;
  stroke: rgba(120,80,255,0.25);
  stroke-width: 4;
}
.vn-progress-fill {
  fill: none;
  stroke: url(#vn-ring-grad);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear;
}
.vn-expand-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(120,80,255,0.4), 0 0 32px rgba(120,80,255,0.35), 0 12px 40px rgba(0,0,0,0.5);
}
.vn-expand-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
/* Pause icon overlay */
.vn-expand-pause-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 2.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.vn-expand-pause-icon.visible {
  opacity: 1;
}
.vn-dur {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  pointer-events: none;
}

/* Recording bar — overlays entire input row, voice btn sits above via z-index */
.voice-rec-bar {
  position: absolute;
  top: 0; bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 58px 0 0.75rem; /* right padding leaves room for voice btn */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  overflow: hidden;
  z-index: 2;
}
.voice-rec-bar.active {
  opacity: 1;
  pointer-events: auto;
}
.voice-rec-slide-cancel {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: rgba(255,255,255,0.45);
  font-size: 0.82rem;
  white-space: nowrap;
  transition: color 0.12s;
  will-change: transform;
}
.voice-rec-slide-cancel i { font-size: 0.7rem; }
.voice-rec-slide-cancel.cancelling { color: var(--danger); }

/* Recording preview bubble in messages area */
.voice-recording-preview {
  display: flex;
  justify-content: flex-end;
  padding: 0.3rem 1rem 0.3rem 3rem;
  animation: fadeInUp 0.18s ease;
}
.voice-rec-preview-bubble {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  background: rgba(120,80,255,0.22);
  border: 1px solid rgba(120,80,255,0.4);
  border-radius: 18px 18px 4px 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  min-width: 160px;
}
.voice-rec-preview-mic {
  color: var(--danger);
  font-size: 0.9rem;
  animation: rec-blink 1s infinite;
  flex-shrink: 0;
}
.voice-rec-preview-waves {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  flex: 1;
}
.voice-rec-preview-waves span {
  width: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.65);
  animation: rec-wave 0.85s ease-in-out infinite;
}
.voice-rec-preview-waves span:nth-child(1) { animation-delay: 0.00s; }
.voice-rec-preview-waves span:nth-child(2) { animation-delay: 0.12s; }
.voice-rec-preview-waves span:nth-child(3) { animation-delay: 0.24s; }
.voice-rec-preview-waves span:nth-child(4) { animation-delay: 0.18s; }
.voice-rec-preview-waves span:nth-child(5) { animation-delay: 0.06s; }
.voice-rec-preview-waves span:nth-child(6) { animation-delay: 0.30s; }
.voice-rec-preview-waves span:nth-child(7) { animation-delay: 0.14s; }
@keyframes rec-wave {
  0%, 100% { height: 3px; }
  50%       { height: 18px; }
}
.voice-rec-preview-timer {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  min-width: 2.3rem;
  flex-shrink: 0;
}

/* Delete button in locked mode */
.voice-rec-delete-btn {
  background: rgba(255,60,60,0.15);
  border: 1px solid rgba(255,60,60,0.3);
  border-radius: 50%;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--danger); font-size: 0.82rem;
  cursor: pointer; flex-shrink: 0;
  margin-left: auto;
}
.voice-rec-delete-btn:hover { background: rgba(255,60,60,0.28); }

/* Lock indicator — floats above the mic button */
.voice-lock-indicator {
  position: absolute;
  bottom: calc(100% + 4px);
  right: 0.75rem;
  width: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 20;
}
.voice-lock-indicator.visible {
  opacity: 1;
  transform: translateY(0);
}
.voice-lock-icon-wrap {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-glass);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.65);
  font-size: 0.88rem;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.voice-lock-icon-wrap.locking {
  background: rgba(120,80,255,0.25);
  border-color: rgba(120,80,255,0.55);
  color: #b090ff;
}
.voice-lock-icon-wrap.locked {
  background: rgba(120,80,255,0.4);
  border-color: rgba(120,80,255,0.75);
  color: #c0a0ff;
}
.voice-lock-track {
  width: 2px; height: 28px;
  background: rgba(255,255,255,0.12);
  border-radius: 1px;
  position: relative;
  overflow: hidden;
}
.voice-lock-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(120,80,255,0.7);
  height: 0%;
  transition: height 0.06s linear;
  border-radius: 1px;
}

/* Mic button in locked-send state */
.voice-btn.locked-send {
  background: linear-gradient(135deg, #7850ff, #5b30e0);
  border-color: #7850ff;
  color: #fff;
  animation: none;
}
.voice-btn.locked-send:hover { opacity: 0.88; }
.voice-rec-dot {
  color: #ff4444;
  font-size: 0.55rem;
  animation: rec-blink 1s infinite;
}
.voice-rec-timer {
  font-weight: 600;
  color: #ff6666;
  min-width: 2.2rem;
}
.voice-rec-cancel-hint {
  color: rgba(255,255,255,0.55);
  font-size: 0.78rem;
  transition: color 0.15s, font-weight 0.15s;
}
.voice-recording-hint.sliding .voice-rec-cancel-hint {
  color: var(--danger);
  font-weight: 600;
}
.voice-recording-hint.sliding {
  border-color: rgba(255,68,68,0.7);
}
@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.voice-message {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.15rem 0;
  min-width: 200px;
  max-width: 260px;
}

.vm-play-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(120,80,255,0.22);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}
.vm-play-btn:hover { background: rgba(120,80,255,0.4); }
.message-bubble.own .vm-play-btn { background: rgba(255,255,255,0.22); }
.message-bubble.own .vm-play-btn:hover { background: rgba(255,255,255,0.35); }

.vm-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.vm-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
}
.vw-bar {
  display: inline-block;
  width: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.35);
  flex-shrink: 0;
  transition: background 0.1s;
}
.vw-bar.played { background: rgba(255,255,255,0.85); }
.message-bubble.other .vw-bar { background: rgba(120,80,255,0.35); }
.message-bubble.other .vw-bar.played { background: #7850ff; }

.vm-progress-track {
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: rgba(255,255,255,0.2);
  overflow: hidden;
}
.message-bubble.other .vm-progress-track { background: rgba(120,80,255,0.2); }
.vm-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: rgba(255,255,255,0.75);
  transition: width 0.1s linear;
}
.message-bubble.other .vm-progress-fill { background: #7850ff; }

.vm-time {
  flex-shrink: 0;
  font-size: 0.7rem;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
}

/* ========================================
   FORWARD MODAL USERS
======================================== */
.forward-user-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}
.forward-user-item:hover { background: var(--glass-hover); }
.forward-user-item img {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
}
.forward-user-name { font-size: 0.88rem; font-weight: 500; }
.forward-user-username { font-size: 0.75rem; color: var(--text-muted); }


/* ========================================
   STORIES
======================================== */

/* Strip container */
.stories-strip {
  padding: 0.6rem 0.5rem 0;
  border-bottom: 1px solid var(--glass-border);
  display: none;
}
.stories-scroll {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.6rem;
  scrollbar-width: none;
}
.stories-scroll::-webkit-scrollbar { display: none; }

/* Story circle item */
.story-circle-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  flex-shrink: 0;
  width: 60px;
}
.story-circle-ring {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  padding: 2.5px;
  background: var(--glass-border);
  transition: transform 0.18s ease;
}
.story-circle-item.has-story .story-circle-ring {
  background: linear-gradient(135deg, #a855f7, #7c3aed, #4f46e5);
  box-shadow: 0 0 10px rgba(120,80,255,0.5);
}
.story-circle-item.all-viewed .story-circle-ring {
  background: var(--glass-border);
}
.story-circle-item:hover .story-circle-ring { transform: scale(1.06); }
.story-circle-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg-primary);
  display: block;
}
.story-add-plus {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: #fff;
  border: 2px solid var(--bg-primary);
}
.story-circle-name {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58px;
  text-align: center;
}

/* ---- STORY VIEWER ---- */
.story-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0,0,0,0.96);
  display: none;
  align-items: center;
  justify-content: center;
}
.story-viewer-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
  background: #111;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
@media (min-width: 480px) {
  .story-viewer-container {
    height: min(100dvh, 780px);
    border-radius: 18px;
  }
}

/* Progress bar */
.story-progress-bar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  z-index: 10;
}
.story-progress-seg {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  overflow: hidden;
}
.story-progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 2px;
}
.story-progress-fill.animating {
  animation: story-progress var(--story-dur, 5000ms) linear forwards;
}
@keyframes story-progress {
  from { width: 0%; }
  to   { width: 100%; }
}

/* Header */
.story-viewer-header {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 30px);
  left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 12px;
  z-index: 10;
}
.story-back-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: none;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.story-viewer-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.6);
  flex-shrink: 0;
}
.story-viewer-user-info { flex: 1; min-width: 0; }
.story-viewer-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.story-viewer-time {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.65);
}
.story-delete-btn {
  background: rgba(255,68,68,0.2);
  border: none;
  color: #ff6b6b;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Media */
.story-media-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.story-media-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Caption */
.story-caption-text {
  position: absolute;
  bottom: 110px;
  left: 16px; right: 16px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  text-align: center;
  z-index: 10;
  backdrop-filter: blur(6px);
}

/* Footer */
.story-viewer-footer {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 10;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
}

/* Views */
.story-views-info {
  display: none;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,0.85);
  font-size: 0.78rem;
  background: rgba(0,0,0,0.4);
  padding: 4px 10px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* Emoji reactions */
.story-emoji-row {
  display: flex;
  gap: 6px;
  background: rgba(0,0,0,0.5);
  padding: 6px 14px;
  border-radius: 30px;
  backdrop-filter: blur(8px);
}
.story-emoji-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 50%;
  transition: transform 0.15s ease;
  line-height: 1;
}
.story-emoji-btn:hover { transform: scale(1.3); }

/* Tap zones */
.story-tap-zone {
  position: absolute;
  top: 60px;
  bottom: 100px;
  width: 40%;
  z-index: 9;
  cursor: pointer;
}
.story-tap-prev { left: 0; }
.story-tap-next { right: 0; }

/* ---- STORY TYPE TABS ---- */
.story-type-tabs {
  display: flex;
  gap: 0;
  background: var(--glass-bg);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 1rem;
}
.story-type-tab {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: calc(var(--radius-md) - 2px);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: transparent;
}
.story-type-tab.active { background: var(--accent); color: var(--bg-primary); }

/* ---- TEXT STORY PREVIEW ---- */
.story-text-preview {
  width: 100%;
  aspect-ratio: 9/16;
  max-height: 260px;
  border-radius: 16px;
  background: linear-gradient(135deg,#7c3aed,#4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  margin-bottom: 0.85rem;
  transition: background 0.3s ease;
}
#story-text-preview-content {
  color: #fff;
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
  word-break: break-word;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ---- GRADIENT PICKER ---- */
.story-gradient-picker {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.story-gradient-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.story-gradient-btn:hover { transform: scale(1.15); }
.story-gradient-btn.active { border-color: #fff; transform: scale(1.15); }

/* ---- TEXT STORY IN VIEWER ---- */
.story-text-card {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  border-radius: 0;
}
.story-text-card-content {
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
  word-break: break-word;
  text-shadow: 0 2px 16px rgba(0,0,0,0.4);
  max-width: 100%;
}

/* ---- CREATE STORY MODAL ---- */
.story-upload-area {
  width: 100%;
  aspect-ratio: 9/14;
  max-height: 320px;
  border: 2px dashed var(--glass-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: border-color 0.2s;
}
.story-upload-area:hover { border-color: var(--accent); }
.story-upload-area i { font-size: 2rem; opacity: 0.5; }

/* body.story-open — prevent scroll */
body.story-open { overflow: hidden; }

/* Mobile full-screen viewer */
@media (max-width: 600px) {
  .story-viewer-container {
    max-width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }
}

/* ========================================
   STORY REACTION ECHO ANIMATION
======================================== */
.story-reaction-echo {
  position: absolute;
  pointer-events: none;
  z-index: 100;
  transform: translateX(-50%);
  animation: story-echo-rise 1.2s ease-out forwards;
  user-select: none;
}
@keyframes story-echo-rise {
  0%   { opacity: 1;   transform: translateX(calc(-50% + 0px))   translateY(0)     scale(1); }
  40%  { opacity: 0.9; transform: translateX(calc(-50% + var(--drift, 0px))) translateY(-60px)  scale(1.3); }
  100% { opacity: 0;   transform: translateX(calc(-50% + var(--drift, 0px))) translateY(-140px) scale(0.7); }
}

/* Story footer actions row */
.story-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: space-between;
}
.story-share-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s;
  padding: 0;
  overflow: hidden;
}
.story-share-btn:hover { background: rgba(255,255,255,0.22); }
.story-share-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* ========================================
   STORY STATS PANEL
======================================== */
.story-stats-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.45);
}
.story-stats-panel {
  width: 100%;
  max-width: 460px;
  max-height: 70vh;
  background: var(--bg-secondary);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slide-up-panel 0.28s cubic-bezier(.34,1.3,.64,1) forwards;
}
@keyframes slide-up-panel {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.story-stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.5rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.story-stats-title { font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.story-stats-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--glass);
  border: none;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 0.8rem;
}
.story-stats-tabs {
  display: flex;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.story-stats-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.65rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  border-bottom: 2px solid transparent;
  transition: all 0.18s;
}
.story-stats-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.story-stats-tab span {
  background: var(--glass);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.72rem;
}
.story-stats-body {
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem 0;
}
.story-stats-section { display: none; }
.story-stats-section.active { display: block; }

.story-stats-loading, .story-stats-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.story-stats-empty i { font-size: 1.6rem; opacity: 0.4; }

.story-stats-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1.2rem;
  transition: background 0.15s;
}
.story-stats-user:hover { background: var(--glass-hover); }
.story-stats-user img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
  flex-shrink: 0;
}
.story-stats-user-info { flex: 1; min-width: 0; }
.story-stats-user-name { display: block; font-size: 0.87rem; font-weight: 500; }
.story-stats-user-time { font-size: 0.72rem; color: var(--text-muted); }
.story-stats-reaction-emoji { font-size: 1.5rem; flex-shrink: 0; }

/* ========================================
   STORY SHARE PANEL
======================================== */
.story-share-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0.45);
}
.story-share-panel {
  width: 100%;
  max-width: 460px;
  max-height: 70vh;
  background: var(--bg-secondary);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slide-up-panel 0.28s cubic-bezier(.34,1.3,.64,1) forwards;
}
.story-share-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.6rem;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.95rem;
  font-weight: 600;
  flex-shrink: 0;
}
.story-share-header button {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--glass);
  border: none;
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.2rem;
  flex-shrink: 0;
}
.story-share-search {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.story-share-search input {
  width: 100%;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}
.story-share-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.4rem 0;
}
.story-share-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1.2rem;
  transition: background 0.15s;
}
.story-share-user:hover { background: var(--glass-hover); }
.story-share-user img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-border);
  flex-shrink: 0;
}
.story-share-user-info { flex: 1; min-width: 0; }
.story-share-user-name { display: block; font-size: 0.87rem; font-weight: 500; }
.story-share-user-username { font-size: 0.72rem; color: var(--text-muted); }
.story-share-send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7850ff, #5b30e0);
  border: none;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 0.9rem;
  transition: opacity 0.18s, transform 0.15s;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(120,80,255,0.4);
}
.story-share-send-btn:hover { opacity: 0.85; transform: scale(1.1); }
.share-header-icon {
  width: 20px; height: 20px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 4px;
  object-fit: cover;
}
.story-share-send-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

/* ========================================
   STORY MESSAGE IN CHAT
======================================== */
.story-msg-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-width: 200px;
}
.story-msg-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 0.3rem;
  opacity: 0.8;
}
.story-msg-img {
  width: 100%;
  max-width: 200px;
  aspect-ratio: 9/16;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

/* ========================================
   PHOTO MESSAGE IN CHAT
======================================== */
.msg-photo-wrap {
  max-width: 240px;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  line-height: 0;
}
.msg-photo {
  width: 100%;
  max-width: 240px;
  max-height: 320px;
  object-fit: cover;
  border-radius: 14px;
  display: block;
  transition: opacity 0.15s;
}

/* ========================================
   POST MEDIA IMAGE
======================================== */
.post-media-img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: block;
  margin: 0.5rem 0;
}

/* ========================================
   POST POLL
======================================== */
.post-poll {
  margin: 0.6rem 0;
  padding: 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}
.post-poll-question {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  color: var(--text-primary);
}
.post-poll-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.post-poll-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
  min-height: 36px;
}
.post-poll-option:hover {
  border-color: rgba(255,255,255,0.25);
  background: var(--glass-hover);
}
.post-poll-option.voted {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.poll-option-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: rgba(255,255,255,0.08);
  transition: width 0.4s ease;
  pointer-events: none;
  border-radius: var(--radius-sm);
}
.post-poll-option.voted .poll-option-bar {
  background: rgba(255,255,255,0.15);
}
.poll-option-text {
  position: relative;
  z-index: 1;
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.poll-option-pct {
  position: relative;
  z-index: 1;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}
.post-poll-total {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ========================================
   POST ATTACH ROW (photo/poll buttons)
======================================== */
.post-attach-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

/* ========================================
   POST INLINE EDIT
======================================== */
.post-inline-edit {
  margin: 0.4rem 0;
}
.post-edit-textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.92rem;
  resize: vertical;
  min-height: 64px;
}
.post-edit-textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.3);
}
.post-edit-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  margin-top: 0.35rem;
}

/* ========================================
   CHANNEL ADMINS MODAL
======================================== */
.modal-wide {
  max-width: 560px;
  width: 100%;
}
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}
.admin-row-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.admin-row-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.admin-row-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.admin-row-username {
  font-size: 0.76rem;
  color: var(--text-muted);
}
.admin-row-perms {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}
.admin-perm-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
}
.admin-perm-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}
.admin-search-result-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}
.admin-search-result-row img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.msg-photo:hover { opacity: 0.92; }

/* ========================================
   CHANNEL SPLIT LAYOUT  (Telegram-style)
======================================== */
.channel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: transparent;
}

/* ── Slim channel list ──────────────────── */
.channel-slim-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.25rem 0;
}

.channel-slim-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.channel-slim-item:hover  { background: var(--glass-hover); }
.channel-slim-item.active { background: var(--accent-soft); }

.channel-slim-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.channel-slim-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.channel-slim-name {
  font-weight: 600;
  font-size: 0.93rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.channel-slim-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.channel-slim-unread {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── Channel header bar ─────────────────── */
.channel-header-bar {
  height: 56px;
  padding: 0 0.25rem 0 0.75rem;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  z-index: 5;
}

.channel-header-clickable {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-md);
  transition: background var(--transition);
}
.channel-header-clickable:hover { background: var(--glass-hover); }

.channel-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.channel-header-text { min-width: 0; }
.channel-header-name {
  font-weight: 600;
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.channel-header-subs {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.channel-header-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

/* Telegram-style borderless icon buttons */
.channel-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.channel-action-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}
.channel-action-btn.active {
  color: var(--accent);
}

/* ── Posts area ─────────────────────────── */
.channel-posts-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.channel-posts-area .post-card:hover {
  transform: none;
}

/* ── Search bar ─────────────────────────── */
.channel-search-bar {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideDown 0.18s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.channel-search-bar input {
  flex: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 0.38rem 0.8rem;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.channel-search-bar input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.25);
}

/* ── Info panel (slide-in from right) ────── */
.channel-info-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--glass-border);
  z-index: 20;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
}
.channel-info-panel.open { transform: translateX(0); }

/* ── Admins panel (slides on top of info panel) ── */
.ch-admins-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--glass-border);
  z-index: 30;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
.ch-admins-panel.open { transform: translateX(0); }
.ch-admins-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Search section */
.ch-admins-search-section {
  padding: 1rem;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.ch-admins-search-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ch-admins-search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.ch-admin-search-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 0.88rem;
}
.ch-admin-search-input:focus { outline: none; border-color: var(--accent); }
.ch-admins-search-empty { font-size: 0.85rem; color: var(--text-muted); padding: 0.25rem 0; }
.ch-admin-search-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--glass-border);
}
.ch-admin-search-row:last-child { border-bottom: none; }
.ch-admin-search-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.ch-admin-search-info { flex: 1; min-width: 0; }
.ch-admin-search-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-admin-search-username { font-size: 0.78rem; color: var(--text-muted); }

/* Section title */
.ch-admins-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.9rem 1rem 0.4rem;
}

/* Empty state */
.ch-admins-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.ch-admins-empty i { font-size: 1.8rem; opacity: 0.5; }

/* Admin card */
.ch-admin-card {
  margin: 0 0.75rem 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ch-admin-card-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 0.9rem 0.75rem;
}
.ch-admin-card-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.ch-admin-card-info { flex: 1; min-width: 0; }
.ch-admin-card-name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-admin-card-username { font-size: 0.78rem; color: var(--text-muted); }
.ch-admin-remove-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(231,76,60,0.12);
  border: 1px solid rgba(231,76,60,0.25);
  color: #e74c3c;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background var(--transition);
}
.ch-admin-remove-btn:hover { background: rgba(231,76,60,0.25); }

/* Permission rows */
.ch-admin-perms {
  border-top: 1px solid var(--glass-border);
  padding: 0.25rem 0;
}
.ch-admin-perm-row {
  display: flex;
  align-items: center;
  padding: 0.7rem 0.9rem;
  gap: 0.75rem;
}
.ch-admin-perm-row + .ch-admin-perm-row { border-top: 1px solid var(--glass-border); }
.ch-admin-perm-info { display: flex; align-items: center; gap: 0.65rem; flex: 1; min-width: 0; }
.ch-admin-perm-icon { font-size: 1rem; color: var(--accent); width: 20px; text-align: center; flex-shrink: 0; }
.ch-admin-perm-title { font-size: 0.875rem; font-weight: 500; color: var(--text-primary); }
.ch-admin-perm-desc { font-size: 0.75rem; color: var(--text-muted); }

/* Toggle switch */
.ch-toggle { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; cursor: pointer; }
.ch-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.ch-toggle-slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.12);
  border-radius: 13px;
  border: 1px solid var(--glass-border);
  transition: background 0.2s, border-color 0.2s;
}
.ch-toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 2px; top: 2px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
}
.ch-toggle input:checked + .ch-toggle-slider { background: rgba(120,80,255,0.35); border-color: var(--accent); }
.ch-toggle input:checked + .ch-toggle-slider::before { transform: translateX(18px); background: var(--accent); }

/* Card footer */
.ch-admin-card-footer {
  border-top: 1px solid var(--glass-border);
  padding: 0.65rem 0.9rem;
  display: flex;
  justify-content: flex-end;
}

/* Mobile: full screen for admins panel */
@media (max-width: 768px) {
  .ch-admins-panel {
    width: 100%;
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    height: 100dvh !important;
    height: 100vh !important;
    z-index: 300;
  }
  .ch-admins-panel:not(.open) { transform: translateX(100%); }
  .ch-admins-panel.open { transform: translateX(0); }
}

/* Info panel top-bar */
.channel-info-header {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 0.25rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  gap: 0;
}

@media (max-width: 768px) {
  .channel-info-header {
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
  }
}
.channel-info-header h4 {
  flex: 1;
  font-size: 0.96rem;
  font-weight: 600;
  padding: 0 0.25rem;
}
.channel-info-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.channel-info-close:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.22);
  transform: scale(1.08);
}

/* Cover edit button overlay */
.channel-info-cover {
  position: relative;
}
.ch-cover-edit-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
  z-index: 2;
}
.ch-cover-edit-btn:hover { background: rgba(0,0,0,0.75); }

/* Verified badge in channel context */
.ch-verified {
  display: inline-flex;
  align-items: center;
  margin-right: 3px;
  vertical-align: middle;
}
.ch-verified i { color: #7850ff; font-size: 0.85em; }

/* Prevent body scroll when modal or panel is open */
html.modal-open,
body.modal-open,
html.panel-open,
body.panel-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* Modal overlay and contents must always receive touch events */
.modal-overlay,
.modal-overlay * {
  touch-action: auto;
}

/* Info panel contents must always receive touch events */
.channel-info-panel,
.channel-info-panel * {
  touch-action: auto;
}

/* Info panel itself must always receive touch */
.channel-info-panel {
  touch-action: auto !important;
  pointer-events: auto !important;
}

/* Cover image */
.channel-info-cover {
  width: 100%;
  height: 140px;
  background: var(--glass-bg);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

/* Avatar + name block */
.channel-info-body {
  padding: 0 1rem 1.5rem;
  display: flex;
  flex-direction: column;
}

.channel-info-avatar-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-top: -30px;
  margin-bottom: 0.75rem;
  position: relative;
  z-index: 2;
}
.channel-info-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg-secondary);
  flex-shrink: 0;
}
.channel-info-subscribe { margin-left: auto; }

.channel-info-name-block {
  margin-bottom: 0.75rem;
}
.channel-info-name {
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.3;
}
.channel-info-username {
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 2px;
}

/* Info rows (Telegram-style) */
.channel-info-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 0.5rem 0;
}

.channel-info-rows {
  display: flex;
  flex-direction: column;
}

.channel-info-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--glass-border);
}
.channel-info-row:last-child { border-bottom: none; }
.channel-info-row-btn {
  cursor: pointer;
  transition: background var(--transition);
  border-radius: var(--radius-sm);
  margin: 0 -0.5rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.channel-info-row-btn:hover { background: var(--glass-hover); }

.channel-info-row-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}

.channel-info-row-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.channel-info-row-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  word-break: break-all;
}
.channel-info-row-label {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.channel-info-row-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.channel-info-link-copy,
.channel-info-link-share {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.channel-info-link-copy:hover,
.channel-info-link-share:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
}

/* Legacy — kept for any leftover usage */
.channel-info-desc { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; }
.channel-info-stat { font-size: 0.82rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.4rem; }
.channel-info-link-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
}
.channel-info-link-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: monospace;
}

/* ── Pinned post ────────────────────────── */
.pinned-post-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition);
}
.pinned-post-banner:hover { background: rgba(255,255,255,0.07); }
.pinned-post-banner i { color: var(--accent); font-size: 0.78rem; }

.post-card.is-pinned {
  border-color: rgba(255,255,255,0.15);
}

.pinned-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.pinned-label i { font-size: 0.68rem; }

.boosted-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: #f59e0b;
  margin-bottom: 0.3rem;
  font-weight: 600;
}
.boosted-label i { font-size: 0.68rem; }

.bolt-react-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  transition: background 0.15s;
  line-height: 1;
}
.bolt-react-btn:hover { background: rgba(245,158,11,0.15); }

/* ── Channel stories strip ──────────────── */
.channel-stories-strip {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  flex-shrink: 0;
  overflow-x: auto;
  display: flex;
  gap: 0.75rem;
  scrollbar-width: none;
}
.channel-stories-strip::-webkit-scrollbar { display: none; }

.channel-story-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.channel-story-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, rgba(255,255,255,0.6), rgba(255,255,255,0.2));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12);
  transition: transform 0.2s ease;
}
.channel-story-ring:hover { transform: scale(1.06); }
.channel-story-ring.unviewed {
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(180,180,255,0.5));
  box-shadow: 0 0 8px rgba(255,255,255,0.2);
}
.channel-story-ring img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg-primary);
  display: block;
}
.channel-story-add-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--glass-hover);
  border: 2px dashed var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.channel-story-add-btn:hover {
  border-color: rgba(255,255,255,0.3);
  color: var(--text-primary);
}
.channel-story-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 54px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Channel highlights (saved stories) ── */
.ch-highlights-strip {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  flex-shrink: 0;
}
.ch-highlights-scroll {
  display: flex;
  gap: 0.85rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.ch-highlights-scroll::-webkit-scrollbar { display: none; }

.ch-highlight-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
}
.ch-highlight-cover {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  padding: 2px;
  background: #7850ff;
  box-shadow: 0 0 0 2px var(--bg-primary);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.ch-highlight-circle:hover .ch-highlight-cover {
  transform: scale(1.07);
}
.ch-highlight-cover img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid var(--bg-primary);
}
.ch-highlight-cover-text {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7850ff, #a855f7) !important;
  font-size: 1.1rem;
  color: rgba(255,255,255,0.9);
}
.ch-highlight-cover-text i {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}
.ch-highlight-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 62px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.ch-highlight-remove {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(30,30,40,0.85);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.ch-highlight-circle:hover .ch-highlight-remove {
  opacity: 1;
}

/* ── Highlight name prompt overlay ──────── */
.highlight-name-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.highlight-name-dialog {
  background: rgba(24,24,36,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 1.4rem 1.3rem;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.highlight-name-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}
.highlight-name-input {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  padding: 0.6rem 0.85rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  width: 100%;
  font-family: inherit;
  text-align: center;
}
.highlight-name-input:focus {
  border-color: rgba(120,80,255,0.7);
}
.highlight-name-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}
.hl-picker-dialog {
  max-width: 340px;
}
.hl-picker-list {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.25rem 0.1rem 0.4rem;
  margin-bottom: 0.25rem;
}
.hl-picker-list::-webkit-scrollbar { display: none; }
.hl-picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.hl-picker-cover {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  border: 2.5px solid #7850ff;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(120,80,255,0.15);
  font-size: 1.1rem;
  color: #a855f7;
  transition: transform 0.15s;
}
.hl-picker-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hl-picker-item:hover .hl-picker-cover {
  transform: scale(1.07);
  border-color: #a855f7;
}
.hl-picker-name {
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 56px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hl-picker-count {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
}
.hl-picker-new {
  width: 100%;
  justify-content: center;
  border: 1px dashed rgba(120,80,255,0.4);
  color: #a855f7;
  border-radius: 10px;
  padding: 0.5rem;
}

/* ── Story viewer save-to-channel btn ─── */
.story-save-channel-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-save-channel-btn:hover,
.story-save-channel-btn.saved {
  color: #a855f7;
}

/* ── Sidebar search ─────────────────────── */
.sidebar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.sidebar-search i { color: var(--text-muted); font-size: 0.85rem; }
.sidebar-search input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
}

/* ── btn-icon (sidebar header create) ────── */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--glass-hover); color: var(--text-primary); }

/* ── Create group button — liquid glass circle ── */
#create-group-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s, color 0.2s;
}
#create-group-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  box-shadow:
    0 6px 22px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  color: #ffffff;
  transform: scale(1.07);
}
#create-group-btn:active {
  transform: scale(0.94);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ── Channel badge on story circle ─────── */
.story-channel-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 1.5px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  color: var(--text-muted);
}

/* ── Mobile ─────────────────────────────── */
@media (max-width: 768px) {
  .channel-main { display: none; }
  #page-channels.channel-open .sidebar-panel { display: none !important; }
  #page-channels.channel-open .channel-main {
    display: flex !important;
    height: 100%;
    width: 100%;
  }
  body.channel-is-open .nav-center,
  body.channel-is-open .nav-search-circle { display: none !important; }
  body.channel-is-open #page-channels { height: 100dvh; height: 100vh; }

  .channel-info-panel {
    width: 100%;
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    height: 100dvh !important;
    height: 100vh !important;
    z-index: 200;
  }
  /* Keep slide-out transform working on mobile */
  .channel-info-panel:not(.open) {
    transform: translateX(100%);
  }
  .channel-info-panel.open {
    transform: translateX(0);
  }
}

/* ========================================
   THEME PICKER
======================================== */
.theme-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.theme-picker {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.theme-card {
  flex: 1;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.5rem;
  border-radius: 16px;
  border: 2px solid var(--glass-border);
  background: var(--glass-bg);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
}
.theme-card:hover { transform: translateY(-2px); border-color: rgba(120,80,255,0.4); }
.theme-card.active { border-color: #7850ff; background: rgba(120,80,255,0.1); }

.theme-check {
  position: absolute;
  top: 7px; right: 9px;
  font-size: 0.75rem;
  color: #7850ff;
  opacity: 0;
  transition: opacity 0.2s;
}
.theme-card.active .theme-check { opacity: 1; }

.theme-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.theme-card.active .theme-label { color: #a080ff; }

.theme-preview {
  width: 72px;
  height: 52px;
  border-radius: 10px;
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: hidden;
}
.theme-preview--classic { background: #080810; border: 1px solid rgba(255,255,255,0.1); }
.theme-preview--dark    { background: #000000; border: 1px solid rgba(255,255,255,0.07); }
.theme-preview--light   { background: #e8eaf0; border: 1px solid rgba(0,0,0,0.1); }

.tp-bubble { height: 13px; border-radius: 8px; width: 65%; }
.theme-preview--classic .tp-other { background: rgba(255,255,255,0.12); align-self: flex-start; }
.theme-preview--classic .tp-own   { background: linear-gradient(135deg,#7850ff,#5b30e0); align-self: flex-end; }
.theme-preview--dark .tp-other    { background: rgba(255,255,255,0.08); align-self: flex-start; }
.theme-preview--dark .tp-own      { background: linear-gradient(135deg,#7850ff,#5b30e0); align-self: flex-end; }
.theme-preview--light .tp-other   { background: rgba(0,0,0,0.1); align-self: flex-start; }
.theme-preview--light .tp-own     { background: linear-gradient(135deg,#7850ff,#5b30e0); align-self: flex-end; }

/* ========================================
   CHAT BACKGROUND THEMES
======================================== */

/* — фон диалога — */
body.chat-bg-dark    #chat-messages-area { background: #000 !important; }
body.chat-bg-light   #chat-messages-area { background: #eef0f5 !important; }
body.chat-bg-blue    #chat-messages-area { background: linear-gradient(160deg, #0a1628 0%, #0e2246 100%) !important; }
body.chat-bg-green   #chat-messages-area { background: linear-gradient(160deg, #071a0f 0%, #0e3020 100%) !important; }
body.chat-bg-orange  #chat-messages-area { background: linear-gradient(160deg, #1a0e00 0%, #3a2200 100%) !important; }
body.chat-bg-red     #chat-messages-area { background: linear-gradient(160deg, #1a0505 0%, #350c0c 100%) !important; }
body.chat-bg-pink    #chat-messages-area { background: linear-gradient(160deg, #1a0510 0%, #380a25 100%) !important; }
body.chat-bg-tiffany #chat-messages-area { background: linear-gradient(160deg, #031a1a 0%, #073535 100%) !important; }

/* светлый фон — меняем цвет чужих пузырей */
body.chat-bg-light .message-bubble.other {
  background: rgba(0,0,0,0.07);
  border-color: rgba(0,0,0,0.1);
  color: #111;
}
body.chat-bg-light .msg-text,
body.chat-bg-light .message-meta,
body.chat-bg-light .vm-time { color: #222; }

/* ========================================
   CHAT BG PICKER UI
======================================== */
.theme-section-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 1.2rem 0;
}

.chat-bg-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
}

.chat-bg-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.3rem 0.55rem;
  border-radius: 14px;
  border: 2px solid var(--glass-border);
  background: var(--glass-bg);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.chat-bg-swatch:hover { transform: translateY(-2px); border-color: rgba(120,80,255,0.4); }
.chat-bg-swatch.active { border-color: #7850ff; background: rgba(120,80,255,0.1); color: #a080ff; }

.cbg-check {
  position: absolute;
  top: 5px; right: 7px;
  font-size: 0.68rem;
  color: #7850ff;
  opacity: 0;
  transition: opacity 0.2s;
}
.chat-bg-swatch.active .cbg-check { opacity: 1; }

.cbg-preview {
  width: 52px;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.cbg-classic  { background: #080810; }
.cbg-dark     { background: #000000; }
.cbg-light    { background: #eef0f5; border-color: rgba(0,0,0,0.1); }
.cbg-blue     { background: linear-gradient(160deg, #0a1628, #0e2246); }
.cbg-green    { background: linear-gradient(160deg, #071a0f, #0e3020); }
.cbg-orange   { background: linear-gradient(160deg, #1a0e00, #3a2200); }
.cbg-red      { background: linear-gradient(160deg, #1a0505, #350c0c); }
.cbg-pink     { background: linear-gradient(160deg, #1a0510, #380a25); }
.cbg-tiffany  { background: linear-gradient(160deg, #031a1a, #073535); }

/* ========================================
   SENT MESSAGE BUBBLE COLORS
======================================== */
body.msg-bg-dark    .message-bubble.own { background: #1a1a1a; box-shadow: none; }
body.msg-bg-light   .message-bubble.own { background: #e0e2ea; color: #111; box-shadow: none; }
body.msg-bg-blue    .message-bubble.own { background: linear-gradient(135deg, #1a4a9e, #0d2d6b); box-shadow: 0 4px 16px rgba(26,74,158,0.4); }
body.msg-bg-green   .message-bubble.own { background: linear-gradient(135deg, #1a7a3a, #0d4a22); box-shadow: 0 4px 16px rgba(26,122,58,0.4); }
body.msg-bg-orange  .message-bubble.own { background: linear-gradient(135deg, #c85a00, #8a3a00); box-shadow: 0 4px 16px rgba(200,90,0,0.4); }
body.msg-bg-red     .message-bubble.own { background: linear-gradient(135deg, #c82020, #8a0e0e); box-shadow: 0 4px 16px rgba(200,32,32,0.4); }
body.msg-bg-pink    .message-bubble.own { background: linear-gradient(135deg, #c8307a, #8a1050); box-shadow: 0 4px 16px rgba(200,48,122,0.4); }
body.msg-bg-tiffany .message-bubble.own { background: linear-gradient(135deg, #0abfbc, #067a78); box-shadow: 0 4px 16px rgba(10,191,188,0.4); }

/* светлый цвет — текст тёмный */
body.msg-bg-light .message-bubble.own .msg-text,
body.msg-bg-light .message-bubble.own .message-status i,
body.msg-bg-light .message-bubble.own .vm-time { color: #222; }

/* Swatch previews for msg bg */
.mbg-classic  { background: linear-gradient(135deg, #7850ff, #5b30e0); }
.mbg-dark     { background: #1a1a1a; }
.mbg-light    { background: #e0e2ea; border-color: rgba(0,0,0,0.1) !important; }
.mbg-blue     { background: linear-gradient(135deg, #1a4a9e, #0d2d6b); }
.mbg-green    { background: linear-gradient(135deg, #1a7a3a, #0d4a22); }
.mbg-orange   { background: linear-gradient(135deg, #c85a00, #8a3a00); }
.mbg-red      { background: linear-gradient(135deg, #c82020, #8a0e0e); }
.mbg-pink     { background: linear-gradient(135deg, #c8307a, #8a1050); }
.mbg-tiffany  { background: linear-gradient(135deg, #0abfbc, #067a78); }

.msg-bg-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.3rem 0.55rem;
  border-radius: 14px;
  border: 2px solid var(--glass-border);
  background: var(--glass-bg);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.msg-bg-swatch:hover { transform: translateY(-2px); border-color: rgba(120,80,255,0.4); }
.msg-bg-swatch.active { border-color: #7850ff; background: rgba(120,80,255,0.1); color: #a080ff; }
.msg-bg-swatch.active .cbg-check { opacity: 1; }

/* ========================================
   PROFILE SLIDER NAVIGATION
======================================== */
#page-profile {
  overflow: hidden;
}

.profile-slider {
  display: flex;
  width: 200%;
  min-height: 100%;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.profile-slider.show-sub {
  transform: translateX(-50%);
}

.profile-slider-panel {
  width: 50%;
  flex-shrink: 0;
  overflow-y: auto;
  min-height: 100%;
}

.profile-sub-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--glass-border);
}

.profile-sub-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: background 0.2s;
}
.profile-sub-back:hover { background: var(--glass-hover); }

.profile-sub-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ========================================
   APP BACKGROUND OVERRIDE
======================================== */
body.app-bg-black {
  background: #000 !important;
  --bg-primary: #000;
  --bg-secondary: #000;
}
body.app-bg-black .blob { display: none !important; }
body.app-bg-black .glass-card,
body.app-bg-black .glass-card-sm,
body.app-bg-black .navbar,
body.app-bg-black .nav-center,
body.app-bg-black .nav-search-circle,
body.app-bg-black .profile-sub-header {
  background: #0a0a0a !important;
}

body.app-bg-white {
  background: #fff !important;
  --bg-primary: #fff;
  --bg-secondary: #f5f5f5;
  --text-primary: #111;
  --text-secondary: rgba(0,0,0,0.65);
  --text-muted: rgba(0,0,0,0.35);
  --glass-bg: rgba(0,0,0,0.04);
  --glass-border: rgba(0,0,0,0.1);
  --glass-hover: rgba(0,0,0,0.07);
}
body.app-bg-white .glass-card,
body.app-bg-white .glass-card-sm {
  background: #f8f8f8 !important;
  border-color: rgba(0,0,0,0.08) !important;
  color: #111;
}
body.app-bg-white .navbar {
  background: rgba(255,255,255,0.9) !important;
  border-bottom: 1px solid rgba(0,0,0,0.08) !important;
}
body.app-bg-white .nav-center {
  background: rgba(255,255,255,0.85) !important;
  border-color: rgba(0,0,0,0.1) !important;
}
body.app-bg-white .nav-search-circle {
  background: rgba(255,255,255,0.85) !important;
  border-color: rgba(0,0,0,0.1) !important;
  color: #111 !important;
}
body.app-bg-white .nav-link,
body.app-bg-white .profile-sub-back { color: #111 !important; }
body.app-bg-white .profile-sub-header {
  background: #fff !important;
  border-bottom-color: rgba(0,0,0,0.08) !important;
}
body.app-bg-white #chat-messages-area { background: #f0f0f0 !important; }
body.app-bg-white .message-bubble.other {
  background: rgba(0,0,0,0.07) !important;
  color: #111 !important;
}
body.app-bg-white .msg-text { color: #111; }
body.app-bg-white .profile-menu-item { background: #f0f0f0 !important; border-color: rgba(0,0,0,0.07) !important; color: #111 !important; }
body.app-bg-white .profile-menu-item:hover { background: #e8e8e8 !important; }

/* ── App BG picker UI ── */
.app-bg-picker {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.app-bg-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 0.4rem 0.7rem;
  border-radius: 14px;
  border: 2px solid var(--glass-border);
  background: var(--glass-bg);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.app-bg-btn:hover { transform: translateY(-2px); border-color: rgba(120,80,255,0.4); }
.app-bg-btn.active { border-color: #7850ff; background: rgba(120,80,255,0.1); color: #a080ff; }

.app-bg-check {
  position: absolute;
  top: 5px; right: 8px;
  font-size: 0.68rem;
  color: #7850ff;
  opacity: 0;
  transition: opacity 0.2s;
}
.app-bg-btn.active .app-bg-check { opacity: 1; }

.app-bg-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
}
.app-bg-dot--classic { background: #080810; }
.app-bg-dot--black   { background: #000000; border-color: rgba(255,255,255,0.25); }
.app-bg-dot--white   { background: #ffffff; border-color: rgba(0,0,0,0.15); }

/* ========================================
   PHOTO FULLSCREEN VIEWER
======================================== */
.photo-fs-viewer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0);
  align-items: center;
  justify-content: center;
  transition: background 0.28s ease;
}
.photo-fs-viewer.open {
  background: rgba(0,0,0,0.92);
}

.photo-fs-img {
  max-width: calc(100% - 2rem);
  max-height: calc(100% - 2rem);
  object-fit: contain;
  border-radius: 20px;
  transform: scale(0.88);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1), opacity 0.22s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.photo-fs-viewer.open .photo-fs-img {
  transform: scale(1);
  opacity: 1;
}

.photo-fs-close {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 1rem);
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: background 0.2s;
}
.photo-fs-close:hover { background: rgba(255,255,255,0.25); }

.msg-photo {
  cursor: zoom-in;
}

/* ========================================
   STORY SAVE BUTTON
======================================== */
.story-save-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 50%;
  transition: color 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}
.story-save-btn:hover { transform: scale(1.15); }
.story-save-btn.saved { color: #7850ff; }

/* ========================================
   SAVED STORIES IN PROFILE
======================================== */

/* ── Own profile saved section ── */
.saved-stories-section {
  margin-top: 1rem;
}
.saved-stories-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.25rem;
}
.saved-stories-header i { color: #7850ff; }

.saved-stories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  justify-items: center;
}

.saved-story-thumb {
  position: relative;
  aspect-ratio: 9/16;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  width: 100%;
  max-height: 150px;
}
.saved-story-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.saved-story-text-thumb {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #7850ff, #5b30e0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: rgba(255,255,255,0.6);
}
.saved-story-del {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: none;
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.saved-story-thumb:hover .saved-story-del { opacity: 1; }
@media (max-width: 768px) {
  .saved-story-del { opacity: 1; }
}

/* ========================================
   VIEW PROFILE — CENTERED LAYOUT
======================================== */
.view-profile-card {
  margin-bottom: 1rem;
  overflow: hidden;
}
.view-profile-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1.25rem 1.25rem;
  text-align: center;
}
.view-profile-avatar {
  width: 110px; height: 110px;
  border-radius: 50%;
  object-fit: cover;
  margin-top: -55px;
  position: relative;
  z-index: 2;
  border: 3px solid var(--bg-primary);
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.08),
    0 0 0 7px rgba(120,80,255,0.15),
    0 8px 28px rgba(120,80,255,0.5),
    0 2px 10px rgba(0,0,0,0.5);
}
.view-profile-name {
  margin: 0.85rem 0 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
}
.view-profile-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
  font-size: 0.92rem;
  min-height: 1.4rem;
}
.offline-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}
.view-profile-username-pill {
  margin-top: 0.3rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 0.45rem 0.55rem 0.45rem 1.1rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.18s;
  /* match width of action row */
  width: fit-content;
  min-width: 0;
}
.view-profile-username-pill:hover { background: rgba(255,255,255,0.09); }
.view-profile-username-pill .uname-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.view-profile-username-pill .uname-bolt-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(120,80,255,0.55), rgba(90,50,220,0.45));
  border: 1px solid rgba(120,80,255,0.4);
  box-shadow: 0 2px 8px rgba(120,80,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  color: #fff;
}
.view-profile-bio {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.view-profile-mutual {
  margin-top: 0.3rem;
  font-size: 0.82rem;
}
.view-profile-cover {
  height: 130px;
  margin: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--glass-bg);
  background-size: cover;
  background-position: center;
  position: relative;
  z-index: 1;
}

/* Own profile cover */
.own-profile-cover-wrap {
  position: relative;
  z-index: 1;
}
.own-profile-cover {
  height: 130px;
  margin: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--glass-bg);
  background-size: cover;
  background-position: center;
}
.own-avatar-wrap {
  position: relative;
  z-index: 2;
  margin-top: -55px;
}
.own-avatar-wrap .view-profile-avatar {
  margin-top: 0;
}
.own-profile-center {
  padding-top: 0 !important;
}

/* ── Viewed user profile saved section ── */
.view-saved-stories-section {
  margin-top: 1rem;
  padding: 0 0.25rem;
}
.view-saved-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.08);
}
.view-saved-header .saved-icon-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(120,80,255,0.5), rgba(90,50,220,0.4));
  border: 1px solid rgba(120,80,255,0.35);
  box-shadow: 0 2px 8px rgba(120,80,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 0.85rem;
}

.view-saved-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  justify-items: center;
}

.view-saved-item {
  position: relative;
  aspect-ratio: 9/16;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background: var(--glass-bg);
  border: 1px solid rgba(140,90,255,0.6);
  box-shadow: 0 0 0 1px rgba(120,80,255,0.4), 0 0 20px rgba(120,80,255,0.6), 0 0 40px rgba(120,80,255,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  width: 100%;
  max-height: 150px;
}
.view-saved-item:hover {
  box-shadow: 0 0 18px rgba(120,80,255,0.5), 0 0 36px rgba(120,80,255,0.25);
}
.view-saved-item:active {
  transform: scale(0.96);
}
.view-saved-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.view-saved-text-thumb {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #7850ff, #5b30e0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: rgba(255,255,255,0.6);
}

/* ========================================
   GROUP CHATS
======================================== */
.group-default-av {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #fff;
}
.group-name-icon { font-size: 0.75em; opacity: 0.6; margin-right: 3px; }

/* Create group modal: member picker */
.group-members-list {
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  margin-top: 0.4rem;
}
.group-member-pick-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.8rem; cursor: pointer;
  transition: background 0.15s;
}
.group-member-pick-item:hover { background: var(--glass-hover); }
.group-member-pick-item.selected { background: rgba(168,85,247,0.12); }
.group-pick-av { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.group-pick-name { flex: 1; font-size: 0.88rem; color: var(--text-primary); }
.group-pick-check { color: #a855f7; opacity: 0; transition: opacity 0.15s; font-size: 0.8rem; }
.group-member-pick-item.selected .group-pick-check { opacity: 1; }

/* Selected badges */
.group-selected-members {
  display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; min-height: 0;
}
.group-selected-badge {
  display: flex; align-items: center; gap: 0.3rem;
  background: rgba(168,85,247,0.18); border-radius: 20px;
  padding: 3px 8px 3px 4px; font-size: 0.78rem;
}
.group-selected-badge img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.group-badge-remove {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 0; font-size: 0.7rem; line-height: 1;
}

/* Group chat header default avatar */
.group-header-av-default {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #fff; cursor: pointer;
}

/* Group message sender info */
.group-msg-sender {
  display: flex; align-items: center; gap: 0.35rem;
  margin-bottom: 2px; padding-left: 2px;
}
.group-msg-av {
  width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.group-msg-name {
  font-size: 0.75rem; font-weight: 600;
  color: #a855f7; line-height: 1;
}

/* Group member count badge in list */
.group-member-count {
  font-size: 0.7rem; color: var(--text-muted);
  background: var(--glass-bg); border-radius: 8px;
  padding: 1px 6px; font-weight: 400; vertical-align: middle;
}

/* Group info modal — rich panel */
.gim-header {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.75rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--glass-border); margin-bottom: 0.75rem;
}
.gim-avatar-wrap {
  position: relative; width: 80px; height: 80px; border-radius: 50%; flex-shrink: 0;
}
.gim-avatar-editable { cursor: pointer; }
.gim-avatar-img {
  width: 80px; height: 80px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(168,85,247,0.4);
}
.gim-avatar-default {
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: #fff;
  border: 2px solid rgba(168,85,247,0.4);
}
.gim-avatar-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem; opacity: 0;
  transition: opacity 0.2s;
}
.gim-avatar-editable:hover .gim-avatar-overlay,
.gim-avatar-editable:active .gim-avatar-overlay { opacity: 1; }

.gim-name-section { width: 100%; text-align: center; }
.gim-name-display {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  font-size: 1.05rem; font-weight: 600; color: var(--text-primary);
}
.gim-edit-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 3px 6px; border-radius: 6px; font-size: 0.8rem;
  transition: color 0.15s;
}
.gim-edit-btn:hover { color: #a855f7; }
.gim-name-edit { padding: 0.3rem 0; }
.gim-name-input { width: 100%; margin-bottom: 0.5rem; text-align: center; }
.gim-edit-btns { display: flex; gap: 0.5rem; justify-content: center; }

.gim-add-member-btn {
  width: 100%; padding: 0.55rem 1rem; margin-bottom: 0.75rem;
  background: rgba(168,85,247,0.12); border: 1px solid rgba(168,85,247,0.3);
  border-radius: var(--radius-sm); color: #c084fc;
  font-size: 0.88rem; cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 0.5rem; transition: background 0.15s;
}
.gim-add-member-btn:hover { background: rgba(168,85,247,0.22); }

.gim-add-member-panel {
  margin-bottom: 0.75rem; border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.gim-add-member-panel input { border-radius: 0; border: none; border-bottom: 1px solid var(--glass-border); }

.gim-members-list { display: flex; flex-direction: column; }

/* Group info modal */
.group-info-member-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--glass-border);
}
.group-info-member-item:last-child { border-bottom: none; }
.group-info-av { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.group-info-name { flex: 1; font-size: 0.9rem; color: var(--text-primary); display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.group-role-badge {
  font-size: 0.68rem; background: rgba(168,85,247,0.2);
  color: #a855f7; border-radius: 8px; padding: 1px 7px;
}
.gim-member-actions { display: flex; align-items: center; gap: 0.2rem; flex-shrink: 0; }
.gim-remove-btn, .gim-role-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px 7px; border-radius: 6px; font-size: 0.82rem;
  flex-shrink: 0; transition: color 0.15s;
}
.gim-remove-btn:hover { color: var(--danger); }
.gim-role-btn:hover { color: #a855f7; }
.group-role-badge.admin { background: rgba(168,85,247,0.18); color: #c084fc; }
.group-role-badge.owner { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.85); }

/* ========================================
   PULL TO REFRESH — LIGHTNING
======================================== */
#ptr-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: calc(env(safe-area-inset-top, 44px) + 10px);
  pointer-events: none;
}

.ptr-lightning-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  opacity: 0;
  transform: translateY(-20px) scale(0.3);
  will-change: opacity, transform;
}

.ptr-lightning-icon {
  font-size: 30px;
  color: #a855f7;
  filter: drop-shadow(0 0 4px rgba(168, 85, 247, 0.4));
  will-change: filter;
}

#ptr-indicator.ptr-ready .ptr-lightning-icon {
  color: #c084fc;
  filter: drop-shadow(0 0 10px #a855f7) drop-shadow(0 0 22px #7c3aed);
}

@keyframes ptr-bolt-flash {
  0%   { opacity: 1;   transform: scale(1.15); filter: drop-shadow(0 0 20px #c084fc) drop-shadow(0 0 40px #7c3aed); }
  25%  { opacity: 0.1; transform: scale(0.85); }
  55%  { opacity: 1;   transform: scale(1.25); filter: drop-shadow(0 0 28px #e9d5ff) drop-shadow(0 0 56px #a855f7); }
  80%  { opacity: 0.2; transform: scale(0.9); }
  100% { opacity: 1;   transform: scale(1.1); }
}

#ptr-indicator.ptr-triggered .ptr-lightning-icon {
  color: #e9d5ff;
  animation: ptr-bolt-flash 0.55s ease-in-out forwards;
}

/* Flash overlay behind bolt when triggered */
#ptr-indicator.ptr-triggered::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 80%, rgba(168,85,247,0.2) 0%, transparent 70%);
  animation: ptr-flash-bg 0.55s ease-out forwards;
}
@keyframes ptr-flash-bg {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Sparks */
.ptr-spark {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #a855f7;
  opacity: 0;
  box-shadow: 0 0 6px #a855f7;
}

@keyframes ptr-spark-1 { 0% { opacity:1; transform:translate(0,0) scale(1); } 100% { opacity:0; transform:translate(-20px,-22px) scale(0); } }
@keyframes ptr-spark-2 { 0% { opacity:1; transform:translate(0,0) scale(1); } 100% { opacity:0; transform:translate(22px,-18px) scale(0); } }
@keyframes ptr-spark-3 { 0% { opacity:1; transform:translate(0,0) scale(1); } 100% { opacity:0; transform:translate(-8px,-26px) scale(0); } }
@keyframes ptr-spark-4 { 0% { opacity:1; transform:translate(0,0) scale(1); } 100% { opacity:0; transform:translate(14px,-24px) scale(0); } }
@keyframes ptr-spark-5 { 0% { opacity:1; transform:translate(0,0) scale(1); } 100% { opacity:0; transform:translate(-26px,-8px) scale(0); } }

#ptr-indicator.ptr-triggered .ptr-spark:nth-child(2) { animation: ptr-spark-1 0.45s 0.05s ease-out forwards; }
#ptr-indicator.ptr-triggered .ptr-spark:nth-child(3) { animation: ptr-spark-2 0.45s 0.08s ease-out forwards; }
#ptr-indicator.ptr-triggered .ptr-spark:nth-child(4) { animation: ptr-spark-3 0.45s 0.03s ease-out forwards; }
#ptr-indicator.ptr-triggered .ptr-spark:nth-child(5) { animation: ptr-spark-4 0.45s 0.1s ease-out forwards; }
#ptr-indicator.ptr-triggered .ptr-spark:nth-child(6) { animation: ptr-spark-5 0.45s 0.06s ease-out forwards; }

/* ======================================== */
/* BLOCKED SCREEN                           */
/* ======================================== */
#blocked-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9000;
  background: var(--bg-primary, #080810);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  box-sizing: border-box;
}

.blocked-card {
  max-width: 400px;
  width: 100%;
  padding: 2rem 1.75rem;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.blocked-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #f87171;
  flex-shrink: 0;
}

.blocked-card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.blocked-card > p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.55;
}

.blocked-card form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.blocked-card textarea {
  width: 100%;
  min-height: 110px;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  resize: none;
  font-family: inherit;
  box-sizing: border-box;
  text-align: left;
}

.blocked-card textarea::placeholder {
  color: var(--text-muted);
}

.blocked-card textarea:focus {
  outline: none;
  border-color: rgba(168, 85, 247, 0.5);
}

.blocked-card button[type="submit"] {
  width: 100%;
}

.block-reason-box {
  width: 100%;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  color: #fca5a5;
  text-align: left;
  word-break: break-word;
  line-height: 1.5;
  box-sizing: border-box;
}

.block-reason-box::before {
  content: '📋 Причина: ';
  font-weight: 600;
  color: #f87171;
}

.appeal-message-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  background: rgba(168, 85, 247, 0.08);
  border-left: 3px solid #a855f7;
  padding: 6px 10px;
  border-radius: 0 8px 8px 0;
  margin-top: 6px;
  text-align: left;
  word-break: break-word;
}
