/* ==========================================================================
   HIVE DESIGN SYSTEM — Linear / Discord Minimalist Theme System
   ========================================================================== */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  /* Color Palette — Hive Dark (default) */
  --bg-base: #0B0B0F;
  --bg-surface: #14141B;
  --bg-surface-elevated: #1A1A24;
  --bg-surface-hover: #1E1E29;
  --bg-surface-active: #20202D;
  --bg-input: #0F0F16;
  --bg-code: #101017;
  --bg-pill: rgba(255, 255, 255, 0.04);
  --bg-pill-border: rgba(255, 255, 255, 0.08);
  --bg-hover-subtle: rgba(255, 255, 255, 0.04);
  --bg-overlay: rgba(0, 0, 0, 0.72);
  --bg-glass: rgba(20, 20, 27, 0.85);
  --bg-header-glass: rgba(15, 15, 22, 0.75);

  --border-subtle: #23232E;
  --border-hover: #323242;
  --border-focus: var(--accent);

  --text-primary: #E8E8F0;
  --text-secondary: #9E9EA8;
  --text-tertiary: #8A8AA0;
  --text-disabled: #8A8AA0;
  --text-muted-pill: #C8C8D8;

  /* Shadows */
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 1px 1px var(--border-subtle);
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-dropdown: 0 16px 36px rgba(0, 0, 0, 0.55);

  /* Semantic Status Colors */
  --danger: #FF4757;
  --danger-hover: #DC2626;
  --danger-text: #FF6B81;
  --danger-soft: rgba(255, 71, 87, 0.14);
  --danger-border: rgba(255, 71, 87, 0.32);
  --danger-glow: 0 0 16px rgba(255, 71, 87, 0.35);

  --success: #10B981;
  --success-hover: #059669;
  --success-text: #34D399;
  --accent-green: #10B981;

  --warning: #FFA502;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --warning-border: rgba(245, 158, 11, 0.3);

  /* Accent Defaults (Purple #7C5CFF) */
  --accent: #7C5CFF;
  --accent-hover: #8D71FF;
  --accent-gradient-end: #5438DC;
  --accent-rgb: 124, 92, 255;
  --on-accent: #000000;
  --accent-text: #9D85FF;

  --accent-soft: rgba(var(--accent-rgb), 0.12);
  --accent-soft-hover: rgba(var(--accent-rgb), 0.20);
  --accent-border: rgba(var(--accent-rgb), 0.28);
  --accent-glow: 0 0 16px rgba(var(--accent-rgb), 0.35);
  --accent-glow-strong: 0 0 22px rgba(var(--accent-rgb), 0.55);

  /* Legacy aliases mapped to dynamic accent */
  --accent-purple: var(--accent);
  --accent-purple-hover: var(--accent-hover);
  --accent-purple-glow: var(--accent-glow);
  --accent-purple-soft: var(--accent-soft);

  /* Metrics & Geometry */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-speed: 150ms;
  --transition-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --transition: all var(--transition-speed) var(--transition-ease);

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 60px;
}

/* Midnight Theme (Pure OLED Black) */
[data-theme="midnight"] {
  color-scheme: dark;
  --bg-base: #000000;
  --bg-surface: #07070A;
  --bg-surface-elevated: #0E0E13;
  --bg-surface-hover: #14141C;
  --bg-surface-active: #181822;
  --bg-input: #050507;
  --bg-code: #08080C;
  --bg-pill: rgba(255, 255, 255, 0.05);
  --bg-pill-border: rgba(255, 255, 255, 0.1);
  --bg-hover-subtle: rgba(255, 255, 255, 0.05);
  --bg-overlay: rgba(0, 0, 0, 0.84);
  --bg-glass: rgba(7, 7, 10, 0.9);
  --bg-header-glass: rgba(0, 0, 0, 0.82);

  --border-subtle: #1A1A24;
  --border-hover: #2C2C3A;

  --text-primary: #F2F2F7;
  --text-secondary: #A4A4B4;
  --text-tertiary: #8E8EA2;
  --text-disabled: #8E8EA2;
  --text-muted-pill: #D0D0E0;

  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.9), 0 0 1px 1px var(--border-hover);
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.75);
  --shadow-dropdown: 0 16px 36px rgba(0, 0, 0, 0.85);
}

/* Light Theme (WCAG AA Verified) */
[data-theme="light"] {
  color-scheme: light;
  --bg-base: #F4F5F8;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #F8F9FC;
  --bg-surface-hover: #EEF0F6;
  --bg-surface-active: #E5E8F0;
  --bg-input: #F0F2F7;
  --bg-code: #ECEEF4;
  --bg-pill: rgba(15, 23, 42, 0.05);
  --bg-pill-border: rgba(15, 23, 42, 0.10);
  --bg-hover-subtle: rgba(15, 23, 42, 0.045);
  --bg-overlay: rgba(15, 23, 42, 0.45);
  --bg-glass: rgba(255, 255, 255, 0.92);
  --bg-header-glass: rgba(255, 255, 255, 0.85);

  --border-subtle: #E2E5EE;
  --border-hover: #CBD0DF;

  --text-primary: #111318;
  --text-secondary: #4B5263;
  --text-tertiary: #5C6475;
  --text-disabled: #6B7280;
  --text-muted-pill: #374151;

  --shadow-modal: 0 20px 50px rgba(15, 23, 42, 0.16), 0 0 1px 1px var(--border-subtle);
  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.07);
  --shadow-dropdown: 0 12px 32px rgba(15, 23, 42, 0.12);

  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --danger-text: #B91C1C;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --danger-border: rgba(220, 38, 38, 0.28);
  --danger-glow: 0 0 12px rgba(220, 38, 38, 0.25);

  --success: #15803D;
  --success-hover: #166534;
  --success-text: #15803D;
  --accent-green: #15803D;

  --warning: #B45309;
  --warning-soft: rgba(180, 83, 9, 0.12);
  --warning-border: rgba(180, 83, 9, 0.28);
}

/* 6 Accent Palettes */
[data-accent="purple"] {
  --accent: #7C5CFF;
  --accent-hover: #8D71FF;
  --accent-gradient-end: #5438DC;
  --accent-rgb: 124, 92, 255;
  --on-accent: #000000;
  --accent-text: #9D85FF;
}
[data-theme="light"][data-accent="purple"] {
  --accent-text: #5B35F5;
}

[data-accent="blue"] {
  --accent: #2563EB;
  --accent-hover: #3B82F6;
  --accent-gradient-end: #1D4ED8;
  --accent-rgb: 37, 99, 235;
  --on-accent: #FFFFFF;
  --accent-text: #60A5FA;
}
[data-theme="light"][data-accent="blue"] {
  --accent-text: #1D4ED8;
}

[data-accent="teal"] {
  --accent: #14B8A6;
  --accent-hover: #2DD4BF;
  --accent-gradient-end: #0D9488;
  --accent-rgb: 20, 184, 166;
  --on-accent: #000000;
  --accent-text: #2DD4BF;
}
[data-theme="light"][data-accent="teal"] {
  --accent-text: #0F766E;
}

[data-accent="pink"] {
  --accent: #DB2777;
  --accent-hover: #EC4899;
  --accent-gradient-end: #BE185D;
  --accent-rgb: 219, 39, 119;
  --on-accent: #FFFFFF;
  --accent-text: #F472B6;
}
[data-theme="light"][data-accent="pink"] {
  --accent-text: #BE185D;
}

[data-accent="orange"] {
  --accent: #F97316;
  --accent-hover: #FB923C;
  --accent-gradient-end: #EA580C;
  --accent-rgb: 249, 115, 22;
  --on-accent: #000000;
  --accent-text: #FB923C;
}
[data-theme="light"][data-accent="orange"] {
  --accent-text: #C2410C;
}

[data-accent="green"] {
  --accent: #22C55E;
  --accent-hover: #4ADE80;
  --accent-gradient-end: #16A34A;
  --accent-rgb: 34, 197, 94;
  --on-accent: #000000;
  --accent-text: #4ADE80;
}
[data-theme="light"][data-accent="green"] {
  --accent-text: #15803D;
}

/* ==========================================================================
   ACCESSIBILITY FOCUS RING, REDUCED MOTION, SKELETONS, OFFLINE & 404
   ========================================================================== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes hiveShimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-elevated) 25%, var(--bg-surface-active) 50%, var(--bg-surface-elevated) 75%);
  background-size: 800px 100%;
  animation: hiveShimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
}

.skeleton-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
}

.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-4);
  background: var(--warning-soft);
  border-bottom: 1px solid var(--warning-border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
}

.not-found-card {
  max-width: 460px;
  margin: 48px auto;
  padding: var(--space-8);
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.not-found-code {
  font-size: 56px;
  font-weight: 800;
  color: var(--accent-text);
  line-height: 1;
  margin-bottom: var(--space-3);
}
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  height: 100vh;
}

/* App Shell Layout */
body.app-loading .app-layout {
  opacity: 0;
  pointer-events: none;
}

.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
  transition: opacity 150ms ease;
}

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

/* ==========================================================================
   COMPONENT 1: BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: var(--transition);
}

.btn:active:not(:disabled),
.chat-call-btn:active:not(:disabled),
.tg-quick-btn:active,
.action-btn:active {
  transform: scale(0.95);
  transition: transform 100ms ease;
}

/* Primary Neon Purple */
.btn-primary {
  background-color: var(--accent-purple);
  color: var(--on-accent);
  border-color: var(--accent-purple);
  box-shadow: var(--accent-purple-glow);
}
.btn-primary:hover {
  background-color: var(--accent-purple-hover);
  border-color: var(--accent-purple-hover);
  box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.55);
}

/* Neon Teal Alternative (Aliased to Purple) */
.btn-teal {
  background-color: var(--accent-purple);
  color: var(--on-accent);
  border-color: var(--accent-purple);
  box-shadow: var(--accent-purple-glow);
}
.btn-teal:hover {
  background-color: var(--accent-purple-hover);
  border-color: var(--accent-purple-hover);
  box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.55);
}

/* Secondary (Surface) */
.btn-secondary {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn-secondary:hover {
  background-color: var(--bg-surface-active);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* Ghost */
.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

/* Danger */
.btn-danger {
  background-color: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger:hover {
  background-color: var(--danger);
  color: #FFFFFF;
  box-shadow: var(--danger-glow);
}

/* Icon Only Button */
.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
}

/* Button Sizes */
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  border-radius: var(--radius);
}
.btn-block {
  width: 100%;
}

/* ==========================================================================
   COMPONENT 2: INPUT FIELDS & FORMS
   ========================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  text-align: left;
  position: relative;
}

.field-error {
  color: var(--danger);
  font-size: 11px;
  font-weight: 500;
  margin-top: 4px;
  display: none;
}

.field-error.visible {
  display: block;
  animation: fadeIn var(--transition-speed) ease;
}

.input.error, .textarea.error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 1px var(--danger), var(--danger-glow) !important;
}

.auth-error-banner {
  background-color: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--danger-text);
  font-size: 12px;
  margin-bottom: 16px;
  display: none;
}

.auth-error-banner.visible {
  display: block;
  animation: fadeIn var(--transition-speed) ease;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input, .textarea {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: var(--transition);
}

.input:focus, .textarea:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 1px var(--accent-purple), var(--accent-purple-glow);
}

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

.input-with-icon {
  padding-left: 38px;
}

.input-icon-left {
  position: absolute;
  left: 12px;
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-wrapper:focus-within .input-icon-left {
  color: var(--accent-purple);
}

.textarea {
  resize: vertical;
  min-height: 90px;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.checkbox:checked {
  background-color: var(--accent-purple);
  border-color: var(--accent-purple);
  box-shadow: var(--accent-purple-glow);
}

.checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
}

/* ==========================================================================
   COMPONENT 3: AVATAR & BADGES
   ========================================================================== */
.avatar-container {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.avatar {
  border-radius: 50%;
  background-color: var(--bg-surface-elevated);
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  display: block;
}

.avatar-xs { width: 24px; height: 24px; border-radius: 50%; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; }
.avatar-md { width: 42px; height: 42px; border-radius: 50%; }
.avatar-lg { width: 56px; height: 56px; border-radius: 50%; }
.avatar-xl { width: 88px; height: 88px; border-radius: 50%; }

.status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-surface);
}

.status-dot.online {
  background-color: var(--accent-purple);
  box-shadow: 0 0 8px var(--accent-purple);
}
.status-dot.idle { background-color: var(--warning); }
.status-dot.dnd { background-color: var(--danger); }
.status-dot.offline { background-color: var(--text-tertiary); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-purple {
  background-color: var(--accent-purple-soft);
  color: var(--accent-purple);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
}

.badge-teal {
  background-color: var(--accent-purple-soft);
  color: var(--accent-purple);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
}

/* ==========================================================================
   COMPONENT 4: POST CARD (Airy, Lucide SVGs, Contrast)
   ========================================================================== */
.post-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
  position: relative;
}

.post-card:hover {
  border-color: var(--accent);
  background-color: var(--bg-surface-elevated);
}

.post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.post-author-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.author-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.author-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.author-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  text-decoration: none;
}
.author-name:hover {
  color: var(--accent-purple);
}

.author-handle {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.post-time {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.post-content {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 16px;
  word-break: break-word;
  white-space: pre-wrap;
}

.post-tag {
  color: var(--accent-purple);
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}
.post-tag:hover {
  text-decoration: underline;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
}

.post-attachment-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.attachment-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-purple-soft);
  color: var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.post-footer {
  display: flex;
  align-items: center;
  gap: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.action-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
}

/* Lucide Like Button: smooth fill with accent purple #7C5CFF */
.action-btn.like-btn svg.heart-icon {
  stroke: currentColor;
  fill: transparent;
  transition: fill 150ms ease, stroke 150ms ease, transform 150ms ease;
}

.action-btn.like-btn:hover {
  color: var(--accent-purple);
  background-color: var(--accent-purple-soft);
}
.action-btn.like-btn:hover svg.heart-icon {
  stroke: var(--accent-purple);
}

.action-btn.like-btn.liked,
.action-btn.like-btn.active {
  color: var(--accent-purple);
  background-color: var(--accent-purple-soft);
}

.action-btn.like-btn.liked svg.heart-icon,
.action-btn.like-btn.active svg.heart-icon {
  fill: var(--accent-purple);
  stroke: var(--accent-purple);
  transform: scale(1.08);
}

.action-btn.comment-btn:hover {
  color: var(--accent-purple);
  background-color: var(--accent-purple-soft);
}

.action-btn.share-btn:hover {
  color: var(--accent-purple);
  background-color: var(--accent-purple-soft);
}

/* ==========================================================================
   COMPONENT 5: SIDEBAR (Discord/Linear Hybrid)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  user-select: none;
  z-index: 20;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-gradient-end));
  box-shadow: var(--accent-purple-glow);
  color: var(--on-accent);
  font-weight: 800;
  font-size: 16px;
}

.logo-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-primary);
}

.logo-version {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-purple);
  background-color: var(--accent-purple-soft);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.sidebar-content {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-nav-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 4px 10px;
  letter-spacing: 0.8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.nav-item:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--accent-purple-soft);
  color: var(--text-primary);
  border-color: rgba(var(--accent-rgb), 0.3);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background-color: var(--accent-purple);
  border-radius: 0 4px 4px 0;
  box-shadow: var(--accent-purple-glow);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 16px;
}

.nav-counter {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background-color: var(--accent-purple);
  color: var(--on-accent);
  box-shadow: var(--accent-purple-glow);
}

/* Sidebar Footer (Discord Style User Profile Pill) */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-code);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  overflow: hidden;
  border-radius: var(--radius-sm);
  padding: 4px;
  flex: 1;
  transition: var(--transition);
  cursor: pointer;
}

.user-pill:hover {
  background-color: var(--bg-surface-elevated);
}

.user-pill-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-pill-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-pill-tag {
  font-size: 11px;
  color: var(--text-tertiary);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background-color: var(--bg-hover-subtle);
  border: 1px solid var(--bg-pill-border);
  color: var(--text-muted-pill);
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-settings-btn:hover {
  background-color: rgba(var(--accent-rgb), 0.16);
  border-color: var(--accent-purple);
  color: var(--text-primary);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.25);
}

/* ==========================================================================
   COMPONENT 6: MODAL WINDOW
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 1px 1px var(--border-subtle);
  opacity: 0;
  transform: scale(0.96) translateY(8px);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-dialog {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}

.modal-close:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  max-height: calc(85vh - 140px);
}

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--bg-header-glass);
}

/* ==========================================================================
   MAIN CONTENT AREA & PAGE VIEWS
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-base);
}

/* Header Bar */
.top-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.api-status-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.api-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-tertiary);
  transition: background-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
  display: inline-block;
}

.api-status-dot.online {
  background-color: var(--text-tertiary);
}

.api-status-dot.error {
  background-color: var(--danger);
  box-shadow: 0 0 8px rgba(255, 71, 87, 0.6);
}

/* Views Container */
.views-viewport {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.page-view {
  display: none;
  padding: 24px 16px;
  max-width: 980px;
  margin: 0 auto;
  animation: fadeIn var(--transition-speed) ease;
}

.page-view.active {
  display: block;
}

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

/* ==========================================================================
   VIEW 1: ЛЕНТА (FEED) — 640px centered feed column
   ========================================================================== */
.feed-layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  width: 100%;
}

.feed-main-column {
  width: 640px;
  max-width: 640px;
  flex: 0 0 640px;
}

.feed-sidebar-column {
  width: 300px;
  max-width: 300px;
  flex: 0 0 300px;
}

/* Composer Card */
.composer-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.composer-top {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
}

.composer-input {
  width: 100%;
  background-color: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  resize: none;
  min-height: 64px;
  line-height: 1.5;
}

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

.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.composer-card.dragover {
  border-color: var(--accent-purple) !important;
  background-color: rgba(var(--accent-rgb), 0.06) !important;
}

.composer-images-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.composer-image-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-input);
}

.composer-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.composer-image-thumb .remove-img-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-overlay);
  color: #fff;
  border: none;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.composer-image-thumb .remove-img-btn:hover {
  background: var(--danger);
}

.composer-upload-progress {
  width: 100%;
  height: 3px;
  background-color: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.composer-upload-progress .progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-hover));
  transition: width 0.2s ease;
}

.composer-actions-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.composer-media-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  background-color: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: var(--radius-sm);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.composer-media-btn:hover {
  background-color: rgba(var(--accent-rgb), 0.2);
  border-color: var(--accent-purple);
  color: var(--text-primary);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.22);
}

.composer-media-btn svg {
  color: var(--accent-purple);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.composer-media-btn:hover svg {
  color: var(--accent-text);
  transform: scale(1.06);
}

.composer-photo-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--on-accent);
  background-color: var(--accent-purple);
  padding: 1px 6px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.composer-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.visibility-selector-wrap {
  position: relative;
}

.visibility-select {
  height: 36px;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}

.visibility-select:hover, .visibility-select:focus {
  border-color: var(--accent-purple);
  color: var(--text-primary);
}

.char-counter {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Feed Filter Tabs */
.feed-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.feed-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.feed-tab:hover {
  color: var(--text-primary);
}

.feed-tab.active {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.empty-state-icon {
  margin-bottom: 12px;
  color: var(--text-secondary);
  opacity: 0.6;
}

.empty-state-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Feed Sidebar Widgets */
.widget-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.widget-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Who To Follow Widget */
.who-to-follow-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.who-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.who-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.who-user-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.who-user-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who-user-handle {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who-follow-btn {
  padding: 4px 12px;
  font-size: 12px;
  flex-shrink: 0;
}

.trend-item {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none;
  transition: var(--transition);
}
.trend-item:last-child { border-bottom: none; }
.trend-item:hover .trend-name { color: var(--accent-purple); }

.trend-category {
  font-size: 11px;
  color: var(--text-tertiary);
}
.trend-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  transition: var(--transition);
}
.trend-posts {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   VIEW 2: ПРОФИЛЬ (PROFILE)
   ========================================================================== */
.profile-container {
  max-width: 820px;
  margin: 0 auto;
}

.profile-banner {
  width: 100%;
  aspect-ratio: 3 / 1;
  min-height: 110px;
  max-height: 240px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.38) 0%, var(--bg-surface-elevated) 55%, rgba(var(--accent-rgb), 0.20) 100%);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}

.profile-banner::after {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.profile-banner.has-image::after,
.edit-banner-preview.has-image::after {
  display: none;
}

.profile-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 8 Ready Banner Presets (Gradients & Patterns in Accent Colors) */
.banner-preset-1 {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-gradient-end) 100%) !important;
}
.banner-preset-2 {
  background: radial-gradient(circle at 20% 25%, rgba(var(--accent-rgb), 0.65), transparent 55%),
              radial-gradient(circle at 80% 75%, var(--accent-gradient-end), transparent 60%),
              var(--bg-surface-elevated) !important;
}
.banner-preset-3 {
  background: repeating-linear-gradient(45deg, rgba(var(--accent-rgb), 0.22) 0 18px, rgba(var(--accent-rgb), 0.08) 18px 36px),
              var(--bg-surface-elevated) !important;
}
.banner-preset-4 {
  background: linear-gradient(90deg, var(--bg-surface-elevated) 0%, rgba(var(--accent-rgb), 0.48) 50%, var(--accent) 100%) !important;
}
.banner-preset-5 {
  background: radial-gradient(rgba(var(--accent-rgb), 0.45) 2px, transparent 2px) 0 0 / 20px 20px,
              linear-gradient(135deg, rgba(var(--accent-rgb), 0.20), var(--bg-surface-elevated)) !important;
}
.banner-preset-6 {
  background: conic-gradient(from 120deg at 70% 40%, var(--accent), var(--bg-surface-elevated), rgba(var(--accent-rgb), 0.4), var(--accent)) !important;
}
.banner-preset-7 {
  background: repeating-linear-gradient(-30deg, rgba(var(--accent-rgb), 0.28) 0 2px, transparent 2px 14px),
              linear-gradient(180deg, rgba(var(--accent-rgb), 0.28) 0%, var(--bg-surface-elevated) 100%) !important;
}
.banner-preset-8 {
  background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.72) 0%, rgba(var(--accent-rgb), 0.16) 55%, var(--bg-surface) 100%) !important;
}

.edit-banner-preview {
  width: 100%;
  aspect-ratio: 3 / 1;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.38) 0%, var(--bg-surface-elevated) 55%, rgba(var(--accent-rgb), 0.20) 100%);
  overflow: hidden;
  position: relative;
}

.banner-presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.banner-preset-tile {
  aspect-ratio: 3 / 1;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}

.banner-preset-tile:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.banner-preset-tile.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.3);
}

.banner-crop-stage {
  width: 100%;
  aspect-ratio: 3 / 1;
  background: var(--bg-input);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.banner-crop-stage:active {
  cursor: grabbing;
}

.banner-crop-stage img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  max-width: none;
  pointer-events: none;
}

.profile-header-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: -60px;
  margin-bottom: 24px;
  position: relative;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

.profile-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
}

.profile-avatar-wrapper {
  position: relative;
}

.profile-avatar-wrapper .avatar-xl {
  border: 4px solid var(--bg-surface);
  box-shadow: var(--accent-purple-glow);
}

.profile-info h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-handle-text {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.profile-bio-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.profile-stats-row {
  display: flex;
  gap: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.stat-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.stat-number {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}
.stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   VIEW 3: ЧАТЫ (CHATS — Discord Style Dual Pane)
   ========================================================================== */
#view-chats.page-view {
  max-width: none;
  width: 100%;
  margin: 0;
  height: 100%;
  max-height: 100%;
  padding: 12px 16px;
  overflow: hidden;
  flex-direction: column;
  box-sizing: border-box;
  transform: none;
  animation: none;
}

#view-chats.page-view.active {
  display: flex;
}

.chat-window {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 1fr;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-sidebar {
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-search-wrap {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-threads-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease;
  text-decoration: none;
}

.thread-item:hover {
  border-color: var(--accent);
  background-color: var(--bg-surface-elevated);
}

.thread-item.active {
  background-color: var(--bg-surface-active);
  box-shadow: inset 2px 0 0 var(--accent-purple);
}

.thread-content {
  flex: 1;
  min-width: 0;
}

.thread-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.thread-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.thread-preview {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-main-pane {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-topbar {
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  flex-shrink: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.messages-stream {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

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

.message-bubble-group,
.msg-system-call-pill {
  animation: msgSlideIn 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.message-bubble-group {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

.message-bubble-group.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}

.message-bubble-group.incoming .message-bubble {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-top-left-radius: 4px;
}

.message-bubble-group.outgoing .message-bubble {
  background-color: var(--accent-purple);
  color: var(--on-accent);
}
.message-bubble-group.outgoing .message-time {
  color: var(--on-accent);
  opacity: 0.78;
  border-top-right-radius: 4px;
  box-shadow: var(--accent-purple-glow);
}

.message-time-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 4px;
}

.message-bubble-group.outgoing .msg-read-count,
.message-bubble-group.outgoing .msg-edited-label,
.message-bubble-group.outgoing .msg-voice-meta {
  color: rgba(255, 255, 255, 0.85);
}

.message-bubble-group.outgoing .msg-voice-speed-btn {
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.35);
}

.message-bubble-group.outgoing .msg-voice-play-btn {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
}

.message-bubble-group.outgoing .msg-voice-bar.played {
  background: #FFFFFF;
}

.msg-system-call-pill {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-surface-elevated, #1A1A24);
  border: 1px solid var(--border-subtle, #23232E);
  color: var(--text-secondary, #9E9EA8);
  font-size: 12px;
  font-weight: 500;
  max-width: 90%;
}

.message-bubble-group.incoming .message-time-meta {
  color: var(--text-tertiary);
  justify-content: flex-start;
}

.message-status-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.message-status-icon svg {
  width: 14px;
  height: 14px;
}

.message-status-icon.read svg {
  stroke: #D8B4FE;
}

.message-status-icon.sent svg {
  stroke: rgba(255, 255, 255, 0.65);
}

.nav-badge {
  margin-left: auto;
  background-color: var(--accent-purple);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.4);
}

.mobile-nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background-color: var(--accent-purple);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}

.thread-badge {
  background-color: var(--accent-purple);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.chat-typing-status {
  font-size: 12px;
  color: var(--accent-purple);
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-purple);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-bar {
  position: relative;
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
}

.chat-input-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
}

.chat-composer-btn {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated, var(--bg-surface-elevated, #1E1E2A));
  border: 1px solid var(--border, var(--border-subtle, #23232E));
  color: var(--text-primary, #E8E8F0);
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.chat-composer-btn::after {
  content: '';
  position: absolute;
  inset: -2px;
}

.chat-composer-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
  flex-shrink: 0;
}

.chat-composer-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft, rgba(124, 92, 255, 0.14));
  color: var(--accent-text, var(--text-primary, #E8E8F0));
}

.chat-composer-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.chat-composer-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-composer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-composer-btn.chat-composer-send {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent, #FFFFFF);
}

.chat-composer-btn.chat-composer-send:hover:not(:disabled) {
  background: var(--accent-hover, var(--accent));
  border-color: var(--accent-hover, var(--accent));
  color: var(--text-on-accent, #FFFFFF);
  filter: brightness(1.06);
}

/* ==========================================================================
   VIEW 4, 5, 6, 7: AUTH PAGES (LOGIN, REGISTER, VERIFY EMAIL, LOGIN CODE)
   ========================================================================== */
#view-login,
#view-register,
#view-verify-email,
#view-login-code {
  max-width: 100%;
  width: 100%;
  padding: 0;
}

.auth-centered-wrapper {
  min-height: calc(100vh - var(--header-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  width: 100%;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-purple-hover));
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-gradient-end));
  box-shadow: var(--accent-purple-glow);
  color: var(--on-accent);
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.auth-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.auth-header p {
  font-size: 13px;
  color: var(--text-tertiary);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-tertiary);
  font-size: 12px;
  text-transform: uppercase;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--border-subtle);
}

.social-auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-switch-link {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-switch-link a {
  color: var(--accent-purple);
  text-decoration: none;
  font-weight: 600;
  margin-left: 4px;
}
.auth-switch-link a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   TOAST NOTIFICATION COMPONENT
   ========================================================================== */
.toast-shelf {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 12px 18px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: slideToast var(--transition-speed) var(--transition-ease);
}

.toast.success {
  border-left: 3px solid var(--accent-purple);
}
.toast.info {
  border-left: 3px solid var(--accent-purple);
}

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

/* ==========================================================================
   MOBILE BOTTOM NAVIGATION & RESPONSIVE BREAKPOINTS
   ========================================================================== */
.mobile-nav-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  z-index: 900;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.mobile-nav-btn.active {
  color: var(--accent-purple);
}

.mobile-nav-btn svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 980px) {
  .feed-sidebar-column {
    display: none;
  }
  .feed-main-column {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none !important;
  }

  .mobile-menu-toggle {
    display: none !important;
  }

  .main-wrapper {
    width: 100vw;
    margin: 0;
  }

  .feed-layout {
    width: 100%;
    display: block;
  }

  .feed-main-column {
    width: 100%;
    max-width: 100%;
    margin: 0;
    flex: 1 1 100%;
  }

  #view-chats.page-view {
    padding: 8px 8px 68px 8px !important;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  .chat-window {
    display: flex;
    position: relative;
    grid-template-columns: 1fr;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0;
  }

  .chat-sidebar {
    width: 100%;
    flex: 1 1 100%;
    display: flex;
  }

  .chat-main-pane {
    display: none;
    width: 100%;
    flex: 1 1 100%;
  }

  .chat-window.mobile-chat-open .chat-sidebar {
    display: none;
  }

  .chat-window.mobile-chat-open .chat-main-pane {
    display: flex;
  }

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

  .mobile-nav-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    backdrop-filter: blur(12px);
  }

  .page-view {
    padding: 16px 12px 80px 12px;
    max-width: 100%;
  }
}

/* ==========================================================================
   OTP / 2FA INPUTS COMPONENT
   ========================================================================== */
.otp-inputs-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.otp-input {
  width: 46px;
  height: 54px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: var(--transition);
  caret-color: var(--accent-purple);
}

.otp-input:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
}

.otp-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 1px var(--accent-purple), var(--accent-purple-glow);
  transform: translateY(-1px);
}

.otp-input.error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 1px var(--danger), var(--danger-glow) !important;
}

.resend-box button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .otp-inputs-row {
    gap: 6px;
  }
  .otp-input {
    width: 38px;
    height: 48px;
    font-size: 20px;
  }
}

/* Lucide SVG Icons Standard Styles */
.lucide-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}

/* ==========================================================================
   VIEW 8: SETTINGS (/#settings)
   ========================================================================== */
.settings-layout {
  display: flex;
  gap: 28px;
  max-width: 960px;
  margin: 0 auto;
  align-items: flex-start;
}

.settings-nav {
  width: 210px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px;
}

.settings-nav-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 8px 12px 6px;
}

.settings-tab-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-speed) ease;
}

.settings-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background-color: var(--bg-hover-subtle);
  border: 1px solid var(--bg-pill);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all var(--transition-speed) ease;
}

.settings-tab-btn:hover {
  background: var(--bg-hover-subtle);
  color: var(--text-primary);
}

.settings-tab-btn:hover .settings-tab-icon {
  background-color: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--text-primary);
}

.settings-tab-btn.active {
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--text-primary);
  font-weight: 600;
}

.settings-tab-btn.active .settings-tab-icon {
  background-color: rgba(var(--accent-rgb), 0.25);
  border-color: rgba(var(--accent-rgb), 0.45);
  color: var(--accent-purple);
}

.settings-tab-btn svg {
  flex-shrink: 0;
}

.settings-content {
  flex: 1;
  min-width: 0;
  position: relative;
}

.settings-tab-pane {
  display: none;
  animation: fadeIn 0.15s ease;
}

.settings-tab-pane.active {
  display: block;
}

.settings-saved-pill {
  position: fixed;
  bottom: 24px;
  right: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: var(--radius-full);
  color: var(--accent-purple);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 999;
}

.settings-saved-pill.visible {
  opacity: 1;
  transform: translateY(0);
}

.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
}

.settings-card-header {
  margin-bottom: 16px;
}

.settings-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.settings-card-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-row-info {
  flex: 1;
  padding-right: 20px;
}

.settings-row-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.settings-row-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Custom iOS / Discord style Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  transition: 0.25s;
  border-radius: 24px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #FFFFFF;
  transition: 0.25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.switch input:checked + .switch-slider {
  background-color: var(--accent-purple);
  border-color: var(--accent-purple);
}

.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* Trusted devices list */
.trusted-device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.trusted-device-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.trusted-device-ua {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.trusted-device-date {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Radio Option Cards */
.density-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.density-option-card {
  padding: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-speed);
}

.density-option-card.active {
  border-color: var(--accent-purple);
  background: rgba(var(--accent-rgb), 0.08);
}

.density-option-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.density-option-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* Feed Density Modifier: Compact mode */
.feed-compact .post-card {
  padding: 12px 14px !important;
  margin-bottom: 8px !important;
}

.feed-compact .post-content {
  font-size: 13.5px !important;
  margin: 8px 0 !important;
}

.danger-card {
  border-color: var(--danger-border) !important;
  background: rgba(255, 71, 87, 0.03) !important;
}

.danger-card .settings-card-title {
  color: var(--danger);
}

/* Mobile Responsiveness for Settings */
@media (max-width: 768px) {
  .settings-layout {
    flex-direction: column;
    gap: 16px;
  }

  .settings-nav {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding: 6px;
    border-radius: var(--radius-md);
  }

  .settings-nav-title {
    display: none;
  }

  .settings-tab-btn {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 12.5px;
  }

  .settings-card {
    padding: 16px;
  }

  .density-options {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Header Search & Dropdown
   ========================================================================== */
.header-center {
  flex: 1;
  max-width: 440px;
  margin: 0 20px;
  position: relative;
}

.header-search-wrap {
  position: relative;
  width: 100%;
}

.header-search-wrap .input-wrapper {
  position: relative;
  width: 100%;
}

.header-search-wrap input {
  width: 100%;
  height: 38px;
  font-size: 13.5px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle, var(--bg-pill-border));
  border-radius: 20px;
  padding-left: 38px;
  padding-right: 14px;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.header-search-wrap input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
  background: var(--bg-surface);
}

.header-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  max-height: 420px;
  overflow-y: auto;
  z-index: 1000;
  padding: 8px 0;
}

.search-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
  gap: 12px;
}

.search-dropdown-item:hover {
  background: var(--bg-surface-hover, var(--border-subtle));
}

.search-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.search-user-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.search-user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-user-handle {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-empty-state {
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   Friends & Search Results Pages & User Cards
   ========================================================================== */
.friends-container, .search-results-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px;
}

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  margin-bottom: 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.user-card:hover {
  border-color: var(--border-hover);
}

.user-card-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  cursor: pointer;
}

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

.user-card-avatar-wrap .status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
}

.user-card-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-card-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-handle {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Dropdown Menu for "Друзья ▾" */
.dropdown-wrap {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  padding: 6px 0;
  z-index: 200;
  min-width: 160px;
}

.dropdown-item {
  width: 100%;
  padding: 8px 16px;
  text-align: left;
  background: transparent;
  border: none;
  font-size: 13px;
  cursor: pointer;
  display: block;
  color: var(--text-primary);
  transition: background 0.15s ease;
}

.dropdown-item:hover {
  background: var(--bg-surface-hover, var(--bg-pill));
}

.dropdown-item.text-danger {
  color: var(--danger);
}

.dropdown-item.text-danger:hover {
  background: var(--danger-soft);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-elevated, var(--bg-pill-border));
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
}

.tab-badge.badge-alert {
  background: var(--accent);
  color: var(--on-accent);
}

@media (max-width: 768px) {
  .header-center {
    margin: 0 10px;
    max-width: none;
  }
}

/* ==========================================================================
   Notifications Bell, Dropdown & Page
   ========================================================================== */
.notifications-btn-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 8px;
}

.header-icon-btn {
  position: relative;
  color: var(--text-secondary);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.header-icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated, var(--bg-pill-border));
}

.notification-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.4);
}

.notifications-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeInDown 0.18s ease-out;
}

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

.notifications-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle, var(--bg-pill-border));
  background: var(--bg-surface);
}

.notifications-dropdown-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.notifications-dropdown-list {
  overflow-y: auto;
  max-height: 350px;
  flex: 1;
}

.notifications-dropdown-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border-subtle, var(--bg-pill-border));
  background: var(--bg-surface-elevated);
}

.notifications-dropdown-empty {
  padding: 36px 20px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle, var(--bg-pill));
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.notification-item:hover {
  background: var(--bg-surface-hover, var(--border-subtle));
}

.notification-item.unread {
  background: rgba(var(--accent-rgb), 0.07);
}

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

.notification-item-icon-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--bg-surface);
}

.notification-item-content {
  flex: 1;
  min-width: 0;
  padding-right: 14px;
}

.notification-item-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
}

.notification-item-text b {
  color: var(--text-primary);
  font-weight: 600;
}

.notification-item-snippet {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-hover-subtle);
  padding: 4px 8px;
  border-radius: 6px;
  margin-top: 5px;
  border-left: 2px solid var(--accent-purple);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-item-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.notification-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  right: 14px;
  top: 18px;
  box-shadow: 0 0 6px var(--accent-purple);
}

/* Notifications Page */
.notifications-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px;
}

.notifications-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.notifications-page-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notifications-stream {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
}

.notifications-empty-state {
  padding: 60px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   14. WEBRTC CALLS & SIGNALLING STYLES
   ========================================================================== */

/* Chat Topbar Call Actions */
.chat-call-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.chat-call-actions .btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: auto; /* allows title hover tooltip */
}

/* Incoming Call Modal */
.incoming-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.incoming-call-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 24px 48px var(--bg-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.incoming-call-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.incoming-call-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
}

.incoming-call-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.incoming-call-avatar-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.incoming-call-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  position: relative;
  z-index: 2;
  object-fit: cover;
  background: var(--bg-surface-elevated);
}

.call-avatar-ripple {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: callRipple 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
  z-index: 1;
}

.call-avatar-ripple.delay {
  animation-delay: 0.8s;
}

@keyframes callRipple {
  0% {
    transform: scale(0.9);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.incoming-caller-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.incoming-call-type {
  font-size: 13px;
  color: var(--text-secondary);
}

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

.btn-call-action {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #fff;
}

.btn-call-action svg {
  width: 24px;
  height: 24px;
}

.btn-call-decline {
  background: var(--danger);
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.35);
}

.btn-call-decline:hover {
  background: var(--danger-hover);
  transform: translateY(-2px);
}

.btn-call-accept {
  background: var(--success);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
}

.btn-call-accept:hover {
  background: var(--success-hover);
  transform: translateY(-2px);
}

/* Active Call Screen Overlay */
.call-screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Minimized Floating Window Mode */
.call-screen-overlay.minimized {
  inset: auto;
  bottom: 24px;
  right: 24px;
  width: 320px;
  height: 220px;
  border-radius: 18px;
  border: 1px solid var(--border-hover);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.8);
  z-index: 9999;
}

.call-screen-overlay.minimized .call-voice-avatar {
  width: 60px;
  height: 60px;
}

.call-screen-overlay.minimized .call-voice-name {
  font-size: 14px;
}

.call-screen-overlay.minimized .call-controls-bar {
  bottom: 12px;
  padding: 6px 12px;
  gap: 8px;
}

.call-screen-overlay.minimized .call-ctrl-btn {
  width: 44px;
  height: 44px;
}

.call-screen-overlay.minimized .call-ctrl-btn svg {
  width: 20px;
  height: 20px;
}

.call-screen-overlay.minimized .btn-ctrl-end {
  width: 46px;
  height: 46px;
}

.call-screen-overlay.minimized .call-pip-container {
  display: none !important;
}

/* Call Top Bar */
.call-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: linear-gradient(180deg, rgba(11, 11, 15, 0.85) 0%, rgba(11, 11, 15, 0) 100%);
}

.call-peer-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-peer-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.call-status-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent-text);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
}

.call-status-pill.reconnecting {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
  border-color: rgba(245, 158, 11, 0.3);
}

/* Call Media Viewport */
.call-media-viewport {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #060608;
  overflow: hidden;
}

.call-video-remote {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* PiP Local Video Container */
.call-pip-container {
  position: absolute;
  top: 72px;
  right: 24px;
  width: 170px;
  height: 110px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(var(--accent-rgb), 0.4);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
  z-index: 25;
  background: var(--bg-surface-elevated);
}

.call-video-local {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror */
}

.call-video-local.no-mirror {
  transform: none;
  object-fit: contain;
}

/* Voice Call Central Avatar */
.call-voice-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  text-align: center;
}

.call-voice-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  position: relative;
  z-index: 2;
  object-fit: cover;
  background: var(--bg-surface-elevated);
}

.call-voice-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 20px;
  margin-bottom: 6px;
}

.call-voice-state {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Bottom Controls Bar */
.call-controls-bar {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
}

.call-ringtone-mute-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  cursor: pointer;
  transition: all 0.2s ease;
}

.call-ringtone-mute-btn svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.chat-call-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated, var(--bg-surface-elevated, #1A1A24));
  border: 1px solid var(--border, var(--border-subtle, #23232E));
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
}

.chat-call-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  flex-shrink: 0;
}

.call-minimize-btn {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-pill);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-call-btn:hover:not(:disabled),
.call-ringtone-mute-btn:hover,
.call-minimize-btn:hover {
  background: rgba(var(--accent-rgb), 0.18);
  border-color: var(--accent);
  color: var(--text-primary);
  transform: scale(1.05);
}

.chat-call-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.call-ringtone-mute-btn.muted {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.call-ctrl-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.call-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.06);
}

.call-ctrl-btn.active-muted {
  background: var(--danger-soft);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.call-ctrl-btn.active-screen {
  background: #7C5CFF;
  color: #fff;
  border-color: #7C5CFF;
}

.btn-ctrl-end {
  width: 64px;
  height: 64px;
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
  box-shadow: 0 8px 20px var(--danger-border);
}

.btn-ctrl-end:hover {
  background: var(--danger-hover) !important;
  transform: scale(1.08);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .call-screen-overlay.minimized {
    bottom: 72px; /* above mobile nav bar */
    right: 12px;
    width: 220px;
    height: 150px;
  }

  .call-pip-container {
    top: 60px;
    right: 14px;
    width: 110px;
    height: 75px;
  }

  .call-controls-bar {
    bottom: 20px;
    gap: 14px;
    padding: 10px 20px;
  }

  .call-ctrl-btn {
    width: 50px;
    height: 50px;
  }

  .btn-ctrl-end {
    width: 56px;
    height: 56px;
  }
}

/* ==========================================================================
   POSTS & COMMENTS ENHANCEMENTS
   ========================================================================== */

/* Post Visibility and Edited Badges */
.post-visibility-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-purple);
  background-color: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  border-radius: 4px;
  padding: 1px 6px;
  vertical-align: middle;
}

.post-edited-badge {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
  font-weight: 400;
  margin-left: 4px;
}

/* Post Three-Dot Menu */
.post-menu-wrap {
  position: relative;
}

.post-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  min-width: 175px;
  padding: 4px 0;
  margin-top: 4px;
}

.post-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.post-menu-item:hover {
  background-color: rgba(var(--accent-rgb), 0.15);
  color: var(--text-primary);
}

.post-menu-item.danger {
  color: var(--danger-text);
}

.post-menu-item.danger:hover {
  background-color: var(--danger-soft);
  color: var(--danger-text);
}

/* Inline Post Editing Box */
.post-edit-box {
  margin-top: 6px;
  margin-bottom: 8px;
}

.edit-post-textarea {
  width: 100%;
  min-height: 80px;
  background-color: var(--bg-input);
  border: 1px solid var(--accent-purple);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
}

.edit-post-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* Post Images Grids (1-4 images, responsive, no distortion) */
.post-images-grid {
  display: grid;
  gap: 6px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 12px;
  margin-bottom: 14px;
  background-color: var(--bg-input);
}

.post-img-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background-color: var(--bg-surface-elevated);
}

.post-img-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.post-img-item:hover img {
  transform: scale(1.02);
}

/* 1 Image: Max height 460px */
.post-images-grid.grid-1 {
  grid-template-columns: 1fr;
  max-height: 460px;
}
.post-images-grid.grid-1 .post-img-item {
  max-height: 460px;
}

/* 2 Images: 2 columns, height 260px */
.post-images-grid.grid-2 {
  grid-template-columns: 1fr 1fr;
  height: 260px;
}

/* 3 Images: Left large, right 2 stacked, height 300px */
.post-images-grid.grid-3 {
  grid-template-columns: 1.2fr 1fr;
  grid-template-rows: 1fr 1fr;
  height: 300px;
}
.post-images-grid.grid-3 .post-img-item:first-child {
  grid-row: 1 / span 2;
}

/* 4 Images: 2x2 grid, height 320px */
.post-images-grid.grid-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  height: 320px;
}

/* Fullscreen Lightbox Modal */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(8, 8, 12, 0.94);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-pill-border);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 100;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 100;
}

.lightbox-nav:hover {
  background: rgba(var(--accent-rgb), 0.4);
  transform: translateY(-50%) scale(1.08);
}

.lightbox-prev {
  left: 24px;
}

.lightbox-next {
  right: 24px;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 84vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8);
}

.lightbox-counter {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 10px;
  border-radius: 12px;
}

/* Single Post View Page */
.single-post-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.single-post-top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.single-post-title-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Post Comments Section & Drawer */
.post-comments-drawer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.comments-wrapper {
  margin-top: 10px;
}

.comment-composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.comment-composer:focus-within {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.12);
}

.comment-reply-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--accent-text);
  background-color: rgba(var(--accent-rgb), 0.14);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  padding: 6px 10px;
  border-radius: 6px;
}

.comment-reply-cancel {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
}

.comment-reply-cancel:hover {
  color: var(--danger-text);
  background: var(--danger-soft);
}

.comment-composer-input-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.comment-composer-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  resize: none;
  min-height: 44px;
  line-height: 1.5;
  padding-top: 4px;
}

.comment-composer-textarea::placeholder {
  color: var(--text-secondary);
}

.comment-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.comment-composer-hint {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

/* Comments List & Tree */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comment-item {
  display: flex;
  gap: 10px;
  position: relative;
  align-items: flex-start;
}

.comment-item-body {
  flex: 1;
  min-width: 0;
}

.comment-bubble {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  transition: border-color 0.15s ease;
}

.comment-item:hover .comment-bubble {
  border-color: var(--border-hover);
}

.comment-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 5px;
}

.comment-author-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.comment-author-name:hover {
  color: var(--accent-purple);
}

.comment-author-handle {
  font-size: 12px;
  color: var(--text-secondary);
}

.comment-time {
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-left: auto;
}

.comment-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.comment-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding-left: 2px;
  font-size: 12px;
}

.comment-like-btn,
.comment-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  transition: var(--transition);
}

.comment-like-btn:hover {
  color: #ff5e7e;
  background-color: rgba(255, 94, 126, 0.1);
}

.comment-like-btn.liked {
  color: #ff5e7e;
}

.comment-like-btn.liked svg {
  fill: currentColor;
}

.comment-tool-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-pill);
}

.comment-tool-btn.danger:hover {
  color: var(--danger-text);
  background-color: var(--danger-soft);
}

/* Comment Replies (1 level nesting) */
.comment-replies-thread {
  margin-left: 26px;
  margin-top: 8px;
  padding-left: 14px;
  border-left: 2px solid rgba(var(--accent-rgb), 0.25);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-thread-toggle {
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 6px;
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  margin-top: 6px;
  margin-left: 26px;
  transition: var(--transition);
}

.comment-thread-toggle:hover {
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--text-primary);
}

/* Comment inline editing */
.comment-edit-box {
  margin-top: 4px;
}

.comment-edit-textarea {
  width: 100%;
  min-height: 48px;
  background-color: var(--bg-surface);
  border: 1px solid var(--accent-purple);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  outline: none;
  resize: vertical;
}

.comment-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

/* ==========================================================================
   APPEARANCE SETTINGS: THEME TILES & ACCENT SWATCHES
   ========================================================================== */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}

@media (max-width: 768px) {
  .theme-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.theme-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg-input);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}

.theme-tile:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.theme-tile.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.18);
}

.theme-preview {
  width: 100%;
  height: 56px;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.theme-preview-dark {
  background: #0B0B0F;
}
.theme-preview-dark .tp-bar {
  height: 6px;
  width: 45%;
  border-radius: 4px;
  background: var(--accent);
}
.theme-preview-dark .tp-card {
  flex: 1;
  background: #14141B;
  border: 1px solid #23232E;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
}
.theme-preview-dark .tp-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.theme-preview-dark .tp-line {
  height: 5px;
  flex: 1;
  border-radius: 3px;
  background: #2E2E3E;
}

.theme-preview-midnight {
  background: #000000;
}
.theme-preview-midnight .tp-bar {
  height: 6px;
  width: 45%;
  border-radius: 4px;
  background: var(--accent);
}
.theme-preview-midnight .tp-card {
  flex: 1;
  background: #07070A;
  border: 1px solid #1A1A24;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
}
.theme-preview-midnight .tp-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.theme-preview-midnight .tp-line {
  height: 5px;
  flex: 1;
  border-radius: 3px;
  background: #232330;
}

.theme-preview-light {
  background: #F4F5F8;
}
.theme-preview-light .tp-bar {
  height: 6px;
  width: 45%;
  border-radius: 4px;
  background: var(--accent);
}
.theme-preview-light .tp-card {
  flex: 1;
  background: #FFFFFF;
  border: 1px solid #E2E5EE;
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
}
.theme-preview-light .tp-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.theme-preview-light .tp-line {
  height: 5px;
  flex: 1;
  border-radius: 3px;
  background: #CBD0DF;
}

.theme-preview-system {
  padding: 0;
  flex-direction: row;
  gap: 0;
}
.theme-preview-system .tp-half {
  flex: 1;
  height: 100%;
}
.theme-preview-system .tp-half-dark {
  background: #0B0B0F;
}
.theme-preview-system .tp-half-light {
  background: #F4F5F8;
}

.accent-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.accent-swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.accent-swatch:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.accent-swatch.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
  font-weight: 600;
}

.accent-swatch-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.guest-theme-bar {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}
.guest-theme-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  padding: 0 4px;
}
.guest-theme-pills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.guest-theme-btn {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: var(--transition);
}
.guest-theme-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.guest-theme-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text-primary);
  font-weight: 600;
}

/* ==========================================================================
   GROUP CALLS (WEBRTC MESH 1-4 TILES & DRAWER & INVITE MODAL)
   ========================================================================== */
.group-call-grid {
  width: 100%;
  height: 100%;
  padding: 72px 20px 104px 20px;
  display: grid;
  gap: 14px;
  align-content: center;
  justify-items: stretch;
  box-sizing: border-box;
}

.group-call-grid[data-count="1"] {
  grid-template-columns: 1fr;
  max-width: 720px;
  margin: 0 auto;
}
.group-call-grid[data-count="2"] {
  grid-template-columns: repeat(2, 1fr);
}
.group-call-grid[data-count="3"],
.group-call-grid[data-count="4"] {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

@media (max-width: 768px) {
  .group-call-grid {
    padding: 64px 10px 96px 10px;
    gap: 10px;
  }
  .group-call-grid[data-count="2"] {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, 1fr);
  }
  .group-call-grid[data-count="3"],
  .group-call-grid[data-count="4"] {
    grid-template-columns: repeat(2, 1fr);
  }
  .call-ctrl-desktop-only {
    display: none !important;
  }
}

.group-tile {
  position: relative;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.group-tile.speaking {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.35), 0 0 20px rgba(var(--accent-rgb), 0.25);
}

.group-tile.poor-connection {
  border-color: var(--warning);
}

.group-tile-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.group-tile.has-video .group-tile-video {
  display: block;
}

.group-tile.has-video .group-tile-avatar-wrap {
  display: none;
}

.group-tile-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.group-tile-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-hover);
}

.group-tile-footer {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.group-tile-name {
  background: rgba(0, 0, 0, 0.62);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  max-width: 68%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-tile-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.group-tile-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #FFFFFF;
}

.group-tile-badge.muted {
  background: rgba(239, 68, 68, 0.85);
}

.group-tile-badge.warn {
  background: rgba(245, 158, 11, 0.9);
  color: #000000;
  width: auto;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  gap: 4px;
}

.group-tile-menu-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.58);
  color: #FFFFFF;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.group-tile-menu-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.call-ctrl-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.group-participants-drawer {
  position: absolute;
  right: 16px;
  bottom: 96px;
  width: 280px;
  max-height: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.group-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.group-drawer-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.group-drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
}

.group-drawer-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.group-drawer-user img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.group-drawer-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-privacy-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 12px;
}

.group-invite-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.group-invite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  cursor: pointer;
  transition: var(--transition);
}

.group-invite-item:hover {
  border-color: var(--border-hover);
}

.group-invite-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==========================================================================
   ONBOARDING & KEYBOARD SHORTCUTS
   ========================================================================== */
.onboarding-card {
  background: var(--bg-surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-card);
}

.onboarding-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.onboarding-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.onboarding-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

@media (max-width: 640px) {
  .onboarding-steps {
    grid-template-columns: 1fr;
  }
}

.onboarding-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.onboarding-step:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.onboarding-step.done {
  opacity: 0.65;
  text-decoration: line-through;
}

.onboarding-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.shortcuts-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-primary);
}

/* ==========================================================================
   RESPONSIVE, SAFE-AREA & 44PX TOUCH TARGETS
   ========================================================================== */
@media (max-width: 768px) {
  .btn-icon,
  .modal-close,
  .mobile-nav-item,
  .post-action-btn,
  .call-ctrl-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .mobile-nav-bar {
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    height: calc(58px + env(safe-area-inset-bottom));
  }

  .call-controls-bar {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .profile-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  .profile-tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .profile-tabs::-webkit-scrollbar {
    display: none;
  }
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-hover);
  border-radius: 6px;
}

/* ==========================================================================
   CHAT MESSAGE ACTIONS, MENU, VIRTUALIZATION & MOBILE OPTIMIZATION
   ========================================================================== */
.chat-main-pane {
  position: relative;
}

.chat-window {
  flex: 1 1 0;
  height: 100%;
  min-height: 0;
}

@media (max-width: 768px) {
  .chat-window {
    height: 100%;
  }
  .chat-input-bar {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}

.chat-input-field {
  font-size: 16px !important;
  line-height: 1.4;
  resize: none;
  max-height: 118px;
  overflow-y: auto;
}

.chat-select-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.chat-reply-edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}

.chat-reply-edit-info {
  min-width: 0;
  flex: 1;
}

.chat-reply-edit-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-text);
}

.chat-reply-edit-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-scroll-bottom-btn {
  position: absolute;
  right: 18px;
  bottom: 86px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-hover);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  transition: transform 150ms ease, opacity 150ms ease;
}

.chat-scroll-bottom-btn:hover {
  border-color: var(--accent);
}

.chat-scroll-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.message-bubble-group {
  position: relative;
  transition: background-color 150ms ease, transform 120ms ease;
}

.message-bubble-group.selected {
  background: var(--accent-soft);
  border-radius: var(--radius);
}

@keyframes msgHighlightFlash {
  0% { background-color: rgba(var(--accent-rgb), 0.35); }
  100% { background-color: transparent; }
}

.message-bubble-group.msg-highlight {
  animation: msgHighlightFlash 1.4s ease-out;
  border-radius: var(--radius);
}

.msg-hover-btn {
  opacity: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  transition: opacity 150ms ease;
  flex-shrink: 0;
}

.message-bubble-group:hover .msg-hover-btn,
.msg-hover-btn:focus-visible {
  opacity: 1;
}

@media (max-width: 768px) {
  .msg-hover-btn {
    display: none;
  }
}

.msg-quote {
  padding: 6px 9px;
  margin-bottom: 6px;
  border-left: 3px solid currentColor;
  background: rgba(0, 0, 0, 0.14);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  max-width: 100%;
}

.msg-quote-author {
  font-weight: 700;
  margin-bottom: 2px;
}

.msg-quote-text {
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-forwarded-label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.82;
  margin-bottom: 4px;
}

.msg-edited-label {
  font-size: 10px;
  opacity: 0.72;
  margin-right: 4px;
}

.msg-link {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}

.msg-retry-btn {
  background: var(--danger);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 6px;
}

.msg-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

@keyframes msgMenuPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.msg-menu {
  position: fixed;
  min-width: 210px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: msgMenuPop 150ms cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2001;
}

.msg-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background-color 120ms ease;
}

.msg-menu-item:hover {
  background: var(--bg-surface-hover);
}

.msg-menu-item.danger {
  color: var(--danger-text);
}

.msg-menu-item.danger:hover {
  background: var(--danger-soft);
}

@media (max-width: 768px) {
  .msg-menu-backdrop {
    align-items: flex-end;
    justify-content: center;
    background: var(--bg-overlay);
  }
  .msg-menu {
    position: static;
    width: 100%;
    max-width: 480px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom)) 12px;
    animation: msgSheetUp 150ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  .msg-menu-item {
    min-height: 46px;
    font-size: 15px;
  }
}

/* ==========================================================================
   CHAT PINS, REACTIONS & FULL-TEXT SEARCH
   ========================================================================== */
.chat-pinned-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  min-height: 40px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}

.chat-pinned-counter {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-text);
  white-space: nowrap;
}

.chat-pinned-text {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

@keyframes reactionPop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.msg-reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  animation: reactionPop 180ms ease;
}

.msg-reaction-pill.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.msg-menu-reactions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 8px 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}

.msg-menu-reactions::-webkit-scrollbar {
  display: none;
}

.msg-react-emoji-btn {
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 120ms ease, background-color 120ms ease;
}

.msg-react-emoji-btn:hover {
  transform: scale(1.18);
  background: var(--bg-surface-hover);
}

@media (max-width: 768px) {
  .msg-react-emoji-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 22px;
  }
}

.chat-search-overlay {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  max-height: 300px;
  z-index: 25;
}

.chat-search-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.chat-search-results {
  flex: 1;
  overflow-y: auto;
  max-height: 200px;
}

.chat-search-item {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-sans);
}

.chat-search-item:hover,
.chat-search-item.active {
  background: var(--accent-soft);
}

.chat-search-snippet mark {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 3px;
  padding: 0 2px;
}

.chat-search-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

@media (max-width: 768px) {
  .chat-search-overlay {
    position: fixed;
    inset: 0;
    max-height: none;
    z-index: 1500;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .chat-search-results {
    max-height: none;
  }
}

.msg-sender-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-text);
  margin-bottom: 2px;
}

.msg-read-count {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-right: 4px;
}

.msg-reaction-who-btn {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}

.msg-reaction-who-btn:hover {
  background: var(--bg-surface-elevated);
}

.group-role-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.group-role-badge.owner {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.group-role-badge.admin {
  background: var(--success-soft, rgba(16, 185, 129, 0.15));
  color: var(--success, #10b981);
}

/* Discord-style Group Call Banner & Badges */
.dg-call-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(16, 185, 129, 0.12);
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 13px;
  font-weight: 600;
}

.dg-call-banner-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dg-call-live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.dg-thread-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  color: #10b981;
  margin-left: 6px;
  white-space: nowrap;
}

/* Discord-style Inline Group Call Stage (with minimized 56px & fullscreen modes) */
.dg-call-overlay {
  position: relative;
  flex-shrink: 0;
  height: 256px;
  background: #0B0B0F;
  color: #E8E8F0;
  border-bottom: 1px solid #23232E;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  transition: height 180ms ease;
}

.dg-call-overlay.minimized {
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 8px 14px;
  justify-content: center;
}

.dg-call-overlay.minimized .dg-call-header {
  padding: 0;
}

.dg-call-overlay.minimized .dg-call-grid,
.dg-call-overlay.minimized .dg-call-controls-wrap,
.dg-call-overlay.minimized .hive-ss-stage {
  display: none !important;
}

.dg-call-overlay.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1600;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  border-bottom: none;
  padding: calc(12px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
}

.dg-call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 8px;
  flex-shrink: 0;
}

.dg-call-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: #E8E8F0;
  min-width: 0;
}

.dg-call-title {
  color: #E8E8F0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dg-call-timer {
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #9E9EA8;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 999px;
  background: #14141B;
  border: 1px solid #23232E;
  flex-shrink: 0;
}

.dg-header-min-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid #23232E;
  background: #14141B;
  color: #E8E8F0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.dg-header-min-btn:hover {
  background: #1E1E2A;
  border-color: var(--accent, #7C5CFF);
}

.dg-unlock-audio-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb, 124, 92, 255), 0.55);
  background: rgba(var(--accent-rgb, 124, 92, 255), 0.18);
  color: #E8E8F0;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.dg-call-grid {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

.dg-call-overlay.fullscreen .dg-call-grid {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-content: center;
  justify-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 16px;
  padding: 8px 0;
}

.dg-call-overlay.fullscreen .dg-call-grid.single-tile {
  grid-template-columns: minmax(280px, 680px);
  justify-content: center;
}

.dg-tile {
  position: relative;
  flex: 0 0 176px;
  height: 128px;
  background: #14141B;
  border: 1px solid #23232E;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.dg-call-overlay.fullscreen .dg-tile {
  flex: none;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  max-height: min(58vh, 460px);
  border-radius: 16px;
}

.dg-tile.speaking {
  border: 2px solid var(--accent, #7C5CFF);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 124, 92, 255), 0.25), 0 6px 20px rgba(var(--accent-rgb, 124, 92, 255), 0.22);
}

.dg-tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dg-tile video[data-is-self="1"] {
  transform: scaleX(-1);
}

.dg-tile video[data-is-self="1"][data-is-screen="1"] {
  transform: none;
  object-fit: contain;
}

.dg-tile.screen-active {
  grid-column: 1 / -1;
  min-height: 260px;
}

.dg-tile.screen-active video {
  object-fit: contain;
}

.dg-tile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  z-index: 1;
  border: 2px solid #23232E;
  transition: box-shadow 150ms ease, border-color 150ms ease;
}

.dg-tile.speaking .dg-tile-avatar {
  border-color: var(--accent, #7C5CFF);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb, 124, 92, 255), 0.28);
}

.dg-call-overlay.fullscreen .dg-tile-avatar {
  width: 80px;
  height: 80px;
}

.dg-tile-footer {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(11, 11, 15, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #E8E8F0;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 500;
  z-index: 2;
  max-width: calc(100% - 16px);
}

.dg-tile-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  align-items: center;
  background: rgba(11, 11, 15, 0.78);
  backdrop-filter: blur(8px);
  padding: 3px 6px;
  border-radius: 8px;
  border: 1px solid #23232E;
  z-index: 2;
  opacity: 0;
  transition: opacity 150ms ease;
}

.dg-tile:hover .dg-tile-actions,
.dg-tile:focus-within .dg-tile-actions {
  opacity: 1;
}

.dg-tile-vol {
  width: 54px;
  accent-color: var(--accent, #7C5CFF);
}

.dg-tile-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #23232E;
  background: #1E1E2A;
  color: #E8E8F0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
}

.dg-tile-action-btn.danger {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.45);
  color: #FCA5A5;
}

.dg-call-controls-wrap {
  display: flex;
  justify-content: center;
  padding-top: 6px;
  flex-shrink: 0;
}

.dg-call-controls {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  background: #14141B;
  border: 1px solid #23232E;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.dg-ctrl-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #23232E;
  background: #1E1E2A;
  color: #E8E8F0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease, transform 150ms ease, border-color 150ms ease, color 150ms ease;
}

.dg-call-overlay.fullscreen .dg-ctrl-btn {
  width: 44px;
  height: 44px;
}

.dg-incoming-toast {
  position: fixed;
  top: calc(var(--header-height, 60px) + 12px);
  right: 16px;
  z-index: 1700;
  width: min(360px, calc(100vw - 32px));
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-surface-elevated, #14141B);
  border: 1px solid var(--border-subtle, #23232E);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
}

.dg-ctrl-btn:hover {
  background: #282838;
  border-color: #3B3B50;
  transform: translateY(-1px);
}

.dg-ctrl-btn:focus-visible,
.dg-call-mini:focus-visible,
.msg-reaction-who-btn:focus-visible {
  outline: 2px solid #7C5CFF;
  outline-offset: 2px;
}

.dg-ctrl-btn.active {
  background: #7C5CFF;
  border-color: #7C5CFF;
  color: #FFFFFF;
}

.dg-ctrl-btn.muted-danger {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
  color: #FCA5A5;
}

.dg-ctrl-btn.danger {
  background: #EF4444;
  color: #FFFFFF;
  border-color: transparent;
}

.dg-ctrl-btn.danger:hover {
  background: #DC2626;
  border-color: transparent;
}

/* Reposted Post Preview Card in Chat */
.msg-post-preview-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle, #23232E);
  border-left: 3px solid var(--accent, #7C5CFF);
  cursor: pointer;
  margin-bottom: 4px;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.msg-post-preview-card:hover {
  background: rgba(124, 92, 255, 0.08);
  border-color: var(--accent, #7C5CFF);
}

.msg-post-preview-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.msg-post-preview-body {
  flex: 1;
  min-width: 0;
}

.msg-post-preview-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-text, #A78BFA);
  margin-bottom: 2px;
}

.msg-post-preview-text {
  font-size: 13px;
  color: var(--text-primary, #E8E8F0);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.share-post-chat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle, #23232E);
  background: var(--bg-surface-elevated, #1A1A24);
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.share-post-chat-row:hover {
  border-color: var(--border-hover, #323242);
}

.share-post-chat-row.selected {
  border-color: var(--accent, #7C5CFF);
  background: var(--accent-soft, rgba(124, 92, 255, 0.14));
}

/* Sticker & Emoji Popover + Sticker-only Message */
.sticker-popover {
  position: absolute;
  right: 12px;
  bottom: 68px;
  z-index: 60;
  width: min(332px, calc(100% - 24px));
  background: #14141B;
  border: 1px solid #23232E;
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform-origin: bottom right;
  animation: popoverPopIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sticker-popover-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 3px;
  background: #0F0F16;
  border-radius: 10px;
  border: 1px solid #23232E;
}

.sticker-tab-btn {
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #9E9EA8);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.sticker-tab-btn.active {
  background: var(--accent, #7C5CFF);
  color: var(--on-accent, #FFFFFF);
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  padding: 2px;
}

.sticker-item-btn {
  background: #1A1A24;
  border: 1px solid #23232E;
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 150ms ease, background-color 150ms ease;
}

.sticker-item-btn:hover {
  border-color: var(--accent, #7C5CFF);
  background: rgba(var(--accent-rgb, 124, 92, 255), 0.12);
  transform: scale(1.04);
}

.emoji-picker-wrap {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.emoji-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary, #8A8AA0);
  padding: 0 2px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.emoji-btn {
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 120ms ease, transform 100ms ease;
}

.emoji-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.12);
}

.message-bubble.sticker-only {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 2px !important;
}

.message-sticker-wrap {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-bubble.sticker-only .message-time-meta {
  background: rgba(11, 11, 15, 0.68);
  padding: 2px 7px;
  border-radius: 999px;
  width: fit-content;
  margin-left: auto;
  color: rgba(255, 255, 255, 0.88);
}

.dg-call-mini {
  position: fixed;
  right: 16px;
  bottom: 76px;
  z-index: 1550;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg-surface-elevated, #1e222d);
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

@media (max-width: 640px) {
  .composer-bottom {
    flex-wrap: wrap;
    gap: 8px;
  }
  .composer-actions-left {
    flex-wrap: wrap;
    gap: 8px;
  }
  .composer-actions-right {
    margin-left: auto;
    gap: 10px;
  }
  .dg-call-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dg-call-grid.single-tile {
    grid-template-columns: 1fr;
  }
  .dg-tile {
    min-height: 140px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dg-tile,
  .dg-ctrl-btn,
  .dg-call-mini {
    transition: none;
  }
}

/* Telegram-style Group Profile Modal */
.tg-mobile-back-btn {
  display: none;
}

@media (max-width: 768px) {
  .tg-group-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  .tg-mobile-back-btn {
    display: inline-flex;
  }
}

.tg-group-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.tg-group-avatar-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  margin-bottom: 10px;
}

.tg-group-avatar-img {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.tg-edit-avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.tg-edit-avatar-circle {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border-subtle, #23232E);
}

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

.tg-edit-avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 15, 0.55);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease;
}

.tg-edit-avatar-circle:hover .tg-edit-avatar-overlay {
  background: rgba(11, 11, 15, 0.72);
}

.tg-perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-surface, #14141B);
  border: 1px solid var(--border-subtle, #23232E);
  margin-bottom: 6px;
  font-size: 13px;
}

.tg-group-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.tg-group-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.tg-group-desc {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
  max-width: 420px;
  word-break: break-word;
}

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

.tg-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 54px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.tg-quick-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tg-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-surface, #14141B);
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 12px;
  gap: 4px;
}

.tg-tab-btn {
  padding: 10px 12px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease;
}

.tg-tab-btn.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
}

.tg-tab-panel {
  padding: 14px 16px;
  max-height: 360px;
  overflow-y: auto;
}

.tg-media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.tg-media-thumb {
  aspect-ratio: 1;
  width: 100%;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
}

.tg-danger-zone {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.06);
}

/* Chat Attachments & Dropzone */
.chat-main-pane.drag-over::after {
  content: 'Отпустите файлы для отправки';
  position: absolute;
  inset: 12px;
  z-index: 40;
  background: rgba(var(--accent-rgb), 0.16);
  border: 2px dashed var(--accent);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  pointer-events: none;
}

.chat-attach-menu {
  position: absolute;
  left: 12px;
  bottom: 66px;
  z-index: 50;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 190px;
}

.chat-attach-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.chat-attach-menu-item:hover {
  background: var(--accent-soft);
}

.chat-attach-preview-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 10px;
}

.chat-preview-card {
  position: relative;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface-elevated);
  overflow: hidden;
}

.chat-preview-card.img-card {
  width: 68px;
  height: 68px;
}

.chat-preview-card.img-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-preview-card.file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 28px 8px 10px;
  max-width: 190px;
  height: 68px;
}

.chat-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.msg-att-grid {
  display: grid;
  gap: 4px;
  margin-bottom: 6px;
  max-width: 320px;
  border-radius: 10px;
  overflow: hidden;
}

.msg-att-grid.cols-1 { grid-template-columns: 1fr; }
.msg-att-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.msg-att-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.msg-att-img-wrap {
  position: relative;
  background: var(--bg-elevated);
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
}

.msg-att-img-wrap img {
  width: 100%;
  height: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
}

.msg-att-file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid var(--border-subtle);
  margin-bottom: 6px;
  min-width: 200px;
  max-width: 300px;
}

.msg-att-file-info {
  min-width: 0;
  flex: 1;
}

.msg-att-file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-att-file-size {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Voice Recorder & Waveform Player */
.voice-rec-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.voice-rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  animation: voiceRecBlink 1s infinite;
}

@keyframes voiceRecBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .voice-rec-dot { animation: none; }
}

.voice-rec-timer {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 42px;
}

.voice-rec-canvas {
  flex: 1;
  height: 28px;
  min-width: 60px;
}

.msg-voice-player {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  max-width: 300px;
  padding: 4px 2px;
}

.msg-voice-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--on-accent, #fff);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.msg-voice-wave {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  cursor: pointer;
}

.msg-voice-bar {
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.28);
  transition: background-color 120ms ease;
}

.msg-voice-bar.played {
  background: var(--accent-text, #a78bfa);
}

.msg-voice-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.msg-voice-speed-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

/* Group Polls */
.msg-poll-card {
  min-width: 240px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-poll-question {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.msg-poll-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
}

.msg-poll-opt {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-surface);
  transition: border-color 150ms ease;
}

.msg-poll-opt.selected {
  border-color: var(--accent);
}

.msg-poll-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(var(--accent-rgb), 0.22);
  transition: width 220ms ease;
  pointer-events: none;
}

.msg-poll-opt-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.msg-poll-opt-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.msg-poll-votes-btn {
  border: none;
  background: transparent;
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
}

.msg-poll-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* @Mentions */
.chat-mention-dropdown {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 66px;
  max-height: 210px;
  overflow-y: auto;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 60;
  animation: popoverPopIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-sticker-popover:not(.hidden) {
  animation: popoverPopIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}

.chat-mention-item:hover {
  background: var(--accent-soft);
}

.msg-mention {
  color: var(--accent-text);
  font-weight: 700;
  cursor: pointer;
}

.msg-mention:hover {
  text-decoration: underline;
}

.thread-mention-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent, #fff);
  margin-right: 4px;
}

.thread-pin-icon {
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.9;
}

.thread-more-btn {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 150ms ease, background-color 150ms ease, color 150ms ease;
}

.thread-item:hover .thread-more-btn,
.thread-more-btn:focus-visible {
  opacity: 1;
}

.thread-more-btn:hover {
  background: var(--bg-surface-active);
  color: var(--text-primary);
}

/* Custom Hive Video Player */
.hive-video-player {
  position: relative;
  width: 100%;
  max-width: 340px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-subtle);
  margin-top: 4px;
}

.hive-video-player video {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: #000;
  cursor: pointer;
}

.hive-video-center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(139, 92, 246, 0.9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  transition: transform 150ms ease, opacity 150ms ease;
}

.hive-video-center-play:hover {
  transform: translate(-50%, -50%) scale(1.06);
}

.hive-video-player.playing .hive-video-center-play {
  opacity: 0;
  pointer-events: none;
}

.hive-video-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(11, 11, 15, 0.88);
  color: #fff;
  font-size: 11px;
}

.hive-video-ctrl-btn {
  background: transparent;
  border: none;
  color: #fff;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.hive-video-seek {
  flex: 1;
  min-width: 60px;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.hive-video-time {
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}

/* Media Grid Cell with Video Badge & Jump Button */
.tg-media-cell {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  cursor: pointer;
}

.tg-media-cell .tg-media-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tg-media-video-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(11, 11, 15, 0.78);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.tg-media-jump-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  background: rgba(11, 11, 15, 0.82);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.tg-media-cell:hover .tg-media-jump-btn {
  opacity: 1;
}

/* OpenGraph Link Preview Card */
.msg-link-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
  color: inherit;
  max-width: 340px;
  transition: background-color 150ms ease;
}

.msg-link-preview:hover {
  background: rgba(255, 255, 255, 0.08);
}

.msg-link-preview-body {
  min-width: 0;
  flex: 1;
}

.msg-link-preview-site {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-link-preview-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin-bottom: 2px;
}

.msg-link-preview-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg-link-preview-thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-surface);
}

/* Word-wrap protection for long links, filenames and unspaced text */
.message-text {
  white-space: pre-wrap;
}

.message-bubble,
.message-text,
.message-text a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg-att-file-name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Telegram-style Photo Preview & Editor Modal */
.photo-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(11, 11, 15, 0.94);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.photo-editor-dialog {
  width: 100%;
  max-width: 780px;
  height: min(90vh, 720px);
  background: #14141B;
  border: 1px solid #23232E;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
}

@media (max-width: 768px) {
  .photo-editor-modal {
    padding: 0;
  }
  .photo-editor-dialog {
    max-width: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }
}

.photo-editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #23232E;
}

.photo-editor-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.photo-editor-stage {
  flex: 1;
  min-height: 0;
  background: #0B0B0F;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}

#photoEditorCanvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  display: block;
}

.pe-crop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.pe-crop-box {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  cursor: move;
}

.pe-crop-handle.se {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: nwse-resize;
}

.photo-editor-subtools,
.photo-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid #23232E;
  flex-wrap: wrap;
}

.pe-aspect-btn.active,
#btnPhotoEditorToolCrop.active,
#btnPhotoEditorToolDraw.active,
#btnPhotoEditorSendAsFile.active {
  border-color: var(--accent);
  color: var(--accent-text);
  background: rgba(139, 92, 246, 0.14);
}

.pe-color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.pe-color-dot.active {
  border-color: #fff;
  transform: scale(1.12);
}

.photo-editor-caption-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #23232E;
  background: #14141B;
}

.pe-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .profile-top-row {
    flex-wrap: wrap;
    gap: 12px;
  }
  .feed-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 4px;
    scrollbar-width: none;
  }
  .feed-tabs::-webkit-scrollbar {
    display: none;
  }
  .feed-tab {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 12px;
  }
  .user-card {
    flex-wrap: wrap;
    gap: 10px;
  }
  .user-card-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .tg-group-modal .modal-header {
    padding: 12px 14px;
  }
  .tg-group-modal .modal-title {
    font-size: 15px;
    white-space: nowrap;
  }
  #tgGroupTabPanel > div > div {
    flex-wrap: wrap;
    gap: 6px;
  }
}

.message-bubble-group.outgoing .msg-poll-card,
.message-bubble-group.outgoing .msg-poll-question,
.message-bubble-group.outgoing .msg-poll-opt-row {
  color: #ffffff;
}

.message-bubble-group.outgoing .msg-poll-subtitle,
.message-bubble-group.outgoing .msg-poll-footer,
.message-bubble-group.outgoing .msg-poll-opt-right {
  color: rgba(255, 255, 255, 0.82);
}

.message-bubble-group.outgoing .msg-poll-opt {
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(255, 255, 255, 0.2);
}

.hive-video-settings-menu {
  position: absolute;
  right: 8px;
  bottom: 40px;
  background: rgba(20, 20, 27, 0.96);
  border: 1px solid #23232E;
  border-radius: 10px;
  padding: 8px 10px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 190px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.hive-video-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.hive-video-pill-group {
  display: flex;
  gap: 4px;
}

.hive-video-pill-btn {
  border: 1px solid #23232E;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.hive-video-pill-btn.active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.2);
  color: #fff;
}

.call-quality-select {
  height: 32px;
  border-radius: 8px;
  border: 1px solid #23232E;
  background: #14141B;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 0 8px;
  cursor: pointer;
}








/* =========================================================
   UNIFIED DISCORD-STYLE SCREEN SHARE (MODAL + STAGE + LIVE)
   ========================================================= */
.hive-ss-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.hive-ss-modal {
  width: 100%;
  max-width: 390px;
  background: var(--bg-card, #14141B);
  border: 1px solid var(--border, #262635);
  border-radius: 16px;
  padding: 20px;
  color: var(--text-primary, #F4F4F8);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.55);
}

.hive-ss-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.hive-ss-modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(124, 92, 255, 0.16);
  color: #7C5CFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hive-ss-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.hive-ss-modal-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary, #8E8EA0);
}

.hive-ss-close-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-secondary, #8E8EA0);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.hive-ss-section {
  margin-bottom: 14px;
}

.hive-ss-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #8E8EA0);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hive-ss-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hive-ss-seg-btn {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border, #262635);
  background: var(--bg-input, #1C1C26);
  color: var(--text-primary, #F4F4F8);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hive-ss-seg-btn.active {
  background: rgba(124, 92, 255, 0.18);
  border-color: #7C5CFF;
  color: #FFFFFF;
}

.hive-ss-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-input, #1C1C26);
  border: 1px solid var(--border, #262635);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 18px;
}

.hive-ss-toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #7C5CFF;
  cursor: pointer;
}

.hive-ss-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hive-ss-btn-cancel {
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border, #262635);
  background: transparent;
  color: var(--text-secondary, #8E8EA0);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.hive-ss-btn-start {
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  background: #7C5CFF;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.hive-ss-btn-start:hover {
  background: #6A48F5;
}

/* LIVE badge & Watch button */
.hive-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #EF4444;
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.45);
}

.dg-tile-live {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 4;
  cursor: pointer;
}

.hive-watch-stream-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(18, 18, 26, 0.85);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.hive-watch-stream-btn:hover {
  background: #7C5CFF;
  border-color: #7C5CFF;
}

.dg-tile-watch-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
}

/* Unified Stage / Spotlight Area */
.hive-ss-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: #09090D;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  overflow: hidden;
  min-height: 220px;
  flex: 1 1 auto;
}

.hive-ss-stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(18, 18, 26, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 2;
}

.hive-ss-stage-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hive-ss-stage-name {
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hive-ss-stage-qual {
  font-size: 11px;
  color: #9CA3AF;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
}

.hive-ss-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hive-ss-switch-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #D1D5DB;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.hive-ss-switch-pill.active {
  background: rgba(124, 92, 255, 0.25);
  border-color: #7C5CFF;
  color: #FFFFFF;
}

.hive-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #EF4444;
}

.hive-ss-stage-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hive-ss-action-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #F4F4F8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.hive-ss-action-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.hive-ss-action-btn.danger {
  background: #EF4444;
  border-color: #EF4444;
  color: #FFFFFF;
}

.hive-ss-vol-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.hive-ss-icon-btn {
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 13px;
  cursor: pointer;
  padding: 2px;
}

.hive-ss-vol-slider {
  width: 64px;
  accent-color: #7C5CFF;
  cursor: pointer;
}

.hive-ss-stage-video {
  width: 100%;
  height: 100%;
  max-height: 62vh;
  object-fit: contain;
  transform: none !important;
  background: #050508;
  flex: 1 1 auto;
}

.hive-ss-stage:fullscreen .hive-ss-stage-video {
  max-height: calc(100vh - 52px);
}

.hive-ss-preview-hidden {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  color: #9CA3AF;
  font-size: 12px;
  text-align: center;
  min-height: 44px;
}

/* Group call Stage layout: keep inline overlay compact so chat stays roomy */
.dg-call-overlay.has-stage:not(.minimized):not(.fullscreen) {
  height: auto;
  min-height: 0;
  max-height: 48vh;
  overflow: hidden;
  z-index: 5;
  padding: 8px 12px;
}

.dg-call-overlay.has-stage:not(.minimized):not(.fullscreen) .dg-call-header {
  padding: 0 2px 6px;
}

.dg-call-overlay.has-stage .hive-ss-stage {
  flex: 1 1 auto;
  min-height: 110px;
  min-width: 0;
}

.dg-call-overlay.has-stage:not(.fullscreen) .hive-ss-stage-bar {
  padding: 5px 10px;
  gap: 6px;
}

.dg-call-overlay.has-stage:not(.fullscreen) .hive-ss-stage-video {
  min-height: 0;
  max-height: 24vh;
}

.dg-call-overlay.fullscreen.has-stage .hive-ss-stage-video {
  max-height: calc(100vh - 200px);
}

.dg-call-overlay.has-stage:not(.fullscreen) .dg-call-grid {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding: 6px 2px;
  min-height: 70px;
  max-height: 78px;
  flex: 0 0 auto;
}

.dg-call-overlay.has-stage:not(.fullscreen) .dg-tile {
  flex: 0 0 132px;
  min-height: 62px;
  height: 64px;
}

.dg-call-overlay.has-stage:not(.fullscreen) .dg-tile-avatar {
  width: 30px;
  height: 30px;
}

.dg-call-overlay.has-stage:not(.fullscreen) .dg-call-controls-wrap {
  padding-top: 4px;
}

.dg-call-overlay.fullscreen.has-stage .dg-call-grid {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding: 8px 4px;
  min-height: 98px;
  max-height: 110px;
  flex: 0 0 auto;
}

.dg-call-overlay.fullscreen.has-stage .dg-tile {
  flex: 0 0 156px;
  min-height: 92px;
  height: 96px;
}

.dg-call-overlay.fullscreen.has-stage .dg-tile-avatar {
  width: 44px;
  height: 44px;
}

/* DM call Stage layout */
.call-video-area.has-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 16px 96px;
  gap: 12px;
}

.call-video-area.has-stage #callScreenStage {
  max-width: 1120px;
  flex: 1 1 auto;
}

.call-video-area.has-stage .call-voice-view {
  flex: 0 0 auto;
  flex-direction: row;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(20, 20, 27, 0.78);
}

.call-video-area.has-stage .call-avatar-wrap {
  width: 44px;
  height: 44px;
  margin-bottom: 0;
}

.call-video-area.has-stage .call-avatar-ripple {
  display: none;
}

.call-video-area.has-stage .call-voice-avatar {
  width: 44px;
  height: 44px;
}
