/* ==========================================================================
   Omni Messenger — Modern Ultra-Sleek Design System & Interface
   ========================================================================== */

:root {
  /* Ultra-Sleek Monochrome & Black-and-White Palette */
  --bg0: #000000;
  --bg1: #0c0c0e;
  --bg2: #141417;
  --bg3: #1c1c22;
  --bg4: #27272e;

  --border: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.35);
  --border-focus: #ffffff;

  --text: #ffffff;
  --text1: #f4f4f6;
  --text2: #a1a1aa;
  --text3: #71717a;

  --accent: #27272a;
  --accent-hover: #3f3f46;
  --accent-light: #ffffff;
  --accent-glow: rgba(255, 255, 255, 0.15);
  --accent-grad: linear-gradient(135deg, #3f3f46 0%, #18181b 100%);
  --accent-grad-hover: linear-gradient(135deg, #52525b 0%, #27272a 100%);
  --accent-surface: rgba(255, 255, 255, 0.08);

  --green: #22c55e;
  --green-glow: rgba(34, 197, 94, 0.25);
  --red: #f87171;
  --yellow: #fbbf24;
  --cyan: #ffffff;
  --gold: #f59e0b;
  --tg-blue: #ffffff;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 30px -6px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 24px 50px -12px rgba(0, 0, 0, 0.95);
  --shadow-glow: 0 0 24px rgba(255, 255, 255, 0.1);
  --shadow-card: 0 20px 48px -10px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Ensure no native or custom search cancel 'X' icons */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration,
#conv-search::-webkit-search-cancel-button {
  -webkit-appearance: none !important;
  display: none !important;
}

/* Light Theme */
[data-theme="light"] {
  --bg0: #f1f5f9;
  --bg1: #ffffff;
  --bg2: #f8fafc;
  --bg3: #e2e8f0;
  --bg4: #cbd5e1;

  --border: rgba(0, 0, 0, 0.12);
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-hover: rgba(2, 132, 199, 0.45);
  --border-focus: #0284c7;

  --text: #0f172a;
  --text1: #1e293b;
  --text2: #475569;
  --text3: #64748b;

  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-light: #0284c7;
  --accent-glow: rgba(2, 132, 199, 0.2);
  --accent-grad: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  --accent-grad-hover: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  --accent-surface: rgba(2, 132, 199, 0.08);

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 24px -6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 36px -10px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .msg-bubble {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.09);
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .msg.self .msg-bubble {
  background: #e0f2fe;
  border: 1px solid rgba(2, 132, 199, 0.22);
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.08);
}

[data-theme="light"] .msg-text,
[data-theme="light"] .msg-text b,
[data-theme="light"] .msg-text strong {
  color: #0f172a;
}

[data-theme="light"] .msg-time {
  color: #64748b;
}

[data-theme="light"] .msg-forward-header,
[data-theme="light"] .msg-forward-label,
[data-theme="light"] .msg-forward-author {
  color: #0284c7;
}

[data-theme="light"] .chat-input-box,
[data-theme="light"] .search-box {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

[data-theme="light"] .chat-input-box input,
[data-theme="light"] .search-box input {
  color: #0f172a;
}

[data-theme="light"] .modal-card,
[data-theme="light"] .tg-drawer,
[data-theme="light"] .msg-context-menu {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 20px 48px -10px rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .tg-setting-row {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .btn-secondary {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

[data-theme="light"] .btn-secondary:hover {
  background: #e2e8f0;
}

/* AMOLED Pitch Black Theme */
[data-theme="amoled"] {
  --bg0: #000000;
  --bg1: #000000;
  --bg2: #09090b;
  --bg3: #121215;
  --bg4: #18181b;
  --border: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.06);
}

[data-theme="amoled"] .msg-bubble {
  background: #0d0d11;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="amoled"] .msg.self .msg-bubble {
  background: #181824;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Monochrome / Black & White Minimalist Theme */
[data-theme="monochrome"], [data-theme="bw"] {
  --bg0: #09090b;
  --bg1: #121215;
  --bg2: #18181c;
  --bg3: #222228;
  --bg4: #2c2c34;

  --border: rgba(255, 255, 255, 0.14);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.4);
  --border-focus: #ffffff;

  --text: #ffffff;
  --text1: #f4f4f5;
  --text2: #a1a1aa;
  --text3: #71717a;

  --accent: #27272a;
  --accent-hover: #3f3f46;
  --accent-light: #ffffff;
  --accent-glow: rgba(255, 255, 255, 0.15);
  --accent-grad: linear-gradient(135deg, #3f3f46 0%, #18181b 100%);
  --accent-grad-hover: linear-gradient(135deg, #52525b 0%, #27272a 100%);
  --accent-surface: rgba(255, 255, 255, 0.08);

  --green: #e4e4e7;
  --green-glow: rgba(255, 255, 255, 0.2);
  --red: #f87171;
  --yellow: #f4f4f5;
  --cyan: #ffffff;
  --gold: #ffffff;
  --tg-blue: #ffffff;
}

[data-theme="monochrome"] .msg.outgoing .msg-bubble,
[data-theme="bw"] .msg.outgoing .msg-bubble,
[data-theme="monochrome"] .msg.self .msg-bubble,
[data-theme="bw"] .msg.self .msg-bubble {
  background: #27272a;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

[data-theme="monochrome"] .btn-primary,
[data-theme="bw"] .btn-primary {
  background: #ffffff !important;
  color: #09090b !important;
  border-color: #ffffff !important;
  font-weight: 700;
}

[data-theme="monochrome"] .btn-primary:hover,
[data-theme="bw"] .btn-primary:hover {
  background: #e4e4e7 !important;
  color: #000000 !important;
}

[data-theme="monochrome"] .tg-badge,
[data-theme="bw"] .tg-badge {
  background: #ffffff;
  color: #09090b;
}

/* Classic Telegram Blue Theme */
[data-theme="telegram"] {
  --bg0: #0e1621;
  --bg1: #17212b;
  --bg2: #1e2c3a;
  --bg3: #243547;
  --bg4: #2b3e54;

  --border: rgba(43, 82, 120, 0.4);
  --border-subtle: rgba(43, 82, 120, 0.2);
  --border-hover: rgba(84, 169, 235, 0.5);
  --border-focus: #2481cc;

  --accent: #2481cc;
  --accent-hover: #1c6ba8;
  --accent-light: #54a9eb;
  --accent-glow: rgba(36, 129, 204, 0.35);
  --accent-grad: linear-gradient(135deg, #2481cc 0%, #1c93e3 100%);
  --accent-grad-hover: linear-gradient(135deg, #1c6ba8 0%, #1579c0 100%);
}

[data-theme="telegram"] .msg-bubble {
  background: #182533;
  border: none;
}

[data-theme="telegram"] .msg.self .msg-bubble {
  background: #2b5278;
  border: none;
}

/* Emerald / Matrix Theme */
[data-theme="emerald"] {
  --bg0: #06140f;
  --bg1: #0b1f18;
  --bg2: #102a21;
  --bg3: #183a2e;
  --bg4: #224d3e;

  --border: rgba(16, 185, 129, 0.25);
  --border-subtle: rgba(16, 185, 129, 0.12);
  --border-hover: rgba(16, 185, 129, 0.5);
  --border-focus: #10b981;

  --accent: #10b981;
  --accent-hover: #059669;
  --accent-light: #34d399;
  --accent-glow: rgba(16, 185, 129, 0.3);
  --accent-grad: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --accent-grad-hover: linear-gradient(135deg, #059669 0%, #047857 100%);
}

[data-theme="emerald"] .msg-bubble {
  background: #102a21;
  border: 1px solid rgba(16, 185, 129, 0.15);
}

[data-theme="emerald"] .msg.self .msg-bubble {
  background: #164e3f;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Sunset / Cyberpunk Theme */
[data-theme="sunset"] {
  --bg0: #0f0a1c;
  --bg1: #17102b;
  --bg2: #21163d;
  --bg3: #2d1e52;
  --bg4: #3c296d;

  --border: rgba(168, 85, 247, 0.25);
  --border-subtle: rgba(168, 85, 247, 0.12);
  --border-hover: rgba(168, 85, 247, 0.5);
  --border-focus: #a855f7;

  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-light: #c084fc;
  --accent-glow: rgba(139, 92, 246, 0.3);
  --accent-grad: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  --accent-grad-hover: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
}

[data-theme="sunset"] .msg-bubble {
  background: #21163d;
  border: 1px solid rgba(168, 85, 247, 0.15);
}

[data-theme="sunset"] .msg.self .msg-bubble {
  background: #4c1d95;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

/* Amber / Gold Theme */
[data-theme="amber"] {
  --bg0: #140d04;
  --bg1: #1f1508;
  --bg2: #2c1e0c;
  --bg3: #3b2811;
  --bg4: #4d3518;

  --border: rgba(245, 158, 11, 0.25);
  --border-subtle: rgba(245, 158, 11, 0.12);
  --border-hover: rgba(245, 158, 11, 0.5);
  --border-focus: #f59e0b;

  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-light: #fbbf24;
  --accent-glow: rgba(245, 158, 11, 0.3);
  --accent-grad: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --accent-grad-hover: linear-gradient(135deg, #d97706 0%, #92400e 100%);
}

[data-theme="amber"] .msg-bubble {
  background: #2c1e0c;
  border: 1px solid rgba(245, 158, 11, 0.15);
}

[data-theme="amber"] .msg.self .msg-bubble {
  background: #593208;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden !important;
  overflow-x: hidden !important;
  overscroll-behavior: none;
  background-color: var(--bg0);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden !important;
  overflow-x: hidden !important;
  position: relative;
  display: flex;
}

body {
  display: flex;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bg3);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Selection */
::selection {
  background: rgba(139, 92, 246, 0.35);
  color: #fff;
}

/* Common button resets */
button {
  font-family: inherit;
  border: none;
  background: transparent;
  outline: none;
}

/* ==========================================================================
   APP CONTAINER & NAVIGATION RAIL
   ========================================================================== */
#app {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  background: var(--bg0);
}

/* Navigation Rail removed — purely drawer-driven navigation */
.rail {
  display: none !important;
}

.badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg1);
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.4);
}

/* ==========================================================================
   PANELS & WORKSPACES
   ========================================================================== */
.panel {
  display: none;
  flex: 1;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.panel.active {
  display: flex;
  animation: panelFadeSmooth 0.15s ease-out forwards;
}

@keyframes panelFadeSmooth {
  0% {
    opacity: 0.85;
  }
  100% {
    opacity: 1;
  }
}

/* ==========================================================================
   CONVERSATIONS & DM PANEL
   ========================================================================== */
.dm-panel {
  flex: 1;
  display: flex;
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  overflow-x: hidden;
}

.conv-sidebar {
  width: 340px;
  flex-shrink: 0;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg1);
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tg-app-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tg-logo-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.sidebar-header h2 {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px;
}

.conv-count-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-surface);
  color: var(--accent-light);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn-header {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg2);
  border: 1px solid var(--border-subtle);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-btn-header:hover {
  background: var(--bg3);
  border-color: var(--border-hover);
  color: var(--text);
  transform: translateY(-1px);
}

.icon-btn-header:active {
  transform: scale(0.95);
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text3);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.search-box input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 34px 9px 36px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.search-box input::placeholder {
  color: var(--text3);
}

.search-box input:focus {
  background: var(--bg3);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-surface);
}

.search-box:focus-within .search-icon {
  color: var(--accent-light);
}

/* Conv filter and FAB removed per user request */

/* Conversation List & Cards */
.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  min-height: 60px;
  border: 1px solid transparent;
  user-select: none;
}

.conv-item:hover {
  background: var(--bg2);
  border-color: var(--border-subtle);
}

.conv-item.active {
  background: var(--bg3);
  border-color: var(--border);
  box-shadow: inset 3px 0 0 var(--accent);
}

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

.conv-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  overflow: hidden;
  color: #fff;
  position: relative;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
}

.conv-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--bg1);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
  z-index: 2;
}

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

.avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  user-select: none;
}

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

.conv-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.conv-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}

.conv-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 3px;
}

.conv-preview {
  font-size: 12.8px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conv-preview-prefix {
  color: var(--accent-light);
  font-weight: 600;
}

.conv-bot-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(36, 129, 204, 0.22);
  color: #59b2ff;
  border: 1px solid rgba(89, 178, 255, 0.35);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.tg-user-tag {
  font-size: 11px;
  font-weight: 700;
  border-radius: 5px;
  padding: 1px 6px;
  margin-left: 5px;
  display: inline-flex;
  align-items: center;
  line-height: 1.25;
  vertical-align: middle;
  text-transform: lowercase;
  letter-spacing: 0.2px;
}

.tg-tag-tester {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.4);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.15);
}

.tg-tag-custom {
  background: rgba(88, 166, 255, 0.18);
  color: #58a6ff;
  border: 1px solid rgba(88, 166, 255, 0.4);
}

.tg-verified-badge {
  display: inline-block;
  vertical-align: -2.5px;
  margin-left: 3px;
  flex-shrink: 0;
}

.tg-premium-custom-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 5px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.32);
  image-rendering: -webkit-optimize-contrast;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tg-premium-custom-badge:hover {
  transform: scale(1.3);
}

.tg-premium-badge-crown {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
}

.profile-name .tg-premium-custom-badge,
.tg-profile-name .tg-premium-custom-badge {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 8px;
  margin-left: 6px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.profile-name .tg-premium-badge-crown svg,
.tg-profile-name .tg-premium-badge-crown svg {
  width: 28px;
  height: 28px;
}

.chat-header-name .tg-premium-custom-badge {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 7px;
  margin-left: 5px;
}

.chat-header-name .tg-premium-badge-crown svg {
  width: 24px;
  height: 24px;
}

.drawer-user-name .tg-premium-custom-badge {
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  border-radius: 6px;
}

.drawer-user-name .tg-premium-badge-crown svg {
  width: 22px;
  height: 22px;
}

/* Premium Badge Picker Styles */
.premium-badge-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 10px;
  margin-top: 10px;
  max-height: 230px;
  overflow-y: auto;
  padding: 4px;
}

.premium-badge-preset-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.premium-badge-preset-item:hover {
  background: rgba(124, 58, 237, 0.15);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.premium-badge-preset-item.active {
  background: rgba(124, 58, 237, 0.25);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.35);
}

.premium-badge-preset-item img,
.premium-badge-preset-item .preset-icon {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 6px;
}

.premium-badge-preset-label {
  font-size: 10.5px;
  color: var(--text2);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.conv-section-header {
  padding: 10px 14px 4px 14px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.conv-time {
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
}

.conv-unread-badge {
  background: var(--accent-grad);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ==========================================================================
   CHAT AREA & MESSAGE BUBBLES
   ========================================================================== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg0);
  height: 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  position: relative;
  overflow: hidden;
  overflow-x: hidden;
}

/* Chat Header */
.chat-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 10;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  overflow: hidden;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.chat-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 12.5px;
  color: #708499;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.chat-header-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: #708499;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.chat-header-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

/* Telegram Pinned Message Bar */
.tg-pinned-bar-container {
  width: 100%;
  background: #17212b;
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  z-index: 9;
}

.tg-pinned-bar {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px 16px;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.tg-pinned-bar:hover {
  background: rgba(255, 255, 255, 0.04);
}

.tg-pinned-border {
  width: 3px;
  height: 28px;
  background: #59b2ff;
  border-radius: 2px;
  flex-shrink: 0;
}

.tg-pinned-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tg-pinned-title {
  color: #59b2ff;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
}

.tg-pinned-text {
  color: #ffffff;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  opacity: 0.9;
}

.tg-pinned-btn {
  background: transparent;
  border: none;
  color: #708499;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.tg-pinned-btn:hover {
  color: #59b2ff;
}

.mobile-back-btn {
  display: none;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  align-items: center;
  gap: 4px;
}

.mobile-back-btn:active {
  background: var(--accent);
  color: #fff;
}

/* Chat Messages Container */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden !important;
  width: 100%;
  max-width: 100%;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: transparent;
  -webkit-overflow-scrolling: touch;
}

#dm-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg0);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.no-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  gap: 14px;
  text-align: center;
  padding: 24px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.empty-chat-pill {
  background: #182533;
  color: #ffffff;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  border: none;
  max-width: 90%;
  text-align: center;
}

/* Individual Message Styles — Telegram Desktop Fidelity */
.msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: min(85%, 680px);
  position: relative;
  animation: msgFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) both;
  overflow-wrap: anywhere;
  word-break: break-word;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.self {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg.direct-msg .msg-avatar {
  display: none !important;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  color: #fff;
  margin-bottom: 1px;
}

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

.msg-bubble {
  background: #182533;
  border: none;
  border-radius: 6px 14px 14px 14px;
  padding: 6px 10px 4px 10px;
  position: relative;
  color: #ffffff;
  min-width: 70px;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.msg.self .msg-bubble {
  background: #2b5278;
  border: none;
  border-radius: 14px 14px 6px 14px;
  color: #ffffff;
  box-shadow: none;
}

.msg-forward-header {
  color: #59b2ff;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  line-height: 1.25;
  user-select: none;
  transition: opacity 0.15s ease;
}

.msg-forward-header:hover {
  opacity: 0.9;
}

.msg-forward-header:hover .msg-forward-author {
  text-decoration: underline;
}

.msg-forward-label {
  color: #59b2ff;
  opacity: 0.85;
  font-weight: 500;
  font-style: italic;
}

.msg-forward-author {
  color: #59b2ff;
  font-weight: 700;
  transition: color 0.15s ease;
}

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
  line-height: 1.2;
}

.msg-author {
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: -0.1px;
}

.msg.self .msg-author {
  display: none;
}

.msg-text {
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  color: #ffffff;
  display: block;
}

.msg-text b,
.msg-text strong {
  font-weight: 700;
  color: #ffffff;
}

.msg-text i,
.msg-text em {
  font-style: italic;
}

.msg-text u {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg-text s,
.msg-text del {
  text-decoration: line-through;
  opacity: 0.85;
}

.msg-text a {
  color: #59b2ff;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.msg-text a:hover {
  color: #82c4ff;
}

.tg-spoiler {
  background: rgba(255, 255, 255, 0.18);
  color: transparent !important;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  padding: 1px 5px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline;
}

.tg-spoiler.revealed,
.tg-spoiler:hover {
  background: rgba(255, 255, 255, 0.08);
  color: inherit !important;
  text-shadow: none;
  user-select: text;
}

.tg-blockquote {
  margin: 6px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--accent, #58a6ff);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0 8px 8px 0;
  color: rgba(255, 255, 255, 0.9);
  font-style: normal;
  font-size: 13.5px;
}

.tg-inline-code {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: #7ee787;
  word-break: break-word;
  display: inline-block;
  vertical-align: baseline;
}

.tg-code-block-wrap {
  margin: 8px 0;
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}

.tg-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tg-code-lang {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text3, #8b949e);
  letter-spacing: 0.5px;
}

.tg-code-copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.tg-code-copy-btn:hover {
  background: var(--accent, #58a6ff);
  border-color: var(--accent, #58a6ff);
}

.tg-code-pre {
  margin: 0;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  color: #e6edf3;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.self .msg-text {
  color: #ffffff;
}

/* Time Row at Bottom — Visible on Hover (as in Telegram Desktop) */
.msg-time-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 3px;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  pointer-events: none;
  width: 100%;
}

.msg:hover .msg-time-row,
.msg:focus-within .msg-time-row,
.msg.show-time .msg-time-row {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (hover: none) {
  .msg-time-row {
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
  }
}

.msg-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 400;
  line-height: 1;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.msg.self .msg-time {
  color: #6ab2f2;
}

.msg.self .msg-time .msg-checkmarks {
  display: inline-flex;
  align-items: center;
  color: #6ab2f2;
}

.msg-edited-badge {
  font-size: 10px;
  color: inherit;
  opacity: 0.8;
  margin-left: 2px;
}

.msg-media-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: 10px;
  overflow: hidden;
}

.msg-media-time {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  line-height: 1.2;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.msg-image {
  max-width: 100%;
  max-height: 380px;
  border-radius: 10px;
  cursor: pointer;
  object-fit: cover;
  display: block;
}

.tg-command {
  color: #59b2ff;
  font-weight: 500;
  cursor: pointer;
}

.tg-command:hover {
  text-decoration: underline;
}

/* Message Hover Actions Menu - Hidden per user preference (actions & reactions accessible strictly via Right-Click / ПКМ) */
.msg-actions {
  display: none !important;
}

.msg:hover .msg-actions {
  display: none !important;
}

.msg.self .msg-actions {
  right: auto;
  left: 12px;
}

.msg-action-btn {
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.15s;
}

.msg-action-btn:hover {
  background: var(--bg3);
  color: var(--text);
}

/* Message Context Menu (Right Click / ПКМ) */
.msg-context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
  padding: 6px;
  min-width: 215px;
  animation: contextMenuPop 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top left;
  user-select: none;
}

@keyframes contextMenuPop {
  0% { opacity: 0; transform: scale(0.92) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.msg-context-reactions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg1);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border: 1px solid var(--border-subtle);
}

.msg-context-react-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.12s;
}

.msg-context-react-btn:hover {
  transform: scale(1.32);
  background: var(--bg3);
}

.msg-context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s ease, color 0.14s ease;
}

.msg-context-item:hover {
  background: var(--bg3);
  color: #ffffff;
}

.msg-context-item.danger {
  color: var(--red);
}

.msg-context-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.msg-context-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--text2);
  flex-shrink: 0;
}

.msg-context-item:hover .msg-context-icon {
  color: currentColor;
}

.msg-context-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* Beautiful Promo Modal */
.promo-modal-card {
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg1) 100%);
  border-radius: var(--radius-lg);
  padding: 8px 0;
}

.promo-modal-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 20px;
}

.promo-modal-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.22) 0%, rgba(124, 58, 237, 0.22) 100%);
  border: 1px solid rgba(255, 215, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(255, 215, 0, 0.15);
}

.promo-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.promo-input {
  width: 100%;
  padding: 13px 14px 13px 42px;
  background: var(--bg1);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  outline: none;
  transition: all 0.2s ease;
}

.promo-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-surface);
}

.promo-input-icon {
  position: absolute;
  left: 14px;
  color: var(--gold);
  display: flex;
  align-items: center;
}

.promo-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  align-items: center;
}

.promo-tag-chip {
  background: rgba(255, 215, 0, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.25);
  color: var(--gold);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.16s ease;
}

.promo-tag-chip:hover {
  background: rgba(255, 215, 0, 0.18);
  transform: translateY(-1px);
}

/* Beautiful Group / Channel Modal */
.create-modal-avatar-pick {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  margin: 0 auto 16px;
  cursor: pointer;
  border: 3px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.3);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.create-modal-avatar-pick:hover {
  transform: scale(1.05);
}

/* Reactions */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #1e2c3a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 2px 7px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  color: #ffffff;
  transition: all 0.15s ease;
}

.reaction-chip:hover {
  background: #283a4c;
  transform: scale(1.05);
}

.reaction-chip.active {
  background: #2b5278;
  border-color: #59b2ff;
  color: #ffffff;
}

.reaction-avatar {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-block;
  vertical-align: middle;
}

/* Reply Bar & Context */
.chat-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: #182533;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  color: var(--text2);
}

.chat-context-bar-body {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.msg-reply {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-left: 3px solid #6ab2f2;
  border-radius: 4px 8px 8px 4px;
  padding: 3px 8px;
  margin-bottom: 4px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  transition: background 0.15s ease;
}

.msg.self .msg-reply {
  background: rgba(0, 0, 0, 0.2);
}

.msg-reply-author {
  font-size: 11.5px;
  font-weight: 700;
  color: #6ab2f2;
}

.msg.self .msg-reply-author {
  color: #ffffff;
}

.msg-reply-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg.self .msg-reply-text {
  color: rgba(255, 255, 255, 0.85);
}

/* Telegram Desktop Chat Input Dock */
.chat-input-wrap {
  padding: 8px 16px 12px 16px;
  background: var(--bg1);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-input-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 0;
}

.chat-input-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  padding: 8px 6px;
}

.chat-input-box input::placeholder {
  color: var(--text3);
}

.input-action-btn {
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.input-action-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  color: var(--accent-light);
  background: var(--accent-surface);
}

.send-btn.has-text {
  color: var(--accent-light);
}

.send-btn:active {
  transform: scale(0.92);
}

.typing-indicator {
  font-size: 12px;
  color: var(--text2);
  padding: 2px 20px 4px;
  min-height: 0;
  background: transparent;
  transition: all 0.2s ease;
}

.typing-indicator:empty {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}

/* Call Overlay & Floating UI */
.tg-call-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(30, 41, 59, 0.96), rgba(10, 14, 23, 0.98));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 16px;
}

.tg-call-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, rgba(26, 34, 52, 0.95), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  padding: 38px 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: callCardEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes callCardEnter {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.tg-call-avatar {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border: 3px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  position: relative;
}

.tg-call-avatar.ringing {
  animation: callPulse 1.6s infinite;
}

@keyframes callPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
  60% { transform: scale(1.06); box-shadow: 0 0 0 24px rgba(56, 189, 248, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.tg-call-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tg-call-name {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  letter-spacing: -0.01em;
}

.tg-call-status {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 34px;
}

.tg-call-status #call-duration-timer {
  color: #38bdf8;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.tg-call-actions {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
  width: 100%;
}

.tg-call-btn-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.tg-call-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  color: #ffffff;
  flex-shrink: 0;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.tg-call-btn svg {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.tg-call-btn:hover {
  transform: translateY(-2px) scale(1.06);
  filter: brightness(1.1);
}

.tg-call-btn:active {
  transform: translateY(1px) scale(0.94);
  filter: brightness(0.95);
}

.tg-call-btn.accept {
  background: linear-gradient(135deg, #22c55e, #15803d);
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.tg-call-btn.decline, .tg-call-btn.end {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.tg-call-btn.mute {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.tg-call-btn.mute.active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.45);
}

.tg-call-btn-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  letter-spacing: 0.01em;
}

/* ==========================================================================
   SERVERS & CHANNELS PANEL
   ========================================================================== */
.servers-panel {
  flex: 1;
  display: flex;
  height: 100%;
}

.server-list-sidebar {
  width: 290px;
  flex-shrink: 0;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.server-channel-sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.channel-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg0);
}

.create-server-btn {
  margin: 10px 14px;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: var(--accent-surface);
  color: var(--accent-light);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  transition: all 0.2s ease;
  text-align: center;
  width: calc(100% - 28px);
}

.create-server-btn:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* ==========================================================================
   SHOP & PREMIUM PANEL
   ========================================================================== */
.shop-panel {
  flex: 1;
  overflow-y: auto;
  padding: 36px 24px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.shop-header {
  margin-bottom: 24px;
}

.shop-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
  margin-bottom: 6px;
}

.shop-header .subtitle {
  color: var(--text2);
  font-size: 14px;
}

.shop-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg2);
  border-radius: var(--radius-full);
  padding: 5px;
  margin-bottom: 28px;
  width: fit-content;
  border: 1px solid var(--border-subtle);
}

.shop-tab {
  padding: 9px 22px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text2);
  transition: all 0.2s ease;
}

.shop-tab:hover {
  color: #fff;
}

.shop-tab.active {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.premium-hero {
  background: radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.3) 0%, rgba(21, 19, 36, 0.95) 70%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: var(--shadow-lg);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.feature-card {
  background: var(--bg2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: all 0.2s ease;
}

.feature-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* Coins & Gifts Grids */
.coins-grid, .gifts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.coin-card, .gift-card {
  background: var(--bg2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px 18px;
  text-align: center;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  position: relative;
}

.coin-card:hover, .gift-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 10px 25px -5px var(--accent-glow);
}

.coin-amount {
  font-size: 32px;
  font-weight: 800;
  color: var(--gold);
}

.btn-buy-card {
  margin-top: 14px;
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-grad);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px var(--accent-glow);
}

.btn-buy-card:hover {
  box-shadow: 0 6px 16px var(--accent-glow);
  transform: translateY(-1px);
}

/* ==========================================================================
   PROFILE VIEW
   ========================================================================== */
.profile-panel {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.profile-card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  position: relative;
}

.profile-header-bg {
  background: radial-gradient(circle at 50% 20%, rgba(139, 92, 246, 0.25) 0%, rgba(14, 13, 24, 0.95) 100%);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  padding: 24px 20px 20px;
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease;
}

.profile-top-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 14px;
}

.profile-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.profile-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.profile-big-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 800;
  margin: 0 auto 12px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  position: relative;
  cursor: pointer;
}

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

.avatar-edit-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: #fff;
}

.profile-big-avatar:hover .avatar-edit-overlay {
  opacity: 1;
}

.profile-name {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.profile-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px 16px 8px;
}

@media (max-width: 520px) {
  .profile-actions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

.profile-action-btn {
  background: var(--bg2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.profile-action-btn:hover {
  background: var(--bg3);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.profile-info-section {
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-info-item {
  background: var(--bg2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.profile-info-item:hover {
  background: var(--bg3);
  border-color: var(--border-hover);
}

.profile-info-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-info-value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text1);
  word-break: break-word;
}

.profile-info-label {
  font-size: 11.5px;
  color: var(--text3);
}

.profile-extra-row {
  margin: 0 16px 10px;
  background: var(--bg2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text1);
  cursor: pointer;
  transition: all 0.18s ease;
}

.profile-extra-row:hover {
  background: var(--bg3);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

/* ==========================================================================
   TELEGRAM USER PROFILE OVERLAY & MODAL (.tg-profile-*)
   ========================================================================== */
.tg-profile-modal {
  position: relative;
  background: var(--bg1);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border);
}

.tg-profile-top-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.tg-profile-top-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.tg-profile-top-btn:hover {
  background: rgba(0, 0, 0, 0.75);
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.35);
}

.tg-profile-edit-btn:hover {
  background: var(--accent);
  border-color: var(--accent-light);
  color: #ffffff;
  box-shadow: 0 0 14px var(--accent-glow);
}

.tg-profile-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tg-profile-close-btn:hover {
  background: rgba(239, 68, 68, 0.8);
  border-color: rgba(239, 68, 68, 0.9);
  transform: scale(1.1);
}

.tg-profile-header {
  background: linear-gradient(180deg, rgba(88, 166, 255, 0.15) 0%, rgba(23, 33, 43, 0.95) 100%);
  padding: 32px 20px 20px;
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.tg-profile-avatar-wrapper {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: var(--accent-grad);
  border: 3px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

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

.tg-profile-avatar-placeholder {
  font-size: 32px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.tg-profile-name {
  font-size: 19px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tg-profile-status {
  font-size: 12.5px;
  color: #708499;
  margin-top: 3px;
}

.tg-profile-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border-subtle);
}

.tg-profile-act-tile {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text1);
  transition: all 0.18s ease;
  user-select: none;
}

.tg-profile-act-tile:hover {
  background: rgba(88, 166, 255, 0.12);
  border-color: rgba(88, 166, 255, 0.3);
  color: #58a6ff;
  transform: translateY(-2px);
}

.tg-profile-act-tile.active {
  background: rgba(88, 166, 255, 0.18);
  border-color: #58a6ff;
  color: #58a6ff;
}

.tg-profile-act-label {
  font-size: 11.5px;
  font-weight: 600;
}

.tg-profile-popover {
  background: #17212b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  margin: 8px 16px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: fadeInBackdrop 0.18s ease;
}

.tg-profile-popover-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #e6edf3;
  transition: background 0.15s ease;
}

.tg-profile-popover-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tg-profile-popover-item.danger {
  color: #ff595a;
}

.tg-profile-popover-item.danger:hover {
  background: rgba(255, 89, 90, 0.12);
}

.tg-profile-popover-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tg-profile-info-section {
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tg-profile-info-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.tg-profile-info-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.tg-profile-info-icon {
  width: 24px;
  height: 24px;
  color: #708499;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tg-profile-info-content {
  flex: 1;
  min-width: 0;
}

.tg-profile-info-title {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  word-break: break-word;
}

.tg-profile-info-sub {
  font-size: 12px;
  color: #708499;
  margin-top: 2px;
}

.tg-profile-info-badge {
  background: #58a6ff;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

/* ==========================================================================
   GIFTS SYSTEM MODALS (.tg-gifts-*)
   ========================================================================== */
.tg-gifts-modal {
  background: var(--bg1);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 480px;
  width: 100%;
}

.tg-gifts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.tg-gifts-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.tg-gifts-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tg-gifts-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.tg-gifts-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg1);
}

.tg-gifts-tab {
  flex: 1;
  padding: 11px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tg-gifts-tab.active {
  color: #58a6ff;
  border-bottom-color: #58a6ff;
}

.tg-gifts-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 16px;
  max-height: 380px;
  overflow-y: auto;
}

.tg-gift-card {
  background: #17212b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
  position: relative;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.tg-gift-card:hover {
  transform: translateY(-2px);
  border-color: rgba(88, 166, 255, 0.4);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.tg-gift-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--gold);
}

.tg-gift-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.tg-gift-price {
  font-size: 11.5px;
  color: var(--yellow);
  font-weight: 700;
}

.send-gift-item.selected {
  border-color: #58a6ff !important;
  background: rgba(88, 166, 255, 0.12) !important;
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.3);
}

/* ==========================================================================
   MODALS, TOASTS & OVERLAYS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 8, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 16px;
  animation: fadeInBackdrop 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s ease;
}

.modal-overlay.closing {
  opacity: 0;
  pointer-events: none;
}

@keyframes fadeInBackdrop {
  from { opacity: 0; backdrop-filter: blur(0px); }
  to { opacity: 1; backdrop-filter: blur(14px); }
}

.modal {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-card);
  animation: modalSpringIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform 0.2s ease, opacity 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal:has(.tg-profile-modal),
.modal:has(.tg-gifts-modal) {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  max-width: 440px;
}

@keyframes modalSpringIn {
  0% { opacity: 0; transform: translateY(16px) scale(0.94); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #ffffff;
}

/* Modal Form Groups & Universal Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  width: 100%;
}

.form-group label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-light, #818cf8);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 2px;
  display: block;
}

.form-group input,
.form-group textarea,
.form-group select,
.tg-input,
.modal input[type="text"],
.modal input[type="password"],
.modal input[type="email"],
.modal input[type="number"],
.modal input[type="tel"],
.modal input[type="url"],
.modal input[type="search"],
.modal input:not([type]),
.modal textarea,
.modal select {
  width: 100%;
  background: var(--bg2, #181c24);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-sm, 10px);
  padding: 11px 14px;
  color: var(--text, #ffffff);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-sizing: border-box;
  display: block;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.tg-input:focus,
.modal input:focus,
.modal textarea:focus,
.modal select:focus {
  border-color: var(--primary, #3b82f6);
  background: var(--bg3, #1e2430);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.form-group input::placeholder,
.form-group textarea::placeholder,
.tg-input::placeholder,
.modal input::placeholder,
.modal textarea::placeholder {
  color: var(--text-subtle, rgba(255, 255, 255, 0.38));
}

.create-modal-avatar-pick {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.create-modal-avatar-pick svg {
  width: 32px;
  height: 32px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg2);
  border: 1px solid var(--border-subtle);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover {
  background: var(--bg3);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

#toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-24px) scale(0.92);
  background: rgba(21, 19, 36, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 10px 22px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 9999;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  opacity: 0;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  gap: 8px;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

#toast.success {
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

#toast.error {
  border-color: rgba(244, 63, 94, 0.4);
  color: #fb7185;
}

#toast.info {
  border-color: rgba(139, 92, 246, 0.4);
  color: #c084fc;
}

/* ==========================================================================
   TELEGRAM DRAWER & BURGER MENU
   ========================================================================== */
.burger-btn {
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}
.burger-btn:hover {
  color: var(--text1);
  background: var(--bg3);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.tg-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 290px;
  max-width: 85vw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg1);
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.tg-drawer.active {
  transform: translateX(0);
}

.drawer-header {
  padding: 24px 20px 18px;
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.22) 0%, rgba(99, 102, 241, 0.1) 100%);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease;
}
.drawer-header:hover {
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.32) 0%, rgba(99, 102, 241, 0.2) 100%);
}

.drawer-avatar-wrap {
  position: relative;
  width: 60px;
  height: 60px;
  margin-bottom: 14px;
}
.drawer-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 14px var(--accent-glow);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}
.drawer-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.drawer-avatar-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg1);
}

.drawer-user-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text1);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-user-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-menu {
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text1);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  width: 100%;
  background: transparent;
  border: none;
}
.drawer-item:hover {
  background: var(--bg2);
  color: #ffffff;
}
.drawer-item-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.drawer-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  flex-shrink: 0;
}
.drawer-item:hover .drawer-icon {
  color: var(--accent-light);
}

.drawer-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 6px 12px;
}

/* Telegram Switch Control */
.tg-switch {
  width: 42px;
  height: 22px;
  border-radius: 12px;
  background: var(--bg4);
  position: relative;
  cursor: pointer;
  transition: background 0.25s ease;
  padding: 2px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.tg-switch.active {
  background: #58a6ff;
}
.tg-switch-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.tg-switch.active .tg-switch-thumb {
  transform: translateX(20px);
}

/* ==========================================================================
   TELEGRAM SETTINGS MODALS & SUBVIEWS
   ========================================================================== */
.tg-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.tg-settings-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tg-subview-back-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.18s ease;
}
.tg-subview-back-btn:hover {
  background: var(--bg3);
  color: var(--text1);
}

.tg-section-header {
  color: #58a6ff;
  font-size: 13.5px;
  font-weight: 700;
  margin: 18px 4px 8px;
}

.tg-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg1);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tg-setting-row:hover {
  background: var(--bg2);
  border-color: var(--border-hover);
}
.tg-setting-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tg-setting-row-left svg {
  color: var(--text2);
  flex-shrink: 0;
}
.tg-setting-row:hover .tg-setting-row-left svg {
  color: var(--text1);
}
.tg-setting-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text1);
}
.tg-setting-sublabel {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}
.tg-setting-value {
  color: #58a6ff;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tg-setting-badge {
  color: #58a6ff;
  font-weight: 700;
  font-size: 13.5px;
  padding: 0 4px;
}
.tg-setting-hint {
  font-size: 12px;
  color: var(--text2);
  padding: 2px 14px 10px;
  line-height: 1.4;
}

/* Notification Preview Card */
.tg-notif-preview-box {
  background: linear-gradient(135deg, #2c124d 0%, #150d2e 100%);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 14px;
  padding: 14px;
  margin: 14px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.tg-notif-preview-inner {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.tg-notif-preview-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}
.tg-notif-preview-name {
  font-weight: 700;
  font-size: 13.5px;
  color: #ffffff;
}
.tg-notif-preview-msg {
  font-size: 12.5px;
  color: #e2e8f0;
  margin-top: 1px;
}
.tg-notif-preview-chips {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.tg-notif-chip {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Chat Wallpaper Preview in Chat Settings */
.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 8px;
  max-height: 270px;
  overflow-y: auto;
  padding: 4px 2px;
}
.wallpaper-thumb {
  height: 76px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 8px;
  user-select: none;
}
.wallpaper-thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
}
.wallpaper-thumb.active {
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.3), 0 4px 14px rgba(88, 166, 255, 0.35);
}
.wallpaper-thumb-tag {
  align-self: flex-start;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  color: #e2e8f0;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.wallpaper-thumb-title {
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
  line-height: 1.2;
}

/* ==========================================================================
   RESPONSIVE DESIGN (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .dm-panel {
    position: relative;
    overflow: hidden;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    height: 100%;
  }

  .conv-sidebar {
    width: 100%;
    max-width: 100%;
    border-right: none;
    overflow-x: hidden;
  }

  body.chat-open .conv-sidebar {
    display: none !important;
  }

  .chat-area {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 500;
    background: var(--bg0);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    overflow: hidden;
    overflow-x: hidden;
  }

  body.chat-open .chat-area,
  .chat-area.mobile-active {
    display: flex !important;
    transform: translateX(0) !important;
    pointer-events: auto !important;
    visibility: visible !important;
  }

  .mobile-back-btn {
    display: inline-flex !important;
  }

  .chat-input-wrap {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* ==========================================================================
   OMNIBOT & CUSTOM BOT INTERACTIVE COMPONENTS
   ========================================================================== */
.bot-interactive-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 100%;
}

.bot-interactive-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text1);
  word-break: break-word;
}

.bot-interactive-text b {
  color: #ffffff;
  font-weight: 700;
}

.bot-inline-code {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: #7ee787;
}

.bot-code-block-wrap {
  margin: 8px 0;
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
}

.bot-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.bot-code-lang {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text3);
  letter-spacing: 0.5px;
}

.bot-copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bot-copy-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.bot-code-pre {
  margin: 0;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.45;
  color: #e6edf3;
  overflow-x: auto;
  white-space: pre;
}

.bot-interactive-buttons-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.bot-interactive-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  text-align: center;
}

.bot-btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 6px rgba(88, 101, 242, 0.25);
}

.bot-btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.bot-btn-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000000;
  font-weight: 700;
  border-color: rgba(255, 215, 0, 0.4);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.bot-btn-gold:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.bot-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
}

.bot-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

/* ==========================================================================
   Omni Admin Tag & Monochrome Styling
   ========================================================================== */
.omni-admin-tag {
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  background: #000000;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.65px;
  padding: 1.5px 6.5px;
  border-radius: 5px;
  vertical-align: middle;
  margin-left: 4px;
  user-select: none;
  line-height: 1.25;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.omni-admin-tag:hover {
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
  transform: translateY(-0.5px);
}

.omni-admin-tag .omni-admin-icon {
  stroke: #ffffff;
  flex-shrink: 0;
  display: inline-block;
}

[data-theme="light"] .omni-admin-tag {
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #1e293b;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.3);
}

/* Custom Premium Badges & Presets Grid */

.badge-customizer-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.badge-preview-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.15) 0%, rgba(99, 102, 241, 0.08) 100%);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
}

.badge-preview-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.badge-preview-icon {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  background: var(--bg1);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.badge-preview-icon img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.badge-tabs-nav {
  display: flex;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--border);
}

.badge-tab-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.badge-tab-btn.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.badge-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.badge-preset-card {
  background: var(--bg1);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.badge-preset-card:hover {
  background: var(--bg2);
  border-color: var(--accent-light);
  transform: translateY(-2px);
}

.badge-preset-card.selected {
  border-color: var(--accent-light);
  background: rgba(139, 92, 246, 0.18);
  box-shadow: 0 0 16px var(--accent-glow);
}

.badge-preset-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.badge-preset-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text2);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.badge-upload-box {
  background: var(--bg1);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.badge-upload-box:hover {
  border-color: var(--accent-light);
  background: var(--bg2);
}

/* ==========================================================================
   Premium Profile Style Customizer (Color & Background Photo/GIF)
   ========================================================================== */
.profile-style-customizer-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-style-live-card {
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.profile-style-live-inner {
  padding: 18px 16px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(14,13,24,0.85) 60%, rgba(14,13,24,0.98) 100%);
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 2;
}

.profile-style-live-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-grad);
}

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

.profile-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.profile-color-swatch-card {
  background: var(--bg1);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-color-swatch-card:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.profile-color-swatch-card.selected {
  border-color: #ffffff;
  background: rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.5);
}

.profile-color-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.profile-color-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-align: center;
  line-height: 1.2;
}

.profile-bg-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.profile-bg-preset-item {
  position: relative;
  height: 68px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: flex-end;
}

.profile-bg-preset-item:hover {
  transform: scale(1.03);
  border-color: rgba(255, 255, 255, 0.4);
}

.profile-bg-preset-item.selected {
  border-color: var(--accent-light);
  box-shadow: 0 0 16px var(--accent-glow);
  outline: 2px solid #ffffff;
}

.profile-bg-preset-name {
  width: 100%;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.75);
  font-size: 10.5px;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(4px);
}

/* ==============================================================================
   OMNI FLOATING MINI UPLOAD PROGRESS BAR & SPINNER
   ============================================================================== */
.omni-upload-progress-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.omni-upload-toast {
  pointer-events: auto;
  min-width: 290px;
  max-width: 380px;
  background: rgba(23, 33, 43, 0.95);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(89, 178, 255, 0.4);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 24px rgba(89, 178, 255, 0.25);
  padding: 12px 16px;
  color: var(--text);
  animation: omniSlideUpFade 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.omni-upload-toast.success {
  border-color: rgba(16, 185, 129, 0.6);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 24px rgba(16, 185, 129, 0.3);
}

.omni-upload-toast.error {
  border-color: rgba(244, 63, 94, 0.6);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 24px rgba(244, 63, 94, 0.3);
}

.omni-upload-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.omni-upload-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex: 1;
}

.omni-upload-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-surface);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: inset 0 0 8px rgba(89, 178, 255, 0.2);
}

.omni-upload-title-block {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.omni-upload-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.omni-upload-size {
  font-size: 11px;
  color: var(--text2);
  margin-top: 1px;
}

.omni-upload-percent {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-light);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.omni-upload-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  position: relative;
}

.omni-upload-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2481cc 0%, #00f2fe 100%);
  width: 0%;
  transition: width 0.15s ease-out;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.7);
}

.omni-upload-bar-fill.success {
  background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.7);
}

.omni-upload-bar-fill.error {
  background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.7);
}

.omni-upload-bar-fill.indeterminate {
  width: 45%;
  animation: omniIndeterminateBar 1.2s infinite ease-in-out;
}

.omni-upload-status-text {
  font-size: 11.5px;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@keyframes omniIndeterminateBar {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(120%); }
  100% { transform: translateX(250%); }
}

@keyframes omniSlideUpFade {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Form validation feedback in profile modal */
.form-input-error {
  border-color: #f43f5e !important;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.35) !important;
  animation: omniShake 0.3s ease;
}

.form-error-hint {
  font-size: 12px;
  color: #f87171;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

@keyframes omniShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ==========================================================================
   EXCLUSIVE PROFILE EDITOR (.exclusive-editor-*)
   ========================================================================== */
.exclusive-editor-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.exclusive-live-preview-wrap {
  position: relative;
  border-radius: var(--radius);
  padding: 16px 18px;
  background: radial-gradient(circle at 50% 20%, rgba(139, 92, 246, 0.3) 0%, rgba(15, 23, 42, 0.96) 100%);
  border: 1.5px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  transition: background 0.25s ease, border-color 0.25s ease;
  width: 100%;
  box-sizing: border-box;
}

.exclusive-preview-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.exclusive-preview-avatar-box {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--accent-grad);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.exclusive-preview-avatar-box:hover {
  transform: scale(1.05);
  border-color: var(--accent-light);
}

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

.exclusive-avatar-cam-badge {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: #ffffff;
}

.exclusive-preview-avatar-box:hover .exclusive-avatar-cam-badge {
  opacity: 1;
}

.exclusive-preview-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.exclusive-preview-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  flex-wrap: wrap;
  word-break: break-word;
}

.exclusive-preview-username {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 2px;
  word-break: break-all;
}

.exclusive-preview-status {
  font-size: 11.5px;
  color: var(--green);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.online-dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  display: inline-block;
}

.exclusive-preview-bio {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.4;
  word-break: break-word;
}

.exclusive-tabs-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
}

.exclusive-tab-btn {
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s ease;
  white-space: nowrap;
  min-width: 0;
}

.exclusive-tab-btn .tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.exclusive-tab-btn .tab-icon svg {
  width: 15px;
  height: 15px;
}

.exclusive-tab-btn:hover {
  color: var(--text1);
  background: rgba(255, 255, 255, 0.04);
}

.exclusive-tab-btn.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.exclusive-tab-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: omniSlideUpFade 0.25s ease;
  width: 100%;
  box-sizing: border-box;
}

.exclusive-avatar-banner-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
}

.exclusive-avatar-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.exclusive-avatar-icon-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
  flex-shrink: 0;
}

.exclusive-avatar-text-block {
  min-width: 0;
}

.exclusive-avatar-box-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text1);
}

.exclusive-avatar-box-sub {
  font-size: 11px;
  color: var(--text3);
  word-break: break-word;
}

.exclusive-upload-btn {
  font-size: 12px;
  padding: 7px 14px;
  flex-shrink: 0;
}

.exclusive-modal-footer {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .exclusive-tabs-nav {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
    padding: 6px !important;
  }
  .exclusive-tab-btn {
    padding: 9px 8px !important;
    font-size: 12.5px !important;
    white-space: nowrap !important;
    justify-content: center !important;
  }
  .exclusive-live-preview-wrap {
    padding: 14px 12px !important;
  }
  .exclusive-preview-avatar-row {
    gap: 10px !important;
  }
  .exclusive-preview-avatar-box {
    width: 54px !important;
    height: 54px !important;
  }
  .exclusive-avatar-banner-box {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 10px !important;
  }
  .exclusive-upload-btn {
    width: 100% !important;
    text-align: center !important;
  }
  .exclusive-modal-footer {
    flex-direction: row !important;
    gap: 8px !important;
  }
  .exclusive-modal-footer button {
    padding: 10px 12px !important;
    font-size: 13.5px !important;
  }
}

/* ==============================================================================
   MESSAGE STATUS & READ RECEIPT CHECKMARKS
   ============================================================================== */
.msg-checkmarks {
  display: inline-flex;
  align-items: center;
  margin-left: 3px;
  vertical-align: -1px;
}
.msg-checkmarks.sent {
  color: var(--text3);
  opacity: 0.75;
}
.msg-checkmarks.read {
  color: #38bdf8;
}
[data-theme="monochrome"] .msg-checkmarks.read,
[data-theme="bw"] .msg-checkmarks.read {
  color: #ffffff;
}

/* Jitter-free seamless transitions */
body, .app, .sidebar, .chat-area, .msg-bubble, .modal {
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* ==============================================================================
   OMNICRYPT E2EE (END-TO-END ENCRYPTION) UI
   ============================================================================== */
.omnicrypt-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  margin-left: 8px;
}

.omnicrypt-header-badge:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.omnicrypt-msg-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: #34d399;
  font-weight: 600;
  margin-right: 4px;
  opacity: 0.9;
}

.omnicrypt-modal {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px;
}

.omnicrypt-header {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.omnicrypt-icon-shield {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(5, 150, 105, 0.15));
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.omnicrypt-title-wrap {
  flex: 1;
  min-width: 0;
}

.omnicrypt-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 2px 0;
  letter-spacing: -0.01em;
}

.omnicrypt-sub {
  font-size: 11.5px;
  color: var(--text3);
  margin: 0;
}

.omnicrypt-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.omnicrypt-dialog-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.omnicrypt-dialog-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.omnicrypt-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.omnicrypt-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.omnicrypt-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
}

.omnicrypt-fingerprint-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.omnicrypt-emoji-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 26px;
  padding: 6px 0;
  user-select: all;
}

.omnicrypt-emoji-item {
  transition: transform 0.2s ease;
  display: inline-block;
}
.omnicrypt-emoji-item:hover {
  transform: scale(1.25);
}

.omnicrypt-numeric-code {
  font-family: monospace;
  font-size: 14px;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--text2);
  user-select: all;
}

.omnicrypt-hint {
  font-size: 11.5px;
  color: var(--text3);
  line-height: 1.5;
  margin-top: 6px;
  text-align: center;
}

.omnicrypt-features-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.omnicrypt-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.omnicrypt-feat-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.omnicrypt-feat-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}

.omnicrypt-feat-desc {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
  margin-top: 1px;
}

.omnicrypt-footer {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

/* ==============================================================================
   MOBILE RESPONSIVENESS & PROFILE MODAL POLISH (< 640px)
   ============================================================================== */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 10px !important;
    align-items: flex-end !important;
  }

  .modal {
    max-width: 100% !important;
    width: 100% !important;
    padding: 18px 14px !important;
    border-radius: 20px !important;
    max-height: 90dvh !important;
    max-height: 90vh !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    margin-bottom: env(safe-area-inset-bottom, 0px) !important;
  }

  .tg-settings-header h2 {
    font-size: 16.5px !important;
  }

  .tg-setting-row {
    padding: 10px 12px !important;
  }

  .tg-setting-label {
    font-size: 13px !important;
  }

  .tg-setting-value {
    font-size: 12.5px !important;
  }

  .profile-color-grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)) !important;
    gap: 6px !important;
    max-height: 170px !important;
  }

  .profile-color-swatch-card {
    padding: 8px 4px !important;
  }

  .profile-color-circle {
    width: 26px !important;
    height: 26px !important;
  }

  .profile-color-label {
    font-size: 10.5px !important;
  }

  .badge-upload-box {
    padding: 10px 12px !important;
  }

  .calc-modal-card {
    max-width: calc(100vw - 24px) !important;
    padding: 18px 14px !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
  }

  .calc-modal-card input {
    font-size: 17px !important;
    padding-right: 60px !important;
  }
}






